Refactor feature flags structure (backport #276) (#314)

* Refactor feature flags structure (#276)

* refactor feature flags structure

Signed-off-by: Andy Lee <andy.lee@suse.com>

* Replace with FEATURE_FLAGS and valid and sort versions

Signed-off-by: Andy Lee <andy.lee@suse.com>

---------

Signed-off-by: Andy Lee <andy.lee@suse.com>
(cherry picked from commit f8079c592485c51155f59037b395c611c04d327a)

# Conflicts:
#	pkg/harvester/config/feature-flags.js

* resolve conflict

Signed-off-by: Andy Lee <andy.lee@suse.com>

---------

Signed-off-by: Andy Lee <andy.lee@suse.com>
Co-authored-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
mergify[bot] 2025-05-26 15:19:28 +08:00 committed by GitHub
parent a2898a2554
commit 3e9a0a4377
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,69 +1,55 @@
// https://github.com/harvester/dashboard/releases/tag/v1.3.0 import semver from 'semver';
const featuresV130 = [
'supportHarvesterClusterVersion'
];
// https://github.com/harvester/dashboard/releases/tag/v1.3.1 const FEATURE_FLAGS = {
const featuresV131 = [ 'v1.3.0': [
...featuresV130, 'supportHarvesterClusterVersion'
'autoRotateRke2CertsSetting', ],
'supportBundleNodeCollectionTimeoutSetting' 'v1.3.1': [
]; 'autoRotateRke2CertsSetting',
'supportBundleNodeCollectionTimeoutSetting'
// https://github.com/harvester/dashboard/releases/tag/v1.3.2 ],
const featuresV132 = [ 'v1.3.2': [
...featuresV131, 'kubeconfigDefaultTokenTTLMinutesSetting',
'kubeconfigDefaultTokenTTLMinutesSetting', 'improveMaintenanceMode',
'improveMaintenanceMode', ],
]; 'v1.3.3': [],
'v1.4.0': [
// TODO: add v1.3.3 official release note 'cpuPinning',
// https://github.com/harvester/dashboard/releases/tag/v1.3.3-dev-20250105 'usbPassthrough',
const featuresV133 = [ 'volumeEncryption',
...featuresV132, 'schedulingVMBackup',
]; 'vmSnapshotQuota',
'longhornV2LVMSupport',
// https://github.com/harvester/dashboard/releases/tag/v1.4.0 'improveMaintenanceMode',
const featuresV140 = [ ],
...featuresV133, 'v1.4.1': [],
'cpuPinning', 'v1.4.2': [
'usbPassthrough', 'refreshIntervalInSecond',
'volumeEncryption', 'allowEmptySnapshotClassName'
'schedulingVMBackup', ],
'vmSnapshotQuota', 'v1.4.3': [],
'longhornV2LVMSupport', 'v1.5.0': [
'improveMaintenanceMode', 'tpmPersistentState',
]; 'efiPersistentState',
'untaggedNetworkSetting',
// https://github.com/harvester/dashboard/releases/tag/v1.4.1 'skipSingleReplicaDetachedVol',
const featuresV141 = [ 'thirdPartyStorage'
...featuresV140 ],
]; 'v1.5.1': [],
// TODO: add v1.4.2 official release note
const featuresV142 = [
...featuresV141,
'refreshIntervalInSecond',
'allowEmptySnapshotClassName'
];
// TODO: add v1.5.0 official release note
const featuresV150 = [
...featuresV142,
'tpmPersistentState',
'efiPersistentState',
'untaggedNetworkSetting',
'skipSingleReplicaDetachedVol',
'thirdPartyStorage'
];
export const RELEASE_FEATURES = {
'v1.3.0': featuresV130,
'v1.3.1': featuresV131,
'v1.3.2': featuresV132,
'v1.3.3': featuresV133,
'v1.4.0': featuresV140,
'v1.4.1': featuresV141,
'v1.4.2': featuresV142,
'v1.5.0': featuresV150
}; };
const generateFeatureFlags = () => {
const versions = [...Object.keys(FEATURE_FLAGS)].filter((version) => semver.valid(version)).sort(semver.compare);
const generatedFlags = {};
versions.forEach((version, index) => {
const previousVersion = versions[index - 1];
generatedFlags[version] = previousVersion ? [...generatedFlags[previousVersion], ...FEATURE_FLAGS[version]] : [...FEATURE_FLAGS[version]];
});
return generatedFlags;
};
export const RELEASE_FEATURES = generateFeatureFlags();