diff --git a/Gopkg.lock b/Gopkg.lock index eaf60c4..59012b9 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -847,7 +847,7 @@ version = "v0.1.2" [[projects]] - digest = "1:4b9e106ec4da06d6d5787a5d5ac1c2f08a38fc5aff287375b98b95dbd42e7181" + digest = "1:ddebdab9c149e675ed4b4a054ede657d228854bc7c95b33caa08c11c07863004" name = "sigs.k8s.io/controller-tools" packages = [ "cmd/controller-gen", @@ -859,7 +859,7 @@ "pkg/util", ] pruneopts = "T" - revision = "fe397b1c87ef4524abf55a7de80f223194146b5e" + revision = "41f36afa0662ee408687cfe70c13420ff2523b74" source = "https://github.com/ichekrygin/controller-tools.git" [[projects]] diff --git a/Gopkg.toml b/Gopkg.toml index 48ffe57..cb8c6b3 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -30,7 +30,7 @@ required = [ [[override]] name="sigs.k8s.io/controller-tools" source = "https://github.com/ichekrygin/controller-tools.git" - revision = "fe397b1c87ef4524abf55a7de80f223194146b5e" + revision = "41f36afa0662ee408687cfe70c13420ff2523b74" # For dependency below: Refer to issue https://github.com/golang/dep/issues/1799 [[override]] diff --git a/Jenkinsfile b/Jenkinsfile index 5405ff1..dfc7b0c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -58,7 +58,7 @@ pipeline { always { script { sh 'make -j\$(nproc) clean' - sh 'make -j$(nproc) prune PRUNE_HOURS=48 PRUNE_KEEP=48' + sh 'make -j\$(nproc) prune PRUNE_HOURS=48 PRUNE_KEEP=48' sh 'docker images' } } diff --git a/Makefile b/Makefile index e42ce89..c105d9b 100644 --- a/Makefile +++ b/Makefile @@ -53,4 +53,4 @@ include build/makelib/image.mk # Generate manifests e.g. CRD, RBAC etc. manifests: - go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd --output-dir cluster/charts/conductor/crds + go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd --output-dir cluster/charts/conductor/crds --nested diff --git a/pkg/test/envtest.go b/pkg/test/envtest.go index f27c73c..52dd62b 100644 --- a/pkg/test/envtest.go +++ b/pkg/test/envtest.go @@ -39,10 +39,11 @@ func NewTestEnv(namespace string, crds ...string) *TestEnv { UseExistingCluster: UseExistingCluster(), } if !t.UseExistingCluster { - if err := CheckCRDFiles(crds); err != nil { + if crds, err := CheckCRDFiles(crds); err != nil { log.Panic(err) + } else { + t.CRDDirectoryPaths = crds } - t.CRDDirectoryPaths = crds } if len(namespace) == 0 { namespace = "default" @@ -105,13 +106,46 @@ func UseExistingCluster() bool { } // CheckCRDFiles - validates that all crds files are found. -func CheckCRDFiles(crds []string) error { +func CheckCRDFiles(crds []string) ([]string, error) { + var rs []string + for _, path := range crds { - if _, err := os.Stat(path); os.IsNotExist(err) { - return err + _, err := os.Stat(path) + if os.IsNotExist(err) { + return nil, err } + files, err := Expand(path) + if err != nil { + return nil, err + } + rs = append(rs, files...) } - return nil + return rs, nil +} + +// Expand recursively and returns list of all sub-directories (if any) +func Expand(path string) ([]string, error) { + var rs []string + + fi, err := os.Stat(path) + if os.IsNotExist(err) { + return nil, err + } + if fi.Mode().IsDir() { + files, err := filepath.Glob(filepath.Join(path, "*")) + if err != nil { + return nil, err + } + for _, f := range files { + exp, err := Expand(f) + if err != nil { + return nil, err + } + rs = append(rs, exp...) + } + rs = append(rs, path) + } + return rs, nil } // CRDs path to project crds location