Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: corrected the tranform validation logic #73

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion workflow/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ type FilterOperationsOptions struct {
Exclude *bool `yaml:"exclude,omitempty"`
}

var transformList = []string{"removeUnused", "filterOperations", "cleanup", "format", "normalize"}

func (t Transformation) Validate() error {
numNil := 0
if t.RemoveUnused != nil {
Expand All @@ -326,8 +328,14 @@ func (t Transformation) Validate() error {
if t.Cleanup != nil {
numNil++
}
if t.Format != nil {
numNil++
}
if t.Normalize != nil {
numNil++
}
if numNil != 1 {
return fmt.Errorf("transformation must have exactly one of removeUnused, filterOperations, or cleanup")
return fmt.Errorf("transformation must have exactly one of %s", strings.Join(transformList, ", "))
}

if t.FilterOperations != nil {
Expand Down
2 changes: 1 addition & 1 deletion workflow/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func TestSource_Validate(t *testing.T) {
},
},
},
wantErr: fmt.Errorf("failed to validate transformation 0: transformation must have exactly one of removeUnused, filterOperations, or cleanup"),
wantErr: fmt.Errorf("failed to validate transformation 0: transformation must have exactly one of removeUnused, filterOperations, cleanup, format, normalize"),
},
{
name: "transformations filter success",
Expand Down
Loading