Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"@mui/material": "^5.11.1",
"@octokit/rest": "19.0.3",
"@octokit/types": "6.40.0",
"@openshift-assisted/locales": "2.15.3-cim",
"@openshift-assisted/ui-lib": "2.15.3-cim",
"@openshift-assisted/locales": "2.16.0-cim",
"@openshift-assisted/ui-lib": "2.16.0-cim",
"@patternfly/patternfly": "^5.4.2",
"@patternfly/react-charts": "^7.4.7",
"@patternfly/react-code-editor": "^5.4.13",
Expand Down
1 change: 1 addition & 0 deletions frontend/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,7 @@
"InstallPlanApproval determines if subscription installation plans are applied automatically.": "InstallPlanApproval determines if subscription installation plans are applied automatically.",
"Instance profile": "Instance profile",
"Instance type": "Instance type",
"Integrate with external partner platforms": "Integrate with external partner platforms",
"Internal server error": "Internal server error",
"invalidclustername.message": "The cluster name is invalid. Change the name to the RFC 1123 standard which consists of lower case alphanumeric characters, '-', and must start and end with an alphanumeric character.",
"IP address": "IP address",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ export const mockAgentClusterInstall: AgentClusterInstallK8sResource = {
clusterDeploymentRef: { name: 'test' },
holdInstallation: true,
provisionRequirements: { workerAgents: 0, controlPlaneAgents: 3 },
imageSetRef: { name: 'ocp-release48' },
imageSetRef: { name: 'img4.19.16-x86_64-appsub' },
networking: {
clusterNetwork: [{ cidr: '10.128.0.0/14', hostPrefix: 23 }],
serviceNetwork: ['172.30.0.0/16'],
networkType: 'OVNKubernetes',
},
sshPublicKey: '',
platformType: 'BareMetal',
} as any,
}

