Skip to content

Commit 2cd9a2e

Browse files
authored
Merge pull request #5768 from dims/remove-starlark-support
Remove starlark support
2 parents 88f19bf + d32eacf commit 2cd9a2e

File tree

91 files changed

+285
-2410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+285
-2410
lines changed

api/go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ require (
2828
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
2929
github.com/sergi/go-diff v1.2.0 // indirect
3030
github.com/xlab/treeprint v1.2.0 // indirect
31-
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
3231
golang.org/x/sys v0.21.0 // indirect
3332
google.golang.org/protobuf v1.33.0 // indirect
3433
gopkg.in/yaml.v3 v3.0.1 // indirect

api/go.sum

-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
22
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
3-
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
4-
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
5-
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
63
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
74
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
85
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -67,11 +64,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
6764
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
6865
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
6966
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
70-
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=
71-
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
7267
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
7368
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
74-
golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7569
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
7670
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
7771
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

api/internal/plugins/fnplugin/fnplugin.go

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func NewFnPlugin(o *types.FnPluginLoadingOptions) *FnPlugin {
7777
runFns: runfn.RunFns{
7878
Functions: []*yaml.RNode{},
7979
Network: o.Network,
80-
EnableStarlark: o.EnableStar,
8180
EnableExec: o.EnableExec,
8281
StorageMounts: toStorageMounts(o.Mounts),
8382
Env: o.Env,

api/types/pluginconfig.go

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type PluginConfig struct {
2828

2929
func EnabledPluginConfig(b BuiltinPluginLoadingOptions) (pc *PluginConfig) {
3030
pc = MakePluginConfig(PluginRestrictionsNone, b)
31-
pc.FnpLoadingOptions.EnableStar = true
3231
pc.HelmConfig.Enabled = true
3332
// If this command is not on PATH, tests needing it should skip.
3433
pc.HelmConfig.Command = "helmV3"

api/types/pluginrestrictions.go

-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ const (
4646
type FnPluginLoadingOptions struct {
4747
// Allow to run executables
4848
EnableExec bool
49-
// Allow to run starlark
50-
EnableStar bool
5149
// Allow container access to network
5250
Network bool
5351
NetworkName string

cmd/config/go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ require (
2525
github.com/sergi/go-diff v1.2.0 // indirect
2626
github.com/spf13/pflag v1.0.5 // indirect
2727
github.com/xlab/treeprint v1.2.0 // indirect
28-
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
2928
golang.org/x/sys v0.21.0 // indirect
3029
google.golang.org/protobuf v1.33.0 // indirect
3130
gopkg.in/yaml.v3 v3.0.1 // indirect

cmd/config/go.sum

-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
2-
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
3-
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
41
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
52
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
63
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -69,9 +66,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
6966
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
7067
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
7168
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
72-
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=
73-
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
74-
golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7569
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
7670
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
7771
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

cmd/config/internal/commands/e2e/e2e_test.go

-198
Original file line numberDiff line numberDiff line change
@@ -493,204 +493,6 @@ metadata:
493493
a-string-value: 'a'
494494
a-int-value: '2'
495495
a-bool-value: 'true'
496-
`,
497-
}
498-
},
499-
},
500-
501-
{
502-
name: "starlark_function_config",
503-
args: func(d string) []string { return []string{"--enable-star"} },
504-
files: func(d string) map[string]string {
505-
return map[string]string{
506-
"script.star": `
507-
# set the foo annotation on each resource
508-
def run(r, fc):
509-
for resource in r:
510-
resource["metadata"]["annotations"]["a-string-value"] = fc["data"]["stringValue"]
511-
resource["metadata"]["annotations"]["a-int-value"] = fc["data"]["intValue"]
512-
resource["metadata"]["annotations"]["a-bool-value"] = fc["data"]["boolValue"]
513-
run(ctx.resource_list["items"], ctx.resource_list["functionConfig"])
514-
`,
515-
"config.yaml": `
516-
apiVersion: example.com/v1alpha1
517-
kind: Input
518-
metadata:
519-
name: foo
520-
annotations:
521-
config.kubernetes.io/function: |
522-
starlark:
523-
path: script.star
524-
name: fn
525-
data:
526-
boolValue: true
527-
intValue: 2
528-
stringValue: a
529-
`,
530-
"deployment.yaml": `
531-
apiVersion: apps/v1
532-
kind: Deployment
533-
metadata:
534-
name: foo
535-
`,
536-
}
537-
},
538-
expectedFiles: func(d string) map[string]string {
539-
return map[string]string{
540-
"config.yaml": `
541-
apiVersion: example.com/v1alpha1
542-
kind: Input
543-
metadata:
544-
name: foo
545-
annotations:
546-
config.kubernetes.io/function: |
547-
starlark:
548-
path: script.star
549-
name: fn
550-
a-bool-value: true
551-
a-int-value: 2
552-
a-string-value: a
553-
data:
554-
boolValue: true
555-
intValue: 2
556-
stringValue: a
557-
`,
558-
"deployment.yaml": `
559-
apiVersion: apps/v1
560-
kind: Deployment
561-
metadata:
562-
name: foo
563-
annotations:
564-
a-bool-value: true
565-
a-int-value: 2
566-
a-string-value: a
567-
`,
568-
}
569-
},
570-
},
571-
572-
{
573-
name: "starlark_function_path",
574-
args: func(d string) []string {
575-
return []string{
576-
"--enable-star", "--star-path", "script.star",
577-
"--", "stringValue=a", "intValue=2", "boolValue=true",
578-
}
579-
},
580-
files: func(d string) map[string]string {
581-
return map[string]string{
582-
"script.star": `
583-
# set the foo annotation on each resource
584-
def run(r, fc):
585-
for resource in r:
586-
resource["metadata"]["annotations"]["a-string-value"] = fc["data"]["stringValue"]
587-
resource["metadata"]["annotations"]["a-int-value"] = fc["data"]["intValue"]
588-
resource["metadata"]["annotations"]["a-bool-value"] = fc["data"]["boolValue"]
589-
run(ctx.resource_list["items"], ctx.resource_list["functionConfig"])
590-
`,
591-
"deployment.yaml": `
592-
apiVersion: apps/v1
593-
kind: Deployment
594-
metadata:
595-
name: foo
596-
`,
597-
}
598-
},
599-
expectedFiles: func(d string) map[string]string {
600-
return map[string]string{
601-
"deployment.yaml": `
602-
apiVersion: apps/v1
603-
kind: Deployment
604-
metadata:
605-
name: foo
606-
annotations:
607-
a-bool-value: true
608-
a-int-value: 2
609-
a-string-value: a
610-
`,
611-
}
612-
},
613-
},
614-
615-
{
616-
name: "starlark_function_url",
617-
args: func(d string) []string {
618-
return []string{
619-
"--enable-star", "--star-url", "https://storage.googleapis.com/kustomize-starlark-functions/annotate.star",
620-
"--star-name", "annotate",
621-
"--", "stringValue=a", "intValue=2", "boolValue=true",
622-
}
623-
},
624-
files: func(d string) map[string]string {
625-
return map[string]string{
626-
"deployment.yaml": `
627-
apiVersion: apps/v1
628-
kind: Deployment
629-
metadata:
630-
name: foo
631-
`,
632-
}
633-
},
634-
expectedFiles: func(d string) map[string]string {
635-
return map[string]string{
636-
"deployment.yaml": `
637-
apiVersion: apps/v1
638-
kind: Deployment
639-
metadata:
640-
name: foo
641-
annotations:
642-
a-bool-value: true
643-
a-int-value: 2
644-
a-string-value: a
645-
`,
646-
}
647-
},
648-
},
649-
650-
{
651-
name: "starlark_function_url_config",
652-
args: func(d string) []string {
653-
return []string{"--enable-star"}
654-
},
655-
files: func(d string) map[string]string {
656-
return map[string]string{
657-
"config.yaml": `
658-
apiVersion: example.com/v1alpha1
659-
kind: Input
660-
metadata:
661-
name: foo
662-
annotations:
663-
a-bool-value: true
664-
a-int-value: 2
665-
a-string-value: a
666-
config.kubernetes.io/function: |
667-
starlark:
668-
url: https://storage.googleapis.com/kustomize-starlark-functions/annotate.star
669-
name: fn
670-
data:
671-
boolValue: true
672-
intValue: 2
673-
stringValue: a
674-
`,
675-
"deployment.yaml": `
676-
apiVersion: apps/v1
677-
kind: Deployment
678-
metadata:
679-
name: foo
680-
`,
681-
}
682-
},
683-
expectedFiles: func(d string) map[string]string {
684-
return map[string]string{
685-
"deployment.yaml": `
686-
apiVersion: apps/v1
687-
kind: Deployment
688-
metadata:
689-
name: foo
690-
annotations:
691-
a-bool-value: true
692-
a-int-value: 2
693-
a-string-value: a
694496
`,
695497
}
696498
},

cmd/config/internal/commands/run-fns.go

+1-49
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ func GetRunFnRunner(name string) *RunFnRunner {
5151
"enable support for exec functions -- note: exec functions run arbitrary code -- do not use for untrusted configs!!! (Alpha)")
5252
r.Command.Flags().StringVar(
5353
&r.ExecPath, "exec-path", "", "run an executable as a function. (Alpha)")
54-
r.Command.Flags().BoolVar(
55-
&r.EnableStar, "enable-star", false, "enable support for starlark functions. (Alpha)")
56-
r.Command.Flags().StringVar(
57-
&r.StarPath, "star-path", "", "run a starlark script as a function. (Alpha)")
58-
r.Command.Flags().StringVar(
59-
&r.StarURL, "star-url", "", "run a starlark script as a function. (Alpha)")
60-
r.Command.Flags().StringVar(
61-
&r.StarName, "star-name", "", "name of starlark program. (Alpha)")
6254

6355
r.Command.Flags().StringVar(
6456
&r.ResultsDir, "results-dir", "", "write function results to this dir")
@@ -91,7 +83,6 @@ type RunFnRunner struct {
9183
GlobalScope bool
9284
FnPaths []string
9385
Image string
94-
EnableStar bool
9586
StarPath string
9687
StarURL string
9788
StarName string
@@ -128,8 +119,6 @@ func (r *RunFnRunner) getContainerFunctions(dataItems []string) (
128119
switch {
129120
case r.Image != "":
130121
fnAnnotation, err = fnAnnotationForImage(r.Image, r.Network)
131-
case r.EnableStar && (r.StarPath != "" || r.StarURL != ""):
132-
fnAnnotation, err = fnAnnotationForStar(r.StarPath, r.StarURL, r.StarName)
133122
case r.EnableExec && r.ExecPath != "":
134123
fnAnnotation, err = fnAnnotationForExec(r.ExecPath)
135124
}
@@ -218,37 +207,6 @@ func fnAnnotationForExec(path string) (*yaml.RNode, error) {
218207
return fn, nil
219208
}
220209

221-
func fnAnnotationForStar(path string, url string, name string) (*yaml.RNode, error) {
222-
fn, err := yaml.Parse(`starlark: {}`)
223-
if err != nil {
224-
return nil, errors.Wrap(err)
225-
}
226-
227-
if path != "" {
228-
err = fn.PipeE(
229-
yaml.Lookup("starlark"),
230-
yaml.SetField("path", yaml.NewScalarRNode(path)))
231-
if err != nil {
232-
return nil, errors.Wrap(err)
233-
}
234-
}
235-
if url != "" {
236-
err = fn.PipeE(
237-
yaml.Lookup("starlark"),
238-
yaml.SetField("url", yaml.NewScalarRNode(url)))
239-
if err != nil {
240-
return nil, errors.Wrap(err)
241-
}
242-
}
243-
err = fn.PipeE(
244-
yaml.Lookup("starlark"),
245-
yaml.SetField("name", yaml.NewScalarRNode(name)))
246-
if err != nil {
247-
return nil, errors.Wrap(err)
248-
}
249-
return fn, nil
250-
}
251-
252210
func fnAnnotationForImage(image string, enableNetwork bool) (*yaml.RNode, error) {
253211
fn, err := yaml.Parse(`container: {}`)
254212
if err != nil {
@@ -286,16 +244,11 @@ func toStorageMounts(mounts []string) []runtimeutil.StorageMount {
286244
}
287245

288246
func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
289-
if !r.EnableStar && (r.StarPath != "" || r.StarURL != "") {
290-
return errors.Errorf("must specify --enable-star with --star-path and --star-url")
291-
}
292-
293247
if !r.EnableExec && r.ExecPath != "" {
294248
return errors.Errorf("must specify --enable-exec with --exec-path")
295249
}
296250

297-
if c.ArgsLenAtDash() >= 0 && r.Image == "" &&
298-
!(r.EnableStar && (r.StarPath != "" || r.StarURL != "")) && !(r.EnableExec && r.ExecPath != "") {
251+
if c.ArgsLenAtDash() >= 0 && r.Image == "" && !(r.EnableExec && r.ExecPath != "") {
299252
return errors.Errorf("must specify --image")
300253
}
301254

@@ -346,7 +299,6 @@ func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
346299
Input: input,
347300
Path: path,
348301
Network: r.Network,
349-
EnableStarlark: r.EnableStar,
350302
EnableExec: r.EnableExec,
351303
StorageMounts: storageMounts,
352304
ResultsDir: r.ResultsDir,

0 commit comments

Comments
 (0)