Skip to content

Commit

Permalink
add env vars for repo mirror config
Browse files Browse the repository at this point in the history
  • Loading branch information
Milica-Cvrkota-IBM committed Dec 24, 2024
1 parent ca1957b commit 94e97f3
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 15 deletions.
18 changes: 18 additions & 0 deletions api/v1/inline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,24 @@ type BaseAgentSpec struct {
// Sets the INSTANA_MVN_REPOSITORY_SHARED_PATH environment variable
// +kubebuilder:validation:Optional
MvnRepoSharedPath string `json:"instanaMvnRepoSharedPath,omitempty"`
// Sets the INSTANA_FEATURES_REPOSITORY_MIRROR_URL environment variable
// +kubebuilder:validation:Optional
MirrorFeaturesRepoUrl string `json:"instanaFeaturesRepoMirrorUrl,omitempty"`
// Sets the INSTANA_FEATURES_REPOSITORY_MIRROR_USERNAME environment variable
// +kubebuilder:validation:Optional
MirrorFeaturesRepoUsername string `json:"instanaFeaturesRepoMirrorUsername,omitempty"`
// Sets the INSTANA_FEATURES_REPOSITORY_MIRROR_PASSWORD environment variable
// +kubebuilder:validation:Optional
MirrorFeaturesRepoPassword string `json:"instanaFeaturesRepoMirrorPassword,omitempty"`
// Sets the INSTANA_SHARED_REPOSITORY_MIRROR_URL environment variable
// +kubebuilder:validation:Optional
MirrorSharedRepoUrl string `json:"instanaSharedRepoMirrorUrl,omitempty"`
// Sets the INSTANA_SHARED_REPOSITORY_MIRROR_USERNAME environment variable
// +kubebuilder:validation:Optional
MirrorSharedRepoUsername string `json:"instanaSharedRepoMirrorUsername,omitempty"`
// Sets the INSTANA_SHARED_REPOSITORY_MIRROR_PASSWORD environment variable
// +kubebuilder:validation:Optional
MirrorSharedRepoPassword string `json:"instanaSharedRepoMirrorPassword,omitempty"`
}

type ResourceRequirements corev1.ResourceRequirements
Expand Down
6 changes: 6 additions & 0 deletions pkg/k8s/object/builders/agent/daemonset/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ func (d *daemonSetBuilder) getEnvVars() []corev1.EnvVar {
env.MavenRepoURLEnv,
env.MavenRepoFeaturesPath,
env.MavenRepoSharedPath,
env.MirrorFeaturesRepoUrlEnv,
env.MirrorFeaturesRepoUsernameEnv,
env.MirrorFeaturesRepoPasswordEnv,
env.MirrorSharedRepoUrlEnv,
env.MirrorSharedRepoUsernameEnv,
env.MirrorSharedRepoPasswordEnv,
env.ProxyHostEnv,
env.ProxyPortEnv,
env.ProxyProtocolEnv,
Expand Down
6 changes: 6 additions & 0 deletions pkg/k8s/object/builders/agent/daemonset/daemonset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ func TestDaemonSetBuilder_getEnvVars(t *testing.T) {
env.MavenRepoURLEnv,
env.MavenRepoFeaturesPath,
env.MavenRepoSharedPath,
env.MirrorFeaturesRepoUrlEnv,
env.MirrorFeaturesRepoUsernameEnv,
env.MirrorFeaturesRepoPasswordEnv,
env.MirrorSharedRepoUrlEnv,
env.MirrorSharedRepoUsernameEnv,
env.MirrorSharedRepoPasswordEnv,
env.ProxyHostEnv,
env.ProxyPortEnv,
env.ProxyProtocolEnv,
Expand Down
18 changes: 18 additions & 0 deletions pkg/k8s/object/builders/common/env/env_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ const (
MavenRepoURLEnv
MavenRepoFeaturesPath
MavenRepoSharedPath
MirrorFeaturesRepoUrlEnv
MirrorFeaturesRepoUsernameEnv
MirrorFeaturesRepoPasswordEnv
MirrorSharedRepoUrlEnv
MirrorSharedRepoUsernameEnv
MirrorSharedRepoPasswordEnv
ProxyHostEnv
ProxyPortEnv
ProxyProtocolEnv
Expand Down Expand Up @@ -107,6 +113,18 @@ func (e *envBuilder) build(envVar EnvVar) *corev1.EnvVar {
return stringToEnvVar("INSTANA_MVN_REPOSITORY_FEATURES_PATH", e.agent.Spec.Agent.MvnRepoFeaturesPath)
case MavenRepoSharedPath:
return stringToEnvVar("INSTANA_MVN_REPOSITORY_SHARED_PATH", e.agent.Spec.Agent.MvnRepoSharedPath)
case MirrorFeaturesRepoUrlEnv:
return stringToEnvVar("INSTANA_FEATURES_REPOSITORY_MIRROR_URL", e.agent.Spec.Agent.MirrorFeaturesRepoUrl)
case MirrorFeaturesRepoUsernameEnv:
return stringToEnvVar("INSTANA_FEATURES_REPOSITORY_MIRROR_USERNAME", e.agent.Spec.Agent.MirrorFeaturesRepoUsername)
case MirrorSharedRepoUrlEnv:
return stringToEnvVar("INSTANA_SHARED_REPOSITORY_MIRROR_URL", e.agent.Spec.Agent.MirrorSharedRepoUrl)
case MirrorSharedRepoUsernameEnv:
return stringToEnvVar("INSTANA_SHARED_REPOSITORY_MIRROR_USERNAME", e.agent.Spec.Agent.MirrorSharedRepoUsername)
case MirrorSharedRepoPasswordEnv:
return stringToEnvVar("INSTANA_SHARED_REPOSITORY_MIRROR_PASSWORD", e.agent.Spec.Agent.MirrorSharedRepoPassword)
case MirrorFeaturesRepoPasswordEnv:
return stringToEnvVar("INSTANA_FEATURES_REPOSITORY_MIRROR_PASSWORD", e.agent.Spec.Agent.MirrorFeaturesRepoPassword)
case ProxyHostEnv:
return stringToEnvVar("INSTANA_AGENT_PROXY_HOST", e.agent.Spec.Agent.ProxyHost)
case ProxyPortEnv:
Expand Down
48 changes: 33 additions & 15 deletions pkg/k8s/object/builders/common/env/env_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,27 @@ func TestEnvBuilderBuild(t *testing.T) {
Zone: instanav1.Name{Name: "INSTANA_AGENT_SPEC_ZONE_NAME"},
Cluster: instanav1.Name{Name: "INSTANA_AGENT_SPEC_CLUSTER_NAME"},
Agent: instanav1.BaseAgentSpec{
EndpointHost: "INSTANA_AGENT_ENDPOINT_HOST",
EndpointPort: "INSTANA_AGENT_ENDPOINT_PORT",
MvnRepoUrl: "INSTANA_MVN_REPOSITORY_URL",
MvnRepoFeaturesPath: "INSTANA_MVN_REPOSITORY_FEATURES_PATH",
MvnRepoSharedPath: "INSTANA_MVN_REPOSITORY_SHARED_PATH",
ProxyHost: "INSTANA_AGENT_PROXY_HOST",
ProxyPort: "",
ProxyProtocol: "INSTANA_AGENT_PROXY_PROTOCOL",
ProxyUser: "INSTANA_AGENT_PROXY_USER",
ProxyPassword: "INSTANA_AGENT_PROXY_PASSWORD",
ProxyUseDNS: true,
ListenAddress: "INSTANA_AGENT_HTTP_LISTEN",
RedactKubernetesSecrets: "INSTANA_KUBERNETES_REDACT_SECRETS",
Mode: "INSTANA_BASE_AGENT_SPEC_MODE",
KeysSecret: "INSTANA_AGENT_KEYS_SECRET",
EndpointHost: "INSTANA_AGENT_ENDPOINT_HOST",
EndpointPort: "INSTANA_AGENT_ENDPOINT_PORT",
MvnRepoUrl: "INSTANA_MVN_REPOSITORY_URL",
MvnRepoFeaturesPath: "INSTANA_MVN_REPOSITORY_FEATURES_PATH",
MvnRepoSharedPath: "INSTANA_MVN_REPOSITORY_SHARED_PATH",
MirrorFeaturesRepoUrl: "INSTANA_FEATURES_REPOSITORY_MIRROR_URL",
MirrorFeaturesRepoUsername: "INSTANA_FEATURES_REPOSITORY_MIRROR_USERNAME",
MirrorFeaturesRepoPassword: "INSTANA_FEATURES_REPOSITORY_MIRROR_PASSWORD",
MirrorSharedRepoUrl: "INSTANA_SHARED_REPOSITORY_MIRROR_URL",
MirrorSharedRepoUsername: "INSTANA_SHARED_REPOSITORY_MIRROR_USERNAME",
MirrorSharedRepoPassword: "INSTANA_SHARED_REPOSITORY_MIRROR_PASSWORD",
ProxyHost: "INSTANA_AGENT_PROXY_HOST",
ProxyPort: "",
ProxyProtocol: "INSTANA_AGENT_PROXY_PROTOCOL",
ProxyUser: "INSTANA_AGENT_PROXY_USER",
ProxyPassword: "INSTANA_AGENT_PROXY_PASSWORD",
ProxyUseDNS: true,
ListenAddress: "INSTANA_AGENT_HTTP_LISTEN",
RedactKubernetesSecrets: "INSTANA_KUBERNETES_REDACT_SECRETS",
Mode: "INSTANA_BASE_AGENT_SPEC_MODE",
KeysSecret: "INSTANA_AGENT_KEYS_SECRET",
Env: map[string]string{
"USER_SPECIFIED_ENV_VAR1": "USER_SPECIFIED_ENV_VAR_VAL1",
"USER_SPECIFIED_ENV_VAR2": "USER_SPECIFIED_ENV_VAR_VAL2",
Expand All @@ -71,6 +77,12 @@ func TestEnvBuilderBuild(t *testing.T) {
MavenRepoURLEnv,
MavenRepoFeaturesPath,
MavenRepoSharedPath,
MirrorFeaturesRepoUrlEnv,
MirrorFeaturesRepoUsernameEnv,
MirrorFeaturesRepoPasswordEnv,
MirrorSharedRepoUrlEnv,
MirrorSharedRepoUsernameEnv,
MirrorSharedRepoPasswordEnv,
ProxyHostEnv,
ProxyPortEnv,
ProxyProtocolEnv,
Expand Down Expand Up @@ -107,6 +119,12 @@ func TestEnvBuilderBuild(t *testing.T) {
{Name: "INSTANA_MVN_REPOSITORY_URL", Value: "INSTANA_MVN_REPOSITORY_URL"},
{Name: "INSTANA_MVN_REPOSITORY_FEATURES_PATH", Value: "INSTANA_MVN_REPOSITORY_FEATURES_PATH"},
{Name: "INSTANA_MVN_REPOSITORY_SHARED_PATH", Value: "INSTANA_MVN_REPOSITORY_SHARED_PATH"},
{Name: "INSTANA_FEATURES_REPOSITORY_MIRROR_URL", Value: "INSTANA_FEATURES_REPOSITORY_MIRROR_URL"},
{Name: "INSTANA_FEATURES_REPOSITORY_MIRROR_USERNAME", Value: "INSTANA_FEATURES_REPOSITORY_MIRROR_USERNAME"},
{Name: "INSTANA_FEATURES_REPOSITORY_MIRROR_PASSWORD", Value: "INSTANA_FEATURES_REPOSITORY_MIRROR_PASSWORD"},
{Name: "INSTANA_SHARED_REPOSITORY_MIRROR_URL", Value: "INSTANA_SHARED_REPOSITORY_MIRROR_URL"},
{Name: "INSTANA_SHARED_REPOSITORY_MIRROR_USERNAME", Value: "INSTANA_SHARED_REPOSITORY_MIRROR_USERNAME"},
{Name: "INSTANA_SHARED_REPOSITORY_MIRROR_PASSWORD", Value: "INSTANA_SHARED_REPOSITORY_MIRROR_PASSWORD"},
{Name: "INSTANA_AGENT_PROXY_HOST", Value: "INSTANA_AGENT_PROXY_HOST"},
{Name: "INSTANA_AGENT_PROXY_PROTOCOL", Value: "INSTANA_AGENT_PROXY_PROTOCOL"},
{Name: "INSTANA_AGENT_PROXY_USER", Value: "INSTANA_AGENT_PROXY_USER"},
Expand Down

0 comments on commit 94e97f3

Please sign in to comment.