Skip to content

Commit

Permalink
Merge branch 'main' into renovate/maru-support-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Racer159 authored Sep 20, 2024
2 parents e1ba440 + d4fa708 commit b301755
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21.8
require (
github.com/defenseunicorns/pkg/exec v0.0.1
github.com/defenseunicorns/pkg/helpers/v2 v2.0.1
github.com/goccy/go-yaml v1.11.3
github.com/goccy/go-yaml v1.12.0
github.com/invopop/jsonschema v0.12.0
github.com/pterm/pterm v0.12.79
github.com/spf13/cobra v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.18.0 h1:BvolUXjp4zuvkZ5YN5t7ebzbhlUtPsPm2S9NAZ5nl9U=
github.com/go-playground/validator/v10 v10.18.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/goccy/go-yaml v1.11.3 h1:B3W9IdWbvrUu2OYQGwvU1nZtvMQJPBKgBUuweJjLj6I=
github.com/goccy/go-yaml v1.11.3/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU=
github.com/goccy/go-yaml v1.12.0 h1:/1WHjnMsI1dlIBQutrvSMGZRQufVO3asrHfTwfACoPM=
github.com/goccy/go-yaml v1.12.0/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/gookit/color v1.4.2/go.mod h1:fqRyamkC1W8uxl+lxCQxOT09l/vYfZ+QeiX3rKQHCoQ=
Expand Down
1 change: 1 addition & 0 deletions src/pkg/variables/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (vc *VariableConfig[T]) PopulateVariables(variables []InteractiveVariable[T

// Variable is present, no need to continue checking
if present {
vc.setVariableMap[variable.Name].Pattern = variable.Pattern
vc.setVariableMap[variable.Name].Extra = variable.Extra
if err := vc.CheckVariablePattern(variable.Name); err != nil {
return err
Expand Down
16 changes: 16 additions & 0 deletions src/test/e2e/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,20 @@ func TestTaskRunner(t *testing.T) {
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "\"input val2 equals 5 and variable VAL1 equals 5\"")
})

t.Run("run successful pattern", func(t *testing.T) {
t.Parallel()

stdOut, stdErr, err := e2e.Maru("run", "--file", "src/test/tasks/more-tasks/pattern.yaml", "--set", "HELLO=HELLO")
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "HELLO")
})

t.Run("run unsuccessful pattern", func(t *testing.T) {
t.Parallel()

stdOut, stdErr, err := e2e.Maru("run", "--file", "src/test/tasks/more-tasks/pattern.yaml", "--set", "HELLO=HI")
require.Error(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "\"HELLO\" does not match pattern \"^HELLO$\"")
})
}
8 changes: 8 additions & 0 deletions src/test/tasks/more-tasks/pattern.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
variables:
- name: HELLO
pattern: ^HELLO$

tasks:
- name: default
actions:
- cmd: echo ${HELLO}

0 comments on commit b301755

Please sign in to comment.