Skip to content
Open
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
27 changes: 25 additions & 2 deletions plugins/aks-desktop/src/components/Deploy/DeployButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Icon } from '@iconify/react';
import { useTranslation } from '@kinvolk/headlamp-plugin/lib';
import { Button, Dialog } from '@mui/material';
import React, { useEffect } from 'react';
import { useAzureContext } from '../../hooks/useAzureContext';
import { useNamespaceCapabilities } from '../../hooks/useNamespaceCapabilities';
import DeployWizard from '../DeployWizard/DeployWizard';
import { useDeployUrlParams } from './hooks/useDeployUrlParams';
import { useDialogState } from './hooks/useDialogState';
Expand Down Expand Up @@ -41,6 +43,15 @@ function DeployButton({ project }: DeployButtonProps) {
const { t } = useTranslation();
const urlParams = useDeployUrlParams();
const dialogState = useDialogState();
const cluster = project.clusters?.[0] || undefined;
const namespace = project.namespaces?.[0] || undefined;
const { azureContext, error: azureContextError } = useAzureContext(cluster);
const { isManagedNamespace, azureRbacEnabled } = useNamespaceCapabilities({
subscriptionId: azureContext?.subscriptionId,
resourceGroup: azureContext?.resourceGroup,
clusterName: cluster,
namespace: namespace ?? '',
});

// Open dialog when URL parameters indicate we should
useEffect(() => {
Expand Down Expand Up @@ -91,10 +102,22 @@ function DeployButton({ project }: DeployButtonProps) {
}}
>
<DeployWizard
cluster={project.clusters?.[0] || undefined}
namespace={project.namespaces?.[0] || undefined}
cluster={cluster}
namespace={namespace}
initialApplicationName={dialogState.initialApplicationName}
onClose={handleClose}
azureContext={
azureContext && cluster
? {
subscriptionId: azureContext.subscriptionId,
resourceGroup: azureContext.resourceGroup,
clusterName: cluster,
isManagedNamespace,
azureRbacEnabled,
}
Comment thread
tejhan marked this conversation as resolved.
: undefined
}
azureContextError={azureContextError ?? undefined}
/>
</Dialog>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type DeployWizardProps = {
onClose?: () => void;
/** Azure context for workload identity setup */
azureContext?: DeployAzureContext;
/** Error message from resolving the Azure context, if any. */
azureContextError?: string;
};

/**
Expand Down Expand Up @@ -71,6 +73,7 @@ export default function DeployWizard(props: DeployWizardProps) {
<ConfigureContainer
containerConfig={containerConfig}
azureContext={props.azureContext}
azureContextError={props.azureContextError}
namespace={props.namespace}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ interface ConfigureContainerProps {
};
/** When false, containerImage is not required to proceed past the Basics step. Default: true. */
requireContainerImage?: boolean;
/** Azure context needed for workload identity setup */
azureContext?: DeployAzureContext;
/** Error message from resolving the Azure context, if any. */
azureContextError?: string;
/** Target namespace for workload identity setup */
namespace?: string;
}
Expand All @@ -32,6 +33,7 @@ export default function ConfigureContainer({
containerConfig,
requireContainerImage = true,
azureContext,
azureContextError,
namespace,
}: ConfigureContainerProps) {
const { t } = useTranslation();
Expand Down Expand Up @@ -93,6 +95,7 @@ export default function ConfigureContainer({
<WorkloadIdentityStep
containerConfig={containerConfig}
azureContext={azureContext}
azureContextError={azureContextError}
namespace={namespace}
/>
</StepContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ import {
interface WorkloadIdentityStepProps {
containerConfig: ContainerConfigProp;
azureContext?: DeployAzureContext;
/** Error message from resolving the Azure context, if any. */
azureContextError?: string;
namespace?: string;
}

export default function WorkloadIdentityStep({
containerConfig,
azureContext,
azureContextError,
namespace,
}: WorkloadIdentityStepProps) {
const { t } = useTranslation();
Expand Down Expand Up @@ -116,7 +119,7 @@ export default function WorkloadIdentityStep({
/>
{!azureContext && (
<Typography variant="caption" color="text.secondary" sx={{ display: 'block', ml: 5 }}>
{t('Azure sign-in is required to configure workload identity.')}
{azureContextError ?? t('Azure sign-in is required to configure workload identity.')}
</Typography>
)}
{containerConfig.config.enableWorkloadIdentity && azureContext && (
Expand Down
Loading