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
10 changes: 7 additions & 3 deletions libs/ui-lib/lib/cim/components/helpers/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../types';
import { CpuArchitecture, OpenshiftVersionOptionType } from '../../../common';
import { OpenshiftVersion } from '@openshift-assisted/types/assisted-installer-service';
import { isMajorMinorVersionEqualOrGreater } from '../../../common/utils';
import { getComparableVersionInt } from '../../../common/utils';

export const getVersionFromReleaseImage = (releaseImage = '') => {
const match = /.+:(\d+\.\d+(?:\.\d+)?(?:-\w+)?)/gm.exec(releaseImage);
Expand Down Expand Up @@ -123,5 +123,9 @@ export const getCurrentClusterVersion = (cv?: ClusterVersionK8sResource): string

export const getNetworkType = (
ocpVersion: OpenshiftVersionOptionType | undefined,
): 'OVNKubernetes' | 'OpenShiftSDN' =>
isMajorMinorVersionEqualOrGreater(ocpVersion?.version, '4.12') ? 'OVNKubernetes' : 'OpenShiftSDN';
): 'OVNKubernetes' | 'OpenShiftSDN' => {
const checkVersionNum = getComparableVersionInt(ocpVersion?.version || '');
const toVersionNum = getComparableVersionInt('4.12');

return !checkVersionNum || checkVersionNum >= toVersionNum ? 'OVNKubernetes' : 'OpenShiftSDN';
};
2 changes: 1 addition & 1 deletion libs/ui-lib/lib/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const getMajorMinorVersion = (version = '') => {
};

// Converts an Openshift version to a comparable integer
const getComparableVersionInt = (version: string): number => {
export const getComparableVersionInt = (version: string): number => {
const majorMinorParts = version.split('.').slice(0, 2).map(Number);
if (majorMinorParts.length < 2 || majorMinorParts.some(isNaN)) {
// If the version doesn't have the required format, returning 0 makes it be considered
Expand Down
Loading