Skip to content

Commit

Permalink
refactor scm env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
rarmatei committed Oct 14, 2024
1 parent 843229a commit d5a1131
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 102 deletions.
102 changes: 25 additions & 77 deletions charts/nx-cloud/templates/_scm-helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,75 +1,4 @@
{{- define "nxCloud.frontend.scm.github" }}
{{- if .Values.github.pr.enabled }}
{{- if eq .Values.github.pr.mode "webhook" }}
- name: NX_CLOUD_VCS_INTEGRATION_TYPE
value: 'GITHUB_WEBHOOK'
{{- if .Values.github.pr.apiUrl }}
- name: GITHUB_API_URL
value: {{ .Values.github.pr.apiUrl }}
{{- end }}
{{- if .Values.github.pr.remoteRepositoryName }}
- name: NX_CLOUD_REMOTE_REPOSITORY_NAME
value: {{ .Values.github.pr.remoteRepositoryName }}
{{- end }}
{{- if .Values.secret.name }}
- name: GITHUB_WEBHOOK_SECRET
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: {{ .Values.secret.githubWebhookSecret }}
- name: GITHUB_AUTH_TOKEN
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: {{ .Values.secret.githubAuthToken }}
{{- end }}
{{- if .Values.github.pr.defaultWorkspaceId }}
- name: NX_CLOUD_INTEGRATION_DEFAULT_WORKSPACE_ID
value: {{ .Values.github.pr.defaultWorkspaceId }}
{{- end }}
{{- end }}
{{- if eq .Values.github.pr.mode "eventless" }}
- name: NX_CLOUD_VCS_INTEGRATION_TYPE
value: 'GITHUB_EVENTLESS'
{{- if .Values.github.pr.apiUrl }}
- name: NX_CLOUD_GITHUB_API_URL
value: {{ .Values.github.pr.apiUrl }}
{{- end }}
{{- if .Values.github.pr.remoteRepositoryName }}
- name: NX_CLOUD_REMOTE_REPOSITORY_NAME
value: {{ .Values.github.pr.remoteRepositoryName }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

{{- define "nxCloud.frontend.scm.gitlab" }}
{{- if .Values.gitlab.mr.enabled }}
- name: NX_CLOUD_VCS_INTEGRATION_TYPE
value: "GITLAB_EVENTLESS"
{{- if .Values.gitlab.projectId }}
- name: NX_CLOUD_GITLAB_PROJECT_ID
value: {{ .Values.gitlab.projectId }}
{{- end }}
{{- if .Values.gitlab.apiUrl }}
- name: NX_CLOUD_GITLAB_BASE_URL
value: {{ .Values.gitlab.apiUrl }}
{{- end }}
{{- if .Values.secret.name }}
{{- if .Values.secret.gitlabAccessToken }}
- name: NX_CLOUD_GITLAB_ACCESS_TOKEN
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: {{ .Values.secret.gitlabAccessToken }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

{{- define "nxCloud.frontend.scm.all" }}
{{- include "nxCloud.frontend.scm.github" . }}
{{- include "nxCloud.frontend.scm.gitlab" . }}
{{- if .Values.vcsHttpsProxy }}
- name: VERSION_CONTROL_HTTPS_PROXY
value: {{ .Values.vcsHttpsProxy }}
Expand All @@ -78,15 +7,13 @@

{{- define "nxCloud.frontend.scm.githubAppEnv" }}
{{- if .Values.secret.name }}
{{- if .Values.secret.githubAuthToken }}
- name: NX_CLOUD_GITHUB_AUTH_TOKEN
{{- if .Values.secret.githubAppId }}
- name: NX_CLOUD_GITHUB_APP_ID
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: {{ .Values.secret.githubAuthToken }}
{{- end }}
{{- if .Values.secret.githubAppId }}
- name: NX_CLOUD_GITHUB_APP_ID
key: {{ .Values.secret.githubAppId }}
- name: NX_CLOUD_GITHUB_APP_APP_ID
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
Expand All @@ -99,5 +26,26 @@
name: {{ .Values.secret.name }}
key: {{ .Values.secret.githubPrivateKey }}
{{- end }}
{{- if .Values.secret.githubWebhookSecret }}
- name: NX_CLOUD_GITHUB_WEBHOOK_SECRET
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: {{ .Values.secret.githubWebhookSecret }}
{{- end }}
{{- if .Values.secret.githubAppClientId }}
- name: NX_CLOUD_GITHUB_APP_CLIENT_ID
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: {{ .Values.secret.githubAppClientId }}
{{- end }}
{{- if .Values.secret.githubAppClientSecret }}
- name: NX_CLOUD_GITHUB_APP_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: {{ .Values.secret.githubAppClientSecret }}
{{- end }}
{{- end }}
{{- end }}
26 changes: 1 addition & 25 deletions charts/nx-cloud/templates/nx-cloud-frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,38 +64,14 @@ spec:
{{- include "nxCloud.frontend.auth" . | indent 12 }}
{{- include "nxCloud.workflows.serviceTarget" . | indent 12 }}
{{- include "nxCloud.frontend.nxApiTarget" . | indent 12 }}
{{- include "nxCloud.frontend.scm.githubAppEnv" . | indent 12 }}
{{- if .Values.frontend.deployment.env }}
{{- toYaml .Values.frontend.deployment.env | nindent 12 }}
{{- end }}
{{- if .Values.selfSignedCertConfigMap }}
- name: NODE_EXTRA_CA_CERTS
value: /self-signed-certs/self-signed-cert.crt
{{- end}}
{{- with .Values.secret }}
{{- if .name }}
{{- if .githubPrivateKey }}
- name: NX_CLOUD_GITHUB_PRIVATE_KEY
valueFrom:
secretKeyRef:
name: {{ .name }}
key: {{ .githubPrivateKey }}
{{- end }}
{{- if .githubAppId }}
- name: NX_CLOUD_GITHUB_APP_ID
valueFrom:
secretKeyRef:
name: {{ .name }}
key: {{ .githubAppId }}
{{- end }}
{{- if .hubspotApiKey }}
- name: HUBSPOT_API_KEY
valueFrom:
secretKeyRef:
name: {{ .name }}
key: {{ .hubspotApiKey }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.selfSignedCertConfigMap }}
volumes:
- configMap:
Expand Down
3 changes: 3 additions & 0 deletions charts/nx-cloud/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ saml:
# If you plan to deploy using your own self-signed certs, add them to a config map and provide the name here
# We will mount the configmap to the pods and import the certs contained within at `self-signed-cert.crt`
selfSignedCertConfigMap: ''
vcsHttpsProxy: ''

secret:
name: ''
Expand All @@ -235,6 +236,8 @@ secret:
githubAuthToken: ''
githubAppId: ''
githubPrivateKey: ''
githubAppClientId: ''
githubAppClientSecret: ''
gitlabAccessToken: ''

extraManifests: {}

0 comments on commit d5a1131

Please sign in to comment.