Move controllers to internal/controller
Make the controller implementations private. Signed-off-by: Sunny <darkowlzz@protonmail.com>
This commit is contained in:
parent
eaa25b9a36
commit
e16d6ebde8
|
@ -40,7 +40,6 @@ RUN go mod download
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY main.go main.go
|
COPY main.go main.go
|
||||||
COPY controllers/ controllers/
|
|
||||||
COPY pkg/ pkg/
|
COPY pkg/ pkg/
|
||||||
COPY internal/ internal/
|
COPY internal/ internal/
|
||||||
|
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -82,7 +82,7 @@ test-ctrl: install-envtest test-api check-deps ## Run controller tests
|
||||||
GIT_CONFIG_GLOBAL=/dev/null \
|
GIT_CONFIG_GLOBAL=/dev/null \
|
||||||
go test $(GO_STATIC_FLAGS) \
|
go test $(GO_STATIC_FLAGS) \
|
||||||
-run "^$(GO_TEST_PREFIX).*" \
|
-run "^$(GO_TEST_PREFIX).*" \
|
||||||
-v ./controllers \
|
-v ./internal/controller \
|
||||||
-coverprofile cover.out
|
-coverprofile cover.out
|
||||||
|
|
||||||
check-deps:
|
check-deps:
|
||||||
|
|
|
@ -133,7 +133,7 @@ kubectl -n source-system wait bucket/podinfo --for=condition=ready --timeout=1m
|
||||||
|
|
||||||
echo "Run HelmChart from Bucket tests"
|
echo "Run HelmChart from Bucket tests"
|
||||||
"${BUILD_DIR}/mc" mb minio/charts
|
"${BUILD_DIR}/mc" mb minio/charts
|
||||||
"${BUILD_DIR}/mc" mirror "${ROOT_DIR}/controllers/testdata/charts/helmchart/" minio/charts/helmchart
|
"${BUILD_DIR}/mc" mirror "${ROOT_DIR}/internal/controller/testdata/charts/helmchart/" minio/charts/helmchart
|
||||||
|
|
||||||
kubectl -n source-system apply -f "${ROOT_DIR}/config/testdata/helmchart-from-bucket/source.yaml"
|
kubectl -n source-system apply -f "${ROOT_DIR}/config/testdata/helmchart-from-bucket/source.yaml"
|
||||||
kubectl -n source-system wait bucket/charts --for=condition=ready --timeout=1m
|
kubectl -n source-system wait bucket/charts --for=condition=ready --timeout=1m
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
import sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -17,7 +17,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sigs.k8s.io/controller-runtime/pkg/event"
|
"sigs.k8s.io/controller-runtime/pkg/event"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
|
@ -39,7 +39,7 @@ import (
|
||||||
"github.com/fluxcd/pkg/sourceignore"
|
"github.com/fluxcd/pkg/sourceignore"
|
||||||
"github.com/fluxcd/pkg/untar"
|
"github.com/fluxcd/pkg/untar"
|
||||||
|
|
||||||
"github.com/fluxcd/source-controller/api/v1"
|
v1 "github.com/fluxcd/source-controller/api/v1"
|
||||||
intdigest "github.com/fluxcd/source-controller/internal/digest"
|
intdigest "github.com/fluxcd/source-controller/internal/digest"
|
||||||
sourcefs "github.com/fluxcd/source-controller/internal/fs"
|
sourcefs "github.com/fluxcd/source-controller/internal/fs"
|
||||||
)
|
)
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package controllers
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -207,7 +207,7 @@ func TestMain(m *testing.M) {
|
||||||
utilruntime.Must(sourcev1.AddToScheme(scheme.Scheme))
|
utilruntime.Must(sourcev1.AddToScheme(scheme.Scheme))
|
||||||
utilruntime.Must(sourcev1beta2.AddToScheme(scheme.Scheme))
|
utilruntime.Must(sourcev1beta2.AddToScheme(scheme.Scheme))
|
||||||
|
|
||||||
testEnv = testenv.New(testenv.WithCRDPath(filepath.Join("..", "config", "crd", "bases")))
|
testEnv = testenv.New(testenv.WithCRDPath(filepath.Join("..", "..", "config", "crd", "bases")))
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
testServer, err = testserver.NewTempArtifactServer()
|
testServer, err = testserver.NewTempArtifactServer()
|
32
main.go
32
main.go
|
@ -47,13 +47,13 @@ import (
|
||||||
"github.com/fluxcd/pkg/runtime/pprof"
|
"github.com/fluxcd/pkg/runtime/pprof"
|
||||||
"github.com/fluxcd/pkg/runtime/probes"
|
"github.com/fluxcd/pkg/runtime/probes"
|
||||||
|
|
||||||
"github.com/fluxcd/source-controller/api/v1"
|
v1 "github.com/fluxcd/source-controller/api/v1"
|
||||||
"github.com/fluxcd/source-controller/api/v1beta2"
|
"github.com/fluxcd/source-controller/api/v1beta2"
|
||||||
|
|
||||||
// +kubebuilder:scaffold:imports
|
// +kubebuilder:scaffold:imports
|
||||||
|
|
||||||
"github.com/fluxcd/source-controller/controllers"
|
|
||||||
"github.com/fluxcd/source-controller/internal/cache"
|
"github.com/fluxcd/source-controller/internal/cache"
|
||||||
|
"github.com/fluxcd/source-controller/internal/controller"
|
||||||
intdigest "github.com/fluxcd/source-controller/internal/digest"
|
intdigest "github.com/fluxcd/source-controller/internal/digest"
|
||||||
"github.com/fluxcd/source-controller/internal/features"
|
"github.com/fluxcd/source-controller/internal/features"
|
||||||
"github.com/fluxcd/source-controller/internal/helm"
|
"github.com/fluxcd/source-controller/internal/helm"
|
||||||
|
@ -178,13 +178,13 @@ func main() {
|
||||||
mustSetupHelmLimits(helmIndexLimit, helmChartLimit, helmChartFileLimit)
|
mustSetupHelmLimits(helmIndexLimit, helmChartLimit, helmChartFileLimit)
|
||||||
helmIndexCache, helmIndexCacheItemTTL := mustInitHelmCache(helmCacheMaxSize, helmCacheTTL, helmCachePurgeInterval)
|
helmIndexCache, helmIndexCacheItemTTL := mustInitHelmCache(helmCacheMaxSize, helmCacheTTL, helmCachePurgeInterval)
|
||||||
|
|
||||||
if err := (&controllers.GitRepositoryReconciler{
|
if err := (&controller.GitRepositoryReconciler{
|
||||||
Client: mgr.GetClient(),
|
Client: mgr.GetClient(),
|
||||||
EventRecorder: eventRecorder,
|
EventRecorder: eventRecorder,
|
||||||
Metrics: metrics,
|
Metrics: metrics,
|
||||||
Storage: storage,
|
Storage: storage,
|
||||||
ControllerName: controllerName,
|
ControllerName: controllerName,
|
||||||
}).SetupWithManagerAndOptions(mgr, controllers.GitRepositoryReconcilerOptions{
|
}).SetupWithManagerAndOptions(mgr, controller.GitRepositoryReconcilerOptions{
|
||||||
MaxConcurrentReconciles: concurrent,
|
MaxConcurrentReconciles: concurrent,
|
||||||
DependencyRequeueInterval: requeueDependency,
|
DependencyRequeueInterval: requeueDependency,
|
||||||
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
||||||
|
@ -193,14 +193,14 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := (&controllers.HelmRepositoryOCIReconciler{
|
if err := (&controller.HelmRepositoryOCIReconciler{
|
||||||
Client: mgr.GetClient(),
|
Client: mgr.GetClient(),
|
||||||
EventRecorder: eventRecorder,
|
EventRecorder: eventRecorder,
|
||||||
Metrics: metrics,
|
Metrics: metrics,
|
||||||
Getters: getters,
|
Getters: getters,
|
||||||
ControllerName: controllerName,
|
ControllerName: controllerName,
|
||||||
RegistryClientGenerator: registry.ClientGenerator,
|
RegistryClientGenerator: registry.ClientGenerator,
|
||||||
}).SetupWithManagerAndOptions(mgr, controllers.HelmRepositoryReconcilerOptions{
|
}).SetupWithManagerAndOptions(mgr, controller.HelmRepositoryReconcilerOptions{
|
||||||
MaxConcurrentReconciles: concurrent,
|
MaxConcurrentReconciles: concurrent,
|
||||||
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
@ -208,7 +208,7 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := (&controllers.HelmRepositoryReconciler{
|
if err := (&controller.HelmRepositoryReconciler{
|
||||||
Client: mgr.GetClient(),
|
Client: mgr.GetClient(),
|
||||||
EventRecorder: eventRecorder,
|
EventRecorder: eventRecorder,
|
||||||
Metrics: metrics,
|
Metrics: metrics,
|
||||||
|
@ -218,7 +218,7 @@ func main() {
|
||||||
Cache: helmIndexCache,
|
Cache: helmIndexCache,
|
||||||
TTL: helmIndexCacheItemTTL,
|
TTL: helmIndexCacheItemTTL,
|
||||||
CacheRecorder: cacheRecorder,
|
CacheRecorder: cacheRecorder,
|
||||||
}).SetupWithManagerAndOptions(mgr, controllers.HelmRepositoryReconcilerOptions{
|
}).SetupWithManagerAndOptions(mgr, controller.HelmRepositoryReconcilerOptions{
|
||||||
MaxConcurrentReconciles: concurrent,
|
MaxConcurrentReconciles: concurrent,
|
||||||
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
@ -226,7 +226,7 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := (&controllers.HelmChartReconciler{
|
if err := (&controller.HelmChartReconciler{
|
||||||
Client: mgr.GetClient(),
|
Client: mgr.GetClient(),
|
||||||
RegistryClientGenerator: registry.ClientGenerator,
|
RegistryClientGenerator: registry.ClientGenerator,
|
||||||
Storage: storage,
|
Storage: storage,
|
||||||
|
@ -237,7 +237,7 @@ func main() {
|
||||||
Cache: helmIndexCache,
|
Cache: helmIndexCache,
|
||||||
TTL: helmIndexCacheItemTTL,
|
TTL: helmIndexCacheItemTTL,
|
||||||
CacheRecorder: cacheRecorder,
|
CacheRecorder: cacheRecorder,
|
||||||
}).SetupWithManagerAndOptions(mgr, controllers.HelmChartReconcilerOptions{
|
}).SetupWithManagerAndOptions(mgr, controller.HelmChartReconcilerOptions{
|
||||||
MaxConcurrentReconciles: concurrent,
|
MaxConcurrentReconciles: concurrent,
|
||||||
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
@ -245,13 +245,13 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := (&controllers.BucketReconciler{
|
if err := (&controller.BucketReconciler{
|
||||||
Client: mgr.GetClient(),
|
Client: mgr.GetClient(),
|
||||||
EventRecorder: eventRecorder,
|
EventRecorder: eventRecorder,
|
||||||
Metrics: metrics,
|
Metrics: metrics,
|
||||||
Storage: storage,
|
Storage: storage,
|
||||||
ControllerName: controllerName,
|
ControllerName: controllerName,
|
||||||
}).SetupWithManagerAndOptions(mgr, controllers.BucketReconcilerOptions{
|
}).SetupWithManagerAndOptions(mgr, controller.BucketReconcilerOptions{
|
||||||
MaxConcurrentReconciles: concurrent,
|
MaxConcurrentReconciles: concurrent,
|
||||||
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
@ -259,13 +259,13 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := (&controllers.OCIRepositoryReconciler{
|
if err := (&controller.OCIRepositoryReconciler{
|
||||||
Client: mgr.GetClient(),
|
Client: mgr.GetClient(),
|
||||||
Storage: storage,
|
Storage: storage,
|
||||||
EventRecorder: eventRecorder,
|
EventRecorder: eventRecorder,
|
||||||
ControllerName: controllerName,
|
ControllerName: controllerName,
|
||||||
Metrics: metrics,
|
Metrics: metrics,
|
||||||
}).SetupWithManagerAndOptions(mgr, controllers.OCIRepositoryReconcilerOptions{
|
}).SetupWithManagerAndOptions(mgr, controller.OCIRepositoryReconcilerOptions{
|
||||||
MaxConcurrentReconciles: concurrent,
|
MaxConcurrentReconciles: concurrent,
|
||||||
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
@ -400,7 +400,7 @@ func mustInitHelmCache(maxSize int, purgeInterval, itemTTL string) (*cache.Cache
|
||||||
return cache.New(maxSize, interval), ttl
|
return cache.New(maxSize, interval), ttl
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustInitStorage(path string, storageAdvAddr string, artifactRetentionTTL time.Duration, artifactRetentionRecords int, artifactDigestAlgo string) *controllers.Storage {
|
func mustInitStorage(path string, storageAdvAddr string, artifactRetentionTTL time.Duration, artifactRetentionRecords int, artifactDigestAlgo string) *controller.Storage {
|
||||||
if storageAdvAddr == "" {
|
if storageAdvAddr == "" {
|
||||||
storageAdvAddr = determineAdvStorageAddr(storageAdvAddr)
|
storageAdvAddr = determineAdvStorageAddr(storageAdvAddr)
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,7 @@ func mustInitStorage(path string, storageAdvAddr string, artifactRetentionTTL ti
|
||||||
intdigest.Canonical = algo
|
intdigest.Canonical = algo
|
||||||
}
|
}
|
||||||
|
|
||||||
storage, err := controllers.NewStorage(path, storageAdvAddr, artifactRetentionTTL, artifactRetentionRecords)
|
storage, err := controller.NewStorage(path, storageAdvAddr, artifactRetentionTTL, artifactRetentionRecords)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
setupLog.Error(err, "unable to initialise storage")
|
setupLog.Error(err, "unable to initialise storage")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
@ -21,5 +21,5 @@ set -euxo pipefail
|
||||||
|
|
||||||
# Some tests requires embedded resources. Embedding does not allow
|
# Some tests requires embedded resources. Embedding does not allow
|
||||||
# for traversing into ascending dirs, therefore we copy those contents here:
|
# for traversing into ascending dirs, therefore we copy those contents here:
|
||||||
mkdir -p controllers/testdata/crd
|
mkdir -p internal/controller/testdata/crd
|
||||||
cp config/crd/bases/*.yaml controllers/testdata/crd/
|
cp config/crd/bases/*.yaml internal/controller/testdata/crd/
|
||||||
|
|
Loading…
Reference in New Issue