Fix config issues with new env library (#273)
* correct config issues #271 #272 * rename type tags * replace env lib * move to config module * read flags * show e2e logs on error * extract env * replace deprecated env var * increment index * check replica numbers do not start with 0 * remove test suite * error handling * refactor flags * flags test * file test * file test * config tests * extend tests * test mixed mode * simplify * simplify * test mask * correct uniqe replicas * Update types_test.go * e2e test with file mode
This commit is contained in:
1
testdata/.gitignore
vendored
1
testdata/.gitignore
vendored
@@ -1 +1,2 @@
|
||||
docker-compose.yaml
|
||||
!config_test_*.yaml
|
||||
|
||||
36
testdata/config_test_replica.yaml
vendored
Normal file
36
testdata/config_test_replica.yaml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
origin:
|
||||
url: https://origin-file:443
|
||||
webURL: https://origin-file:443
|
||||
apiPath: /control
|
||||
username: foo
|
||||
password: '*********'
|
||||
insecureSkipVerify: true
|
||||
autoSetup: false
|
||||
replica:
|
||||
url: https://replica-file:443
|
||||
webURL: https://replica-file:443
|
||||
apiPath: /control
|
||||
username: bar
|
||||
password: '*********'
|
||||
insecureSkipVerify: false
|
||||
autoSetup: false
|
||||
interfaceName: eth3
|
||||
cron: '*/15 * * * *'
|
||||
runOnStart: true
|
||||
printConfigOnly: true
|
||||
api:
|
||||
port: 9090
|
||||
features:
|
||||
dns:
|
||||
accessLists: true
|
||||
serverConfig: false
|
||||
rewrites: true
|
||||
dhcp:
|
||||
serverConfig: true
|
||||
staticLeases: true
|
||||
generalSettings: true
|
||||
queryLogConfig: true
|
||||
statsConfig: true
|
||||
clientSettings: true
|
||||
services: true
|
||||
filters: true
|
||||
36
testdata/config_test_replicas.yaml
vendored
Normal file
36
testdata/config_test_replicas.yaml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
origin:
|
||||
url: https://origin-file:443
|
||||
webURL: https://origin-file:443
|
||||
apiPath: /control
|
||||
username: foo
|
||||
password: '*********'
|
||||
insecureSkipVerify: true
|
||||
autoSetup: false
|
||||
replicas:
|
||||
- url: https://replica-file:443
|
||||
webURL: https://replica-file:443
|
||||
apiPath: /control
|
||||
username: bar
|
||||
password: '*********'
|
||||
insecureSkipVerify: false
|
||||
autoSetup: false
|
||||
interfaceName: eth3
|
||||
cron: '*/15 * * * *'
|
||||
runOnStart: true
|
||||
printConfigOnly: true
|
||||
api:
|
||||
port: 9090
|
||||
features:
|
||||
dns:
|
||||
accessLists: true
|
||||
serverConfig: false
|
||||
rewrites: true
|
||||
dhcp:
|
||||
serverConfig: true
|
||||
staticLeases: true
|
||||
generalSettings: true
|
||||
queryLogConfig: true
|
||||
statsConfig: true
|
||||
clientSettings: true
|
||||
services: true
|
||||
filters: true
|
||||
45
testdata/config_test_replicas_and_replica.yaml
vendored
Normal file
45
testdata/config_test_replicas_and_replica.yaml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
origin:
|
||||
url: https://origin-file:443
|
||||
webURL: https://origin-file:443
|
||||
apiPath: /control
|
||||
username: foo
|
||||
password: '*********'
|
||||
insecureSkipVerify: true
|
||||
autoSetup: false
|
||||
replica:
|
||||
url: https://replica-file:443
|
||||
webURL: https://replica-file:443
|
||||
apiPath: /control
|
||||
username: bar
|
||||
password: '*********'
|
||||
insecureSkipVerify: false
|
||||
autoSetup: false
|
||||
interfaceName: eth3
|
||||
replicas:
|
||||
- url: https://replicas-file:443
|
||||
webURL: https://replicas-file:443
|
||||
apiPath: /control
|
||||
username: bar
|
||||
password: '*********'
|
||||
insecureSkipVerify: false
|
||||
autoSetup: false
|
||||
interfaceName: eth3
|
||||
cron: '*/15 * * * *'
|
||||
runOnStart: true
|
||||
printConfigOnly: true
|
||||
api:
|
||||
port: 9090
|
||||
features:
|
||||
dns:
|
||||
accessLists: true
|
||||
serverConfig: false
|
||||
rewrites: true
|
||||
dhcp:
|
||||
serverConfig: true
|
||||
staticLeases: true
|
||||
generalSettings: true
|
||||
queryLogConfig: true
|
||||
statsConfig: true
|
||||
clientSettings: true
|
||||
services: true
|
||||
filters: true
|
||||
2
testdata/e2e/bin/install-chart.sh
vendored
2
testdata/e2e/bin/install-chart.sh
vendored
@@ -6,4 +6,4 @@ kubectl config set-context --current --namespace=agh-e2e
|
||||
if [[ $(helm list --no-headers -n agh-e2e | grep agh-e2e | wc -l) == "1" ]]; then
|
||||
helm delete agh-e2e -n agh-e2e --wait
|
||||
fi
|
||||
helm install agh-e2e testdata/e2e -n agh-e2e --create-namespace
|
||||
helm install agh-e2e testdata/e2e -n agh-e2e --create-namespace --set mode=${1}
|
||||
|
||||
6
testdata/e2e/bin/wait-for-sync.sh
vendored
6
testdata/e2e/bin/wait-for-sync.sh
vendored
@@ -1,4 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
kubectl wait --for=jsonpath='{.status.phase}'=Succeeded pod/adguardhome-sync --timeout=1m
|
||||
RESULT=$?
|
||||
if [[ "${RESULT}" != "0" ]]; then
|
||||
kubectl logs adguardhome-sync
|
||||
fi
|
||||
exit ${RESULT}
|
||||
|
||||
18
testdata/e2e/templates/configmap-sync-env.yaml
vendored
Normal file
18
testdata/e2e/templates/configmap-sync-env.yaml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{{- if eq .Values.mode "env" }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: sync-conf
|
||||
namespace: {{ .Release.Namespace }}
|
||||
data:
|
||||
API_PORT: '0'
|
||||
ORIGIN_URL: 'http://service-origin.{{ $.Release.Namespace }}.svc.cluster.local:3000'
|
||||
ORIGIN_PASSWORD: 'password'
|
||||
ORIGIN_USERNAME: 'username'
|
||||
{{- range $i,$version := .Values.replica.versions }}
|
||||
REPLICA{{ add 1 $i }}_AUTO_SETUP: 'true'
|
||||
REPLICA{{ add 1 $i }}_URL: 'http://service-replica-{{ $version | toString | replace "." "-" }}.{{ $.Release.Namespace }}.svc.cluster.local:3000'
|
||||
REPLICA{{ add 1 $i }}_PASSWORD: 'password'
|
||||
REPLICA{{ add 1 $i }}_USERNAME: 'username'
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
22
testdata/e2e/templates/configmap-sync-file.yaml
vendored
Normal file
22
testdata/e2e/templates/configmap-sync-file.yaml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{{- if eq .Values.mode "file" }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: sync-conf
|
||||
namespace: {{ .Release.Namespace }}
|
||||
data:
|
||||
config.yaml: |
|
||||
origin:
|
||||
url: 'http://service-origin.{{ $.Release.Namespace }}.svc.cluster.local:3000'
|
||||
username: username
|
||||
password: password
|
||||
api:
|
||||
port: 0
|
||||
replicas:
|
||||
{{- range $i,$version := .Values.replica.versions }}
|
||||
- url: 'http://service-replica-{{ $version | toString | replace "." "-" }}.{{ $.Release.Namespace }}.svc.cluster.local:3000'
|
||||
username: username
|
||||
password: password
|
||||
autoSetup: true
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
17
testdata/e2e/templates/configmap-sync.yaml
vendored
17
testdata/e2e/templates/configmap-sync.yaml
vendored
@@ -1,17 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: sync-conf
|
||||
namespace: {{ .Release.Namespace }}
|
||||
data:
|
||||
API_PORT: '0'
|
||||
LOG_LEVEL: 'debug'
|
||||
ORIGIN_URL: 'http://service-origin.{{ $.Release.Namespace }}.svc.cluster.local:3000'
|
||||
ORIGIN_PASSWORD: 'password'
|
||||
ORIGIN_USERNAME: 'username'
|
||||
{{ range $i,$version := .Values.replica.versions }}
|
||||
REPLICA{{ $i }}_AUTOSETUP: 'true'
|
||||
REPLICA{{ $i }}_URL: 'http://service-replica-{{ $version | toString | replace "." "-" }}.{{ $.Release.Namespace }}.svc.cluster.local:3000'
|
||||
REPLICA{{ $i }}_PASSWORD: 'password'
|
||||
REPLICA{{ $i }}_USERNAME: 'username'
|
||||
{{- end }}
|
||||
@@ -1,3 +1,4 @@
|
||||
{{- if eq .Values.mode "env" }}
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
@@ -7,7 +8,7 @@ spec:
|
||||
serviceAccountName: agh-e2e
|
||||
initContainers:
|
||||
- name: wait-for-others
|
||||
image: bitnami/kubectl:1.24
|
||||
image: {{ .Values.kubectl.repository }}:{{ .Values.kubectl.tag }}
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
@@ -19,7 +20,11 @@ spec:
|
||||
command:
|
||||
- /opt/go/adguardhome-sync
|
||||
- run
|
||||
env:
|
||||
- name: LOG_LEVEL
|
||||
value: 'debug'
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: sync-conf
|
||||
restartPolicy: Never
|
||||
{{- end }}
|
||||
36
testdata/e2e/templates/pod-adguardhome-sync-file.yaml
vendored
Normal file
36
testdata/e2e/templates/pod-adguardhome-sync-file.yaml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{{- if eq .Values.mode "file" }}
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: adguardhome-sync
|
||||
namespace: {{ $.Release.Namespace }}
|
||||
spec:
|
||||
serviceAccountName: agh-e2e
|
||||
initContainers:
|
||||
- name: wait-for-others
|
||||
image: {{ .Values.kubectl.repository }}:{{ .Values.kubectl.tag }}
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
{{- .Files.Get "bin/wait-for-agh-pods.sh" | nindent 10}}
|
||||
containers:
|
||||
- name: adguardhome-sync
|
||||
image: localhost:5001/adguardhome-sync:e2e
|
||||
command:
|
||||
- /opt/go/adguardhome-sync
|
||||
- run
|
||||
- '--config'
|
||||
- /etc/go/adguardhome-sync/config.yaml
|
||||
env:
|
||||
- name: LOG_LEVEL
|
||||
value: 'debug'
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/go/adguardhome-sync/
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: sync-conf
|
||||
restartPolicy: Never
|
||||
{{- end }}
|
||||
6
testdata/e2e/values.yaml
vendored
6
testdata/e2e/values.yaml
vendored
@@ -3,3 +3,9 @@ replica:
|
||||
- v0.107.40
|
||||
- v0.107.43
|
||||
- latest
|
||||
|
||||
mode: env
|
||||
|
||||
kubectl:
|
||||
repository: bitnami/kubectl
|
||||
tag: 1.27
|
||||
|
||||
Reference in New Issue
Block a user