Skip to content

Commit e18f250

Browse files
committed
feat: add service account name to scaffold command
Add a new flag `--service-account-name` to the `spin-plugin-kube scaffold` command to allow specifying the service account name for the SpinApp CRD. The default service account name is `default`. Signed-off-by: Jiaxiao (mossaka) Zhou <[email protected]>
1 parent 04d5916 commit e18f250

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/cmd/scaffold.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type ScaffoldOptions struct {
2727
memoryRequest string
2828
output string
2929
replicas int32
30+
serviceAccountName string
3031
targetCPUUtilizationPercentage int32
3132
targetMemoryUtilizationPercentage int32
3233
variables map[string]string
@@ -49,6 +50,7 @@ type appConfig struct {
4950
Name string
5051
Replicas int32
5152
RuntimeConfig string
53+
ServiceAccountName string
5254
TargetCPUUtilizationPercentage int32
5355
TargetMemoryUtilizationPercentage int32
5456
Variables map[string]string
@@ -70,6 +72,8 @@ spec:
7072
{{- if .AzureWorkloadIdentity }}
7173
podLabels:
7274
azure.workload.identity/use: "true"
75+
{{- if .ServiceAccountName }}
76+
serviceAccountName: {{ .ServiceAccountName }}
7377
{{- end }}
7478
{{- if .Variables }}
7579
variables:
@@ -279,6 +283,7 @@ func scaffold(opts ScaffoldOptions) ([]byte, error) {
279283
Variables: opts.variables,
280284
Components: opts.components,
281285
AzureWorkloadIdentity: opts.azureWorkloadIdentity,
286+
ServiceAccountName: opts.serviceAccountName,
282287
}
283288

284289
if opts.configfile != "" {
@@ -335,6 +340,7 @@ func init() {
335340
scaffoldCmd.Flags().StringVar(&scaffoldOpts.memoryLimit, "memory-limit", "", "The maximum amount of memory the application is allowed to use")
336341
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")
337342
scaffoldCmd.Flags().BoolVar(&scaffoldOpts.azureWorkloadIdentity, "azure-identity", false, "Enable Azure Workload Identity for the application")
343+
scaffoldCmd.Flags().StringVar(&scaffoldOpts.serviceAccountName, "service-account-name", "default", "The name of the service account to use for the application")
338344
scaffoldCmd.Flags().StringVarP(&scaffoldOpts.from, "from", "f", "", "Reference in the registry of the application")
339345
scaffoldCmd.Flags().StringVarP(&scaffoldOpts.output, "out", "o", "", "Path to file to write manifest yaml")
340346
scaffoldCmd.Flags().StringVarP(&scaffoldOpts.configfile, "runtime-config-file", "c", "", "Path to runtime config file")

0 commit comments

Comments
 (0)