-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Configmap handling to deployments (#419)
Co-authored-by: David Gamero <[email protected]>
- Loading branch information
1 parent
ee68ec6
commit ea0fc31
Showing
47 changed files
with
805 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -444,6 +444,8 @@ jobs: | |
npm install -g [email protected] | ||
ajv validate -s test/update_dry_run_schema.json -d test/temp/update_dry_run.json | ||
- run: ./draft -v update -d ./langtest/ -a webapp_routing --variable ingress-tls-cert-keyvault-uri=test.cert.keyvault.uri --variable ingress-use-osm-mtls=true --variable ingress-host=host1 | ||
- name: print manifests | ||
run: cat ./langtest/manifests/* | ||
- name: start minikube | ||
id: minikube | ||
uses: medyagh/setup-minikube@master | ||
|
@@ -2238,7 +2240,7 @@ jobs: | |
- run: mkdir ./langtest | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: OliverMKing/ruby-hello-world | ||
repository: davidgamero/sinatra-hello-world | ||
path: ./langtest | ||
- name: Execute Dry Run with config file | ||
run: | | ||
|
@@ -2273,7 +2275,7 @@ jobs: | |
- run: mkdir ./langtest | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: OliverMKing/ruby-hello-world | ||
repository: davidgamero/sinatra-hello-world | ||
path: ./langtest | ||
- run: rm -rf ./langtest/manifests && rm -f ./langtest/Dockerfile ./langtest/.dockerignore | ||
- run: ./draft -v create -c ./test/integration/ruby/helm.yaml -d ./langtest/ | ||
|
@@ -2379,7 +2381,7 @@ jobs: | |
- run: mkdir ./langtest | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: OliverMKing/ruby-hello-world | ||
repository: davidgamero/sinatra-hello-world | ||
path: ./langtest | ||
- name: Execute Dry Run with config file | ||
run: | | ||
|
@@ -2414,7 +2416,7 @@ jobs: | |
- run: mkdir ./langtest | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: OliverMKing/ruby-hello-world | ||
repository: davidgamero/sinatra-hello-world | ||
path: ./langtest | ||
- run: rm -rf ./langtest/manifests && rm -f ./langtest/Dockerfile ./langtest/.dockerignore | ||
- run: ./draft -v create -c ./test/integration/ruby/kustomize.yaml -d ./langtest/ | ||
|
@@ -2511,7 +2513,7 @@ jobs: | |
- run: mkdir ./langtest | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: OliverMKing/ruby-hello-world | ||
repository: davidgamero/sinatra-hello-world | ||
path: ./langtest | ||
- name: Execute Dry Run with config file | ||
run: | | ||
|
@@ -2546,7 +2548,7 @@ jobs: | |
- run: mkdir ./langtest | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: OliverMKing/ruby-hello-world | ||
repository: davidgamero/sinatra-hello-world | ||
path: ./langtest | ||
- run: rm -rf ./langtest/manifests && rm -f ./langtest/Dockerfile ./langtest/.dockerignore | ||
- run: ./draft -v create -c ./test/integration/ruby/manifest.yaml -d ./langtest/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
package transformers | ||
|
||
func GetTransformer(variableKind string) func(string) (string, error) { | ||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func GetTransformer(variableKind string) func(string) (any, error) { | ||
switch variableKind { | ||
case "envVarMap": | ||
return EnvironmentVariableMapTransformer | ||
default: | ||
return DefaultTransformer | ||
} | ||
} | ||
|
||
func DefaultTransformer(inputVar string) (string, error) { | ||
func EnvironmentVariableMapTransformer(inputVar string) (any, error) { | ||
var inputVarMap map[string]string | ||
if err := json.Unmarshal([]byte(inputVar), &inputVarMap); err != nil { | ||
return "", fmt.Errorf("failed to unmarshal variable as map[string]string: %s", err) | ||
} | ||
return inputVarMap, nil | ||
} | ||
|
||
func DefaultTransformer(inputVar string) (any, error) { | ||
return inputVar, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
package validators | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func GetValidator(variableKind string) func(string) error { | ||
switch variableKind { | ||
case "envVarMap": | ||
return KeyValueMapValidator | ||
default: | ||
return DefaultValidator | ||
} | ||
} | ||
|
||
func KeyValueMapValidator(input string) error { | ||
if err := json.Unmarshal([]byte(input), &map[string]string{}); err != nil { | ||
return fmt.Errorf("failed to unmarshal variable as map[string]string: %s", err) | ||
} | ||
return nil | ||
} | ||
|
||
func DefaultValidator(input string) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
pkg/fixtures/deployments/helm/charts/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "testapp.fullname" . }}-config | ||
labels: | ||
{{- include "testapp.labels" . | nindent 4 }} | ||
namespace: {{ .Values.namespace }} | ||
data: | ||
{{- range $key, $value := .Values.envVars }} | ||
{{ $key }}: {{ $value }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: testapp-config | ||
namespace: default | ||
labels: | ||
app.kubernetes.io/name: testapp | ||
kubernetes.azure.com/generator: draft | ||
data: |
Oops, something went wrong.