Make the namespace and secret name configurable via env var for the k8s provider
Fixes #695
This commit is contained in:
parent
278bc736e3
commit
05262125a0
1 changed files with 5 additions and 5 deletions
|
@ -14,8 +14,8 @@ KUBERNETES_API_HOST = 'kubernetes.default.svc.cluster.local'
|
||||||
|
|
||||||
SERVICE_ACCOUNT_TOKEN_PATH = '/var/run/secrets/kubernetes.io/serviceaccount/token'
|
SERVICE_ACCOUNT_TOKEN_PATH = '/var/run/secrets/kubernetes.io/serviceaccount/token'
|
||||||
|
|
||||||
ER_NAMESPACE = 'quay'
|
QE_NAMESPACE = os.environ.get('QE_K8S_NAMESPACE', 'quay-enterprise')
|
||||||
ER_CONFIG_SECRET = 'quay-config-secret'
|
QE_CONFIG_SECRET = os.environ.get('QE_K8S_CONFIG_SECRET', 'quay-enterprise-config-secret')
|
||||||
|
|
||||||
class KubernetesConfigProvider(FileConfigProvider):
|
class KubernetesConfigProvider(FileConfigProvider):
|
||||||
""" Implementation of the config provider that reads and writes configuration
|
""" Implementation of the config provider that reads and writes configuration
|
||||||
|
@ -67,12 +67,12 @@ class KubernetesConfigProvider(FileConfigProvider):
|
||||||
"kind": "Secret",
|
"kind": "Secret",
|
||||||
"apiVersion": "v1",
|
"apiVersion": "v1",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": ER_CONFIG_SECRET
|
"name": QE_CONFIG_SECRET
|
||||||
},
|
},
|
||||||
"data": secret_data
|
"data": secret_data
|
||||||
}
|
}
|
||||||
|
|
||||||
secret_url = 'namespaces/%s/secrets/%s' % (ER_NAMESPACE, ER_CONFIG_SECRET)
|
secret_url = 'namespaces/%s/secrets/%s' % (QE_NAMESPACE, QE_CONFIG_SECRET)
|
||||||
secret = self._lookup_secret()
|
secret = self._lookup_secret()
|
||||||
if not secret:
|
if not secret:
|
||||||
self._assert_success(self._execute_k8s_api('POST', secret_url, data))
|
self._assert_success(self._execute_k8s_api('POST', secret_url, data))
|
||||||
|
@ -86,7 +86,7 @@ class KubernetesConfigProvider(FileConfigProvider):
|
||||||
|
|
||||||
|
|
||||||
def _lookup_secret(self):
|
def _lookup_secret(self):
|
||||||
secret_url = 'namespaces/%s/secrets/%s' % (ER_NAMESPACE, ER_CONFIG_SECRET)
|
secret_url = 'namespaces/%s/secrets/%s' % (QE_NAMESPACE, QE_CONFIG_SECRET)
|
||||||
response = self._execute_k8s_api('GET', secret_url)
|
response = self._execute_k8s_api('GET', secret_url)
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
return None
|
return None
|
||||||
|
|
Reference in a new issue