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

Set creator principal id annotation when creating clusters #5180

Merged
merged 1 commit into from
Oct 15, 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
6 changes: 6 additions & 0 deletions lib/shared/addon/components/cru-cluster/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ChildHook from 'shared/mixins/child-hook';
import ViewNewEdit from 'shared/mixins/view-new-edit';
import { loadStylesheet, proxifyUrl } from 'shared/utils/load-script';
import layout from './template';
import C from '../../utils/constants';

const MEMBER_CONFIG = { type: 'clusterRoleTemplateBinding', };
const BUILD_IN_UI = ['tencentkubernetesengine', 'huaweicontainercloudengine', 'oraclecontainerengine', 'linodekubernetesengine'];
Expand Down Expand Up @@ -67,6 +68,11 @@ export default Component.extend(ViewNewEdit, ChildHook, {

if ( isEmpty(get(this, 'cluster.id')) ){
set(this, 'newCluster', true);
const principal = get(this, 'access.principal')

if (principal?.provider !== 'local'){
set(this.cluster, 'annotations', { [C.LABEL.CREATOR_PRINCIPAL_ID]: principal.id })
}
}

this.router.on('routeWillChange', (/* transition */) => {
Expand Down
5 changes: 3 additions & 2 deletions lib/shared/addon/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ var C = {

DEPLOYMENT_REVISION: 'deployment.kubernetes.io/revision',

CREATOR_ID: 'field.cattle.io/creatorId',
TIMESTAMP: 'cattle.io/timestamp',
CREATOR_ID: 'field.cattle.io/creatorId',
TIMESTAMP: 'cattle.io/timestamp',
CREATOR_PRINCIPAL_ID: 'field.cattle.io/creator-principal-name',

// EKS Cluster session token
EKS_SESSION_TOKEN: 'clusterstatus.management.cattle.io/temporary-security-credentials',
Expand Down
Loading