Skip to content

Commit dc7043e

Browse files
authored
Merge pull request #97 from Mossaka/azure-workload-identity
feat: add azure workload identity support in scaffold command
2 parents 6089cc4 + a891ce1 commit dc7043e

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
go-version: stable
2424
cache: false
2525
- name: golangci-lint
26-
uses: golangci/golangci-lint-action@v4
26+
uses: golangci/golangci-lint-action@v6
2727
with:
28-
version: v1.61.0
28+
version: v1.64.6
2929
args: --timeout 3m

pkg/cmd/scaffold.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
type ScaffoldOptions struct {
1717
autoscaler string
18+
azureWorkloadIdentity bool
1819
configfile string
1920
cpuLimit string
2021
cpuRequest string
@@ -36,6 +37,7 @@ var scaffoldOpts = ScaffoldOptions{}
3637

3738
type appConfig struct {
3839
Autoscaler string
40+
AzureWorkloadIdentity bool
3941
CPULimit string
4042
CPURequest string
4143
Executor string
@@ -65,6 +67,10 @@ spec:
6567
{{- else }}
6668
replicas: {{ .Replicas }}
6769
{{- end}}
70+
{{- if .AzureWorkloadIdentity }}
71+
podLabels:
72+
azure.workload.identity/use: "true"
73+
{{- end }}
6874
{{- if .Variables }}
6975
variables:
7076
{{- range $key, $value := .Variables }}
@@ -272,6 +278,7 @@ func scaffold(opts ScaffoldOptions) ([]byte, error) {
272278
ImagePullSecrets: opts.imagePullSecrets,
273279
Variables: opts.variables,
274280
Components: opts.components,
281+
AzureWorkloadIdentity: opts.azureWorkloadIdentity,
275282
}
276283

277284
if opts.configfile != "" {
@@ -327,6 +334,7 @@ func init() {
327334
scaffoldCmd.Flags().StringVar(&scaffoldOpts.cpuRequest, "cpu-request", "", "The amount of CPU resource units requested by the application. Used to determine which node the application will run on")
328335
scaffoldCmd.Flags().StringVar(&scaffoldOpts.memoryLimit, "memory-limit", "", "The maximum amount of memory the application is allowed to use")
329336
scaffoldCmd.Flags().StringVar(&scaffoldOpts.memoryRequest, "memory-request", "", "The amount of memory requested by the application. Used to determine which node the application will run on")
337+
scaffoldCmd.Flags().BoolVar(&scaffoldOpts.azureWorkloadIdentity, "azure-identity", false, "Enable Azure Workload Identity for the application")
330338
scaffoldCmd.Flags().StringVarP(&scaffoldOpts.from, "from", "f", "", "Reference in the registry of the application")
331339
scaffoldCmd.Flags().StringVarP(&scaffoldOpts.output, "out", "o", "", "Path to file to write manifest yaml")
332340
scaffoldCmd.Flags().StringVarP(&scaffoldOpts.configfile, "runtime-config-file", "c", "", "Path to runtime config file")

pkg/cmd/scaffold_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ func TestScaffoldOutput(t *testing.T) {
3333
},
3434
expected: "scaffold_runtime_config.yml",
3535
},
36+
{
37+
name: "azure identity is enabled",
38+
opts: ScaffoldOptions{
39+
from: "ghcr.io/foo/example-app:v0.1.0",
40+
replicas: 2,
41+
executor: "containerd-shim-spin",
42+
azureWorkloadIdentity: true,
43+
},
44+
expected: "azure_workload_identity.yml",
45+
},
3646
{
3747
name: "one image pull secret is provided",
3848
opts: ScaffoldOptions{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: core.spinkube.dev/v1alpha1
2+
kind: SpinApp
3+
metadata:
4+
name: example-app
5+
spec:
6+
image: "ghcr.io/foo/example-app:v0.1.0"
7+
executor: containerd-shim-spin
8+
replicas: 2
9+
podLabels:
10+
azure.workload.identity/use: "true"

0 commit comments

Comments
 (0)