Expand Down Expand Up @@ -115,13 +116,13 @@ export const clusterImageSet: ClusterImageSetK8sResource = {
apiVersion: ClusterImageSetApiVersion,
kind: ClusterImageSetKind,
metadata: {
name: 'ocp-release48',
name: 'img4.19.16-x86_64-appsub',
labels: {
visible: 'true',
},
},
spec: {
releaseImage: 'quay.io/openshift-release-dev/ocp-release:4.8.15-x86_64',
releaseImage: 'quay.io/openshift-release-dev/ocp-release:4.19.16-x86_64',
},
}
export const mockClusterImageSet = [clusterImageSet]
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ describe('CreateCluster on premise', () => {
await typeByTestId('form-input-name-field', clusterName)
await typeByTestId('form-input-baseDnsDomain-field', baseDomain)

await waitForText('OpenShift 4.8.15-x86_64') // single value of combobox
await waitForText('OpenShift 4.19.16-x86_64') // single value of combobox
await typeByTestId('additionalLabels', 'myLabelKey=myValue')
await clickByTestId('form-input-pullSecret-field')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import getControlDataVMW from './controlData/ControlDataVMW'
import { useLocalHubName } from '../../../../../hooks/use-local-hub'
import './style.css'
import { VALID_DNS_LABEL } from '../../../../../components/TemplateEditor/utils/validation-types'
import { getPlatform } from './components/assisted-installer/hypershift/utils'

// Register the custom 'and' helper
Handlebars.registerHelper('and', function (a, b) {
return a && b
Expand Down Expand Up @@ -592,6 +594,8 @@ export default function CreateCluster(props: { infrastructureType: ClusterInfras
break
case HostInventoryInfrastructureType.CIM:
template = Handlebars.compile(cimTemplate)
Handlebars.registerHelper('convert', getPlatform)

controlData = getControlDataCIM(t, handleModalToggle, <Warning />, isACMAvailable)
breadcrumbs.push(controlPlaneBreadCrumbBM)
break
Expand All @@ -607,6 +611,8 @@ export default function CreateCluster(props: { infrastructureType: ClusterInfras
break
case HostInventoryInfrastructureType.AI:
template = Handlebars.compile(aiTemplate)
Handlebars.registerHelper('convert', getPlatform)

controlData = getControlDataAI(t, handleModalToggle, isACMAvailable)
breadcrumbs.push(controlPlaneBreadCrumbBM, hostsBreadCrumb)
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from '@openshift-assisted/ui-lib/cim'
import React from 'react'
import { FieldName } from './types'
import { getFieldLabels } from './hypershift/utils'
import { getFieldLabels, getPlatformLabel } from './hypershift/utils'
import { getFirstAgentServiceConfig } from '../../../../../InfraEnvironments/InfraEnvironmentsPage'

type FormControl = {
Expand Down Expand Up @@ -146,6 +146,10 @@ const DetailsForm: React.FC<DetailsFormProps> = ({ control, handleChange, contro
},
pullSecret: {},
controlPlaneCount: { path: 'AgentClusterInstall[0].spec.provisionRequirements.controlPlaneAgents' },
platform: {
path: 'AgentClusterInstall[0].spec.platformType',
transform: (a?: string) => a?.toLowerCase() || a,
},
}),
[control.additionalProps?.aiFlow]
)
Expand Down Expand Up @@ -184,8 +188,13 @@ const DetailsForm: React.FC<DetailsFormProps> = ({ control, handleChange, contro
}
Object.keys(fields).forEach((key) => {
const path = fields[key].path
const transform = fields[key].transform
if (path) {
set(active, key, getValue(templateObject, path) || '')
set(
active,
key,
(transform && transform(getValue(templateObject, path))) || getValue(templateObject, path) || ''
)
}
})
if (!isEqual(active, control.active)) {
Expand All @@ -207,6 +216,9 @@ const DetailsForm: React.FC<DetailsFormProps> = ({ control, handleChange, contro
if (key === 'openshiftVersion') {
desc = getVersion(get(control, `active.${key}`))
}
if (key === 'platform') {
desc = getPlatformLabel(get(control, `active.${key}`))
}
return {
term: fieldLabels[key as FieldName] ?? 'Error' + key,
desc: desc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ describe('DetailsForm', () => {
control={{
active: {
name: '',
highAvailabilityMode: 'Full',
openshiftVersion: '',
pullSecret: '',
baseDnsDomain: '',
SNODisclaimer: false,
useRedHatDnsService: true,
enableDiskEncryptionOnMasters: false,
enableDiskEncryptionOnWorkers: false,
Expand All @@ -41,6 +39,7 @@ describe('DetailsForm', () => {
userManagedNetworking: false,
customOpenshiftSelect: null,
controlPlaneCount: 3,
enableDiskEncryptionOnArbiters: false,
},
step: {
title: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ exports[`DetailsForm it renders 1`] = `
<span
class="pf-v5-c-menu-toggle__text"
>
OpenShift 4.8.15-x86_64
OpenShift 4.19.16-x86_64
</span>
<span
class="pf-v5-c-menu-toggle__controls"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,27 @@ export const getFieldLabels = (t: TFunction): Partial<{ [K in FieldName]: string
openshiftVersion: t('OpenShift version'),
cpuArchitecture: t('CPU architecture'),
controlPlaneCount: t('Number of control plane nodes'),
platform: t('Integrate with external partner platforms'),
})

export type PlatformType = 'none' | 'baremetal' | 'vsphere' | 'nutanix' | 'external'

const CIMPlatforms: { [key in PlatformType]: string } = {
none: 'None',
baremetal: 'BareMetal',
vsphere: 'VSphere',
nutanix: 'Nutanix',
external: 'External',
}

const CIMPlatformsLabels: { [key in PlatformType]: string } = {
none: 'No platform integration',
baremetal: 'No platform integration',
vsphere: 'vSphere',
nutanix: 'Nutanix',
external: 'External cloud provider',
}

export const getPlatform = (a: PlatformType) => (a ? CIMPlatforms[a] : CIMPlatforms['none'])

export const getPlatformLabel = (a: PlatformType) => (a ? CIMPlatformsLabels[a] : CIMPlatformsLabels['none'])
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export type FieldName =
| 'openshiftVersion'
| 'cpuArchitecture'
| 'controlPlaneCount'
| 'platform'
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ spec:
{{else}}
controlPlaneAgents: 3
{{/if}}
{{#switch ai.controlPlaneCount}}
{{#case 2}}
arbiterAgents: 1
{{/case}}
{{/switch}}
imageSetRef:
name: '{{{ai.openshiftVersion}}}'
networking:
Expand All @@ -56,6 +61,14 @@ spec:
- 172.30.0.0/16
userManagedNetworking: {{{ai.userManagedNetworking}}}
sshPublicKey: '{{{ai.sshPublicKey}}}'
platformType: '{{convert ai.platform}}'
{{#switch ai.platform}}
{{#case 'external'}}
external:
platformName: 'External platform'
cloudControllerManager: External
{{/case}}
{{/switch}}

---
apiVersion: v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ spec:
{{else}}
controlPlaneAgents: 3
{{/if}}
{{#switch ai.controlPlaneCount}}
{{#case 2}}
arbiterAgents: 1
{{/case}}
{{/switch}}
imageSetRef:
name: '{{{ai.openshiftVersion}}}'
networking:
Expand All @@ -64,6 +69,14 @@ spec:
{{else}}
sshPublicKey: ''
{{/if}}
platformType: '{{convert ai.platform}}'
{{#switch ai.platform}}
{{#case 'external'}}
external:
platformName: 'External platform'
cloudControllerManager: External
{{/case}}
{{/switch}}

---
apiVersion: v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ jest.mock('lodash', () => ({
}
return result
}),
memoize: jest.fn((fn, resolver) => {
const cache = new Map()
return (...args: any[]) => {
const key = resolver ? resolver(...args) : args.join('~')
if (cache.has(key)) {
return cache.get(key)
}
const result = fn(...args)
cache.set(key, result)
return result
}
}),
}))

describe('useRoleAssignmentFormData', () => {
Expand Down