Skip to content

Commit

Permalink
Changes in command help content for service acnts
Browse files Browse the repository at this point in the history
  • Loading branch information
radhikav1 committed Nov 8, 2023
1 parent f72ff68 commit f2391e0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface IEditConfirmDialogProps {
isShow: boolean;
closeFn: () => void;
namespaceIdentity: string;
k8snamespace?: string;
}

const StyledTextField = styled(TextField)`
Expand Down Expand Up @@ -65,15 +66,19 @@ const getGcloudCommand = ({
tenantProjectId = '${TENANT_PROJECT_ID}',
identity = '${IDENTITY}',
gsaEmail = '${GSA_EMAIL}',
gsaProjectId = '${GSA_PROJECT_ID}',
k8snamespace = 'default',
}): string =>
`gcloud iam service-accounts add-iam-policy-binding --role roles/iam.workloadIdentityUser --member "serviceAccount:${tenantProjectId}.svc.id.goog[default/${identity}]" ${gsaEmail}`;
`gcloud iam service-accounts add-iam-policy-binding --role roles/iam.workloadIdentityUser --member "serviceAccount:${tenantProjectId}.svc.id.goog[${k8snamespace}/${identity}]" ${gsaEmail} --project ${gsaProjectId}`;

export const EditConfirmDialog = ({
selectedServiceAcccount,
isShow,
closeFn,
namespaceIdentity,
k8snamespace,
}: IEditConfirmDialogProps) => {
const namespacedCreationHookEnabled = window.CDAP_CONFIG.cdap.namespaceCreationHookEnabled;
const [serviceAccountInputValue, setServiceAccountInputValue] = useState<string>(
selectedServiceAcccount
);
Expand All @@ -88,6 +93,7 @@ export const EditConfirmDialog = ({
const gcloudCommandParams = {
identity: namespaceIdentity || undefined,
gsaEmail: serviceAccountInputValue || undefined,
k8snamespace: namespacedCreationHookEnabled ? k8snamespace : 'default',
};

const copyableExtendedMessage =
Expand Down
4 changes: 3 additions & 1 deletion app/cdap/components/NamespaceAdmin/ServiceAccounts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const SubTitleBox = styled(Box)`
margin-bottom: 15px;
`;

const ServiceAccountsView = ({ serviceAccounts, namespaceIdentity }) => {
const ServiceAccountsView = ({ serviceAccounts, namespaceIdentity, k8snamespace }) => {
const [showPopover, setShowPopover] = useState(false);
const [selectedServiceAcccount, setSelectedServiceAcccount] = useState<string>('');
const [isSaveDialogOpen, setSaveDialogOpen] = useState(false);
Expand Down Expand Up @@ -125,6 +125,7 @@ const ServiceAccountsView = ({ serviceAccounts, namespaceIdentity }) => {
isShow={isSaveDialogOpen}
closeFn={closeSaveDialog}
namespaceIdentity={namespaceIdentity}
k8snamespace={k8snamespace}
></EditConfirmDialog>
)}
</div>
Expand All @@ -135,6 +136,7 @@ const mapStateToProps = (state) => {
return {
serviceAccounts: state.serviceAccounts,
namespaceIdentity: state.identity,
k8snamespace: state.k8snamespace,
};
};

Expand Down
1 change: 1 addition & 0 deletions app/cdap/components/NamespaceAdmin/store/ActionCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function getNamespaceDetail(namespace) {
exploreAsPrincipal: res.config['explore.as.principal'],
schedulerQueueName: res.config['scheduler.queue.name'],
identity: res.identity,
k8snamespace: res.config['k8s.namespace'],
},
});
});
Expand Down
2 changes: 2 additions & 0 deletions app/cdap/components/NamespaceAdmin/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ interface INamespaceAdmin {
sourceControlManagementConfig: ISourceControlManagementConfig;
serviceAccounts: IServiceAccount[];
identity: string;
k8snamespace: string;
}

type INamespaceAdminState = Partial<INamespaceAdmin>;
Expand All @@ -113,6 +114,7 @@ const defaultInitialState: Partial<INamespaceAdminState> = {
sourceControlManagementConfig: null,
serviceAccounts: [],
identity: null,
k8snamespace: null,
};

const namespaceAdmin: Reducer<INamespaceAdminState> = (state = defaultInitialState, action) => {
Expand Down

0 comments on commit f2391e0

Please sign in to comment.