mirror of
https://github.com/ansible/awx.git
synced 2026-02-01 09:38:10 -03:30
Implement project pulling from Azure DevOps using Service Principals (#14628)
* Credential Lookup with multiple types Allow looking up a credential with one of multiple type IDs. * Allow Azure cred for SCM Allow selecting an Azure Resource Manager credential for Git-based SCMs. This is in order to enable using Azure Service Principals for project updates. * Implement Azure Service Principal Git This adds support for using an Azure Service Principal for project updates. --------- Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
This commit is contained in:
committed by
GitHub
parent
727278aaa3
commit
2e2cd7f2de
@@ -32,6 +32,7 @@ const QS_CONFIG = getQSConfig('credentials', {
|
||||
function CredentialLookup({
|
||||
autoPopulate,
|
||||
credentialTypeId,
|
||||
credentialTypeIds,
|
||||
credentialTypeKind,
|
||||
credentialTypeNamespace,
|
||||
fieldName,
|
||||
@@ -61,6 +62,9 @@ function CredentialLookup({
|
||||
const typeIdParams = credentialTypeId
|
||||
? { credential_type: credentialTypeId }
|
||||
: {};
|
||||
const typeIdsParams = credentialTypeIds
|
||||
? { credential_type__in: credentialTypeIds.join() }
|
||||
: {};
|
||||
const typeKindParams = credentialTypeKind
|
||||
? { credential_type__kind: credentialTypeKind }
|
||||
: {};
|
||||
@@ -72,6 +76,7 @@ function CredentialLookup({
|
||||
CredentialsAPI.read(
|
||||
mergeParams(params, {
|
||||
...typeIdParams,
|
||||
...typeIdsParams,
|
||||
...typeKindParams,
|
||||
...typeNamespaceParams,
|
||||
})
|
||||
@@ -101,6 +106,7 @@ function CredentialLookup({
|
||||
autoPopulate,
|
||||
autoPopulateLookup,
|
||||
credentialTypeId,
|
||||
credentialTypeIds,
|
||||
credentialTypeKind,
|
||||
credentialTypeNamespace,
|
||||
history.location.search,
|
||||
|
||||
@@ -33,6 +33,11 @@ const fetchCredentials = async (credential) => {
|
||||
results: [scmCredentialType],
|
||||
},
|
||||
},
|
||||
{
|
||||
data: {
|
||||
results: [azurermCredentialType],
|
||||
},
|
||||
},
|
||||
{
|
||||
data: {
|
||||
results: [insightsCredentialType],
|
||||
@@ -45,13 +50,14 @@ const fetchCredentials = async (credential) => {
|
||||
},
|
||||
] = await Promise.all([
|
||||
CredentialTypesAPI.read({ kind: 'scm' }),
|
||||
CredentialTypesAPI.read({ namespace: 'azure_rm' }),
|
||||
CredentialTypesAPI.read({ name: 'Insights' }),
|
||||
CredentialTypesAPI.read({ kind: 'cryptography' }),
|
||||
]);
|
||||
|
||||
if (!credential) {
|
||||
return {
|
||||
scm: { typeId: scmCredentialType.id },
|
||||
scm: { typeIds: [scmCredentialType.id, azurermCredentialType.id] },
|
||||
insights: { typeId: insightsCredentialType.id },
|
||||
cryptography: { typeId: cryptographyCredentialType.id },
|
||||
};
|
||||
@@ -60,8 +66,12 @@ const fetchCredentials = async (credential) => {
|
||||
const { credential_type_id } = credential;
|
||||
return {
|
||||
scm: {
|
||||
typeId: scmCredentialType.id,
|
||||
value: credential_type_id === scmCredentialType.id ? credential : null,
|
||||
typeIds: [scmCredentialType.id, azurermCredentialType.id],
|
||||
value:
|
||||
credential_type_id === scmCredentialType.id ||
|
||||
credential_type_id === azurermCredentialType.id
|
||||
? credential
|
||||
: null,
|
||||
},
|
||||
insights: {
|
||||
typeId: insightsCredentialType.id,
|
||||
@@ -367,13 +377,13 @@ function ProjectForm({ project, submitError, ...props }) {
|
||||
});
|
||||
const [scmTypeOptions, setScmTypeOptions] = useState(null);
|
||||
const [credentials, setCredentials] = useState({
|
||||
scm: { typeId: null, value: null },
|
||||
scm: { typeIds: null, value: null },
|
||||
insights: { typeId: null, value: null },
|
||||
cryptography: { typeId: null, value: null },
|
||||
});
|
||||
const [signatureValidationCredentials, setSignatureValidationCredentials] =
|
||||
useState({
|
||||
scm: { typeId: null, value: null },
|
||||
scm: { typeIds: null, value: null },
|
||||
insights: { typeId: null, value: null },
|
||||
cryptography: { typeId: null, value: null },
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ export const ScmCredentialFormField = ({
|
||||
|
||||
return (
|
||||
<CredentialLookup
|
||||
credentialTypeId={credential.typeId}
|
||||
credentialTypeIds={credential.typeIds}
|
||||
label={t`Source Control Credential`}
|
||||
value={credential.value}
|
||||
onChange={onCredentialChange}
|
||||
|
||||
Reference in New Issue
Block a user