Skip to content

Commit f23256d

Browse files
authored
Merge pull request #217 from aalves08/feature-gating-prs-backport
BP: gate features to a specific elemental operator version
2 parents e137dc5 + aac9faa commit f23256d

File tree

6 files changed

+76
-8
lines changed

6 files changed

+76
-8
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "elemental-ui",
33
"description": "Elemental UI extension",
4-
"version": "1.3.1-rc9",
4+
"version": "1.3.1-rc10",
55
"private": false,
66
"engines": {
77
"node": ">=12"

pkg/elemental/components/BuildMedia.vue

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ import { Banner } from '@components/Banner';
55
import AsyncButton from '@shell/components/AsyncButton';
66
import { randomStr, CHARSET } from '@shell/utils/string';
77
import { ELEMENTAL_SCHEMA_IDS } from '../config/elemental-types';
8-
import { getOperatorVersion, checkGatedFeatureCompatibility, BUILD_MEDIA_RAW_SUPPORT } from '../utils/feature-versioning';
8+
import {
9+
getOperatorVersion,
10+
checkGatedFeatureCompatibility,
11+
BUILD_MEDIA_RAW_SUPPORT,
12+
CHANNEL_NO_LONGER_IN_SYNC,
13+
ALL_AREAS,
14+
ALL_MODES,
15+
} from '../utils/feature-versioning';
916
1017
export const MEDIA_TYPES = {
1118
RAW: {
@@ -88,14 +95,17 @@ export default {
8895
this.filteredManagedOsVersions = this.managedOsVersions.filter(v => v.spec?.type === selectedFilterType) || [];
8996
this.buildMediaOsVersions = this.filteredManagedOsVersions.map((f) => {
9097
return {
91-
label: `${ f.spec?.metadata?.displayName } ${ f.spec?.version } ${ typeof f.inSync === 'boolean' && !f.inSync ? '(deprecated)' : '' }`,
98+
label: `${ f.spec?.metadata?.displayName } ${ f.spec?.version } ${ this.supportChannelNoLongerInSync && typeof f.inSync === 'boolean' && !f.inSync ? '(deprecated)' : '' }`,
9299
value: neu === MEDIA_TYPES.ISO.type ? f.spec?.metadata?.uri : f.spec?.metadata?.upgradeImage,
93100
};
94101
});
95102
}
96103
}
97104
},
98105
computed: {
106+
supportChannelNoLongerInSync() {
107+
return checkGatedFeatureCompatibility(ALL_AREAS, ALL_MODES, CHANNEL_NO_LONGER_IN_SYNC, this.operatorVersion);
108+
},
99109
isRawDiskImageBuildSupported() {
100110
const check = checkGatedFeatureCompatibility(this.resource, this.mode, BUILD_MEDIA_RAW_SUPPORT, this.operatorVersion);
101111

pkg/elemental/edit/elemental.cattle.io.managedosversionchannel.vue

+18-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import CreateEditView from '@shell/mixins/create-edit-view';
55
import { LabeledInput } from '@components/Form/LabeledInput';
66
import NameNsDescription from '@shell/components/form/NameNsDescription';
77
import Checkbox from '@components/Form/Checkbox/Checkbox.vue';
8+
import { getOperatorVersion, checkGatedFeatureCompatibility, DELETE_NO_LONGER_IN_SYNC_CHANNELS } from '../utils/feature-versioning';
89
910
export default {
1011
name: 'ManagedOsVersionChannelEditView',
@@ -24,8 +25,23 @@ export default {
2425
mode: {
2526
type: String,
2627
required: true
28+
},
29+
resource: {
30+
type: String,
31+
required: true
32+
}
33+
},
34+
async fetch() {
35+
this.operatorVersion = await getOperatorVersion(this.$store);
36+
},
37+
data() {
38+
return { operatorVersion: '' };
39+
},
40+
computed: {
41+
supportsNoLongerInSyncChannelDeletion() {
42+
return checkGatedFeatureCompatibility(this.resource, this.mode, DELETE_NO_LONGER_IN_SYNC_CHANNELS, this.operatorVersion);
2743
}
28-
}
44+
},
2945
};
3046
</script>
3147

@@ -59,6 +75,7 @@ export default {
5975
:mode="mode"
6076
/>
6177
<Checkbox
78+
v-if="supportsNoLongerInSyncChannelDeletion"
6279
v-model="value.spec.deleteNoLongerInSyncVersions"
6380
:mode="mode"
6481
:label="t('elemental.osversionchannels.create.automaticDelete')"

pkg/elemental/formatters/InSync.vue

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
11
<script>
2+
import {
3+
getOperatorVersion,
4+
checkGatedFeatureCompatibility,
5+
CHANNEL_NO_LONGER_IN_SYNC,
6+
ALL_AREAS,
7+
ALL_MODES,
8+
} from '../utils/feature-versioning';
9+
210
export default {
311
props: {
412
value: {
513
type: String,
614
default: () => ''
715
}
816
},
17+
async fetch() {
18+
this.operatorVersion = await getOperatorVersion(this.$store);
19+
},
20+
data() {
21+
return { operatorVersion: '' };
22+
},
923
computed: {
24+
supportChannelNoLongerInSync() {
25+
return checkGatedFeatureCompatibility(ALL_AREAS, ALL_MODES, CHANNEL_NO_LONGER_IN_SYNC, this.operatorVersion);
26+
},
27+
parsedValue() {
28+
if (this.supportChannelNoLongerInSync) {
29+
return this.value;
30+
} else {
31+
return this.t('elemental.osVersions.notApplicable');
32+
}
33+
},
1034
isOutOfSync() {
11-
return this.value === this.t('elemental.osVersions.outOfSync');
35+
return this.parsedValue === this.t('elemental.osVersions.outOfSync');
1236
}
1337
},
1438
};
1539
</script>
1640

1741
<template>
1842
<p :class="{ 'outOfSync': isOutOfSync }">
19-
{{ value }}
43+
{{ parsedValue }}
2044
</p>
2145
</template>
2246

pkg/elemental/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "elemental",
33
"description": "OS Management extension",
4-
"version": "1.3.1-rc9",
4+
"version": "1.3.1-rc10",
55
"private": false,
66
"rancher": {
77
"annotations": {

pkg/elemental/utils/feature-versioning.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import semver from 'semver';
22

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

@@ -11,9 +11,14 @@ interface FeaturesGatingConfig {
1111
features: string[],
1212
}
1313

14+
export const ALL_AREAS:string = 'all-areas';
15+
export const ALL_MODES:string = 'all-modes';
16+
1417
// features to be gated to specific operator versions
1518
export const MACH_REG_CONFIG_DEFAULTS:string = 'machine-reg-config-defaults';
1619
export const BUILD_MEDIA_RAW_SUPPORT:string = 'build-media-raw-support';
20+
export const DELETE_NO_LONGER_IN_SYNC_CHANNELS:string = 'delete-no-longer-in-sync-channels';
21+
export const CHANNEL_NO_LONGER_IN_SYNC:string = 'channel-no-longer-in-sync';
1722

1823
const FEATURES_GATING:FeaturesGatingConfig[] = [
1924
{
@@ -33,6 +38,18 @@ const FEATURES_GATING:FeaturesGatingConfig[] = [
3338
mode: [_VIEW],
3439
minOperatorVersion: '1.6.2',
3540
features: [BUILD_MEDIA_RAW_SUPPORT]
41+
},
42+
{
43+
area: ELEMENTAL_SCHEMA_IDS.MANAGED_OS_VERSION_CHANNELS,
44+
mode: [_CREATE, _EDIT],
45+
minOperatorVersion: '1.6.3',
46+
features: [DELETE_NO_LONGER_IN_SYNC_CHANNELS]
47+
},
48+
{
49+
area: ALL_AREAS,
50+
mode: [ALL_MODES],
51+
minOperatorVersion: '1.6.3',
52+
features: [CHANNEL_NO_LONGER_IN_SYNC]
3653
}
3754
];
3855

0 commit comments

Comments
 (0)