Skip to content

Commit

Permalink
fix: the CRD paths is only ../.. when is multigroup
Browse files Browse the repository at this point in the history
  • Loading branch information
Camila Macedo committed Sep 16, 2020
1 parent f27fc18 commit 02e2756
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type SuiteTest struct {
file.MultiGroupMixin
file.BoilerplateMixin
file.ResourceMixin

// Define the Path for the CRD when it is multigroup
CRDDirectoryPaths string
}

// SetTemplateDefaults implements file.Template
Expand All @@ -51,6 +54,15 @@ func (f *SuiteTest) SetTemplateDefaults() error {
file.NewMarkerFor(f.Path, addSchemeMarker),
)

// If is multigroup the path needs to be ../../ since it has
// the group dir.
f.CRDDirectoryPaths = `".."`
if f.MultiGroup {
f.CRDDirectoryPaths = `"..", ".."`
}



return nil
}

Expand Down Expand Up @@ -138,7 +150,7 @@ var _ = BeforeSuite(func(done Done) {
By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryPaths }}, "config", "crd", "bases")},
}
var err error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type SuiteTest struct {
file.MultiGroupMixin
file.BoilerplateMixin
file.ResourceMixin

// Define the Path for the CRD when it is multigroup
CRDDirectoryPaths string
}

// SetTemplateDefaults implements file.Template
Expand All @@ -51,6 +54,15 @@ func (f *SuiteTest) SetTemplateDefaults() error {
file.NewMarkerFor(f.Path, addSchemeMarker),
)

// If is multigroup the path needs to be ../../ since it has
// the group dir.
f.CRDDirectoryPaths = `".."`
if f.MultiGroup {
f.CRDDirectoryPaths = `"..", ".."`
}



return nil
}

Expand Down Expand Up @@ -138,7 +150,7 @@ var _ = BeforeSuite(func(done Done) {
By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryPaths }}, "config", "crd", "bases")},
}
var err error
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v2-addon/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = BeforeSuite(func(done Done) {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
}

var err error
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v2/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = BeforeSuite(func(done Done) {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
}

var err error
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v3-addon/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = BeforeSuite(func(done Done) {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
}

var err error
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v3/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = BeforeSuite(func(done Done) {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
}

var err error
Expand Down

0 comments on commit 02e2756

Please sign in to comment.