Skip to content

Commit

Permalink
feat(roboll#344): removed dict subhelm path
Browse files Browse the repository at this point in the history
  • Loading branch information
sgandon committed May 5, 2019
1 parent 4581e00 commit fec1dfb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 57 deletions.
29 changes: 15 additions & 14 deletions pkg/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package app

import (
"fmt"
"github.com/roboll/helmfile/helmexec"
"github.com/roboll/helmfile/state"
"gotest.tools/env"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"strings"
"testing"

"github.com/roboll/helmfile/helmexec"
"github.com/roboll/helmfile/state"
"gotest.tools/env"
)

type testFs struct {
Expand Down Expand Up @@ -329,13 +330,13 @@ func TestVisitDesiredStatesWithReleasesFiltered_EmbeddedSelectors(t *testing.T)
files := map[string]string{
"/path/to/helmfile.yaml": `
helmfiles:
- helmfile.d/a*.yaml:
selectors:
- name=prometheus
- name=zipkin
- path: helmfile.d/a*.yaml
selectors:
- name=prometheus
- name=zipkin
- helmfile.d/b*.yaml
- helmfile.d/c*.yaml:
selectors: {}
- path: helmfile.d/c*.yaml
selectors: {}
`,
"/path/to/helmfile.d/a1.yaml": `
releases:
Expand Down Expand Up @@ -462,17 +463,17 @@ func TestVisitDesiredStatesWithReleasesFiltered_InheritedSelectors_inherits(t *t
"/path/to/helmfile.yaml": `
helmfiles:
- helmfile.d/a*.yaml
- helmfile.d/a*.yaml:
selectors:
- select=foo
- path: helmfile.d/a*.yaml
selectors:
- select=foo
releases:
- name: mongodb
chart: stable/mongodb
`,
"/path/to/helmfile.d/a.yaml": `
helmfiles:
- b*.yaml:
selectors: inherits
- path: b*.yaml
selectors: inherits
releases:
- name: zipkin
chart: stable/zipkin
Expand Down
44 changes: 9 additions & 35 deletions state/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

. "gotest.tools/assert"
"gotest.tools/assert/cmp"
)

func TestReadFromYaml(t *testing.T) {
Expand Down Expand Up @@ -261,79 +262,52 @@ func TestReadFromYaml_Helmfiles_Selectors(t *testing.T) {
path: "working/selector",
content: []byte(`helmfiles:
- simple/helmfile.yaml
- simple/helmfile/with/semicolon.yaml:
- two/selectors.yaml:
selectors:
- name=foo
- name=bar
- empty/selector.yaml:
selectors: {}
- inherits/selector.yaml:
selectors: inherits
- path: path/prefix/selector.yaml
selectors:
- name=zorba
- foo=bar
- path: path/prefix/empty/selector.yaml
selectors: {}
- path: path/prefix/inherits/selector.yaml
selectors: inherits
`),
wantErr: false,
helmfiles: []SubHelmfileSpec{{Path: "simple/helmfile.yaml"},
{Path: "simple/helmfile/with/semicolon.yaml", Selectors: nil, Inherits: false},
{Path: "two/selectors.yaml", Selectors: []string{"name=foo", "name=bar"}, Inherits: false},
{Path: "empty/selector.yaml", Selectors: []string{}, Inherits: false},
{Path: "inherits/selector.yaml", Selectors: nil, Inherits: true},
{Path: "path/prefix/selector.yaml", Selectors: []string{"name=zorba"}, Inherits: false},
helmfiles: []SubHelmfileSpec{{Path: "simple/helmfile.yaml", Selectors: nil, Inherits: false},
{Path: "path/prefix/selector.yaml", Selectors: []string{"name=zorba", "foo=bar"}, Inherits: false},
{Path: "path/prefix/empty/selector.yaml", Selectors: []string{}, Inherits: false},
{Path: "path/prefix/inherits/selector.yaml", Selectors: nil, Inherits: true},
},
},
{
path: "failing1/selector",
content: []byte(`helmfiles:
- failing1/helmfile.yaml: foo
`),
wantErr: true,
},
{
path: "failing2/selector",
content: []byte(`helmfiles:
- failing2/helmfile.yaml:
- path: failing2/helmfile.yaml
wrongkey:
`),
wantErr: true,
},
{
path: "failing3/selector",
content: []byte(`helmfiles:
- failing3/helmfile.yaml:
- path: failing3/helmfile.yaml
selectors: foo
`),
wantErr: true,
},
{
path: "failing4/selector",
content: []byte(`helmfiles:
- failing4/helmfile.yaml:
- path: failing4/helmfile.yaml
selectors:
`),
wantErr: true,
},
{
path: "failing4/selector",
content: []byte(`helmfiles:
- failing4/helmfile.yaml:
- path: failing4/helmfile.yaml
selectors:
- colon: not-authorized
`),
wantErr: true,
},
{
path: "failing5/selector",
content: []byte(`helmfiles:
- selectors:
- colon: not-authorized
`),
wantErr: true,
},
Expand All @@ -355,6 +329,6 @@ func TestReadFromYaml_Helmfiles_Selectors(t *testing.T) {
t.Error("unexpected error:", err)
}
}
DeepEqual(t, st.Helmfiles, test.helmfiles)
Assert(t, cmp.DeepEqual(st.Helmfiles, test.helmfiles), "for path %v", test.path)
}
}
8 changes: 0 additions & 8 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1422,14 +1422,6 @@ func (hf *SubHelmfileSpec) UnmarshalYAML(unmarshal func(interface{}) error) erro
if err := extractSelectorContent(hf, v); err != nil {
return err
}
} else {
hf.Path = key
//get the selectors if something is specified
if v != nil { //we have a path, now compute the selector
if err := extractSelector(hf, v); err != nil {
return err
}
} //else it is a path with ending semi-colon without anything else below and it is fine
}
default:
return fmt.Errorf("Expecting a \"string\" scalar for the helmfile collection but got: %v", key)
Expand Down

0 comments on commit fec1dfb

Please sign in to comment.