Skip to content

Commit da1cadf

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 6089cc4 commit da1cadf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/cmd/scaffold.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type ScaffoldOptions struct {
2626
memoryRequest string
2727
output string
2828
replicas int32
29+
serviceAccountName string
2930
targetCPUUtilizationPercentage int32
3031
targetMemoryUtilizationPercentage int32
3132
variables map[string]string
@@ -47,6 +48,7 @@ type appConfig struct {
4748
Name string
4849
Replicas int32
4950
RuntimeConfig string
51+
ServiceAccountName string
5052
TargetCPUUtilizationPercentage int32
5153
TargetMemoryUtilizationPercentage int32
5254
Variables map[string]string
@@ -65,6 +67,9 @@ spec:
6567
{{- else }}
6668
replicas: {{ .Replicas }}
6769
{{- end}}
70+
{{- if .ServiceAccountName }}
71+
serviceAccountName: {{ .ServiceAccountName }}
72+
{{- end }}
6873
{{- if .Variables }}
6974
variables:
7075
{{- range $key, $value := .Variables }}
@@ -272,6 +277,7 @@ func scaffold(opts ScaffoldOptions) ([]byte, error) {
272277
ImagePullSecrets: opts.imagePullSecrets,
273278
Variables: opts.variables,
274279
Components: opts.components,
280+
ServiceAccountName: opts.serviceAccountName,
275281
}
276282

277283
if opts.configfile != "" {
@@ -327,6 +333,7 @@ func init() {
327333
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")
328334
scaffoldCmd.Flags().StringVar(&scaffoldOpts.memoryLimit, "memory-limit", "", "The maximum amount of memory the application is allowed to use")
329335
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")
336+
scaffoldCmd.Flags().StringVar(&scaffoldOpts.serviceAccountName, "service-account-name", "default", "The name of the service account to use for the application")
330337
scaffoldCmd.Flags().StringVarP(&scaffoldOpts.from, "from", "f", "", "Reference in the registry of the application")
331338
scaffoldCmd.Flags().StringVarP(&scaffoldOpts.output, "out", "o", "", "Path to file to write manifest yaml")
332339
scaffoldCmd.Flags().StringVarP(&scaffoldOpts.configfile, "runtime-config-file", "c", "", "Path to runtime config file")

0 commit comments

Comments
 (0)