Skip to content

Commit

Permalink
Merge pull request #216 from aalves08/feature-gating-prs
Browse files Browse the repository at this point in the history
gate features to a specific elemental operator version
  • Loading branch information
aalves08 authored Aug 7, 2024
2 parents d4fc895 + 33aeae1 commit 071b67f
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elemental-ui",
"description": "Elemental UI extension",
"version": "2.0.0-rc1",
"version": "2.0.0-rc2",
"private": false,
"engines": {
"node": ">=12"
Expand Down
14 changes: 12 additions & 2 deletions pkg/elemental/components/BuildMedia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { Banner } from '@components/Banner';
import AsyncButton from '@shell/components/AsyncButton';
import { randomStr, CHARSET } from '@shell/utils/string';
import { ELEMENTAL_SCHEMA_IDS } from '../config/elemental-types';
import { getOperatorVersion, checkGatedFeatureCompatibility, BUILD_MEDIA_RAW_SUPPORT } from '../utils/feature-versioning';
import {
getOperatorVersion,
checkGatedFeatureCompatibility,
BUILD_MEDIA_RAW_SUPPORT,
CHANNEL_NO_LONGER_IN_SYNC,
ALL_AREAS,
ALL_MODES,
} from '../utils/feature-versioning';
export const MEDIA_TYPES = {
RAW: {
Expand Down Expand Up @@ -88,14 +95,17 @@ export default {
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 } ${ typeof f.inSync === 'boolean' && !f.inSync ? '(deprecated)' : '' }`,
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,
};
});
}
}
},
computed: {
supportChannelNoLongerInSync() {
return checkGatedFeatureCompatibility(ALL_AREAS, ALL_MODES, CHANNEL_NO_LONGER_IN_SYNC, this.operatorVersion);
},
isRawDiskImageBuildSupported() {
const check = checkGatedFeatureCompatibility(this.resource, this.mode, BUILD_MEDIA_RAW_SUPPORT, this.operatorVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import CreateEditView from '@shell/mixins/create-edit-view';
import { LabeledInput } from '@components/Form/LabeledInput';
import NameNsDescription from '@shell/components/form/NameNsDescription';
import Checkbox from '@components/Form/Checkbox/Checkbox.vue';
import { getOperatorVersion, checkGatedFeatureCompatibility, DELETE_NO_LONGER_IN_SYNC_CHANNELS } from '../utils/feature-versioning';
export default {
name: 'ManagedOsVersionChannelEditView',
Expand All @@ -24,8 +25,23 @@ export default {
mode: {
type: String,
required: true
},
resource: {
type: String,
required: true
}
},
async fetch() {
this.operatorVersion = await getOperatorVersion(this.$store);
},
data() {
return { operatorVersion: '' };
},
computed: {
supportsNoLongerInSyncChannelDeletion() {
return checkGatedFeatureCompatibility(this.resource, this.mode, DELETE_NO_LONGER_IN_SYNC_CHANNELS, this.operatorVersion);
}
}
},
};
</script>

Expand Down Expand Up @@ -59,6 +75,7 @@ export default {
:mode="mode"
/>
<Checkbox
v-if="supportsNoLongerInSyncChannelDeletion"
v-model="value.spec.deleteNoLongerInSyncVersions"
:mode="mode"
:label="t('elemental.osversionchannels.create.automaticDelete')"
Expand Down
28 changes: 26 additions & 2 deletions pkg/elemental/formatters/InSync.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,46 @@
<script>
import {
getOperatorVersion,
checkGatedFeatureCompatibility,
CHANNEL_NO_LONGER_IN_SYNC,
ALL_AREAS,
ALL_MODES,
} from '../utils/feature-versioning';
export default {
props: {
value: {
type: String,
default: () => ''
}
},
async fetch() {
this.operatorVersion = await getOperatorVersion(this.$store);
},
data() {
return { operatorVersion: '' };
},
computed: {
supportChannelNoLongerInSync() {
return checkGatedFeatureCompatibility(ALL_AREAS, ALL_MODES, CHANNEL_NO_LONGER_IN_SYNC, this.operatorVersion);
},
parsedValue() {
if (this.supportChannelNoLongerInSync) {
return this.value;
} else {
return this.t('elemental.osVersions.notApplicable');
}
},
isOutOfSync() {
return this.value === this.t('elemental.osVersions.outOfSync');
return this.parsedValue === this.t('elemental.osVersions.outOfSync');
}
},
};
</script>

<template>
<p :class="{ 'outOfSync': isOutOfSync }">
{{ value }}
{{ parsedValue }}
</p>
</template>

Expand Down
2 changes: 1 addition & 1 deletion pkg/elemental/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elemental",
"description": "OS Management extension",
"version": "2.0.0-rc1",
"version": "2.0.0-rc2",
"private": false,
"rancher": {
"annotations": {
Expand Down
19 changes: 18 additions & 1 deletion pkg/elemental/utils/feature-versioning.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import semver from 'semver';

import { _CREATE, _VIEW } from '@shell/config/query-params';
import { _CREATE, _EDIT, _VIEW } from '@shell/config/query-params';
import { ELEMENTAL_SCHEMA_IDS } from '../config/elemental-types';
import { ELEMENTAL_TYPES } from '../types';

Expand All @@ -11,9 +11,14 @@ interface FeaturesGatingConfig {
features: string[],
}

export const ALL_AREAS:string = 'all-areas';
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 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';

const FEATURES_GATING:FeaturesGatingConfig[] = [
{
Expand All @@ -33,6 +38,18 @@ const FEATURES_GATING:FeaturesGatingConfig[] = [
mode: [_VIEW],
minOperatorVersion: '1.6.2',
features: [BUILD_MEDIA_RAW_SUPPORT]
},
{
area: ELEMENTAL_SCHEMA_IDS.MANAGED_OS_VERSION_CHANNELS,
mode: [_CREATE, _EDIT],
minOperatorVersion: '1.6.3',
features: [DELETE_NO_LONGER_IN_SYNC_CHANNELS]
},
{
area: ALL_AREAS,
mode: [ALL_MODES],
minOperatorVersion: '1.6.3',
features: [CHANNEL_NO_LONGER_IN_SYNC]
}
];

Expand Down

0 comments on commit 071b67f

Please sign in to comment.