Skip to content

Commit dcac521

Browse files
authored
[AAP-25805] Add support for OpenShift Virtualization inventory source. (#2580)
1 parent 48d94b5 commit dcac521

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

frontend/awx/resources/inventories/inventorySources/InventorySourceDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export function InventorySourceDetails(props: {
131131
const getSourceVarsHelpText = (source: string) => {
132132
let sourceType = '';
133133
if (source && source !== 'scm') {
134-
const type: string[] = ansibleDocUrls[source].split(/[/,.]/);
134+
const type: string[] = ansibleDocUrls[source]?.split(/[/,.]/) ?? [];
135135
sourceType = type[type.length - 2];
136136
}
137137

frontend/awx/resources/sources/InventorySourceSubForm.tsx

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PageFormTextInput } from '../../../../framework/PageForm/Inputs/PageFor
77
import { PageFormHidden } from '../../../../framework/PageForm/Utils/PageFormHidden';
88
import { PageFormSection } from '../../../../framework/PageForm/Utils/PageFormSection';
99
import { PageFormCredentialSelect } from '../../access/credentials/components/PageFormCredentialSelect';
10+
import { QueryParams } from '../../common/useAwxView';
1011
import { InventorySourceForm } from '../../interfaces/InventorySource';
1112
import { PageFormProjectSelect } from '../projects/components/PageFormProjectSelect';
1213
import { PageFormInventoryFileSelect } from './component/PageFormInventoryFileSelect';
@@ -30,8 +31,30 @@ export function InventorySourceSubForm() {
3031
'controller',
3132
'insights',
3233
'terraform',
34+
'openshift_virtualization',
3335
];
3436

37+
const handleQueryParams = (source: string): QueryParams => {
38+
switch (source) {
39+
case 'scm':
40+
return {
41+
credential_type__kind__in: 'cloud,kubernetes',
42+
};
43+
case 'ec2':
44+
return {
45+
credential_type__namespace: 'aws',
46+
};
47+
case 'openshift_virtualization':
48+
return {
49+
credential_type__namespace: 'kubernetes_bearer_token',
50+
};
51+
default:
52+
return {
53+
credential_type__namespace: source,
54+
};
55+
}
56+
};
57+
3558
return (
3659
<>
3760
<PageFormHidden
@@ -46,19 +69,7 @@ export function InventorySourceSubForm() {
4669
'Select credentials for accessing the nodes this job will be ran against. You can only select one credential of each type. For machine credentials (SSH), checking "Prompt on launch" without selecting credentials will require you to select a machine credential at run time. If you select credentials and check "Prompt on launch", the selected credential(s) become the defaults that can be updated at run time.'
4770
)}
4871
isRequired={sourceTypes.slice(1).includes(source)}
49-
queryParams={
50-
source === 'scm'
51-
? {
52-
credential_type__kind__in: 'cloud,kubernetes',
53-
}
54-
: source === 'ec2'
55-
? {
56-
credential_type__namespace: 'aws',
57-
}
58-
: {
59-
credential_type__namespace: source,
60-
}
61-
}
72+
queryParams={handleQueryParams(source)}
6273
/>
6374
<PageFormHidden watch="source" hidden={(type: string) => type !== 'scm'}>
6475
<PageFormProjectSelect<InventorySourceForm> name="source_project" isRequired />

0 commit comments

Comments
 (0)