Fleet: Labels refactoring

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
Francesco Torchia 2025-02-06 17:39:27 +01:00
parent 573406b341
commit b6973366fc
No known key found for this signature in database
GPG Key ID: E6D011B7415D4393
3 changed files with 12 additions and 8 deletions

View File

@ -109,6 +109,7 @@ export const CATALOG = {
};
export const FLEET = {
REPO_NAME: 'fleet.cattle.io/repo-name',
CLUSTER_DISPLAY_NAME: 'management.cattle.io/cluster-display-name',
CLUSTER_NAME: 'management.cattle.io/cluster-name',
BUNDLE_ID: 'fleet.cattle.io/bundle-id',
@ -116,7 +117,9 @@ export const FLEET = {
BUNDLE_NAMESPACE: 'fleet.cattle.io/bundle-namespace',
MANAGED: 'fleet.cattle.io/managed',
CLUSTER_NAMESPACE: 'fleet.cattle.io/cluster-namespace',
CLUSTER: 'fleet.cattle.io/cluster'
CLUSTER: 'fleet.cattle.io/cluster',
CREATED_BY_USER_ID: 'fleet.cattle.io/created-by-user-id',
CREATED_BY_USER_NAME: 'fleet.cattle.io/created-by-display-name',
};
export const RBAC = { PRODUCT: 'management.cattle.io/ui-product' };

View File

@ -3,6 +3,7 @@ import SteveModel from '@shell/plugins/steve/steve-class';
import typeHelper from '@shell/utils/type-helpers';
import { addObject, addObjects, findBy } from '@shell/utils/array';
import { FLEET, MANAGEMENT } from '@shell/config/types';
import { FLEET as FLEET_ANNOTATIONS } from '@shell/config/labels-annotations';
import { convertSelectorObj, matching } from '@shell/utils/selector';
export default class FleetBundle extends SteveModel {
@ -21,7 +22,7 @@ export default class FleetBundle extends SteveModel {
get repoName() {
const labels = this.metadata?.labels || {};
return labels['fleet.cattle.io/repo-name'];
return labels[FLEET_ANNOTATIONS.REPO_NAME];
}
get targetClusters() {
@ -129,7 +130,7 @@ export default class FleetBundle extends SteveModel {
}
get authorId() {
return this.metadata.labels['fleet.cattle.io/created-by-user-id'];
return this.metadata.labels[FLEET_ANNOTATIONS.CREATED_BY_USER_ID];
}
get author() {
@ -141,7 +142,7 @@ export default class FleetBundle extends SteveModel {
}
get createdBy() {
const displayName = this.metadata.labels['fleet.cattle.io/created-by-display-name'];
const displayName = this.metadata.labels[FLEET_ANNOTATIONS.CREATED_BY_USER_NAME];
if (!displayName) {
return null;

View File

@ -352,11 +352,11 @@ export default class GitRepo extends SteveModel {
}
get bundles() {
return this.$getters['matching'](FLEET.BUNDLE, { 'fleet.cattle.io/repo-name': this.name }, this.namespace);
return this.$getters['matching'](FLEET.BUNDLE, { [FLEET_ANNOTATIONS.REPO_NAME]: this.name }, this.namespace);
}
get bundleDeployments() {
return this.$getters['matching'](FLEET.BUNDLE_DEPLOYMENT, { 'fleet.cattle.io/repo-name': this.name });
return this.$getters['matching'](FLEET.BUNDLE_DEPLOYMENT, { [FLEET_ANNOTATIONS.REPO_NAME]: this.name });
}
get allBundlesStatuses() {
@ -481,7 +481,7 @@ export default class GitRepo extends SteveModel {
}
get authorId() {
return this.metadata.labels['fleet.cattle.io/created-by-user-id'];
return this.metadata.labels[FLEET_ANNOTATIONS.CREATED_BY_USER_ID];
}
get author() {
@ -493,7 +493,7 @@ export default class GitRepo extends SteveModel {
}
get createdBy() {
const displayName = this.metadata.labels['fleet.cattle.io/created-by-display-name'];
const displayName = this.metadata.labels[FLEET_ANNOTATIONS.CREATED_BY_USER_NAME];
if (!displayName) {
return null;