Skip to content

Commit

Permalink
Merge pull request #1682 from camilamacedo86/fix-1673
Browse files Browse the repository at this point in the history
🐛 fix: the CRD paths is only ../.. when is multigroup
  • Loading branch information
k8s-ci-robot committed Sep 17, 2020
2 parents e40c883 + b54106b commit 39d833c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019 The Kubernetes Authors.
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,9 @@ type SuiteTest struct {
file.MultiGroupMixin
file.BoilerplateMixin
file.ResourceMixin

// CRDDirectoryRelativePath define the Path for the CRD when it is multigroup
CRDDirectoryRelativePath string
}

// SetTemplateDefaults implements file.Template
Expand All @@ -51,6 +54,13 @@ 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.CRDDirectoryRelativePath = `".."`
if f.MultiGroup {
f.CRDDirectoryRelativePath = `"..", ".."`
}

return nil
}

Expand Down Expand Up @@ -138,7 +148,7 @@ var _ = BeforeSuite(func(done Done) {
By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryRelativePath }}, "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

// CRDDirectoryRelativePath define the Path for the CRD when it is multigroup
CRDDirectoryRelativePath string
}

// SetTemplateDefaults implements file.Template
Expand All @@ -51,6 +54,13 @@ 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.CRDDirectoryRelativePath = `".."`
if f.MultiGroup {
f.CRDDirectoryRelativePath = `"..", ".."`
}

return nil
}

Expand Down Expand Up @@ -138,7 +148,7 @@ var _ = BeforeSuite(func(done Done) {
By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join({{ .CRDDirectoryRelativePath }}, "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 39d833c

Please sign in to comment.