This commit is contained in:
davidga 2022-11-13 15:48:32 +02:00
commit 10bf82bcc0
2 changed files with 27 additions and 2 deletions

View File

@ -103,12 +103,15 @@ spec:
- {{ .Values.appsec.proxy }}
{{- end }}
imagePullPolicy: {{ .Values.appsec.image.pullPolicy }}
{{- if eq .Values.appsec.playground false }}
env:
{{- if eq .Values.appsec.playground false }}
- name: SHARED_STORAGE_HOST
value: {{ .Values.appsec.storage.name }}-svc
- name: LEARNING_HOST
value: {{ .Values.appsec.learning.name }}-svc
{{- else }}
- name: PLAYGROUND
value: "true"
{{- end }}
resources:
{{ toYaml .Values.resources | nindent 12 }}

View File

@ -13,9 +13,12 @@
#include "local_policy_mgmt_gen.h"
#include <algorithm>
#include <cctype>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <fstream>
#include <streambuf>
#include <cereal/types/vector.hpp>
@ -1215,9 +1218,28 @@ private:
LocalPolicyEnv env_type;
map<string, string> practice_name_to_id_map;
bool
isPlaygroundEnv()
{
string playground_variable = "PLAYGROUND";
const char* env_string = getenv(playground_variable.c_str());
if (env_string)
{
string env_value = env_string;
std::transform(env_value.begin(), env_value.end(), env_value.begin(),
[](unsigned char c){ return std::tolower(c); });
return env_value == "true";
}
return false;
}
bool
getClusterId()
{
string playground_uid = isPlaygroundEnv() ? "playground-" : "";
dbgTrace(D_K8S_POLICY) << "Getting cluster UID";
auto maybe_namespaces_data = getObjectFromCluster<NamespaceData>("/api/v1/namespaces/");
@ -1241,7 +1263,7 @@ private:
uid,
EnvKeyAttr::LogSection::SOURCE
);
Singleton::Consume<I_AgentDetails>::by<LocalPolicyMgmtGenerator::Impl>()->setClusterId(uid);
Singleton::Consume<I_AgentDetails>::by<LocalPolicyMgmtGenerator::Impl>()->setClusterId(playground_uid + uid);
return true;
}
}