Skip to content

Commit

Permalink
chore(ci-automation): Introduce new Gen3 CLI cmds to mutate k8s confi…
Browse files Browse the repository at this point in the history
…gmaps (#1621)

* chore(ci-automation): Introduce new Gen3 CLI cmds to mutate k8s configmaps

* add comments

Co-authored-by: Atharva Rane <[email protected]>
  • Loading branch information
Marcelo R Costa and atharvar28 authored Jun 7, 2021
1 parent 07980fe commit fda0430
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gen3/bin/mutate-etl-mapping-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

source "${GEN3_HOME}/gen3/lib/utils.sh"
gen3_load "gen3/gen3setup"

set -xe

# script for mutating the ETLMapping.yaml on jenkins env
# the incoming PR environment's ETLMapping.yaml is mutated to Jenkins environment

# how it is executed?
# gen3 mutate-etl-mapping-config {PR} {repoName}

echo "hello world"

prNumber=$1
repoName=$2

kubectl get cm etl-mapping -o jsonpath='{.data.etlMapping\.yaml}' > etlMapping.yaml
sed -i 's/.*name: \(.*\)_subject$/ name: '"${prNumber}"'.'"${repoName}"'.\1_subject/' etlMapping.yaml
sed -i 's/.*name: \(.*\)_etl$/ name: '"${prNumber}"'.'"${repoName}"'.\1_etl/' etlMapping.yaml
sed -i 's/.*name: \(.*\)_file$/ name: '"${prNumber}"'.'"${repoName}"'.\1_file/' etlMapping.yaml
kubectl delete configmap etl-mapping
kubectl create configmap etl-mapping --from-file=etlMapping.yaml=etlMapping.yaml
24 changes: 24 additions & 0 deletions gen3/bin/mutate-guppy-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

source "${GEN3_HOME}/gen3/lib/utils.sh"
gen3_load "gen3/gen3setup"

set -xe

# script for mutating the guppy configuration on jenkins env
# the incoming PR's guppy configuration is mutated to Jenkins environment

# how it is executed?
# gen3 mutate-guppy-config {PR} {repoName}

prNumber=$1
repoName=$2

kubectl get configmap manifest-guppy -o yaml > original_guppy_config.yaml
sed -i 's/\(.*\)"index": "\(.*\)_subject",$/\1"index": "'"${prNumber}"'.'"${repoName}"'.\2_subject",/' original_guppy_config.yaml
sed -i 's/\(.*\)"index": "\(.*\)_etl",$/\1"index": "'"${prNumber}"'.'"${repoName}"'.\2_etl",/' original_guppy_config.yaml
sed -i 's/\(.*\)"index": "\(.*\)_file",$/\1"index": "'"${prNumber}"'.'"${repoName}"'.\2_file",/' original_guppy_config.yaml
sed -i 's/\(.*\)"config_index": "\(.*\)_array-config",$/\1"config_index": "'"${prNumber}"'.'"${repoName}"'.\2_array-config",/' original_guppy_config.yaml
kubectl delete configmap manifest-guppy
kubectl apply -f original_guppy_config.yaml
gen3 roll guppy

0 comments on commit fda0430

Please sign in to comment.