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)[]) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue