From 486b7fcb9dfb7d18f56d498fa6d7c397a1b2cf66 Mon Sep 17 00:00:00 2001 From: morvencao Date: Mon, 14 Oct 2024 09:01:30 +0000 Subject: [PATCH] consistent environment settings. Signed-off-by: morvencao --- Makefile | 16 ++++++++-------- cmd/maestro/environments/types.go | 2 +- templates/agent-template-aro-hcp.yml | 13 +++++++++++++ templates/agent-template.yml | 14 ++++++++++++++ templates/service-template-aro-hcp.yml | 6 +++--- templates/service-template.yml | 6 +++--- 6 files changed, 42 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index bf261dd8..9830d127 100755 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ mqtt_password_file=${PWD}/secrets/mqtt.password mqtt_config_file=${PWD}/secrets/mqtt.config # Log verbosity level -klog_v:=10 +klog_v:=4 # Location of the JSON web key set used to verify tokens: jwks_url:=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/certs @@ -126,11 +126,11 @@ GOLANGCI_LINT_BIN:=$(shell go env GOPATH)/bin/golangci-lint ### Envrionment-sourced variables with defaults # Can be overriden by setting environment var before running # Example: -# OCM_ENV=testing make run -# export OCM_ENV=testing; make run +# MAESTRO_ENV=testing make run +# export MAESTRO_ENV=testing; make run # Set the environment to development by default -ifndef OCM_ENV - OCM_ENV:=development +ifndef MAESTRO_ENV + MAESTRO_ENV:=development endif ifndef TEST_SUMMARY_FORMAT @@ -202,7 +202,7 @@ install: check-gopath # Examples: # make test TESTFLAGS="-run TestSomething" test: - OCM_ENV=testing gotestsum --jsonfile-timing-events=$(unit_test_json_output) --format $(TEST_SUMMARY_FORMAT) -- -p 1 -v $(TESTFLAGS) \ + MAESTRO_ENV=testing gotestsum --jsonfile-timing-events=$(unit_test_json_output) --format $(TEST_SUMMARY_FORMAT) -- -p 1 -v $(TESTFLAGS) \ ./pkg/... \ ./cmd/... .PHONY: test @@ -218,7 +218,7 @@ test: # make test-integration TESTFLAGS="-run TestAccountsGet" runs TestAccountsGet # make test-integration TESTFLAGS="-short" skips long-run tests test-integration: - OCM_ENV=testing gotestsum --jsonfile-timing-events=$(integration_test_json_output) --format $(TEST_SUMMARY_FORMAT) -- -p 1 -ldflags -s -v -timeout 1h $(TESTFLAGS) \ + MAESTRO_ENV=testing gotestsum --jsonfile-timing-events=$(integration_test_json_output) --format $(TEST_SUMMARY_FORMAT) -- -p 1 -ldflags -s -v -timeout 1h $(TESTFLAGS) \ ./test/integration .PHONY: test-integration @@ -268,7 +268,7 @@ cmds: --filename="templates/$*-template.yml" \ --local="true" \ --ignore-unknown-parameters="true" \ - --param="ENVIRONMENT=$(OCM_ENV)" \ + --param="ENVIRONMENT=$(MAESTRO_ENV)" \ --param="KLOG_V=$(klog_v)" \ --param="SERVER_REPLICAS=$(SERVER_REPLICAS)" \ --param="DATABASE_HOST=$(db_host)" \ diff --git a/cmd/maestro/environments/types.go b/cmd/maestro/environments/types.go index 53fbf2ce..2f3c0c71 100755 --- a/cmd/maestro/environments/types.go +++ b/cmd/maestro/environments/types.go @@ -16,7 +16,7 @@ const ( DevelopmentEnv string = "development" ProductionEnv string = "production" - EnvironmentStringKey string = "OCM_ENV" + EnvironmentStringKey string = "MAESTRO_ENV" EnvironmentDefault string = DevelopmentEnv ) diff --git a/templates/agent-template-aro-hcp.yml b/templates/agent-template-aro-hcp.yml index 7e3d462a..fdd27afe 100644 --- a/templates/agent-template-aro-hcp.yml +++ b/templates/agent-template-aro-hcp.yml @@ -14,6 +14,11 @@ labels: template: maestro-agent parameters: +- name: ENVIRONMENT + displayName: Environment + description: Which maestro environment to use for this deployment + value: production + - name: AGENT_NAMESPACE description: namespace of maestro agent @@ -33,6 +38,11 @@ parameters: displayName: Image tag value: latest +- name: KLOG_V + displayName: KLOG V Level + description: Log verbosity level + value: "1" + objects: - apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -271,7 +281,10 @@ objects: - --workload-source-driver=mqtt - --workload-source-config=/secrets/mqtt/config.yaml - --cloudevents-client-id=$(CONSUMER_NAME)-work-agent + - -v=${KLOG_V} env: + - name: "MAESTRO_ENV" + value: "${ENVIRONMENT}" - name: CONSUMER_NAME valueFrom: secretKeyRef: diff --git a/templates/agent-template.yml b/templates/agent-template.yml index 7350c8f5..284097e7 100644 --- a/templates/agent-template.yml +++ b/templates/agent-template.yml @@ -14,6 +14,11 @@ labels: template: maestro-agent parameters: +- name: ENVIRONMENT + displayName: Environment + description: Which maestro environment to use for this deployment + value: production + - name: AGENT_NAMESPACE description: namespace of maestro agent @@ -33,6 +38,11 @@ parameters: displayName: Image tag value: latest +- name: KLOG_V + displayName: KLOG V Level + description: Log verbosity level + value: "1" + - name: MESSAGE_DRIVER_TYPE displayName: Message Driver Type description: Message driver type, mqtt or grpc. @@ -290,6 +300,9 @@ objects: - name: maestro-agent image: ${IMAGE_REGISTRY}/${IMAGE_REPOSITORY}:${IMAGE_TAG} imagePullPolicy: IfNotPresent + env: + - name: "MAESTRO_ENV" + value: "${ENVIRONMENT}" command: - /usr/local/bin/maestro - agent @@ -297,6 +310,7 @@ objects: - --workload-source-driver=${MESSAGE_DRIVER_TYPE} - --workload-source-config=/secrets/${MESSAGE_DRIVER_TYPE}/config.yaml - --cloudevents-client-id=${CONSUMER_NAME}-work-agent + - -v=${KLOG_V} volumeMounts: - name: ${MESSAGE_DRIVER_TYPE} mountPath: /secrets/${MESSAGE_DRIVER_TYPE} diff --git a/templates/service-template-aro-hcp.yml b/templates/service-template-aro-hcp.yml index 90b5df81..26e7ff1a 100755 --- a/templates/service-template-aro-hcp.yml +++ b/templates/service-template-aro-hcp.yml @@ -16,7 +16,7 @@ parameters: - name: ENVIRONMENT displayName: Environment - description: Which Account Manager environment to use for this deployment + description: Which maestro environment to use for this deployment value: production - name: IMAGE_REGISTRY @@ -38,7 +38,7 @@ parameters: - name: KLOG_V displayName: KLOG V Level description: Log verbosity level - value: "10" + value: "1" - name: MEMORY_REQUEST description: Memory request for the API pods. @@ -230,7 +230,7 @@ objects: mountPath: /secrets/mqtt-creds readOnly: true env: - - name: "AMS_ENV" + - name: "MAESTRO_ENV" value: "${ENVIRONMENT}" - name: POD_NAME valueFrom: diff --git a/templates/service-template.yml b/templates/service-template.yml index 296235da..71c960e9 100755 --- a/templates/service-template.yml +++ b/templates/service-template.yml @@ -16,7 +16,7 @@ parameters: - name: ENVIRONMENT displayName: Environment - description: Which Account Manager environment to use for this deployment + description: Which maestro environment to use for this deployment value: production - name: IMAGE_REGISTRY @@ -47,7 +47,7 @@ parameters: - name: KLOG_V displayName: KLOG V Level description: Log verbosity level - value: "10" + value: "1" - name: MEMORY_REQUEST description: Memory request for the API pods. @@ -314,7 +314,7 @@ objects: - name: authentication mountPath: /configs/authentication env: - - name: "AMS_ENV" + - name: "MAESTRO_ENV" value: "${ENVIRONMENT}" - name: POD_NAME valueFrom: