V2Wizard/Repositories: Add payload_repositories to request and test it
Previously the V2 Wizard's request mapper was only adding the custom_repositories field. We also need to add a nearly duplicate payload_repositories field due to how the image-builder API works... which is admittedly not intuitive. Tests are also added to ensure that requests are generated correctly when using the custom repositories feature.
This commit is contained in:
parent
08563b9dfa
commit
e923cccd41
4 changed files with 180 additions and 3 deletions
|
|
@ -38,9 +38,13 @@ import {
|
|||
useListRepositoriesQuery,
|
||||
} from '../../../../store/contentSourcesApi';
|
||||
import { useAppDispatch, useAppSelector } from '../../../../store/hooks';
|
||||
import { CustomRepository } from '../../../../store/imageBuilderApi';
|
||||
import {
|
||||
CustomRepository,
|
||||
Repository,
|
||||
} from '../../../../store/imageBuilderApi';
|
||||
import {
|
||||
changeCustomRepositories,
|
||||
changePayloadRepositories,
|
||||
selectArchitecture,
|
||||
selectCustomRepositories,
|
||||
selectDistribution,
|
||||
|
|
@ -144,6 +148,22 @@ const convertSchemaToIBCustomRepo = (repo: ApiRepositoryResponseRead) => {
|
|||
return imageBuilderRepo;
|
||||
};
|
||||
|
||||
// Utility function to convert from Content Sources to Image Builder payload repo API schema
|
||||
const convertSchemaToIBPayloadRepo = (repo: ApiRepositoryResponseRead) => {
|
||||
const imageBuilderRepo: Repository = {
|
||||
baseurl: repo.url,
|
||||
rhsm: false,
|
||||
check_gpg: false,
|
||||
};
|
||||
if (repo.gpg_key) {
|
||||
imageBuilderRepo.gpgkey = repo.gpg_key;
|
||||
imageBuilderRepo.check_gpg = true;
|
||||
imageBuilderRepo.check_repo_gpg = repo.metadata_verification;
|
||||
}
|
||||
|
||||
return imageBuilderRepo;
|
||||
};
|
||||
|
||||
const Repositories = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
|
@ -269,7 +289,12 @@ const Repositories = () => {
|
|||
convertSchemaToIBCustomRepo(repo!)
|
||||
);
|
||||
|
||||
const payloadRepositories = selectedRepos.map((repo) =>
|
||||
convertSchemaToIBPayloadRepo(repo!)
|
||||
);
|
||||
|
||||
dispatch(changeCustomRepositories(customRepositories));
|
||||
dispatch(changePayloadRepositories(payloadRepositories));
|
||||
};
|
||||
|
||||
const updateSelected = (selectedRepos: (string | undefined)[]) => {
|
||||
|
|
|
|||
|
|
@ -26,12 +26,14 @@ import {
|
|||
selectBaseUrl,
|
||||
selectBlueprintDescription,
|
||||
selectBlueprintName,
|
||||
selectCustomRepositories,
|
||||
selectDistribution,
|
||||
selectGcpAccountType,
|
||||
selectGcpEmail,
|
||||
selectGcpShareMethod,
|
||||
selectImageTypes,
|
||||
selectPackages,
|
||||
selectPayloadRepositories,
|
||||
selectRegistrationType,
|
||||
selectServerUrl,
|
||||
} from '../../../store/wizardSlice';
|
||||
|
|
@ -156,8 +158,8 @@ const getCustomizations = (state: RootState, orgID: string): Customizations => {
|
|||
files: undefined,
|
||||
subscription: getSubscription(state, orgID),
|
||||
packages: getPackages(state),
|
||||
payload_repositories: undefined,
|
||||
custom_repositories: undefined,
|
||||
payload_repositories: getPayloadRepositories(state),
|
||||
custom_repositories: getCustomRepositories(state),
|
||||
openscap: undefined,
|
||||
filesystem: undefined,
|
||||
users: undefined,
|
||||
|
|
@ -219,3 +221,19 @@ const getSubscription = (
|
|||
return { ...initialSubscription, insights: false, rhc: false };
|
||||
}
|
||||
};
|
||||
|
||||
const getCustomRepositories = (state: RootState) => {
|
||||
const customRepositories = selectCustomRepositories(state);
|
||||
if (customRepositories.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return customRepositories;
|
||||
};
|
||||
|
||||
const getPayloadRepositories = (state: RootState) => {
|
||||
const payloadRepositories = selectPayloadRepositories(state);
|
||||
if (payloadRepositories.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return payloadRepositories;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue