Skip to content

Commit

Permalink
Use util for getting latest version in test specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mjac0bs committed Dec 9, 2024
1 parent 80cb608 commit ed7f53e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/manager/cypress/support/constants/lke.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getLatestKubernetesVersion } from 'support/util/lke';

import type { KubernetesTieredVersion } from '@linode/api-v4';
import type { LkePlanDescription } from 'support/api/lke';

Expand All @@ -23,7 +25,9 @@ export const enterpriseKubernetesVersions = ['v1.31.1+lke1'];
/**
* The latest Kubernetes version available for cluster creation via Cloud Manager.
*/
export const latestKubernetesVersion = kubernetesVersions[0];
export const latestKubernetesVersion = getLatestKubernetesVersion(
kubernetesVersions
);

/**
* The latest standard tier Kubernetes version available for cluster creation via Cloud Manager.
Expand All @@ -37,6 +41,6 @@ export const latestStandardTierKubernetesVersion: KubernetesTieredVersion = {
* The latest enterprise tier Kubernetes version available for cluster creation via Cloud Manager.
*/
export const latestEnterpriseTierKubernetesVersion: KubernetesTieredVersion = {
id: enterpriseKubernetesVersions[0],
id: getLatestKubernetesVersion(enterpriseKubernetesVersions),
tier: 'enterprise',
};
18 changes: 18 additions & 0 deletions packages/manager/cypress/support/util/lke.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { sortByVersion } from 'src/utilities/sort-by';

/**
* Returns the string of the highest semantic version.
*/
export const getLatestKubernetesVersion = (versions: string[]) => {
const sortedVersions = versions.sort((a, b) => {
return sortByVersion(a, b, 'asc');
});

const latestVersion = sortedVersions.pop();

if (!latestVersion) {
// Return an empty string if sorting does not yield latest version
return '';
}
return latestVersion;
};

0 comments on commit ed7f53e

Please sign in to comment.