Skip to content

Commit

Permalink
Remove "validations" experimental flag
Browse files Browse the repository at this point in the history
Signed-off-by: John Ryan <[email protected]>
  • Loading branch information
vmunishwar authored and jtigger committed Sep 15, 2022
1 parent 1c80040 commit f5ffa14
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 32 deletions.
5 changes: 1 addition & 4 deletions pkg/cmd/template/data_values_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)")
}

Expand Down
9 changes: 0 additions & 9 deletions pkg/experiments/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 0 additions & 5 deletions pkg/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions pkg/workspace/library_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
17 changes: 7 additions & 10 deletions pkg/yttlibrary/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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",
Expand Down

0 comments on commit f5ffa14

Please sign in to comment.