From 5afe1c1fc1ef06ad43cea2089d1229fdd941f538 Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Tue, 29 Apr 2025 16:39:19 +0000 Subject: [PATCH] cloudConfig: save the aws configs Save the AWS config modifications to the `osbuild-worker.toml` file. --- .../CloudProviderConfig/CloudProviderConfig.tsx | 16 ++++++++++++++-- src/store/cockpit/cockpitApi.ts | 10 +++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Components/CloudProviderConfig/CloudProviderConfig.tsx b/src/Components/CloudProviderConfig/CloudProviderConfig.tsx index 966f627c..e5897a09 100644 --- a/src/Components/CloudProviderConfig/CloudProviderConfig.tsx +++ b/src/Components/CloudProviderConfig/CloudProviderConfig.tsx @@ -23,10 +23,14 @@ import { changeAWSBucketName, changeAWSCredsPath, reinitializeAWSConfig, + selectAWSConfig, } from '../../store/cloudProviderConfigSlice'; -import { useGetWorkerConfigQuery } from '../../store/cockpit/cockpitApi'; +import { + useGetWorkerConfigQuery, + useUpdateWorkerConfigMutation, +} from '../../store/cockpit/cockpitApi'; import { AWSWorkerConfig } from '../../store/cockpit/types'; -import { useAppDispatch } from '../../store/hooks'; +import { useAppDispatch, useAppSelector } from '../../store/hooks'; import { resolveRelPath } from '../../Utilities/path'; import { ImageBuilderHeader } from '../sharedComponents/ImageBuilderHeader'; @@ -62,8 +66,10 @@ const ConfigError = ({ export const CloudProviderConfig = () => { const navigate = useNavigate(); const dispatch = useAppDispatch(); + const config = useAppSelector(selectAWSConfig); const handleClose = () => navigate(resolveRelPath('')); + const [updateConfig] = useUpdateWorkerConfigMutation(); const { data, error, refetch, isLoading } = useGetWorkerConfigQuery({}); const initAWSConfig = useCallback( @@ -109,6 +115,12 @@ export const CloudProviderConfig = () => { nextButtonText: 'Submit', isNextDisabled: !isAwsStepValid(config), isBackDisabled: true, + onNext: () => { + updateConfig({ + updateWorkerConfigRequest: { aws: config }, + }); + navigate(resolveRelPath('')); + }, }} > { - contents[key] = Section({ - ...merged[key], - }); + // this check helps prevent saving empty objects + // into the osbuild-worker.toml config file. + if (merged[key] !== undefined) { + contents[key] = Section({ + ...merged[key], + }); + } }); return TOML.stringify(contents, {