Skip to content

Commit

Permalink
consistent environment settings.
Browse files Browse the repository at this point in the history
Signed-off-by: morvencao <[email protected]>
  • Loading branch information
morvencao committed Oct 14, 2024
1 parent 715e01d commit 207deb0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 15 deletions.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:=1

# 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)" \
Expand Down
2 changes: 1 addition & 1 deletion cmd/maestro/environments/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
DevelopmentEnv string = "development"
ProductionEnv string = "production"

EnvironmentStringKey string = "OCM_ENV"
EnvironmentStringKey string = "MAESTRO_ENV"
EnvironmentDefault string = DevelopmentEnv
)

Expand Down
13 changes: 13 additions & 0 deletions templates/agent-template-aro-hcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions templates/agent-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down Expand Up @@ -290,13 +300,17 @@ 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
- --consumer-name=${CONSUMER_NAME}
- --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}
Expand Down
6 changes: 3 additions & 3 deletions templates/service-template-aro-hcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -230,7 +230,7 @@ objects:
mountPath: /secrets/mqtt-creds
readOnly: true
env:
- name: "AMS_ENV"
- name: "MAESTRO_ENV"
value: "${ENVIRONMENT}"
- name: POD_NAME
valueFrom:
Expand Down
6 changes: 3 additions & 3 deletions templates/service-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -314,7 +314,7 @@ objects:
- name: authentication
mountPath: /configs/authentication
env:
- name: "AMS_ENV"
- name: "MAESTRO_ENV"
value: "${ENVIRONMENT}"
- name: POD_NAME
valueFrom:
Expand Down

0 comments on commit 207deb0

Please sign in to comment.