From 84d9b3dd3a55d4c32fa5efe4987fe59b2b05b7e4 Mon Sep 17 00:00:00 2001 From: "Yeshaswini.M" Date: Wed, 14 Jul 2021 16:14:50 +0530 Subject: [PATCH 1/7] Auto config for s3 and stash --- .../configmaps/datasource-creation.yaml | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/charts/oes/templates/configmaps/datasource-creation.yaml b/charts/oes/templates/configmaps/datasource-creation.yaml index 4f3187c2..0208f770 100644 --- a/charts/oes/templates/configmaps/datasource-creation.yaml +++ b/charts/oes/templates/configmaps/datasource-creation.yaml @@ -29,7 +29,7 @@ data: SAPOR=$(grep oes-sapor /tmp/inst.status | awk '{print $2}') PLATFORM=$(grep oes-platform /tmp/inst.status | awk '{print $2}') AUTOPILOT=$(grep oes-autopilot /tmp/inst.status | awk '{print $2}') - + wait_period=$(($wait_period+10)) @@ -41,9 +41,36 @@ data: curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST --data '{"datasourceType": "AUTOPILOT", "name": "Autopilot", "configurationFields": {"username": "admin"} }' http://oes-platform:8095/platformservice/v2/datasources #curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST --data '{"datasourceType": "ELASTICSEARCH", "name": "elastic-default", "configurationFields": {"endPoint": "https://newoeselastic.opsmx.com", "username": "opsmxuser", "password": "OpsMx@123", "kibanaEndPoint": "https://newoeskibana.opsmx.com", "kibanaPassword": "OpsMx@123", "kibanaUsername": "opsmxuser" }}' http://oes-platform:8095/platformservice/v2/datasources #curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST --data '{"datasourceType": "PROMETHEUS", "name": "prometheus-default", "configurationFields": {"endPoint": "http://prometheus:9090"} }' http://oes-platform:8095/platformservice/v2/datasources - curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType": "GITHUB", "name": "gitops", "spinEnabled": "false", "configurationFields": {"token": "{{ .Values.spinnaker.gitopsHalyard.repo.token }}", "username": "{{ .Values.spinnaker.gitopsHalyard.repo.username }}" } }' - curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "YWRtaW46b3BzbXhhZG1pbjEyMw==", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops", "endPoint": "https://github.com/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "GITHUB" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://github.com/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops" , "provider": "GITHUB" } }' - break + + + {{- if .Values.spinnaker.gitopsHalyard.enabled -}} + STORAGE_TYPE = {{ .Values.spinnaker.gitopsHalyard.repo.type }} + USERNAME = {{ .Values.spinnaker.spinCli.auth.basic.username }} + PASSWORD = {{ .Values.spinnaker.spinCli.auth.basic.password }} + TOKEN = $($USERNAME:$PASSWORD | base64) + response=$(curl -s {{ .Values.oesGate.protocol }}://{{ .Values.oesGate.host }}/oes/accountsConfig/v1/spinnaker -u $USERNAME:$PASSWORD) + name=$(echo $response | jq '.[].name') + if [ -z "$name" ]; + then + if [[ "$STORAGE_TYPE" == "git" ]]; + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType": "GITHUB", "name": "gitops", "spinEnabled": "false", "configurationFields": {"token": "{{ .Values.spinnaker.gitopsHalyard.repo.token }}", "username": "{{ .Values.spinnaker.gitopsHalyard.repo.username }}" } }' + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "$TOKEN", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops", "endPoint": "https://github.com/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "GITHUB" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://github.com/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops" , "provider": "GITHUB" } }' + break + fi + if [[ "$STORAGE_TYPE" == "stash" ]]; + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType": "BITBUCKET", "name": "gitops-bitbucket", "spinEnabled": "false", "configurationFields": {"authType":"bearer","username": "{{ .Values.spinnaker.gitopsHalyard.repo.username }}","token": "{{ .Values.spinnaker.gitopsHalyard.repo.token }}","read":"","write":""} }' + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "$TOKEN", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-bitbucket", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "BITBUCKET" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops-bitbucket" , "provider": "BITBUCKET" } }' + break + fi + if [[ "$STORAGE_TYPE" == "s3" ]]; + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType":"AMAZONS3","name":"gitops-s3","configurationFields":{"access_id":"{{ .Values.spinnaker.gitopsHalyard.repo.s3accesskey }}","secret_key":"{{ .Values.spinnaker.gitopsHalyard.repo.s3secretkey }}"},"spinnakerNames":[""],"spinEnabled":false} }' + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "$TOKEN", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-s3", "endPoint": "", "provider": "AMAZONS3" }, "halConfiguration": {"accountName": "gitops-s3", "bucketName":"{{ .Values.spinnaker.gitopsHalyard.repo.s3bucket }}","region":"{{ .Values.spinnaker.gitopsHalyard.repo.s3region }}" , "endPoint": "", "accountName": "gitops-s3" , "provider": "AMAZONS3" } }' + break + fi + else + echo "Spinnaker is already Integrated" + fi + {{- end -}} else if [ $wait_period -gt 2000 ]; then From 84c6f8b44de73f11696019b14bb119d4bb555086 Mon Sep 17 00:00:00 2001 From: "Yeshaswini.M" Date: Fri, 16 Jul 2021 20:21:02 +0530 Subject: [PATCH 2/7] Fixing the syntax errors --- .../configmaps/datasource-creation.yaml | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/charts/oes/templates/configmaps/datasource-creation.yaml b/charts/oes/templates/configmaps/datasource-creation.yaml index 0208f770..d9a924bf 100644 --- a/charts/oes/templates/configmaps/datasource-creation.yaml +++ b/charts/oes/templates/configmaps/datasource-creation.yaml @@ -44,33 +44,38 @@ data: {{- if .Values.spinnaker.gitopsHalyard.enabled -}} - STORAGE_TYPE = {{ .Values.spinnaker.gitopsHalyard.repo.type }} - USERNAME = {{ .Values.spinnaker.spinCli.auth.basic.username }} - PASSWORD = {{ .Values.spinnaker.spinCli.auth.basic.password }} - TOKEN = $($USERNAME:$PASSWORD | base64) + + STORAGE_TYPE={{ .Values.spinnaker.gitopsHalyard.repo.type }} + USERNAME={{ .Values.spinnaker.spinCli.auth.basic.username }} + PASSWORD={{ .Values.spinnaker.spinCli.auth.basic.password }} + TOKEN=$(echo -n "$USERNAME":"$PASSWORD" | base64) response=$(curl -s {{ .Values.oesGate.protocol }}://{{ .Values.oesGate.host }}/oes/accountsConfig/v1/spinnaker -u $USERNAME:$PASSWORD) name=$(echo $response | jq '.[].name') if [ -z "$name" ]; then if [[ "$STORAGE_TYPE" == "git" ]]; + then curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType": "GITHUB", "name": "gitops", "spinEnabled": "false", "configurationFields": {"token": "{{ .Values.spinnaker.gitopsHalyard.repo.token }}", "username": "{{ .Values.spinnaker.gitopsHalyard.repo.username }}" } }' - curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "$TOKEN", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops", "endPoint": "https://github.com/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "GITHUB" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://github.com/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops" , "provider": "GITHUB" } }' + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops", "endPoint": "https://github.com/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "GITHUB" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://github.com/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops" , "provider": "GITHUB" } }' break fi if [[ "$STORAGE_TYPE" == "stash" ]]; + then curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType": "BITBUCKET", "name": "gitops-bitbucket", "spinEnabled": "false", "configurationFields": {"authType":"bearer","username": "{{ .Values.spinnaker.gitopsHalyard.repo.username }}","token": "{{ .Values.spinnaker.gitopsHalyard.repo.token }}","read":"","write":""} }' - curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "$TOKEN", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-bitbucket", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "BITBUCKET" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops-bitbucket" , "provider": "BITBUCKET" } }' + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-bitbucket", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "BITBUCKET" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops-bitbucket" , "provider": "BITBUCKET" } }' break fi if [[ "$STORAGE_TYPE" == "s3" ]]; + then curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType":"AMAZONS3","name":"gitops-s3","configurationFields":{"access_id":"{{ .Values.spinnaker.gitopsHalyard.repo.s3accesskey }}","secret_key":"{{ .Values.spinnaker.gitopsHalyard.repo.s3secretkey }}"},"spinnakerNames":[""],"spinEnabled":false} }' - curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "$TOKEN", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-s3", "endPoint": "", "provider": "AMAZONS3" }, "halConfiguration": {"accountName": "gitops-s3", "bucketName":"{{ .Values.spinnaker.gitopsHalyard.repo.s3bucket }}","region":"{{ .Values.spinnaker.gitopsHalyard.repo.s3region }}" , "endPoint": "", "accountName": "gitops-s3" , "provider": "AMAZONS3" } }' - break + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/v1/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'" , "externalAccountFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-s3","provider": "AMAZONS3","config":{"bucketName":"{{ .Values.spinnaker.gitopsHalyard.repo.s3bucket }}","region":"{{ .Values.spinnaker.gitopsHalyard.repo.s3region }}","endPoint":""}}}' fi else echo "Spinnaker is already Integrated" fi + {{- end -}} + else if [ $wait_period -gt 2000 ]; then From 27564afa622d258b978e316781d77896e1ba2ff5 Mon Sep 17 00:00:00 2001 From: "Yeshaswini.M" Date: Fri, 16 Jul 2021 20:52:13 +0530 Subject: [PATCH 3/7] changed the image tag --- charts/oes/templates/configmaps/datasource-creation.yaml | 1 + charts/oes/templates/hooks/oes-config-job.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/oes/templates/configmaps/datasource-creation.yaml b/charts/oes/templates/configmaps/datasource-creation.yaml index d9a924bf..4f7eb50b 100644 --- a/charts/oes/templates/configmaps/datasource-creation.yaml +++ b/charts/oes/templates/configmaps/datasource-creation.yaml @@ -72,6 +72,7 @@ data: fi else echo "Spinnaker is already Integrated" + break fi {{- end -}} diff --git a/charts/oes/templates/hooks/oes-config-job.yaml b/charts/oes/templates/hooks/oes-config-job.yaml index e8fe3f33..c7423a5a 100644 --- a/charts/oes/templates/hooks/oes-config-job.yaml +++ b/charts/oes/templates/hooks/oes-config-job.yaml @@ -22,7 +22,7 @@ spec: containers: - command: ["bash", "/tmp/config/datasource-api.sh" ] name: datasource-creation-api - image: quay.io/opsmxpublic/oes-pre-configure:v1 + image: quay.io/opsmxpublic/oes-pre-configure:v2 volumeMounts: - mountPath: /tmp/config name: datasource-creation From eb24f2c1d5b75dcbded813bc332192a6375e1476 Mon Sep 17 00:00:00 2001 From: "Yeshaswini.M" Date: Tue, 20 Jul 2021 10:52:46 +0530 Subject: [PATCH 4/7] fixed the curl command --- charts/oes/templates/configmaps/datasource-creation.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/oes/templates/configmaps/datasource-creation.yaml b/charts/oes/templates/configmaps/datasource-creation.yaml index 4f7eb50b..977a8bb4 100644 --- a/charts/oes/templates/configmaps/datasource-creation.yaml +++ b/charts/oes/templates/configmaps/datasource-creation.yaml @@ -43,7 +43,7 @@ data: #curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST --data '{"datasourceType": "PROMETHEUS", "name": "prometheus-default", "configurationFields": {"endPoint": "http://prometheus:9090"} }' http://oes-platform:8095/platformservice/v2/datasources - {{- if .Values.spinnaker.gitopsHalyard.enabled -}} + {{- if .Values.spinnaker.gitopsHalyard.enabled }} STORAGE_TYPE={{ .Values.spinnaker.gitopsHalyard.repo.type }} USERNAME={{ .Values.spinnaker.spinCli.auth.basic.username }} @@ -75,7 +75,7 @@ data: break fi - {{- end -}} + {{- end }} else if [ $wait_period -gt 2000 ]; From f81ee3850ad0fb868e1c2dd994618951f99ad831 Mon Sep 17 00:00:00 2001 From: "Yeshaswini.M" Date: Tue, 20 Jul 2021 11:24:16 +0530 Subject: [PATCH 5/7] fixed the curl command --- charts/oes/templates/configmaps/datasource-creation.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/oes/templates/configmaps/datasource-creation.yaml b/charts/oes/templates/configmaps/datasource-creation.yaml index 977a8bb4..23abe5ff 100644 --- a/charts/oes/templates/configmaps/datasource-creation.yaml +++ b/charts/oes/templates/configmaps/datasource-creation.yaml @@ -68,7 +68,7 @@ data: if [[ "$STORAGE_TYPE" == "s3" ]]; then curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType":"AMAZONS3","name":"gitops-s3","configurationFields":{"access_id":"{{ .Values.spinnaker.gitopsHalyard.repo.s3accesskey }}","secret_key":"{{ .Values.spinnaker.gitopsHalyard.repo.s3secretkey }}"},"spinnakerNames":[""],"spinEnabled":false} }' - curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/v1/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'" , "externalAccountFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-s3","provider": "AMAZONS3","config":{"bucketName":"{{ .Values.spinnaker.gitopsHalyard.repo.s3bucket }}","region":"{{ .Values.spinnaker.gitopsHalyard.repo.s3region }}","endPoint":""}}}' + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/v1/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'" , "externalAccountFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-s3","config":{"bucketName":"{{ .Values.spinnaker.gitopsHalyard.repo.s3bucket }}","region":"{{ .Values.spinnaker.gitopsHalyard.repo.s3region }}","endPoint":""},"provider": "AMAZONS3"}}' fi else echo "Spinnaker is already Integrated" From b2dd7284b77801b09d8dd06a0759a93939539d8b Mon Sep 17 00:00:00 2001 From: Yeshaswini Murthy <68692913+yeshaswiniOpsmx@users.noreply.github.com> Date: Thu, 19 Aug 2021 16:24:48 +0530 Subject: [PATCH 6/7] Update datasource-creation.yaml --- .../configmaps/datasource-creation.yaml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/charts/oes/templates/configmaps/datasource-creation.yaml b/charts/oes/templates/configmaps/datasource-creation.yaml index 23abe5ff..a714d5f1 100644 --- a/charts/oes/templates/configmaps/datasource-creation.yaml +++ b/charts/oes/templates/configmaps/datasource-creation.yaml @@ -61,20 +61,27 @@ data: fi if [[ "$STORAGE_TYPE" == "stash" ]]; then - curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType": "BITBUCKET", "name": "gitops-bitbucket", "spinEnabled": "false", "configurationFields": {"authType":"bearer","username": "{{ .Values.spinnaker.gitopsHalyard.repo.username }}","token": "{{ .Values.spinnaker.gitopsHalyard.repo.token }}","read":"","write":""} }' - curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-bitbucket", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "BITBUCKET" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops-bitbucket" , "provider": "BITBUCKET" } }' + if [[ "{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}" ]] + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType": "BITBUCKET", "name": "gitops-bitbucket", "spinEnabled": "false", "configurationFields": {"authType":"bearer","username": "{{ .Values.spinnaker.gitopsHalyard.repo.username }}","token": "{{ .Values.spinnaker.gitopsHalyard.repo.token }}","read":"","write":""} }' + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-bitbucket", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "BITBUCKET" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops-bitbucket" , "provider": "BITBUCKET" } }' break + else + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType": "BITBUCKET", "name": "gitops-bitbucket", "spinEnabled": "false", "configurationFields": {"authType":"bearer","username": "{{ .Values.spinnaker.gitopsHalyard.repo.username }}","token": "{{ .Values.spinnaker.gitopsHalyard.repo.token }}","read":"","write":""} }' + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-bitbucket", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "BITBUCKET" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops-bitbucket" , "provider": "BITBUCKET" } }' + break + fi fi if [[ "$STORAGE_TYPE" == "s3" ]]; then - curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType":"AMAZONS3","name":"gitops-s3","configurationFields":{"access_id":"{{ .Values.spinnaker.gitopsHalyard.repo.s3accesskey }}","secret_key":"{{ .Values.spinnaker.gitopsHalyard.repo.s3secretkey }}"},"spinnakerNames":[""],"spinEnabled":false} }' - curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/v1/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'" , "externalAccountFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-s3","config":{"bucketName":"{{ .Values.spinnaker.gitopsHalyard.repo.s3bucket }}","region":"{{ .Values.spinnaker.gitopsHalyard.repo.s3region }}","endPoint":""},"provider": "AMAZONS3"}}' + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType":"AMAZONS3","name":"gitops-s3","configurationFields":{"access_id":"{{ .Values.spinnaker.gitopsHalyard.repo.s3accesskey }}","secret_key":"{{ .Values.spinnaker.gitopsHalyard.repo.s3secretkey }}"},"spinnakerNames":[""],"spinEnabled":false} }' + curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/v1/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'" , "externalAccountFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-s3","config":{"bucketName":"{{ .Values.spinnaker.gitopsHalyard.repo.s3bucket }}","region":"{{ .Values.spinnaker.gitopsHalyard.repo.s3region }}","endPoint":""},"provider": "AMAZONS3"}}' fi else echo "Spinnaker is already Integrated" break fi - + {{ else }} + break {{- end }} else From 429bd881d040ca8b4889a935812942c025d0bd5e Mon Sep 17 00:00:00 2001 From: Yeshaswini Murthy <68692913+yeshaswiniOpsmx@users.noreply.github.com> Date: Thu, 19 Aug 2021 17:02:43 +0530 Subject: [PATCH 7/7] syntax fix --- charts/oes/templates/configmaps/datasource-creation.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/oes/templates/configmaps/datasource-creation.yaml b/charts/oes/templates/configmaps/datasource-creation.yaml index a714d5f1..7920f54a 100644 --- a/charts/oes/templates/configmaps/datasource-creation.yaml +++ b/charts/oes/templates/configmaps/datasource-creation.yaml @@ -62,6 +62,7 @@ data: if [[ "$STORAGE_TYPE" == "stash" ]]; then if [[ "{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}" ]] + then curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-platform:8095/platformservice/v2/datasources --data '{"datasourceType": "BITBUCKET", "name": "gitops-bitbucket", "spinEnabled": "false", "configurationFields": {"authType":"bearer","username": "{{ .Values.spinnaker.gitopsHalyard.repo.username }}","token": "{{ .Values.spinnaker.gitopsHalyard.repo.token }}","read":"","write":""} }' curl --header "Content-Type: application/json" --header "x-spinnaker-user: admin" --request POST http://oes-sapor:8085/oes/accountsConfig/spinnaker --data '{"name": "preview-saas", "url": "{{ .Values.global.spinGate.protocol }}://{{ .Values.global.spinGate.host }}", "authenticationType": "LDAP", "token": "'"${TOKEN}"'", "externalAccountFlag": "true", "halyardConfigurationFlag": "true", "externalAccountConfiguration": {"accountName": "gitops-bitbucket", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "provider": "BITBUCKET" }, "halConfiguration": {"accountName": "gitops", "endPoint": "https://{{ .Values.spinnaker.gitopsHalyard.repo.baseUrlHostName }}/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.projectName }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git", "accountName": "gitops-bitbucket" , "provider": "BITBUCKET" } }' break