Skip to content

Commit 8d6a2fd

Browse files
authored
Merge pull request #563 from Azure/thgamble/fix-agent-template
fix: pin kubelogin version, add actions:read, instruct two-job split in agent templates
2 parents 27170e5 + a0faf74 commit 8d6a2fd

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

plugins/aks-desktop/src/components/GitHubPipeline/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export const SCHEMA_VERSION = 1;
3131
/** Version of the containerization-assist-mcp used in agent setup steps. */
3232
export const CONTAINERIZATION_MCP_VERSION = '1.3.2';
3333

34+
/** Pinned kubelogin version for AAD-enabled AKS clusters. */
35+
export const KUBELOGIN_VERSION = 'v0.1.6';
36+
3437
/** Default polling interval for GitHub API checks (5 seconds). */
3538
export const POLLING_INTERVAL_MS = 5_000;
3639

plugins/aks-desktop/src/components/GitHubPipeline/utils/agentTemplates.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
55
import { createContainerConfig, createValidConfig } from '../__fixtures__/pipelineConfig';
6+
import { KUBELOGIN_VERSION } from '../constants';
67
import type { PipelineConfig } from '../types';
78
import {
89
generateAgentConfig,
@@ -84,6 +85,23 @@ describe('agentTemplates', () => {
8485
expect(result).not.toContain('Trigger on push to main');
8586
});
8687

88+
it('should instruct agent to pin kubelogin version instead of skip-cache', () => {
89+
const result = generateAgentConfig(validConfig);
90+
expect(result).toContain(`kubelogin-version: '${KUBELOGIN_VERSION}'`);
91+
expect(result).not.toContain('skip-cache: true');
92+
});
93+
94+
it('should instruct agent to include actions: read permission', () => {
95+
const result = generateAgentConfig(validConfig);
96+
expect(result).toContain('actions: read');
97+
});
98+
99+
it('should instruct agent to split workflow into two jobs', () => {
100+
const result = generateAgentConfig(validConfig);
101+
expect(result).toContain('buildImage');
102+
expect(result).toContain('needs: [buildImage]');
103+
});
104+
87105
it('should include optional fields when provided', () => {
88106
const config: PipelineConfig = {
89107
...validConfig,

plugins/aks-desktop/src/components/GitHubPipeline/utils/agentTemplates.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getServiceAccountName } from '../../../utils/kubernetes/serviceAccountN
55
import {
66
CONTAINERIZATION_MCP_VERSION,
77
DEFAULT_IMAGE_TAG,
8+
KUBELOGIN_VERSION,
89
PIPELINE_WORKFLOW_FILENAME,
910
} from '../constants';
1011
import type { PipelineConfig } from '../types';
@@ -305,7 +306,9 @@ Generate \`.github/workflows/${PIPELINE_WORKFLOW_FILENAME}\` with the following:
305306
- Do NOT add a \`push\` trigger — deployment is always triggered explicitly
306307
- Use \`azure/login@v2\` with OIDC (\`secrets.AZURE_CLIENT_ID\`, \`secrets.AZURE_TENANT_ID\`, \`secrets.AZURE_SUBSCRIPTION_ID\`)
307308
- Use \`azure/aks-set-context@v4\` with cluster \`\${{ inputs.cluster-name }}\` and resource group \`\${{ inputs.resource-group }}\`
308-
- Install kubelogin (required for AAD-enabled AKS clusters): \`azure/use-kubelogin@v1\` with \`skip-cache: true\`
309+
- The deploy job MUST include \`actions: read\` in its permissions block (required for GITHUB_TOKEN access)
310+
- Split the workflow into two jobs: a \`buildImage\` job (build + push to ACR) and a \`deploy\` job (apply manifests) with \`needs: [buildImage]\`
311+
- Install kubelogin (required for AAD-enabled AKS clusters): \`azure/use-kubelogin@v1\` with \`kubelogin-version: '${KUBELOGIN_VERSION}'\`
309312
- Convert kubeconfig to use kubelogin: \`kubelogin convert-kubeconfig -l workloadidentity\`${
310313
config.acrLoginServer
311314
? `\n- Build and push the container image using ACR Tasks: \`az acr build --registry \${{ secrets.AZURE_ACR_NAME }} --image ${config.appName}:\${{ github.sha }} .\`\n- Update the container image reference in manifests to use \`${config.acrLoginServer}/${config.appName}:\${{ github.sha }}\``

0 commit comments

Comments
 (0)