Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add arcihtecture target selector when building seed image #245

Merged
merged 1 commit into from
Dec 9, 2024
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
43 changes: 37 additions & 6 deletions pkg/elemental/components/BuildMedia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getOperatorVersion,
checkGatedFeatureCompatibility,
BUILD_MEDIA_RAW_SUPPORT,
BUILD_MEDIA_ARCH_SUPPORT,
CHANNEL_NO_LONGER_IN_SYNC,
ALL_AREAS,
ALL_MODES,
Expand All @@ -28,6 +29,8 @@ export const MEDIA_TYPES = {
}
};

const SPECIAL_DELIMITATOR = ':::::';

export default {
name: 'BuildMedia',
components: {
Expand Down Expand Up @@ -93,19 +96,35 @@ export default {
const selectedFilterType = neu === MEDIA_TYPES.ISO.type ? MEDIA_TYPES.ISO.type : MEDIA_TYPES.RAW.filterType;

this.filteredManagedOsVersions = this.managedOsVersions.filter(v => v.spec?.type === selectedFilterType) || [];
this.buildMediaOsVersions = this.filteredManagedOsVersions.map((f) => {
return {
label: `${ f.spec?.metadata?.displayName } ${ f.spec?.version } ${ this.supportChannelNoLongerInSync && typeof f.inSync === 'boolean' && !f.inSync ? '(deprecated)' : '' }`,
value: neu === MEDIA_TYPES.ISO.type ? f.spec?.metadata?.uri : f.spec?.metadata?.upgradeImage,
};
const buildMediaOsVersions = [];

this.filteredManagedOsVersions.forEach((osVersion) => {
if (this.supportBuildMediaArchitecture && osVersion.spec?.metadata?.platforms?.length) {
osVersion.spec?.metadata?.platforms.forEach((arch) => {
buildMediaOsVersions.push({
label: `${ osVersion.spec?.metadata?.displayName } ${ osVersion.spec?.version } - ${arch}${ this.supportChannelNoLongerInSync && typeof osVersion.inSync === 'boolean' && !osVersion.inSync ? ' - (deprecated)' : '' }`,
value: `${neu === MEDIA_TYPES.ISO.type ? osVersion.spec?.metadata?.uri : osVersion.spec?.metadata?.upgradeImage}${SPECIAL_DELIMITATOR}${arch}`,
});
});
} else {
buildMediaOsVersions.push({
label: `${ osVersion.spec?.metadata?.displayName } ${ osVersion.spec?.version } ${ this.supportChannelNoLongerInSync && typeof osVersion.inSync === 'boolean' && !osVersion.inSync ? '(deprecated)' : '' }`,
value: neu === MEDIA_TYPES.ISO.type ? osVersion.spec?.metadata?.uri : osVersion.spec?.metadata?.upgradeImage,
});
}
});

this.buildMediaOsVersions = buildMediaOsVersions;
}
}
},
computed: {
supportChannelNoLongerInSync() {
return checkGatedFeatureCompatibility(ALL_AREAS, ALL_MODES, CHANNEL_NO_LONGER_IN_SYNC, this.operatorVersion);
},
supportBuildMediaArchitecture() {
return checkGatedFeatureCompatibility(this.resource, this.mode, BUILD_MEDIA_ARCH_SUPPORT, this.operatorVersion);
},
isRawDiskImageBuildSupported() {
const check = checkGatedFeatureCompatibility(this.resource, this.mode, BUILD_MEDIA_RAW_SUPPORT, this.operatorVersion);

Expand Down Expand Up @@ -188,13 +207,21 @@ export default {
const machineRegName = this.displayRegEndpoints ? this.registrationEndpointSelected.split('/')[1] : this.registrationEndpoint.split('/')[1];
const machineRegNamespace = this.displayRegEndpoints ? this.registrationEndpointSelected.split('/')[0] : this.registrationEndpoint.split('/')[0];

let targetPlatform = '';
let baseImage = this.buildMediaOsVersionSelected;

if (this.supportBuildMediaArchitecture && this.buildMediaOsVersionSelected.includes(SPECIAL_DELIMITATOR)) {
targetPlatform = this.buildMediaOsVersionSelected.split(SPECIAL_DELIMITATOR)[1];
baseImage = this.buildMediaOsVersionSelected.split(SPECIAL_DELIMITATOR)[0];
}

const seedImageObject = {
metadata: {
name: `media-image-reg-${ machineRegName }-${ randomStr(8, CHARSET.ALPHA_LOWER ) }`,
namespace: 'fleet-default'
},
spec: {
baseImage: this.buildMediaOsVersionSelected,
baseImage,
registrationRef: {
name: machineRegName,
namespace: machineRegNamespace
Expand All @@ -207,6 +234,10 @@ export default {
seedImageObject.spec.type = this.buildMediaTypeSelected;
}

if (targetPlatform) {
seedImageObject.spec.targetPlatform = targetPlatform;
}

const seedImageModel = await this.$store.dispatch('management/create', seedImageObject);

try {
Expand Down
13 changes: 13 additions & 0 deletions pkg/elemental/utils/feature-versioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const ALL_MODES:string = 'all-modes';
// features to be gated to specific operator versions
export const MACH_REG_CONFIG_DEFAULTS:string = 'machine-reg-config-defaults';
export const BUILD_MEDIA_RAW_SUPPORT:string = 'build-media-raw-support';
export const BUILD_MEDIA_ARCH_SUPPORT:string = 'build-media-arch-support';
export const DELETE_NO_LONGER_IN_SYNC_CHANNELS:string = 'delete-no-longer-in-sync-channels';
export const CHANNEL_NO_LONGER_IN_SYNC:string = 'channel-no-longer-in-sync';

Expand All @@ -39,6 +40,18 @@ const FEATURES_GATING:FeaturesGatingConfig[] = [
minOperatorVersion: '1.6.2',
features: [BUILD_MEDIA_RAW_SUPPORT]
},
{
area: ELEMENTAL_TYPES.DASHBOARD,
mode: [_VIEW],
minOperatorVersion: '1.6.3',
features: [BUILD_MEDIA_ARCH_SUPPORT]
},
{
area: ELEMENTAL_SCHEMA_IDS.MACHINE_REGISTRATIONS,
mode: [_VIEW],
minOperatorVersion: '1.6.3',
features: [BUILD_MEDIA_ARCH_SUPPORT]
},
{
area: ELEMENTAL_SCHEMA_IDS.MANAGED_OS_VERSION_CHANNELS,
mode: [_CREATE, _EDIT, _DETAIL, _VIEW],
Expand Down