mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 02:47:35 -02:30
Add the ability to specify K8S/OCP credentials on a Job Template
see: https://github.com/ansible/awx/issues/5735
This commit is contained in:
@@ -4100,7 +4100,8 @@ class JobLaunchSerializer(BaseSerializer):
|
||||
errors.setdefault('credentials', []).append(_(
|
||||
'Cannot assign multiple {} credentials.'
|
||||
).format(cred.unique_hash(display=True)))
|
||||
if cred.credential_type.kind not in ('ssh', 'vault', 'cloud', 'net'):
|
||||
if cred.credential_type.kind not in ('ssh', 'vault', 'cloud',
|
||||
'net', 'kubernetes'):
|
||||
errors.setdefault('credentials', []).append(_(
|
||||
'Cannot assign a Credential of kind `{}`'
|
||||
).format(cred.credential_type.kind))
|
||||
|
||||
@@ -2657,7 +2657,7 @@ class JobTemplateCredentialsList(SubListCreateAttachDetachAPIView):
|
||||
return {"error": _("Cannot assign multiple {credential_type} credentials.").format(
|
||||
credential_type=sub.unique_hash(display=True))}
|
||||
kind = sub.credential_type.kind
|
||||
if kind not in ('ssh', 'vault', 'cloud', 'net'):
|
||||
if kind not in ('ssh', 'vault', 'cloud', 'net', 'kubernetes'):
|
||||
return {'error': _('Cannot assign a Credential of kind `{}`.').format(kind)}
|
||||
|
||||
return super(JobTemplateCredentialsList, self).is_valid_relation(parent, sub, created)
|
||||
|
||||
@@ -1169,7 +1169,18 @@ ManagedCredentialType(
|
||||
'multiline': True,
|
||||
}],
|
||||
'required': ['host', 'bearer_token'],
|
||||
}
|
||||
},
|
||||
injectors={
|
||||
'file': {
|
||||
'template': '{{ ssl_ca_cert }}'
|
||||
},
|
||||
'env': {
|
||||
'K8S_AUTH_HOST': '{{ host }}',
|
||||
'K8S_AUTH_API_KEY': '{{ bearer_token }}',
|
||||
'K8S_AUTH_VERIFY_SSL': '{{ verify_ssl }}',
|
||||
'K8S_AUTH_SSL_CA_CERT': '{{ tower.filename }}',
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -67,6 +67,10 @@
|
||||
&--external:before {
|
||||
content: '\f14c'
|
||||
}
|
||||
|
||||
&--kubernetes_bearer_token:before {
|
||||
content: '\f0c2';
|
||||
}
|
||||
}
|
||||
|
||||
.TagComponent-button {
|
||||
|
||||
@@ -111,7 +111,7 @@ function multiCredentialModalController(GetBasePath, qs, MultiCredentialService)
|
||||
|
||||
scope.credentialTypes.forEach((credentialType => {
|
||||
if(credentialType.kind
|
||||
.match(/^(machine|cloud|net|ssh|vault)$/)) {
|
||||
.match(/^(machine|cloud|net|ssh|vault|kubernetes)$/)) {
|
||||
scope.displayedCredentialTypes.push(credentialType);
|
||||
}
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user