@@ -63,11 +63,6 @@ export function selectDisplayUpdates(allUpdates: DisplayUpdate[], currentVersion
6363 return filteredUpdates
6464}
6565
66- export function latestApplicableUpdateVersion ( versions : VersionInfo [ ] , clusterK8sVersion : string ) {
67- const applicableUpdates = versions . filter ( ( update ) => update . supported_k8s_versions . includes ( clusterK8sVersion ) )
68- return applicableUpdates . length > 0 ? applicableUpdates [ applicableUpdates . length - 1 ] : undefined
69- }
70-
7166export function valueArrayToObject (
7267 array ?:
7368 | {
@@ -92,13 +87,28 @@ export function mapObjectToKeyValueArray(obj?: Record<string, string>): { key: s
9287 return Object . entries ( obj ) . map ( ( [ key , value ] ) => ( { key, value } ) )
9388}
9489
90+ function normalizeVersion ( version : string ) : string {
91+ return version . replace ( / ^ v / , '' )
92+ }
93+
94+ function stripPatchVersion ( version : string ) : string {
95+ const parts = normalizeVersion ( version ) . split ( '.' )
96+ return parts . slice ( 0 , 2 ) . join ( '.' )
97+ }
98+
99+ export function latestApplicableUpdateVersion ( versions : VersionInfo [ ] , clusterK8sVersion : string ) {
100+ const applicableUpdates = versions . filter ( ( update ) =>
101+ update . supported_k8s_versions . includes ( stripPatchVersion ( clusterK8sVersion ) ) ,
102+ )
103+ return applicableUpdates . length > 0 ? applicableUpdates [ applicableUpdates . length - 1 ] : undefined
104+ }
105+
95106export function checkAgainstK8sVersion ( update : VersionInfo , currentVersion : string ) {
96107 const supportedVersions = update . supported_k8s_versions
97108
98109 if ( ! supportedVersions || supportedVersions . length === 0 ) return false
99-
100- // Check for exact match or match ignoring patch version
101- const currentVersionMajorMinor = currentVersion . split ( '.' ) . slice ( 0 , 2 ) . join ( '.' )
110+ // Remove 'v' prefix if present and extract major.minor version
111+ const currentVersionMajorMinor = stripPatchVersion ( currentVersion )
102112
103113 return supportedVersions . includes ( currentVersionMajorMinor )
104114}
0 commit comments