From c62e9f289c481c51ff33a10c3207197222baf2f6 Mon Sep 17 00:00:00 2001 From: Sanskar Jaiswal Date: Mon, 27 Mar 2023 22:32:58 +0530 Subject: [PATCH] move `controllers` to `internal/controllers` Signed-off-by: Sanskar Jaiswal --- .gitignore | 5 ++++- Dockerfile | 1 - Makefile | 2 +- .../controllers}/controllers_fuzzer_test.go | 0 .../controllers}/imageupdateautomation_controller.go | 0 .../imageupdateautomation_controller_test.go | 0 {controllers => internal/controllers}/suite_test.go | 2 +- .../testdata/appconfig-expected/deploy.yaml | 0 .../testdata/appconfig-expected2/deploy.yaml | 0 .../testdata/appconfig-setters-expected/deploy.yaml | 0 .../controllers}/testdata/appconfig/deploy.yaml | 0 .../controllers}/testdata/brokenlink/bar.yaml | 0 .../controllers}/testdata/pathconfig/no/deploy.yaml | 0 .../controllers}/testdata/pathconfig/yes/deploy.yaml | 0 {controllers => internal/controllers}/update_test.go | 0 main.go | 2 +- tests/fuzz/oss_fuzz_prebuild.sh | 12 ++++++------ 17 files changed, 13 insertions(+), 11 deletions(-) rename {controllers => internal/controllers}/controllers_fuzzer_test.go (100%) rename {controllers => internal/controllers}/imageupdateautomation_controller.go (100%) rename {controllers => internal/controllers}/imageupdateautomation_controller_test.go (100%) rename {controllers => internal/controllers}/suite_test.go (98%) rename {controllers => internal/controllers}/testdata/appconfig-expected/deploy.yaml (100%) rename {controllers => internal/controllers}/testdata/appconfig-expected2/deploy.yaml (100%) rename {controllers => internal/controllers}/testdata/appconfig-setters-expected/deploy.yaml (100%) rename {controllers => internal/controllers}/testdata/appconfig/deploy.yaml (100%) rename {controllers => internal/controllers}/testdata/brokenlink/bar.yaml (100%) rename {controllers => internal/controllers}/testdata/pathconfig/no/deploy.yaml (100%) rename {controllers => internal/controllers}/testdata/pathconfig/yes/deploy.yaml (100%) rename {controllers => internal/controllers}/update_test.go (100%) diff --git a/.gitignore b/.gitignore index 22079dbf..434bdc57 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ notes # Thes are downloaded in the Makefile cache/* -controllers/testdata/crds/* +internal/controllers/testdata/crds/* # Binaries for programs and plugins *.exe @@ -31,3 +31,6 @@ testbin # Exclude all build related files build/ + +# CRDs for fuzzing tests. +internal/controllers/testdata/crd diff --git a/Dockerfile b/Dockerfile index 815ea65c..79e93bc5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,7 +40,6 @@ RUN go mod download # Copy source code COPY main.go main.go -COPY controllers/ controllers/ COPY pkg/ pkg/ COPY internal/ internal/ diff --git a/Makefile b/Makefile index 4e543c58..8fb2d056 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ ifeq ($(shell uname -s),Darwin) ENVTEST_ARCH=amd64 endif -TEST_CRDS := controllers/testdata/crds +TEST_CRDS := internal/controllers/testdata/crds # Log level for `make run` LOG_LEVEL ?= info diff --git a/controllers/controllers_fuzzer_test.go b/internal/controllers/controllers_fuzzer_test.go similarity index 100% rename from controllers/controllers_fuzzer_test.go rename to internal/controllers/controllers_fuzzer_test.go diff --git a/controllers/imageupdateautomation_controller.go b/internal/controllers/imageupdateautomation_controller.go similarity index 100% rename from controllers/imageupdateautomation_controller.go rename to internal/controllers/imageupdateautomation_controller.go diff --git a/controllers/imageupdateautomation_controller_test.go b/internal/controllers/imageupdateautomation_controller_test.go similarity index 100% rename from controllers/imageupdateautomation_controller_test.go rename to internal/controllers/imageupdateautomation_controller_test.go diff --git a/controllers/suite_test.go b/internal/controllers/suite_test.go similarity index 98% rename from controllers/suite_test.go rename to internal/controllers/suite_test.go index 5381c81d..92037e0d 100644 --- a/controllers/suite_test.go +++ b/internal/controllers/suite_test.go @@ -67,7 +67,7 @@ func TestMain(m *testing.M) { func runTestsWithFeatures(m *testing.M, feats map[string]bool) int { testEnv = testenv.New(testenv.WithCRDPath( - filepath.Join("..", "config", "crd", "bases"), + filepath.Join("..", "..", "config", "crd", "bases"), filepath.Join("testdata", "crds"), )) diff --git a/controllers/testdata/appconfig-expected/deploy.yaml b/internal/controllers/testdata/appconfig-expected/deploy.yaml similarity index 100% rename from controllers/testdata/appconfig-expected/deploy.yaml rename to internal/controllers/testdata/appconfig-expected/deploy.yaml diff --git a/controllers/testdata/appconfig-expected2/deploy.yaml b/internal/controllers/testdata/appconfig-expected2/deploy.yaml similarity index 100% rename from controllers/testdata/appconfig-expected2/deploy.yaml rename to internal/controllers/testdata/appconfig-expected2/deploy.yaml diff --git a/controllers/testdata/appconfig-setters-expected/deploy.yaml b/internal/controllers/testdata/appconfig-setters-expected/deploy.yaml similarity index 100% rename from controllers/testdata/appconfig-setters-expected/deploy.yaml rename to internal/controllers/testdata/appconfig-setters-expected/deploy.yaml diff --git a/controllers/testdata/appconfig/deploy.yaml b/internal/controllers/testdata/appconfig/deploy.yaml similarity index 100% rename from controllers/testdata/appconfig/deploy.yaml rename to internal/controllers/testdata/appconfig/deploy.yaml diff --git a/controllers/testdata/brokenlink/bar.yaml b/internal/controllers/testdata/brokenlink/bar.yaml similarity index 100% rename from controllers/testdata/brokenlink/bar.yaml rename to internal/controllers/testdata/brokenlink/bar.yaml diff --git a/controllers/testdata/pathconfig/no/deploy.yaml b/internal/controllers/testdata/pathconfig/no/deploy.yaml similarity index 100% rename from controllers/testdata/pathconfig/no/deploy.yaml rename to internal/controllers/testdata/pathconfig/no/deploy.yaml diff --git a/controllers/testdata/pathconfig/yes/deploy.yaml b/internal/controllers/testdata/pathconfig/yes/deploy.yaml similarity index 100% rename from controllers/testdata/pathconfig/yes/deploy.yaml rename to internal/controllers/testdata/pathconfig/yes/deploy.yaml diff --git a/controllers/update_test.go b/internal/controllers/update_test.go similarity index 100% rename from controllers/update_test.go rename to internal/controllers/update_test.go diff --git a/main.go b/main.go index 9d0f2c32..8932c2d1 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,7 @@ import ( "github.com/fluxcd/pkg/git" // +kubebuilder:scaffold:imports - "github.com/fluxcd/image-automation-controller/controllers" + "github.com/fluxcd/image-automation-controller/internal/controllers" ) const ( diff --git a/tests/fuzz/oss_fuzz_prebuild.sh b/tests/fuzz/oss_fuzz_prebuild.sh index 28663494..a9d7418d 100755 --- a/tests/fuzz/oss_fuzz_prebuild.sh +++ b/tests/fuzz/oss_fuzz_prebuild.sh @@ -21,8 +21,8 @@ set -euxo pipefail # Some tests requires embedded resources. Embedding does not allow # for traversing into ascending dirs, therefore we copy those contents here: -mkdir -p controllers/testdata/crd -cp config/crd/bases/*.yaml controllers/testdata/crd +mkdir -p internal/controllers/testdata/crd +cp config/crd/bases/*.yaml internal/controllers/testdata/crd # Version of the source-controller from which to get the GitRepository CRD. # Pulls source-controller/api's version set in go.mod. @@ -32,10 +32,10 @@ SOURCE_VER=$(go list -m github.com/fluxcd/source-controller/api | awk '{print $2 # Pulls image-reflector-controller/api's version set in go.mod. REFLECTOR_VER=$(go list -m github.com/fluxcd/image-reflector-controller/api | awk '{print $2}') -if [ -d "../../controllers/testdata/crds" ]; then - cp ../../controllers/testdata/crds/*.yaml testdata/crds +if [ -d "../../internal/controllers/testdata/crds" ]; then + cp ../../internal/controllers/testdata/crds/*.yaml testdata/crds else # Fetch the CRDs if not present since we need them when running fuzz tests on CI. - curl -s --fail https://raw.githubusercontent.com/fluxcd/source-controller/${SOURCE_VER}/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml -o controllers/testdata/crd/gitrepositories.yaml - curl -s --fail https://raw.githubusercontent.com/fluxcd/image-reflector-controller/${REFLECTOR_VER}/config/crd/bases/image.toolkit.fluxcd.io_imagepolicies.yaml -o controllers/testdata/crd/imagepolicies.yaml + curl -s --fail https://raw.githubusercontent.com/fluxcd/source-controller/${SOURCE_VER}/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml -o internal/controllers/testdata/crd/gitrepositories.yaml + curl -s --fail https://raw.githubusercontent.com/fluxcd/image-reflector-controller/${REFLECTOR_VER}/config/crd/bases/image.toolkit.fluxcd.io_imagepolicies.yaml -o internal/controllers/testdata/crd/imagepolicies.yaml fi