Skip to content

Commit e7a668f

Browse files
committed
feat: add fallback constant for buildx driver type and refactor parsing logic
1 parent 01327b8 commit e7a668f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/Pages/GlobalConfigurations/BuildInfra/constants.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,5 @@ export const DEFAULT_TOLERANCE_OPERATOR = BuildInfraToleranceOperatorType.EQUALS
247247
export const INFRA_CONFIG_NOT_SUPPORTED_BY_BUILD_X: Partial<Record<BuildInfraConfigTypes, true>> = {
248248
[BuildInfraConfigTypes.BUILD_TIMEOUT]: true,
249249
}
250+
251+
export const USE_BUILD_X_DRIVER_FALLBACK = true

src/Pages/GlobalConfigurations/BuildInfra/utils.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
BUILD_INFRA_DEFAULT_PLATFORM_NAME,
4444
BUILD_INFRA_LATEST_API_VERSION,
4545
INFRA_CONFIG_NOT_SUPPORTED_BY_BUILD_X,
46+
USE_BUILD_X_DRIVER_FALLBACK,
4647
} from './constants'
4748
import { getUniqueId } from '../../../Shared'
4849

@@ -108,14 +109,20 @@ export const parsePlatformConfigIntoValue = (
108109
}
109110
}
110111

112+
export const getParsedValueForUseK8sDriver = (buildxDriverType: BuildXDriverType): boolean => {
113+
if (!buildxDriverType) {
114+
return USE_BUILD_X_DRIVER_FALLBACK
115+
}
116+
117+
return buildxDriverType === BuildXDriverType.KUBERNETES
118+
}
119+
111120
const getBaseProfileObject = ({
112121
fromCreateView,
113122
profile,
114123
canConfigureUseK8sDriver,
115124
}: GetBaseProfileObjectParamsType): BuildInfraProfileBase => {
116-
const parsedUseK8sDriverValue = profile?.buildxDriverType
117-
? profile.buildxDriverType === BuildXDriverType.KUBERNETES
118-
: true
125+
const parsedUseK8sDriverValue = getParsedValueForUseK8sDriver(profile?.buildxDriverType)
119126
const useK8sDriver = canConfigureUseK8sDriver ? parsedUseK8sDriverValue : null
120127

121128
if (fromCreateView || !profile) {

0 commit comments

Comments
 (0)