From f5ffa14f39246b62b56afaf50bd064b4ed6b96cf Mon Sep 17 00:00:00 2001 From: Varsha Munishwar Date: Thu, 15 Sep 2022 11:19:49 -0700 Subject: [PATCH] Remove "validations" experimental flag Signed-off-by: John Ryan --- pkg/cmd/template/data_values_flags.go | 5 +---- pkg/experiments/flags.go | 9 --------- pkg/schema/schema.go | 5 ----- pkg/workspace/library_execution.go | 4 ---- pkg/yttlibrary/assert.go | 17 +++++++---------- 5 files changed, 8 insertions(+), 32 deletions(-) diff --git a/pkg/cmd/template/data_values_flags.go b/pkg/cmd/template/data_values_flags.go index 23246fb8..dbafbe67 100644 --- a/pkg/cmd/template/data_values_flags.go +++ b/pkg/cmd/template/data_values_flags.go @@ -9,7 +9,6 @@ import ( "strings" "github.com/k14s/starlark-go/starlark" - "github.com/vmware-tanzu/carvel-ytt/pkg/experiments" "github.com/vmware-tanzu/carvel-ytt/pkg/filepos" "github.com/vmware-tanzu/carvel-ytt/pkg/files" "github.com/vmware-tanzu/carvel-ytt/pkg/template" @@ -57,9 +56,7 @@ func (s *DataValuesFlags) Set(cmdFlags CmdFlags) { cmdFlags.StringArrayVar(&s.FromFiles, "data-values-file", nil, "Set multiple data values via plain YAML files (format: [@lib1:]{file path, HTTP URL, or '-' (i.e. stdin)}) (can be specified multiple times)") cmdFlags.BoolVar(&s.Inspect, "data-values-inspect", false, "Determine the final data values (applying any overlays) and display that result") - if experiments.IsValidationsEnabled() { - cmdFlags.BoolVar(&s.SkipValidation, "dangerous-data-values-disable-validation", false, "Skip validating data values (not recommended: may result in templates failing or invalid output)") - } + cmdFlags.BoolVar(&s.SkipValidation, "dangerous-data-values-disable-validation", false, "Skip validating data values (not recommended: may result in templates failing or invalid output)") cmdFlags.BoolVar(&s.InspectSchema, "data-values-schema-inspect", false, "Determine the complete schema for data values (applying any overlays) and display the result (only OpenAPI v3.0 is supported, see --output)") } diff --git a/pkg/experiments/flags.go b/pkg/experiments/flags.go index bf7d3e41..7bcbf37d 100644 --- a/pkg/experiments/flags.go +++ b/pkg/experiments/flags.go @@ -28,20 +28,11 @@ Registering a New Experiment // Env is the OS environment variable with comma-separated names of experiments to enable. const Env = "YTTEXPERIMENTS" -// IsValidationsEnabled reports whether the "validations" experiment was enabled by the user (via the Env). -func IsValidationsEnabled() bool { - return isSet("validations") -} - // GetEnabled reports the name of all enabled experiments. // // An experiment is enabled by including its name in the OS environment variable named Env. func GetEnabled() []string { experiments := []string{} - if IsValidationsEnabled() { - experiments = append(experiments, "validations") - } - return experiments } diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go index 4faa70f3..8d79f453 100644 --- a/pkg/schema/schema.go +++ b/pkg/schema/schema.go @@ -6,7 +6,6 @@ package schema import ( "fmt" - "github.com/vmware-tanzu/carvel-ytt/pkg/experiments" "github.com/vmware-tanzu/carvel-ytt/pkg/filepos" "github.com/vmware-tanzu/carvel-ytt/pkg/validations" "github.com/vmware-tanzu/carvel-ytt/pkg/yamlmeta" @@ -160,10 +159,6 @@ func getValue(node yamlmeta.Node, t Type) (interface{}, error) { } func getValidation(node yamlmeta.Node) (*validations.NodeValidation, error) { - if !experiments.IsValidationsEnabled() { - return nil, nil - } - validationAnn, err := processValidationAnnotation(node) if err != nil { return nil, err diff --git a/pkg/workspace/library_execution.go b/pkg/workspace/library_execution.go index 1d540a6e..5758f317 100644 --- a/pkg/workspace/library_execution.go +++ b/pkg/workspace/library_execution.go @@ -10,7 +10,6 @@ import ( "github.com/k14s/starlark-go/starlark" "github.com/vmware-tanzu/carvel-ytt/pkg/cmd/ui" - "github.com/vmware-tanzu/carvel-ytt/pkg/experiments" "github.com/vmware-tanzu/carvel-ytt/pkg/files" "github.com/vmware-tanzu/carvel-ytt/pkg/template" "github.com/vmware-tanzu/carvel-ytt/pkg/validations" @@ -117,9 +116,6 @@ func (ll *LibraryExecution) Values(valuesOverlays []*datavalues.Envelope, schema // Returns an error if the arguments to an @assert/validate are invalid, // otherwise, checks the Check for violations, and returns nil if there are no violations. func (ll *LibraryExecution) validateValues(values *datavalues.Envelope) error { - if !experiments.IsValidationsEnabled() { - return nil - } err := validations.ProcessAssertValidateAnns(values.Doc) if err != nil { return err diff --git a/pkg/yttlibrary/assert.go b/pkg/yttlibrary/assert.go index 6b9cdadb..598b26bd 100644 --- a/pkg/yttlibrary/assert.go +++ b/pkg/yttlibrary/assert.go @@ -9,7 +9,6 @@ import ( "github.com/k14s/starlark-go/starlark" "github.com/k14s/starlark-go/starlarkstruct" "github.com/k14s/starlark-go/syntax" - "github.com/vmware-tanzu/carvel-ytt/pkg/experiments" "github.com/vmware-tanzu/carvel-ytt/pkg/orderedmap" "github.com/vmware-tanzu/carvel-ytt/pkg/template/core" ) @@ -28,15 +27,13 @@ func (m AssertModule) AsModule() starlark.StringDict { members["equals"] = starlark.NewBuiltin("assert.equals", core.ErrWrapper(m.Equals)) members["fail"] = starlark.NewBuiltin("assert.fail", core.ErrWrapper(m.Fail)) members["try_to"] = starlark.NewBuiltin("assert.try_to", core.ErrWrapper(m.TryTo)) - if experiments.IsValidationsEnabled() { - members["min"] = starlark.NewBuiltin("assert.min", core.ErrWrapper(m.Min)) - members["min_len"] = starlark.NewBuiltin("assert.min_len", core.ErrWrapper(m.MinLen)) - members["max"] = starlark.NewBuiltin("assert.max", core.ErrWrapper(m.Max)) - members["max_len"] = starlark.NewBuiltin("assert.max_len", core.ErrWrapper(m.MaxLen)) - members["not_null"] = starlark.NewBuiltin("assert.not_null", core.ErrWrapper(m.NotNull)) - members["one_not_null"] = starlark.NewBuiltin("assert.one_not_null", core.ErrWrapper(m.OneNotNull)) - members["one_of"] = starlark.NewBuiltin("assert.one_of", core.ErrWrapper(m.OneOf)) - } + members["min"] = starlark.NewBuiltin("assert.min", core.ErrWrapper(m.Min)) + members["min_len"] = starlark.NewBuiltin("assert.min_len", core.ErrWrapper(m.MinLen)) + members["max"] = starlark.NewBuiltin("assert.max", core.ErrWrapper(m.Max)) + members["max_len"] = starlark.NewBuiltin("assert.max_len", core.ErrWrapper(m.MaxLen)) + members["not_null"] = starlark.NewBuiltin("assert.not_null", core.ErrWrapper(m.NotNull)) + members["one_not_null"] = starlark.NewBuiltin("assert.one_not_null", core.ErrWrapper(m.OneNotNull)) + members["one_of"] = starlark.NewBuiltin("assert.one_of", core.ErrWrapper(m.OneOf)) return starlark.StringDict{ "assert": &starlarkstruct.Module{ Name: "assert",