Remove starlark support

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas
2024-09-23 16:52:05 -04:00
parent 88f19bffa9
commit d32eacf034
91 changed files with 285 additions and 2410 deletions

View File

@@ -19,7 +19,6 @@ import (
"sigs.k8s.io/kustomize/kyaml/fn/runtime/container"
"sigs.k8s.io/kustomize/kyaml/fn/runtime/exec"
"sigs.k8s.io/kustomize/kyaml/fn/runtime/runtimeutil"
"sigs.k8s.io/kustomize/kyaml/fn/runtime/starlark"
"sigs.k8s.io/kustomize/kyaml/kio"
"sigs.k8s.io/kustomize/kyaml/kio/kioutil"
"sigs.k8s.io/kustomize/kyaml/yaml"
@@ -61,9 +60,6 @@ type RunFns struct {
// and only use explicit sources
NoFunctionsFromInput *bool
// EnableStarlark will enable functions run as starlark scripts
EnableStarlark bool
// EnableExec will enable exec functions
EnableExec bool
@@ -209,8 +205,6 @@ func (r RunFns) runFunctions(
identifier = filter.Image
case *exec.Filter:
identifier = filter.Path
case *starlark.Filter:
identifier = filter.String()
default:
identifier = "unknown-type function"
}
@@ -496,41 +490,6 @@ func (r *RunFns) ffp(spec runtimeutil.FunctionSpec, api *yaml.RNode, currentUser
cf.Exec.DeferFailure = spec.DeferFailure
return cf, nil
}
if r.EnableStarlark && (spec.Starlark.Path != "" || spec.Starlark.URL != "") {
// the script path is relative to the function config file
m, err := api.GetMeta()
if err != nil {
return nil, errors.Wrap(err)
}
var p string
if spec.Starlark.Path != "" {
pathAnno := m.Annotations[kioutil.PathAnnotation]
if pathAnno == "" {
pathAnno = m.Annotations[kioutil.LegacyPathAnnotation]
}
p = filepath.ToSlash(path.Clean(pathAnno))
spec.Starlark.Path = filepath.ToSlash(path.Clean(spec.Starlark.Path))
if filepath.IsAbs(spec.Starlark.Path) || path.IsAbs(spec.Starlark.Path) {
return nil, errors.Errorf(
"absolute function path %s not allowed", spec.Starlark.Path)
}
if strings.HasPrefix(spec.Starlark.Path, "..") {
return nil, errors.Errorf(
"function path %s not allowed to start with ../", spec.Starlark.Path)
}
p = filepath.ToSlash(filepath.Join(r.Path, filepath.Dir(p), spec.Starlark.Path))
}
sf := &starlark.Filter{Name: spec.Starlark.Name, Path: p, URL: spec.Starlark.URL}
sf.FunctionConfig = api
sf.GlobalScope = r.GlobalScope
sf.ResultsFile = resultsFile
sf.DeferFailure = spec.DeferFailure
return sf, nil
}
if r.EnableExec && spec.Exec.Path != "" {
ef := &exec.Filter{

View File

@@ -255,8 +255,6 @@ func TestRunFns_getFilters(t *testing.T) {
// value to set for NoFunctionsFromInput
noFunctionsFromInput *bool
enableStarlark bool
disableContainers bool
}{
// Test
@@ -589,92 +587,6 @@ metadata:
},
out: []string{"b", "a", "c"},
},
// Test
//
//
{name: "starlark-function",
in: []f{
{
path: filepath.Join("foo", "bar.yaml"),
value: `
apiVersion: example.com/v1alpha1
kind: ExampleFunction
metadata:
annotations:
config.kubernetes.io/function: |
starlark:
path: a/b/c
`,
},
},
enableStarlark: true,
outFn: func(path string) []string {
return []string{
fmt.Sprintf("name: path: %s/foo/a/b/c url: program:", filepath.ToSlash(path))}
},
},
// Test
//
//
{name: "starlark-function-absolute",
in: []f{
{
path: filepath.Join("foo", "bar.yaml"),
value: `
apiVersion: example.com/v1alpha1
kind: ExampleFunction
metadata:
annotations:
config.kubernetes.io/function: |
starlark:
path: /a/b/c
`,
},
},
enableStarlark: true,
error: "absolute function path /a/b/c not allowed",
},
// Test
//
//
{name: "starlark-function-escape-parent",
in: []f{
{
path: filepath.Join("foo", "bar.yaml"),
value: `
apiVersion: example.com/v1alpha1
kind: ExampleFunction
metadata:
annotations:
config.kubernetes.io/function: |
starlark:
path: ../a/b/c
`,
},
},
enableStarlark: true,
error: "function path ../a/b/c not allowed to start with ../",
},
{name: "starlark-function-disabled",
in: []f{
{
path: filepath.Join("foo", "bar.yaml"),
value: `
apiVersion: example.com/v1alpha1
kind: ExampleFunction
metadata:
annotations:
config.kubernetes.io/function: |
starlark:
path: a/b/c
`,
},
},
},
}
for i := range tests {
@@ -722,7 +634,6 @@ metadata:
// init the instance
r := &RunFns{
EnableStarlark: tt.enableStarlark,
DisableContainers: tt.disableContainers,
FunctionPaths: fnPaths,
Functions: parsedFns,