From 6c7a8f86e2bb9c55f5c5562c5d38c73b2e2fc49b Mon Sep 17 00:00:00 2001 From: OlegErshov Date: Fri, 26 Dec 2025 12:00:43 +0100 Subject: [PATCH 1/8] feat: migrated to the latest mcr version On-behalf-of: SAP aleh.yarshou@sap.com --- cmd/initializer.go | 10 ------ cmd/model_generator.go | 14 ++++---- cmd/operator.go | 36 ++++++++++++------- go.mod | 9 +++-- go.sum | 14 ++++---- internal/controller/apibinding_controller.go | 6 ++-- internal/controller/initializer_controller.go | 2 +- .../authorization_model_generation.go | 2 +- .../authorization_model_generation_test.go | 2 +- internal/subroutine/invite.go | 2 +- internal/subroutine/invite_test.go | 2 +- internal/subroutine/realm.go | 2 +- internal/subroutine/realm_test.go | 2 +- internal/subroutine/remove_initializer.go | 4 +-- .../subroutine/remove_initializer_test.go | 2 +- .../subroutine/worksapce_authorization.go | 4 +-- .../workspace_authorization_test.go | 4 +-- internal/subroutine/workspace_initializer.go | 2 +- 18 files changed, 60 insertions(+), 59 deletions(-) diff --git a/cmd/initializer.go b/cmd/initializer.go index 33fb3e83..7d6aff4f 100644 --- a/cmd/initializer.go +++ b/cmd/initializer.go @@ -9,7 +9,6 @@ import ( "github.com/kcp-dev/logicalcluster/v3" "github.com/kcp-dev/multicluster-provider/initializingworkspaces" - pmcontext "github.com/platform-mesh/golang-commons/context" "github.com/spf13/cobra" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -28,9 +27,6 @@ var initializerCmd = &cobra.Command{ Use: "initializer", Short: "FGA initializer for the organization workspacetype", RunE: func(cmd *cobra.Command, args []string) error { - ctx, _, shutdown := pmcontext.StartContext(log, initializerCfg, defaultCfg.ShutdownTimeout) - defer shutdown() - restCfg, err := getKubeconfigFromPath(initializerCfg.KCP.Kubeconfig) if err != nil { log.Error().Err(err).Msg("unable to get KCP kubeconfig") @@ -113,12 +109,6 @@ var initializerCmd = &cobra.Command{ os.Exit(1) } - go func() { - if err := provider.Run(ctx, mgr); err != nil { - log.Fatal().Err(err).Msg("unable to run provider") - } - }() - setupLog.Info("starting manager") return mgr.Start(ctrl.SetupSignalHandler()) diff --git a/cmd/model_generator.go b/cmd/model_generator.go index 657ec870..e923069b 100644 --- a/cmd/model_generator.go +++ b/cmd/model_generator.go @@ -70,7 +70,12 @@ var modelGeneratorCmd = &cobra.Command{ return fmt.Errorf("scheme should not be nil") } - provider, err := apiexport.New(restCfg, apiexport.Options{ + providerConfig, err := getPlatformMeshSystemConfig(restCfg) + if err != nil { + setupLog.Error(err, "unable to create provider config") + return err + } + provider, err := apiexport.New(providerConfig, "core.platform-mesh.io", apiexport.Options{ Scheme: mgrOpts.Scheme, }) if err != nil { @@ -99,18 +104,11 @@ var modelGeneratorCmd = &cobra.Command{ return err } - go func() { - if err := provider.Run(ctx, mgr); err != nil { - log.Fatal().Err(err).Msg("unable to run provider") - } - }() - setupLog.Info("starting manager") if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { setupLog.Error(err, "problem running manager") return err } - return nil }, } diff --git a/cmd/operator.go b/cmd/operator.go index 1865f5b3..f22b9f3b 100644 --- a/cmd/operator.go +++ b/cmd/operator.go @@ -8,10 +8,10 @@ import ( // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. - apisv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1" - kcpcorev1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" "github.com/kcp-dev/logicalcluster/v3" "github.com/kcp-dev/multicluster-provider/apiexport" + apisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" openfgav1 "github.com/openfga/api/proto/openfga/v1" accountsv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" "google.golang.org/grpc" @@ -34,7 +34,7 @@ import ( "github.com/platform-mesh/golang-commons/sentry" "github.com/spf13/cobra" - kcptenancyv1alphav1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1" + kcptenancyv1alphav1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1" corev1alpha1 "github.com/platform-mesh/security-operator/api/v1alpha1" "github.com/platform-mesh/security-operator/internal/controller" @@ -47,6 +47,20 @@ var ( type NewLogicalClusterClientFunc func(clusterKey logicalcluster.Name) (client.Client, error) +func getPlatformMeshSystemConfig(cfg *rest.Config) (*rest.Config, error) { + providerConfig := rest.CopyConfig(cfg) + + parsed, err := url.Parse(providerConfig.Host) + if err != nil { + return nil, fmt.Errorf("unable to parse URL: %w", err) + } + + parsed.Path = "/clusters/root:platform-mesh-system/" + providerConfig.Host = parsed.String() + + return providerConfig, nil +} + func logicalClusterClientFromKey(mgr ctrl.Manager, log *logger.Logger) NewLogicalClusterClientFunc { return func(clusterKey logicalcluster.Name) (client.Client, error) { cfg := rest.CopyConfig(mgr.GetConfig()) @@ -122,8 +136,12 @@ var operatorCmd = &cobra.Command{ log.Error().Err(fmt.Errorf("scheme should not be nil")).Msg("scheme should not be nil") return fmt.Errorf("scheme should not be nil") } - - provider, err := apiexport.New(restCfg, apiexport.Options{ + providerConfig, err := getPlatformMeshSystemConfig(restCfg) + if err != nil { + setupLog.Error(err, "unable to create provider config") + return err + } + provider, err := apiexport.New(providerConfig, "core.platform-mesh.io", apiexport.Options{ Scheme: mgrOpts.Scheme, }) if err != nil { @@ -151,7 +169,7 @@ var operatorCmd = &cobra.Command{ fga := openfgav1.NewOpenFGAServiceClient(conn) - if err = controller.NewStoreReconciler(log, fga, mgr). + if err = controller.NewStoreReconciler(log, fga, mgr, operatorCfg.KCP.Kubeconfig). SetupWithManager(mgr, defaultCfg); err != nil { log.Error().Err(err).Str("controller", "store").Msg("unable to create controller") return err @@ -181,12 +199,6 @@ var operatorCmd = &cobra.Command{ return err } - go func() { - if err := provider.Run(ctx, mgr); err != nil { - log.Fatal().Err(err).Msg("unable to run provider") - } - }() - setupLog.Info("starting manager") if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { log.Error().Err(err).Msg("problem running manager") diff --git a/go.mod b/go.mod index bf41cd24..eb6371fb 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,6 @@ module github.com/platform-mesh/security-operator go 1.25.0 -replace github.com/kcp-dev/multicluster-provider v0.2.0 => github.com/kcp-dev/multicluster-provider v0.0.0-20250827085327-2b5ca378b7b4 - require ( github.com/coreos/go-oidc v2.4.0+incompatible github.com/fluxcd/helm-controller/api v1.4.5 @@ -12,7 +10,8 @@ require ( github.com/google/gnostic-models v0.7.1 github.com/kcp-dev/kcp/sdk v0.28.1-0.20250926104223-cec2e15f24c6 github.com/kcp-dev/logicalcluster/v3 v3.0.5 - github.com/kcp-dev/multicluster-provider v0.2.0 + github.com/kcp-dev/multicluster-provider v0.3.3 + github.com/kcp-dev/sdk v0.28.1-0.20251209130449-436a0347809b github.com/openfga/api/proto v0.0.0-20251105142303-feed3db3d69d github.com/openfga/language/pkg/go v0.2.0-beta.2.0.20251027165255-0f8f255e5f6c github.com/platform-mesh/account-operator v0.5.53 @@ -31,7 +30,7 @@ require ( k8s.io/client-go v0.35.0 k8s.io/utils v0.0.0-20251222233032-718f0e51e6d2 sigs.k8s.io/controller-runtime v0.22.4 - sigs.k8s.io/multicluster-runtime v0.21.0-alpha.9 + sigs.k8s.io/multicluster-runtime v0.22.4-beta.1 sigs.k8s.io/yaml v1.6.0 ) @@ -68,7 +67,7 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250728122101-adbf20db3e51 // indirect + github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983 // indirect github.com/mailru/easyjson v0.9.0 // indirect github.com/martinlindhe/base36 v1.1.1 // indirect github.com/mattn/go-colorable v0.1.14 // indirect diff --git a/go.sum b/go.sum index 895a07c4..cffc6a24 100644 --- a/go.sum +++ b/go.sum @@ -110,14 +110,16 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250728122101-adbf20db3e51 h1:l38RDS+VUMx9etvyaCgJIZa4nM7FaNevNubWN0kDZY4= -github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250728122101-adbf20db3e51/go.mod h1:rF1jfvUfPjFXs+HV/LN1BtPzAz1bfjJOwVa+hAVfroQ= +github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983 h1:4hCauFTFMwvIhwL9fqZ5omjeZ+vsOUNO1tLsrCeprxM= +github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983/go.mod h1:DOv0iw5tcgzFBhudwLFe2WHCLqtlgNkuO4AcqbZ4zVo= github.com/kcp-dev/kcp/sdk v0.28.1-0.20250926104223-cec2e15f24c6 h1:bOR4mdLD24VCJRrHxmtTh21AdbbzkBBKkEh0ngL+XTc= github.com/kcp-dev/kcp/sdk v0.28.1-0.20250926104223-cec2e15f24c6/go.mod h1:aC2BPGPvy8QtkI2gQNH9NfW6xpfGIKZkR93gy9O02BE= github.com/kcp-dev/logicalcluster/v3 v3.0.5 h1:JbYakokb+5Uinz09oTXomSUJVQsqfxEvU4RyHUYxHOU= github.com/kcp-dev/logicalcluster/v3 v3.0.5/go.mod h1:EWBUBxdr49fUB1cLMO4nOdBWmYifLbP1LfoL20KkXYY= -github.com/kcp-dev/multicluster-provider v0.0.0-20250827085327-2b5ca378b7b4 h1:GUihV22j2J/cGF5Svr/zGVvfqTJepIO+sOnYTn9o4Vc= -github.com/kcp-dev/multicluster-provider v0.0.0-20250827085327-2b5ca378b7b4/go.mod h1:E/NxN2SMtC7b6iXgFMlQYWA7lJIfDPqRkPdvpxOEQLA= +github.com/kcp-dev/multicluster-provider v0.3.3 h1:wTu1Zbk6+kVlB/d/K9TM7KPjUEe/Dg8SYzKQsVDiDFY= +github.com/kcp-dev/multicluster-provider v0.3.3/go.mod h1:4QGU39wyNztoYNatdWqbdOV6/R9ZzaIh4DdSj30dm9o= +github.com/kcp-dev/sdk v0.28.1-0.20251209130449-436a0347809b h1:hPwN5SK3L5bx4Ymeb5NeYN0lqIXd+Xt1cAr3qcSlQxU= +github.com/kcp-dev/sdk v0.28.1-0.20251209130449-436a0347809b/go.mod h1:kdlYfujcotSPrBzwtI6qrsNo4JQ+GB1o04buOfKUo2c= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -318,8 +320,8 @@ sigs.k8s.io/controller-runtime v0.22.4 h1:GEjV7KV3TY8e+tJ2LCTxUTanW4z/FmNB7l327U sigs.k8s.io/controller-runtime v0.22.4/go.mod h1:+QX1XUpTXN4mLoblf4tqr5CQcyHPAki2HLXqQMY6vh8= sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= -sigs.k8s.io/multicluster-runtime v0.21.0-alpha.9 h1:baonM4f081WWct3U7O4EfqrxcUGtmCrFDbsT1FQ8xlo= -sigs.k8s.io/multicluster-runtime v0.21.0-alpha.9/go.mod h1:CpBzLMLQKdm+UCchd2FiGPiDdCxM5dgCCPKuaQ6Fsv0= +sigs.k8s.io/multicluster-runtime v0.22.4-beta.1 h1:0XWbDINepM9UOyLkqhG4g7BtGBFKCDvZFyPsw1vufKE= +sigs.k8s.io/multicluster-runtime v0.22.4-beta.1/go.mod h1:zSMb4mC8MAZK42l8eE1ywkeX6vjuNRenYzJ1w+GPdfI= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco= diff --git a/internal/controller/apibinding_controller.go b/internal/controller/apibinding_controller.go index b7a3ab44..1779257c 100644 --- a/internal/controller/apibinding_controller.go +++ b/internal/controller/apibinding_controller.go @@ -5,8 +5,8 @@ import ( "net/url" "strings" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1" "github.com/kcp-dev/logicalcluster/v3" + apisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" platformeshconfig "github.com/platform-mesh/golang-commons/config" "github.com/platform-mesh/golang-commons/controller/lifecycle/builder" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" @@ -76,9 +76,9 @@ type APIBindingReconciler struct { func (r *APIBindingReconciler) Reconcile(ctx context.Context, req mcreconcile.Request) (ctrl.Result, error) { ctxWithCluster := mccontext.WithCluster(ctx, req.ClusterName) - return r.mclifecycle.Reconcile(ctxWithCluster, req, &kcpv1alpha1.APIBinding{}) + return r.mclifecycle.Reconcile(ctxWithCluster, req, &apisv1alpha1.APIBinding{}) } func (r *APIBindingReconciler) SetupWithManager(mgr mcmanager.Manager, cfg *platformeshconfig.CommonServiceConfig, evp ...predicate.Predicate) error { - return r.mclifecycle.SetupWithManager(mgr, cfg.MaxConcurrentReconciles, "apibinding-controller", &kcpv1alpha1.APIBinding{}, cfg.DebugLabelValue, r, r.log, evp...) + return r.mclifecycle.SetupWithManager(mgr, cfg.MaxConcurrentReconciles, "apibinding-controller", &apisv1alpha1.APIBinding{}, cfg.DebugLabelValue, r, r.log, evp...) } diff --git a/internal/controller/initializer_controller.go b/internal/controller/initializer_controller.go index 8aa3d5ae..a4176849 100644 --- a/internal/controller/initializer_controller.go +++ b/internal/controller/initializer_controller.go @@ -3,7 +3,7 @@ package controller import ( "context" - kcpcorev1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" platformeshconfig "github.com/platform-mesh/golang-commons/config" "github.com/platform-mesh/golang-commons/controller/lifecycle/builder" "github.com/platform-mesh/golang-commons/controller/lifecycle/multicluster" diff --git a/internal/subroutine/authorization_model_generation.go b/internal/subroutine/authorization_model_generation.go index 597d3e78..95a2f7c2 100644 --- a/internal/subroutine/authorization_model_generation.go +++ b/internal/subroutine/authorization_model_generation.go @@ -7,7 +7,7 @@ import ( "strings" "text/template" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" "github.com/kcp-dev/logicalcluster/v3" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" lifecyclecontrollerruntime "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" diff --git a/internal/subroutine/authorization_model_generation_test.go b/internal/subroutine/authorization_model_generation_test.go index c65a606e..acb2b1d9 100644 --- a/internal/subroutine/authorization_model_generation_test.go +++ b/internal/subroutine/authorization_model_generation_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" "github.com/platform-mesh/security-operator/internal/subroutine" "github.com/platform-mesh/security-operator/internal/subroutine/mocks" "github.com/stretchr/testify/assert" diff --git a/internal/subroutine/invite.go b/internal/subroutine/invite.go index 7202a0ae..6dc59b9b 100644 --- a/internal/subroutine/invite.go +++ b/internal/subroutine/invite.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" diff --git a/internal/subroutine/invite_test.go b/internal/subroutine/invite_test.go index bc373391..93e55fcc 100644 --- a/internal/subroutine/invite_test.go +++ b/internal/subroutine/invite_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" "github.com/platform-mesh/golang-commons/logger/testlogger" secopv1alpha1 "github.com/platform-mesh/security-operator/api/v1alpha1" diff --git a/internal/subroutine/realm.go b/internal/subroutine/realm.go index 6a32aab7..b1531257 100644 --- a/internal/subroutine/realm.go +++ b/internal/subroutine/realm.go @@ -9,7 +9,7 @@ import ( "strings" "text/template" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" "github.com/platform-mesh/golang-commons/errors" diff --git a/internal/subroutine/realm_test.go b/internal/subroutine/realm_test.go index c6595667..d0dc0e98 100644 --- a/internal/subroutine/realm_test.go +++ b/internal/subroutine/realm_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" "github.com/platform-mesh/golang-commons/errors" "github.com/platform-mesh/golang-commons/logger" "github.com/platform-mesh/security-operator/internal/config" diff --git a/internal/subroutine/remove_initializer.go b/internal/subroutine/remove_initializer.go index 1810a193..72136253 100644 --- a/internal/subroutine/remove_initializer.go +++ b/internal/subroutine/remove_initializer.go @@ -6,8 +6,8 @@ import ( "slices" "time" - "github.com/kcp-dev/kcp/sdk/apis/cache/initialization" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + "github.com/kcp-dev/sdk/apis/cache/initialization" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" "github.com/platform-mesh/golang-commons/errors" diff --git a/internal/subroutine/remove_initializer_test.go b/internal/subroutine/remove_initializer_test.go index 8bdca849..2c25747a 100644 --- a/internal/subroutine/remove_initializer_test.go +++ b/internal/subroutine/remove_initializer_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" "github.com/platform-mesh/security-operator/internal/config" "github.com/platform-mesh/security-operator/internal/subroutine" "github.com/platform-mesh/security-operator/internal/subroutine/mocks" diff --git a/internal/subroutine/worksapce_authorization.go b/internal/subroutine/worksapce_authorization.go index 8194da7b..727206ab 100644 --- a/internal/subroutine/worksapce_authorization.go +++ b/internal/subroutine/worksapce_authorization.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" - kcptenancyv1alphav1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + kcptenancyv1alphav1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" "github.com/platform-mesh/golang-commons/errors" diff --git a/internal/subroutine/workspace_authorization_test.go b/internal/subroutine/workspace_authorization_test.go index b32a6640..6d968c9b 100644 --- a/internal/subroutine/workspace_authorization_test.go +++ b/internal/subroutine/workspace_authorization_test.go @@ -5,8 +5,8 @@ import ( "errors" "testing" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" - kcptenancyv1alphav1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + kcptenancyv1alphav1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1" "github.com/platform-mesh/security-operator/internal/config" "github.com/platform-mesh/security-operator/internal/subroutine/mocks" "github.com/stretchr/testify/assert" diff --git a/internal/subroutine/workspace_initializer.go b/internal/subroutine/workspace_initializer.go index 7ae591bb..428c4181 100644 --- a/internal/subroutine/workspace_initializer.go +++ b/internal/subroutine/workspace_initializer.go @@ -6,7 +6,7 @@ import ( "os" "strings" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" accountsv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" From 994e3c20b1888809546c25095492cd1476e3fad5 Mon Sep 17 00:00:00 2001 From: OlegErshov Date: Fri, 26 Dec 2025 12:40:30 +0100 Subject: [PATCH 2/8] fix: updated tests to use the latest mcr On-behalf-of: SAP aleh.yarshou@sap.com --- cmd/operator.go | 2 +- .../authorization_model_generation.go | 2 +- .../authorization_model_generation_test.go | 15 ++--- internal/test/integration/suite_test.go | 67 +++++++++++-------- 4 files changed, 47 insertions(+), 39 deletions(-) diff --git a/cmd/operator.go b/cmd/operator.go index f22b9f3b..57ae5a96 100644 --- a/cmd/operator.go +++ b/cmd/operator.go @@ -169,7 +169,7 @@ var operatorCmd = &cobra.Command{ fga := openfgav1.NewOpenFGAServiceClient(conn) - if err = controller.NewStoreReconciler(log, fga, mgr, operatorCfg.KCP.Kubeconfig). + if err = controller.NewStoreReconciler(log, fga, mgr). SetupWithManager(mgr, defaultCfg); err != nil { log.Error().Err(err).Str("controller", "store").Msg("unable to create controller") return err diff --git a/internal/subroutine/authorization_model_generation.go b/internal/subroutine/authorization_model_generation.go index 95a2f7c2..7606e905 100644 --- a/internal/subroutine/authorization_model_generation.go +++ b/internal/subroutine/authorization_model_generation.go @@ -7,8 +7,8 @@ import ( "strings" "text/template" - kcpv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" "github.com/kcp-dev/logicalcluster/v3" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" lifecyclecontrollerruntime "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" diff --git a/internal/test/integration/authorization_model_generation_test.go b/internal/test/integration/authorization_model_generation_test.go index 9b517adb..1f4babcf 100644 --- a/internal/test/integration/authorization_model_generation_test.go +++ b/internal/test/integration/authorization_model_generation_test.go @@ -12,12 +12,11 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" - kcpapiv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1" - "github.com/kcp-dev/kcp/sdk/apis/core" - tenancyv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1" "github.com/kcp-dev/logicalcluster/v3" clusterclient "github.com/kcp-dev/multicluster-provider/client" "github.com/kcp-dev/multicluster-provider/envtest" + kcpapiv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" + "github.com/kcp-dev/sdk/apis/core" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" securityv1alpha1 "github.com/platform-mesh/security-operator/api/v1alpha1" @@ -42,9 +41,9 @@ func (suite *IntegrationSuite) TestAuthorizationModelGeneration_Process() { testAccount = "test-account" ) - _, testOrgPath := envtest.NewWorkspaceFixture(suite.T(), cli, orgsPath, envtest.WithName(testOrgName), envtest.WithType(core.RootCluster.Path(), tenancyv1alpha1.WorkspaceTypeName("org"))) + _, testOrgPath := envtest.NewWorkspaceFixture(suite.T(), cli, orgsPath, envtest.WithName(testOrgName), envtest.WithType(core.RootCluster.Path(), "org")) - _, testAccountPath := envtest.NewWorkspaceFixture(suite.T(), cli, testOrgPath, envtest.WithName(testAccount), envtest.WithType(core.RootCluster.Path(), tenancyv1alpha1.WorkspaceTypeName("account"))) + _, testAccountPath := envtest.NewWorkspaceFixture(suite.T(), cli, testOrgPath, envtest.WithName(testAccount), envtest.WithType(core.RootCluster.Path(), "account")) testAccountClient := cli.Cluster(testAccountPath) @@ -83,14 +82,14 @@ func (suite *IntegrationSuite) TestAuthorizationModelGeneration_Finalize() { testOrgName = "generator-test-finalize" ) - _, testOrgPath := envtest.NewWorkspaceFixture(suite.T(), cli, orgsPath, envtest.WithName(testOrgName), envtest.WithType(core.RootCluster.Path(), tenancyv1alpha1.WorkspaceTypeName("org"))) + _, testOrgPath := envtest.NewWorkspaceFixture(suite.T(), cli, orgsPath, envtest.WithName(testOrgName), envtest.WithType(core.RootCluster.Path(), "org")) testClient := cli.Cluster(testOrgPath) suite.createAccount(ctx, testClient, testAccount1Name, accountv1alpha1.AccountTypeAccount, suite.T()) suite.createAccount(ctx, testClient, testAccount2Name, accountv1alpha1.AccountTypeAccount, suite.T()) - _, testAccount1Path := envtest.NewWorkspaceFixture(suite.T(), cli, testOrgPath, envtest.WithName(testAccount1Name), envtest.WithType(core.RootCluster.Path(), tenancyv1alpha1.WorkspaceTypeName("account"))) - _, testAccount2Path := envtest.NewWorkspaceFixture(suite.T(), cli, testOrgPath, envtest.WithName(testAccount2Name), envtest.WithType(core.RootCluster.Path(), tenancyv1alpha1.WorkspaceTypeName("account"))) + _, testAccount1Path := envtest.NewWorkspaceFixture(suite.T(), cli, testOrgPath, envtest.WithName(testAccount1Name), envtest.WithType(core.RootCluster.Path(), "account")) + _, testAccount2Path := envtest.NewWorkspaceFixture(suite.T(), cli, testOrgPath, envtest.WithName(testAccount2Name), envtest.WithType(core.RootCluster.Path(), "account")) testAccount1Client := cli.Cluster(testAccount1Path) testAccount2Client := cli.Cluster(testAccount2Path) diff --git a/internal/test/integration/suite_test.go b/internal/test/integration/suite_test.go index 64fad59d..64d7e2a3 100644 --- a/internal/test/integration/suite_test.go +++ b/internal/test/integration/suite_test.go @@ -3,15 +3,15 @@ package test import ( "context" _ "embed" - "errors" + "fmt" "io" + "net/url" "testing" "time" "github.com/spf13/cobra" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - eventsv1 "k8s.io/api/events/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -21,17 +21,15 @@ import ( mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager" "sigs.k8s.io/yaml" - kcpapiv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1" - apisv1alpha2 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha2" "github.com/kcp-dev/kcp/sdk/apis/core" - corev1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" - tenancyv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1" - topologyv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/topology/v1alpha1" "github.com/kcp-dev/logicalcluster/v3" "github.com/kcp-dev/multicluster-provider/apiexport" clusterclient "github.com/kcp-dev/multicluster-provider/client" "github.com/kcp-dev/multicluster-provider/envtest" - "golang.org/x/sync/errgroup" + apisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" + apisv1alpha2 "github.com/kcp-dev/sdk/apis/apis/v1alpha2" + corev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + tenancyv1alpha1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" platformeshconfig "github.com/platform-mesh/golang-commons/config" @@ -71,13 +69,12 @@ var ( ) func init() { - utilruntime.Must(kcpapiv1alpha1.AddToScheme(scheme.Scheme)) + utilruntime.Must(apisv1alpha1.AddToScheme(scheme.Scheme)) utilruntime.Must(corev1alpha1.AddToScheme(scheme.Scheme)) utilruntime.Must(tenancyv1alpha1.AddToScheme(scheme.Scheme)) - utilruntime.Must(topologyv1alpha1.AddToScheme(scheme.Scheme)) - utilruntime.Must(eventsv1.AddToScheme(scheme.Scheme)) utilruntime.Must(accountv1alpha1.AddToScheme(scheme.Scheme)) utilruntime.Must(securityv1alpha1.AddToScheme(scheme.Scheme)) + utilruntime.Must(apisv1alpha2.AddToScheme(scheme.Scheme)) } type IntegrationSuite struct { @@ -140,7 +137,7 @@ func (suite *IntegrationSuite) setupPlatformMesh(t *testing.T) { // register api-resource schemas schemas := [][]byte{AccountInfoSchemaYAML, AccountSchemaYAML, AuthorizationModelSchemaYAML, StoreSchemaYAML} for _, schemaYAML := range schemas { - var schema kcpapiv1alpha1.APIResourceSchema + var schema apisv1alpha1.APIResourceSchema suite.Require().NoError(yaml.Unmarshal(schemaYAML, &schema)) err = cli.Cluster(platformMeshSystemClusterPath).Create(ctx, &schema) if err != nil && !kerrors.IsAlreadyExists(err) { @@ -150,7 +147,7 @@ func (suite *IntegrationSuite) setupPlatformMesh(t *testing.T) { } suite.Require().NoError(err) - var apiExport kcpapiv1alpha1.APIExport + var apiExport apisv1alpha1.APIExport suite.Require().NoError(yaml.Unmarshal(ApiExportPlatformMeshSystemYAML, &apiExport)) err = cli.Cluster(platformMeshSystemClusterPath).Create(ctx, &apiExport) @@ -203,10 +200,10 @@ func (suite *IntegrationSuite) setupPlatformMesh(t *testing.T) { t.Log("created WorkspaceType 'account' in root workspace") // create :root:orgs ws - orgsWs, orgsClusterPath := envtest.NewWorkspaceFixture(suite.T(), cli, core.RootCluster.Path(), envtest.WithName("orgs"), envtest.WithType(core.RootCluster.Path(), tenancyv1alpha1.WorkspaceTypeName("orgs"))) + orgsWs, orgsClusterPath := envtest.NewWorkspaceFixture(suite.T(), cli, core.RootCluster.Path(), envtest.WithName("orgs"), envtest.WithType(core.RootCluster.Path(), "orgs")) t.Logf("orgs workspace path (%s), cluster id (%s)", orgsClusterPath, orgsWs.Spec.Cluster) - var endpointSlice kcpapiv1alpha1.APIExportEndpointSlice + var endpointSlice apisv1alpha1.APIExportEndpointSlice suite.Assert().Eventually(func() bool { err := cli.Cluster(platformMeshSystemClusterPath).Get(ctx, client.ObjectKey{Name: "core.platform-mesh.io"}, &endpointSlice) if err != nil { @@ -228,7 +225,10 @@ func (suite *IntegrationSuite) setupPlatformMesh(t *testing.T) { func (suite *IntegrationSuite) setupControllers(defaultCfg *platformeshconfig.CommonServiceConfig, testLogger *logger.Logger) { ctx := suite.T().Context() - provider, err := apiexport.New(suite.apiExportEndpointSliceConfig, apiexport.Options{Scheme: scheme.Scheme}) + providerConfig, err := getPlatformMeshSystemConfig(suite.apiExportEndpointSliceConfig) + suite.Require().NoError(err) + + provider, err := apiexport.New(providerConfig, "core.platform-mesh.io", apiexport.Options{Scheme: scheme.Scheme}) suite.Require().NoError(err) mgr, err := mcmanager.New(suite.apiExportEndpointSliceConfig, provider, mcmanager.Options{ @@ -236,24 +236,19 @@ func (suite *IntegrationSuite) setupControllers(defaultCfg *platformeshconfig.Co }) suite.Require().NoError(err) + err = controller.NewAPIBindingReconciler(testLogger, mgr).SetupWithManager(mgr, defaultCfg) + suite.Require().NoError(err) + managerCtx, cancel := context.WithCancel(ctx) - eg, egCtx := errgroup.WithContext(managerCtx) - eg.Go(func() error { - return mgr.Start(egCtx) - }) - eg.Go(func() error { - return provider.Run(egCtx, mgr) - }) + go func() { + if err := mgr.Start(managerCtx); err != nil { + suite.T().Logf("controller manager exited with error: %v", err) + } + }() suite.T().Cleanup(func() { cancel() - if err := eg.Wait(); err != nil && !errors.Is(err, context.Canceled) { - suite.T().Logf("controller manager exited with error: %v", err) - } }) - - err = controller.NewAPIBindingReconciler(testLogger, mgr).SetupWithManager(mgr, defaultCfg) - suite.Require().NoError(err) } func (suite *IntegrationSuite) createAccount(ctx context.Context, client client.Client, accountName string, accountType accountv1alpha1.AccountType, t *testing.T) { @@ -305,3 +300,17 @@ func (suite *IntegrationSuite) createAccountInfo(ctx context.Context, accountCli } t.Logf("created accountInfo 'account' in %s workspace", accountPath) } + +func getPlatformMeshSystemConfig(cfg *rest.Config) (*rest.Config, error) { + providerConfig := rest.CopyConfig(cfg) + + parsed, err := url.Parse(providerConfig.Host) + if err != nil { + return nil, fmt.Errorf("unable to parse URL: %w", err) + } + + parsed.Path = "/clusters/root:platform-mesh-system/" + providerConfig.Host = parsed.String() + + return providerConfig, nil +} From e0b7d1e5ce6012e879dd75101e7385828cc111c8 Mon Sep 17 00:00:00 2001 From: OlegErshov Date: Fri, 26 Dec 2025 13:03:25 +0100 Subject: [PATCH 3/8] chore: refactored url configuration On-behalf-of: SAP aleh.yarshou@sap.com --- cmd/operator.go | 9 ++++++++- internal/test/integration/suite_test.go | 9 ++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/operator.go b/cmd/operator.go index 57ae5a96..9615db7e 100644 --- a/cmd/operator.go +++ b/cmd/operator.go @@ -45,6 +45,10 @@ var ( scheme = runtime.NewScheme() ) +const ( + platformMeshWorkspace = "root:platform-mesh-system" +) + type NewLogicalClusterClientFunc func(clusterKey logicalcluster.Name) (client.Client, error) func getPlatformMeshSystemConfig(cfg *rest.Config) (*rest.Config, error) { @@ -55,7 +59,10 @@ func getPlatformMeshSystemConfig(cfg *rest.Config) (*rest.Config, error) { return nil, fmt.Errorf("unable to parse URL: %w", err) } - parsed.Path = "/clusters/root:platform-mesh-system/" + parsed.Path, err = url.JoinPath("clusters", platformMeshWorkspace) + if err != nil { + return nil, fmt.Errorf("failed to join path") + } providerConfig.Host = parsed.String() return providerConfig, nil diff --git a/internal/test/integration/suite_test.go b/internal/test/integration/suite_test.go index 64d7e2a3..ffa35f8f 100644 --- a/internal/test/integration/suite_test.go +++ b/internal/test/integration/suite_test.go @@ -225,7 +225,7 @@ func (suite *IntegrationSuite) setupPlatformMesh(t *testing.T) { func (suite *IntegrationSuite) setupControllers(defaultCfg *platformeshconfig.CommonServiceConfig, testLogger *logger.Logger) { ctx := suite.T().Context() - providerConfig, err := getPlatformMeshSystemConfig(suite.apiExportEndpointSliceConfig) + providerConfig, err := suite.getPlatformMeshSystemConfig(suite.apiExportEndpointSliceConfig) suite.Require().NoError(err) provider, err := apiexport.New(providerConfig, "core.platform-mesh.io", apiexport.Options{Scheme: scheme.Scheme}) @@ -301,7 +301,7 @@ func (suite *IntegrationSuite) createAccountInfo(ctx context.Context, accountCli t.Logf("created accountInfo 'account' in %s workspace", accountPath) } -func getPlatformMeshSystemConfig(cfg *rest.Config) (*rest.Config, error) { +func (suite *IntegrationSuite) getPlatformMeshSystemConfig(cfg *rest.Config) (*rest.Config, error) { providerConfig := rest.CopyConfig(cfg) parsed, err := url.Parse(providerConfig.Host) @@ -309,7 +309,10 @@ func getPlatformMeshSystemConfig(cfg *rest.Config) (*rest.Config, error) { return nil, fmt.Errorf("unable to parse URL: %w", err) } - parsed.Path = "/clusters/root:platform-mesh-system/" + parsed.Path, err = url.JoinPath("clusters", suite.platformMeshSysPath.String()) + if err != nil { + return nil, fmt.Errorf("failed to join path") + } providerConfig.Host = parsed.String() return providerConfig, nil From 0a86296e99b06299af27c0b0a89a3885b0a393fa Mon Sep 17 00:00:00 2001 From: OlegErshov Date: Fri, 26 Dec 2025 13:18:21 +0100 Subject: [PATCH 4/8] chore: refactored kcp api imports On-behalf-of: SAP aleh.yarshou@sap.com --- cmd/operator.go | 4 +- internal/controller/apibinding_controller.go | 6 +- .../authorization_model_generation.go | 16 +- .../authorization_model_generation_test.go | 150 +++++++++--------- internal/subroutine/invite.go | 4 +- internal/subroutine/invite_test.go | 28 ++-- internal/subroutine/remove_initializer.go | 6 +- .../subroutine/remove_initializer_test.go | 42 ++--- .../subroutine/worksapce_authorization.go | 4 +- .../workspace_authorization_test.go | 22 +-- internal/subroutine/workspace_initializer.go | 6 +- 11 files changed, 144 insertions(+), 144 deletions(-) diff --git a/cmd/operator.go b/cmd/operator.go index 9615db7e..5ad009ac 100644 --- a/cmd/operator.go +++ b/cmd/operator.go @@ -10,7 +10,7 @@ import ( // to ensure that exec-entrypoint and run can make use of them. "github.com/kcp-dev/logicalcluster/v3" "github.com/kcp-dev/multicluster-provider/apiexport" - apisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" + kcpapisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" openfgav1 "github.com/openfga/api/proto/openfga/v1" accountsv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" @@ -220,7 +220,7 @@ func init() { utilruntime.Must(kcptenancyv1alphav1.AddToScheme(scheme)) utilruntime.Must(corev1alpha1.AddToScheme(scheme)) - utilruntime.Must(apisv1alpha1.AddToScheme(scheme)) + utilruntime.Must(kcpapisv1alpha1.AddToScheme(scheme)) utilruntime.Must(kcpcorev1alpha1.AddToScheme(scheme)) utilruntime.Must(accountsv1alpha1.AddToScheme(scheme)) // +kubebuilder:scaffold:scheme diff --git a/internal/controller/apibinding_controller.go b/internal/controller/apibinding_controller.go index 1779257c..b0199e1a 100644 --- a/internal/controller/apibinding_controller.go +++ b/internal/controller/apibinding_controller.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/kcp-dev/logicalcluster/v3" - apisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" + kcpapisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" platformeshconfig "github.com/platform-mesh/golang-commons/config" "github.com/platform-mesh/golang-commons/controller/lifecycle/builder" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" @@ -76,9 +76,9 @@ type APIBindingReconciler struct { func (r *APIBindingReconciler) Reconcile(ctx context.Context, req mcreconcile.Request) (ctrl.Result, error) { ctxWithCluster := mccontext.WithCluster(ctx, req.ClusterName) - return r.mclifecycle.Reconcile(ctxWithCluster, req, &apisv1alpha1.APIBinding{}) + return r.mclifecycle.Reconcile(ctxWithCluster, req, &kcpapisv1alpha1.APIBinding{}) } func (r *APIBindingReconciler) SetupWithManager(mgr mcmanager.Manager, cfg *platformeshconfig.CommonServiceConfig, evp ...predicate.Predicate) error { - return r.mclifecycle.SetupWithManager(mgr, cfg.MaxConcurrentReconciles, "apibinding-controller", &apisv1alpha1.APIBinding{}, cfg.DebugLabelValue, r, r.log, evp...) + return r.mclifecycle.SetupWithManager(mgr, cfg.MaxConcurrentReconciles, "apibinding-controller", &kcpapisv1alpha1.APIBinding{}, cfg.DebugLabelValue, r, r.log, evp...) } diff --git a/internal/subroutine/authorization_model_generation.go b/internal/subroutine/authorization_model_generation.go index 7606e905..6051391e 100644 --- a/internal/subroutine/authorization_model_generation.go +++ b/internal/subroutine/authorization_model_generation.go @@ -8,7 +8,7 @@ import ( "text/template" "github.com/kcp-dev/logicalcluster/v3" - kcpv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" + kcpapisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" lifecyclecontrollerruntime "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" @@ -87,14 +87,14 @@ type modelInput struct { func (a *AuthorizationModelGenerationSubroutine) Finalize(ctx context.Context, instance lifecyclecontrollerruntime.RuntimeObject) (ctrl.Result, errors.OperatorError) { log := logger.LoadLoggerFromContext(ctx) - bindingToDelete := instance.(*kcpv1alpha1.APIBinding) + bindingToDelete := instance.(*kcpapisv1alpha1.APIBinding) bindingCluster, err := a.mgr.ClusterFromContext(ctx) if err != nil { return ctrl.Result{}, errors.NewOperatorError(fmt.Errorf("unable to get cluster from context: %w", err), true, false) } - var bindings kcpv1alpha1.APIBindingList + var bindings kcpapisv1alpha1.APIBindingList err = a.allClient.List(ctx, &bindings) if err != nil { return ctrl.Result{}, errors.NewOperatorError(err, true, true) @@ -149,7 +149,7 @@ func (a *AuthorizationModelGenerationSubroutine) Finalize(ctx context.Context, i } apiExportClient := apiExportCluster.GetClient() - var apiExport kcpv1alpha1.APIExport + var apiExport kcpapisv1alpha1.APIExport err = apiExportClient.Get(ctx, types.NamespacedName{Name: bindingToDelete.Spec.Reference.Export.Name}, &apiExport) if err != nil { log.Error().Err(err).Msg("failed to get apiexport for binding deletion") @@ -157,7 +157,7 @@ func (a *AuthorizationModelGenerationSubroutine) Finalize(ctx context.Context, i } for _, latestResourceSchema := range apiExport.Spec.LatestResourceSchemas { - var resourceSchema kcpv1alpha1.APIResourceSchema + var resourceSchema kcpapisv1alpha1.APIResourceSchema err := apiExportClient.Get(ctx, types.NamespacedName{Name: latestResourceSchema}, &resourceSchema) if err != nil { log.Error().Err(err).Msg("failed to get resource schema for binding deletion") @@ -198,7 +198,7 @@ func (a *AuthorizationModelGenerationSubroutine) GetName() string { // Process implements lifecycle.Subroutine. func (a *AuthorizationModelGenerationSubroutine) Process(ctx context.Context, instance lifecyclecontrollerruntime.RuntimeObject) (ctrl.Result, errors.OperatorError) { - binding := instance.(*kcpv1alpha1.APIBinding) + binding := instance.(*kcpapisv1alpha1.APIBinding) cluster, err := a.mgr.ClusterFromContext(ctx) if err != nil { @@ -225,14 +225,14 @@ func (a *AuthorizationModelGenerationSubroutine) Process(ctx context.Context, in return ctrl.Result{}, errors.NewOperatorError(err, true, true) } - var apiExport kcpv1alpha1.APIExport + var apiExport kcpapisv1alpha1.APIExport err = apiExportCluster.GetClient().Get(ctx, types.NamespacedName{Name: binding.Spec.Reference.Export.Name}, &apiExport) if err != nil { return ctrl.Result{}, errors.NewOperatorError(err, true, true) } for _, latestResourceSchema := range apiExport.Spec.LatestResourceSchemas { - var resourceSchema kcpv1alpha1.APIResourceSchema + var resourceSchema kcpapisv1alpha1.APIResourceSchema err := apiExportCluster.GetClient().Get(ctx, types.NamespacedName{Name: latestResourceSchema}, &resourceSchema) if err != nil { return ctrl.Result{}, errors.NewOperatorError(err, true, true) diff --git a/internal/subroutine/authorization_model_generation_test.go b/internal/subroutine/authorization_model_generation_test.go index acb2b1d9..2f61209f 100644 --- a/internal/subroutine/authorization_model_generation_test.go +++ b/internal/subroutine/authorization_model_generation_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - kcpv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" + kcpapisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" "github.com/platform-mesh/security-operator/internal/subroutine" "github.com/platform-mesh/security-operator/internal/subroutine/mocks" "github.com/stretchr/testify/assert" @@ -18,13 +18,13 @@ import ( apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) -func newApiBinding(name, path string) *kcpv1alpha1.APIBinding { - return &kcpv1alpha1.APIBinding{ - Spec: kcpv1alpha1.APIBindingSpec{Reference: kcpv1alpha1.BindingReference{Export: &kcpv1alpha1.ExportBindingReference{Name: name, Path: path}}}, +func newApiBinding(name, path string) *kcpapisv1alpha1.APIBinding { + return &kcpapisv1alpha1.APIBinding{ + Spec: kcpapisv1alpha1.APIBindingSpec{Reference: kcpapisv1alpha1.BindingReference{Export: &kcpapisv1alpha1.ExportBindingReference{Name: name, Path: path}}}, } } -func bindingWithCluster(name, path, cluster string) *kcpv1alpha1.APIBinding { +func bindingWithCluster(name, path, cluster string) *kcpapisv1alpha1.APIBinding { b := newApiBinding(name, path) if b.Annotations == nil { b.Annotations = make(map[string]string) @@ -33,7 +33,7 @@ func bindingWithCluster(name, path, cluster string) *kcpv1alpha1.APIBinding { return b } -func bindingWithApiExportCluster(name, path, exportCluster string) *kcpv1alpha1.APIBinding { +func bindingWithApiExportCluster(name, path, exportCluster string) *kcpapisv1alpha1.APIBinding { b := newApiBinding(name, path) b.Status.APIExportClusterName = exportCluster return b @@ -52,7 +52,7 @@ func mockAccountInfo(cl *mocks.MockClient, orgName, originCluster string) { func TestAuthorizationModelGeneration_Process(t *testing.T) { tests := []struct { name string - binding *kcpv1alpha1.APIBinding + binding *kcpapisv1alpha1.APIBinding mockSetup func(*mocks.MockManager, *mocks.MockClient, *mocks.MockCluster, *mocks.MockClient) expectError bool }{ @@ -106,14 +106,14 @@ func TestAuthorizationModelGeneration_Process(t *testing.T) { }).Once() manager.EXPECT().GetCluster(mock.Anything, mock.Anything).Return(cluster, nil) kcpClient.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - if ae, ok := o.(*kcpv1alpha1.APIExport); ok { + if ae, ok := o.(*kcpapisv1alpha1.APIExport); ok { ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil } return nil }).Once() kcpClient.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - if rs, ok := o.(*kcpv1alpha1.APIResourceSchema); ok { + if rs, ok := o.(*kcpapisv1alpha1.APIResourceSchema); ok { rs.Spec.Group = "group" rs.Spec.Names.Plural = "things" rs.Spec.Names.Singular = "thing" @@ -144,14 +144,14 @@ func TestAuthorizationModelGeneration_Process(t *testing.T) { mockAccountInfo(kcpClient, "org", "origin") manager.EXPECT().GetCluster(mock.Anything, mock.Anything).Return(cluster, nil) kcpClient.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - if ae, ok := o.(*kcpv1alpha1.APIExport); ok { + if ae, ok := o.(*kcpapisv1alpha1.APIExport); ok { ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil } return nil }).Once() kcpClient.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - if rs, ok := o.(*kcpv1alpha1.APIResourceSchema); ok { + if rs, ok := o.(*kcpapisv1alpha1.APIResourceSchema); ok { rs.Spec.Group = "group" rs.Spec.Names.Plural = "foos" rs.Spec.Names.Singular = "foo" @@ -174,14 +174,14 @@ func TestAuthorizationModelGeneration_Process(t *testing.T) { mockAccountInfo(kcpClient, "org", "origin") manager.EXPECT().GetCluster(mock.Anything, mock.Anything).Return(cluster, nil) kcpClient.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - if ae, ok := o.(*kcpv1alpha1.APIExport); ok { + if ae, ok := o.(*kcpapisv1alpha1.APIExport); ok { ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil } return nil }).Once() kcpClient.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - if rs, ok := o.(*kcpv1alpha1.APIResourceSchema); ok { + if rs, ok := o.(*kcpapisv1alpha1.APIResourceSchema); ok { rs.Spec.Group = "group" rs.Spec.Names.Plural = "foos" rs.Spec.Names.Singular = "foo" @@ -217,7 +217,7 @@ func TestAuthorizationModelGeneration_Process(t *testing.T) { mockAccountInfo(kcpClient, "org", "origin") manager.EXPECT().GetCluster(mock.Anything, mock.Anything).Return(cluster, nil) kcpClient.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - if ae, ok := o.(*kcpv1alpha1.APIExport); ok { + if ae, ok := o.(*kcpapisv1alpha1.APIExport); ok { ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil } @@ -235,14 +235,14 @@ func TestAuthorizationModelGeneration_Process(t *testing.T) { mockAccountInfo(kcpClient, "org", "origin") manager.EXPECT().GetCluster(mock.Anything, mock.Anything).Return(cluster, nil) kcpClient.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - if ae, ok := o.(*kcpv1alpha1.APIExport); ok { + if ae, ok := o.(*kcpapisv1alpha1.APIExport); ok { ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil } return nil }).Once() kcpClient.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - if rs, ok := o.(*kcpv1alpha1.APIResourceSchema); ok { + if rs, ok := o.(*kcpapisv1alpha1.APIResourceSchema); ok { rs.Spec.Group = "veryverylonggroup.platform-mesh.org" rs.Spec.Names.Plural = "plural" rs.Spec.Names.Singular = "singular" @@ -303,14 +303,14 @@ func TestAuthorizationModelGeneration_Process(t *testing.T) { func TestAuthorizationModelGeneration_Finalize(t *testing.T) { tests := []struct { name string - binding *kcpv1alpha1.APIBinding - mockSetup func(*mocks.MockManager, *mocks.MockClient, *kcpv1alpha1.APIBinding) + binding *kcpapisv1alpha1.APIBinding + mockSetup func(*mocks.MockManager, *mocks.MockClient, *kcpapisv1alpha1.APIBinding) expectError bool }{ { name: "bindings with non-matching export are skipped", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) bindingWsCluster := mocks.NewMockCluster(t) @@ -321,10 +321,10 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b1 := bindingWithCluster("foo", "bar", "cluster1") b2 := bindingWithCluster("other", "other", "cluster2") - list.Items = []kcpv1alpha1.APIBinding{*b1, *b2} + list.Items = []kcpapisv1alpha1.APIBinding{*b1, *b2} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -344,12 +344,12 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().GetCluster(mock.Anything, "export-cluster").Return(apiExportCluster, nil) apiExportCluster.EXPECT().GetClient().Return(apiExportClient) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "foo"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - ae := o.(*kcpv1alpha1.APIExport) + ae := o.(*kcpapisv1alpha1.APIExport) ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil }) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "schema1"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - rs := o.(*kcpv1alpha1.APIResourceSchema) + rs := o.(*kcpapisv1alpha1.APIResourceSchema) rs.Spec.Names.Plural = "foos" return nil }) @@ -360,7 +360,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { name: "error on ClusterFromContext in Finalize", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), expectError: true, - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(nil, assert.AnError) }, }, @@ -368,20 +368,20 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { name: "early return when accountInfo missing in Finalize", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), expectError: true, - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := binding.DeepCopy() if b.Annotations == nil { b.Annotations = make(map[string]string) } b.Annotations["kcp.io/cluster"] = "cluster1" - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).Return( @@ -392,7 +392,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { name: "delete returns error in Finalize", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), expectError: true, - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) apiExportCluster := mocks.NewMockCluster(t) @@ -401,13 +401,13 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := binding.DeepCopy() if b.Annotations == nil { b.Annotations = make(map[string]string) } b.Annotations["kcp.io/cluster"] = "cluster1" - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -426,12 +426,12 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().GetCluster(mock.Anything, "export-cluster").Return(apiExportCluster, nil) apiExportCluster.EXPECT().GetClient().Return(apiExportClient) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "foo"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - ae := o.(*kcpv1alpha1.APIExport) + ae := o.(*kcpapisv1alpha1.APIExport) ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil }) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "schema1"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - rs := o.(*kcpv1alpha1.APIResourceSchema) + rs := o.(*kcpapisv1alpha1.APIResourceSchema) rs.Spec.Names.Plural = "foos" return nil }) @@ -441,7 +441,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { { name: "skip Finalize if other bindings exist", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) bindingWsCluster1 := mocks.NewMockCluster(t) @@ -452,10 +452,10 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b1 := bindingWithCluster("foo", "bar", "cluster1") b2 := bindingWithCluster("foo", "bar", "cluster2") - list.Items = []kcpv1alpha1.APIBinding{*b1, *b2} + list.Items = []kcpapisv1alpha1.APIBinding{*b1, *b2} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -485,7 +485,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { { name: "delete model in Finalize if last binding", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) bindingWsCluster := mocks.NewMockCluster(t) @@ -496,13 +496,13 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := binding.DeepCopy() if b.Annotations == nil { b.Annotations = make(map[string]string) } b.Annotations["kcp.io/cluster"] = "cluster1" - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -522,12 +522,12 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().GetCluster(mock.Anything, "export-cluster").Return(apiExportCluster, nil) apiExportCluster.EXPECT().GetClient().Return(apiExportClient) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "foo"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - ae := o.(*kcpv1alpha1.APIExport) + ae := o.(*kcpapisv1alpha1.APIExport) ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil }) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "schema1"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - rs := o.(*kcpv1alpha1.APIResourceSchema) + rs := o.(*kcpapisv1alpha1.APIResourceSchema) rs.Spec.Names.Plural = "foos" return nil }) @@ -537,7 +537,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { { name: "delete model in Finalize but model is not found", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) bindingWsCluster := mocks.NewMockCluster(t) @@ -548,13 +548,13 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := binding.DeepCopy() if b.Annotations == nil { b.Annotations = make(map[string]string) } b.Annotations["kcp.io/cluster"] = "cluster1" - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -574,12 +574,12 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().GetCluster(mock.Anything, "export-cluster").Return(apiExportCluster, nil) apiExportCluster.EXPECT().GetClient().Return(apiExportClient) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "foo"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - ae := o.(*kcpv1alpha1.APIExport) + ae := o.(*kcpapisv1alpha1.APIExport) ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil }) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "schema1"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - rs := o.(*kcpv1alpha1.APIResourceSchema) + rs := o.(*kcpapisv1alpha1.APIResourceSchema) rs.Spec.Names.Plural = "foos" return nil }) @@ -591,7 +591,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { name: "error on List in Finalize", binding: newApiBinding("foo", "bar"), expectError: true, - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) @@ -604,20 +604,20 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { name: "error on getRelatedAuthorizationModels in Finalize", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), expectError: true, - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := binding.DeepCopy() if b.Annotations == nil { b.Annotations = make(map[string]string) } b.Annotations["kcp.io/cluster"] = "cluster1" - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).Return(assert.AnError) @@ -626,7 +626,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { { name: "only bindings for same org are counted; delete called if only one, not called if none", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) bindingWsCluster1 := mocks.NewMockCluster(t) @@ -639,10 +639,10 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b1 := bindingWithCluster("foo", "bar", "cluster1") b2 := bindingWithCluster("foo", "bar", "cluster2") - list.Items = []kcpv1alpha1.APIBinding{*b1, *b2} + list.Items = []kcpapisv1alpha1.APIBinding{*b1, *b2} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -666,12 +666,12 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().GetCluster(mock.Anything, "export-cluster").Return(apiExportCluster, nil) apiExportCluster.EXPECT().GetClient().Return(apiExportClient) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "foo"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - ae := o.(*kcpv1alpha1.APIExport) + ae := o.(*kcpapisv1alpha1.APIExport) ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil }) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "schema1"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - rs := o.(*kcpv1alpha1.APIResourceSchema) + rs := o.(*kcpapisv1alpha1.APIResourceSchema) rs.Spec.Names.Plural = "foos" return nil }) @@ -681,16 +681,16 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { { name: "error on GetCluster for binding workspace in Finalize loop", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := bindingWithCluster("foo", "bar", "cluster1") - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -706,7 +706,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { { name: "error on Get accountInfo in Finalize loop (not NotFound)", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) bindingWsCluster := mocks.NewMockCluster(t) @@ -715,9 +715,9 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := bindingWithCluster("foo", "bar", "cluster1") - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -735,7 +735,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { { name: "bindings with different org are skipped in Finalize", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) bindingWsCluster := mocks.NewMockCluster(t) @@ -746,9 +746,9 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := bindingWithCluster("foo", "bar", "cluster1") - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -768,12 +768,12 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().GetCluster(mock.Anything, "export-cluster").Return(apiExportCluster, nil) apiExportCluster.EXPECT().GetClient().Return(apiExportClient) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "foo"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - ae := o.(*kcpv1alpha1.APIExport) + ae := o.(*kcpapisv1alpha1.APIExport) ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil }) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "schema1"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - rs := o.(*kcpv1alpha1.APIResourceSchema) + rs := o.(*kcpapisv1alpha1.APIResourceSchema) rs.Spec.Names.Plural = "foos" return nil }) @@ -784,7 +784,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { name: "error on GetCluster for APIExport cluster in Finalize", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), expectError: true, - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) bindingWsCluster := mocks.NewMockCluster(t) @@ -793,9 +793,9 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := bindingWithCluster("foo", "bar", "cluster1") - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -819,7 +819,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { name: "error on Get APIExport in Finalize", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), expectError: true, - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) bindingWsCluster := mocks.NewMockCluster(t) @@ -830,9 +830,9 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := bindingWithCluster("foo", "bar", "cluster1") - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -858,7 +858,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { name: "error on Get resource schema in Finalize", binding: bindingWithApiExportCluster("foo", "bar", "export-cluster"), expectError: true, - mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpv1alpha1.APIBinding) { + mockSetup: func(manager *mocks.MockManager, allClient *mocks.MockClient, binding *kcpapisv1alpha1.APIBinding) { bindingCluster := mocks.NewMockCluster(t) bindingClient := mocks.NewMockClient(t) bindingWsCluster := mocks.NewMockCluster(t) @@ -869,9 +869,9 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().ClusterFromContext(mock.Anything).Return(bindingCluster, nil) bindingCluster.EXPECT().GetClient().Return(bindingClient) allClient.EXPECT().List(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, ol client.ObjectList, lo ...client.ListOption) error { - list := ol.(*kcpv1alpha1.APIBindingList) + list := ol.(*kcpapisv1alpha1.APIBindingList) b := bindingWithCluster("foo", "bar", "cluster1") - list.Items = []kcpv1alpha1.APIBinding{*b} + list.Items = []kcpapisv1alpha1.APIBinding{*b} return nil }) bindingClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "account"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { @@ -891,7 +891,7 @@ func TestAuthorizationModelGeneration_Finalize(t *testing.T) { manager.EXPECT().GetCluster(mock.Anything, "export-cluster").Return(apiExportCluster, nil) apiExportCluster.EXPECT().GetClient().Return(apiExportClient) apiExportClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "foo"}, mock.Anything).RunAndReturn(func(ctx context.Context, nn types.NamespacedName, o client.Object, opts ...client.GetOption) error { - ae := o.(*kcpv1alpha1.APIExport) + ae := o.(*kcpapisv1alpha1.APIExport) ae.Spec.LatestResourceSchemas = []string{"schema1"} return nil }) diff --git a/internal/subroutine/invite.go b/internal/subroutine/invite.go index 6dc59b9b..bd3ff6f4 100644 --- a/internal/subroutine/invite.go +++ b/internal/subroutine/invite.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" @@ -51,7 +51,7 @@ func (w *inviteSubroutine) Finalizers(_ runtimeobject.RuntimeObject) []string { func (w *inviteSubroutine) GetName() string { return "InviteInitilizationSubroutine" } func (w *inviteSubroutine) Process(ctx context.Context, instance runtimeobject.RuntimeObject) (ctrl.Result, errors.OperatorError) { - lc := instance.(*kcpv1alpha1.LogicalCluster) + lc := instance.(*kcpcorev1alpha1.LogicalCluster) wsName := getWorkspaceName(lc) if wsName == "" { diff --git a/internal/subroutine/invite_test.go b/internal/subroutine/invite_test.go index 93e55fcc..3069fcfd 100644 --- a/internal/subroutine/invite_test.go +++ b/internal/subroutine/invite_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" "github.com/platform-mesh/golang-commons/logger/testlogger" secopv1alpha1 "github.com/platform-mesh/security-operator/api/v1alpha1" @@ -54,7 +54,7 @@ func TestInviteSubroutine_Finalize(t *testing.T) { subroutine := NewInviteSubroutine(orgsClient, mgr) ctx := context.Background() - instance := &kcpv1alpha1.LogicalCluster{} + instance := &kcpcorev1alpha1.LogicalCluster{} result, opErr := subroutine.Finalize(ctx, instance) @@ -66,14 +66,14 @@ func TestInviteSubroutine_Process(t *testing.T) { tests := []struct { name string setupMocks func(*mocks.MockClient, *mocks.MockManager, *mocks.MockCluster) - lc *kcpv1alpha1.LogicalCluster + lc *kcpcorev1alpha1.LogicalCluster expectedErr bool expectedResult ctrl.Result }{ { name: "Empty workspace name - early return", setupMocks: func(orgsClient *mocks.MockClient, mgr *mocks.MockManager, cluster *mocks.MockCluster) {}, - lc: &kcpv1alpha1.LogicalCluster{ + lc: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{}, }, @@ -86,7 +86,7 @@ func TestInviteSubroutine_Process(t *testing.T) { setupMocks: func(orgsClient *mocks.MockClient, mgr *mocks.MockManager, cluster *mocks.MockCluster) { mgr.EXPECT().ClusterFromContext(mock.Anything).Return(nil, assert.AnError).Once() }, - lc: &kcpv1alpha1.LogicalCluster{ + lc: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test", @@ -103,7 +103,7 @@ func TestInviteSubroutine_Process(t *testing.T) { orgsClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "test"}, mock.AnythingOfType("*v1alpha1.Account")). Return(assert.AnError).Once() }, - lc: &kcpv1alpha1.LogicalCluster{ + lc: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test", @@ -126,7 +126,7 @@ func TestInviteSubroutine_Process(t *testing.T) { return nil }).Once() }, - lc: &kcpv1alpha1.LogicalCluster{ + lc: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test", @@ -166,7 +166,7 @@ func TestInviteSubroutine_Process(t *testing.T) { return nil }).Maybe() }, - lc: &kcpv1alpha1.LogicalCluster{ + lc: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:acme", @@ -206,7 +206,7 @@ func TestInviteSubroutine_Process(t *testing.T) { return nil }).Maybe() }, - lc: &kcpv1alpha1.LogicalCluster{ + lc: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:beta", @@ -245,12 +245,12 @@ func TestInviteSubroutine_Process(t *testing.T) { func TestGetWorkspaceName(t *testing.T) { tests := []struct { name string - lc *kcpv1alpha1.LogicalCluster + lc *kcpcorev1alpha1.LogicalCluster expected string }{ { name: "valid workspace path", - lc: &kcpv1alpha1.LogicalCluster{ + lc: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test", @@ -261,7 +261,7 @@ func TestGetWorkspaceName(t *testing.T) { }, { name: "workspace path with multiple segments", - lc: &kcpv1alpha1.LogicalCluster{ + lc: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test:sub", @@ -272,7 +272,7 @@ func TestGetWorkspaceName(t *testing.T) { }, { name: "missing annotation", - lc: &kcpv1alpha1.LogicalCluster{ + lc: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{}, }, @@ -281,7 +281,7 @@ func TestGetWorkspaceName(t *testing.T) { }, { name: "empty annotation", - lc: &kcpv1alpha1.LogicalCluster{ + lc: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "", diff --git a/internal/subroutine/remove_initializer.go b/internal/subroutine/remove_initializer.go index 72136253..d354d9f8 100644 --- a/internal/subroutine/remove_initializer.go +++ b/internal/subroutine/remove_initializer.go @@ -7,7 +7,7 @@ import ( "time" "github.com/kcp-dev/sdk/apis/cache/initialization" - kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" "github.com/platform-mesh/golang-commons/errors" @@ -45,9 +45,9 @@ func (r *removeInitializer) GetName() string { return "RemoveInitializer" } // Process implements subroutine.Subroutine. func (r *removeInitializer) Process(ctx context.Context, instance runtimeobject.RuntimeObject) (ctrl.Result, errors.OperatorError) { - lc := instance.(*kcpv1alpha1.LogicalCluster) + lc := instance.(*kcpcorev1alpha1.LogicalCluster) - initializer := kcpv1alpha1.LogicalClusterInitializer(r.initializerName) + initializer := kcpcorev1alpha1.LogicalClusterInitializer(r.initializerName) cluster, err := r.mgr.ClusterFromContext(ctx) if err != nil { diff --git a/internal/subroutine/remove_initializer_test.go b/internal/subroutine/remove_initializer_test.go index 2c25747a..bf57d1d2 100644 --- a/internal/subroutine/remove_initializer_test.go +++ b/internal/subroutine/remove_initializer_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" "github.com/platform-mesh/security-operator/internal/config" "github.com/platform-mesh/security-operator/internal/subroutine" "github.com/platform-mesh/security-operator/internal/subroutine/mocks" @@ -20,7 +20,7 @@ import ( // fakeStatusWriter implements client.SubResourceWriter to intercept Status().Patch calls type fakeStatusWriter struct { t *testing.T - expectClear kcpv1alpha1.LogicalClusterInitializer + expectClear kcpcorev1alpha1.LogicalClusterInitializer err error } @@ -33,7 +33,7 @@ func (f *fakeStatusWriter) Update(ctx context.Context, obj client.Object, opts . } func (f *fakeStatusWriter) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.SubResourcePatchOption) error { - lc := obj.(*kcpv1alpha1.LogicalCluster) + lc := obj.(*kcpcorev1alpha1.LogicalCluster) // Ensure initializer was removed before patch for _, init := range lc.Status.Initializers { if init == f.expectClear { @@ -52,8 +52,8 @@ func TestRemoveInitializer_Process(t *testing.T) { cluster := mocks.NewMockCluster(t) mgr.EXPECT().ClusterFromContext(mock.Anything).Return(cluster, nil) - lc := &kcpv1alpha1.LogicalCluster{} - lc.Status.Initializers = []kcpv1alpha1.LogicalClusterInitializer{"other.initializer"} + lc := &kcpcorev1alpha1.LogicalCluster{} + lc.Status.Initializers = []kcpcorev1alpha1.LogicalClusterInitializer{"other.initializer"} r := subroutine.NewRemoveInitializer(mgr, config.Config{InitializerName: initializerName, SecretWaitingTimeoutInSeconds: 60}, runtimeClient) _, err := r.Process(context.Background(), lc) @@ -70,11 +70,11 @@ func TestRemoveInitializer_Process(t *testing.T) { // Secret must exist for the flow to proceed runtimeClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "portal-client-secret-test", Namespace: subroutine.PortalClientSecretNamespace}, mock.Anything).Return(nil) cluster.EXPECT().GetClient().Return(k8s) - k8s.EXPECT().Status().Return(&fakeStatusWriter{t: t, expectClear: kcpv1alpha1.LogicalClusterInitializer(initializerName), err: nil}) + k8s.EXPECT().Status().Return(&fakeStatusWriter{t: t, expectClear: kcpcorev1alpha1.LogicalClusterInitializer(initializerName), err: nil}) - lc := &kcpv1alpha1.LogicalCluster{} - lc.Status.Initializers = []kcpv1alpha1.LogicalClusterInitializer{ - kcpv1alpha1.LogicalClusterInitializer(initializerName), + lc := &kcpcorev1alpha1.LogicalCluster{} + lc.Status.Initializers = []kcpcorev1alpha1.LogicalClusterInitializer{ + kcpcorev1alpha1.LogicalClusterInitializer(initializerName), "another.initializer", } lc.Annotations = map[string]string{"kcp.io/path": "root:org:test"} @@ -98,11 +98,11 @@ func TestRemoveInitializer_Process(t *testing.T) { // Secret exists so we hit the patch failure path runtimeClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "portal-client-secret-test", Namespace: subroutine.PortalClientSecretNamespace}, mock.Anything).Return(nil) cluster.EXPECT().GetClient().Return(k8s) - k8s.EXPECT().Status().Return(&fakeStatusWriter{t: t, expectClear: kcpv1alpha1.LogicalClusterInitializer(initializerName), err: assert.AnError}) + k8s.EXPECT().Status().Return(&fakeStatusWriter{t: t, expectClear: kcpcorev1alpha1.LogicalClusterInitializer(initializerName), err: assert.AnError}) - lc := &kcpv1alpha1.LogicalCluster{} - lc.Status.Initializers = []kcpv1alpha1.LogicalClusterInitializer{ - kcpv1alpha1.LogicalClusterInitializer(initializerName), + lc := &kcpcorev1alpha1.LogicalCluster{} + lc.Status.Initializers = []kcpcorev1alpha1.LogicalClusterInitializer{ + kcpcorev1alpha1.LogicalClusterInitializer(initializerName), } lc.Annotations = map[string]string{"kcp.io/path": "root:org:test"} @@ -120,9 +120,9 @@ func TestRemoveInitializer_Process(t *testing.T) { // Simulate NotFound error runtimeClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "portal-client-secret-test", Namespace: subroutine.PortalClientSecretNamespace}, mock.Anything).Return(apierrors.NewNotFound(schema.GroupResource{Group: "", Resource: "secrets"}, "portal-client-secret-test")) - lc := &kcpv1alpha1.LogicalCluster{} - lc.Status.Initializers = []kcpv1alpha1.LogicalClusterInitializer{ - kcpv1alpha1.LogicalClusterInitializer(initializerName), + lc := &kcpcorev1alpha1.LogicalCluster{} + lc.Status.Initializers = []kcpcorev1alpha1.LogicalClusterInitializer{ + kcpcorev1alpha1.LogicalClusterInitializer(initializerName), } lc.Annotations = map[string]string{"kcp.io/path": "root:org:test"} lc.CreationTimestamp.Time = time.Now().Add(-30 * time.Second) @@ -142,9 +142,9 @@ func TestRemoveInitializer_Process(t *testing.T) { // Simulate NotFound error runtimeClient.EXPECT().Get(mock.Anything, types.NamespacedName{Name: "portal-client-secret-test", Namespace: subroutine.PortalClientSecretNamespace}, mock.Anything).Return(apierrors.NewNotFound(schema.GroupResource{Group: "", Resource: "secrets"}, "portal-client-secret-test")) - lc := &kcpv1alpha1.LogicalCluster{} - lc.Status.Initializers = []kcpv1alpha1.LogicalClusterInitializer{ - kcpv1alpha1.LogicalClusterInitializer(initializerName), + lc := &kcpcorev1alpha1.LogicalCluster{} + lc.Status.Initializers = []kcpcorev1alpha1.LogicalClusterInitializer{ + kcpcorev1alpha1.LogicalClusterInitializer(initializerName), } lc.Annotations = map[string]string{"kcp.io/path": "root:org:test"} lc.CreationTimestamp.Time = time.Now().Add(-2 * time.Minute) @@ -163,7 +163,7 @@ func TestRemoveInitializer_Misc(t *testing.T) { assert.Equal(t, "RemoveInitializer", r.GetName()) assert.Equal(t, []string{}, r.Finalizers(nil)) - _, err := r.Finalize(context.Background(), &kcpv1alpha1.LogicalCluster{}) + _, err := r.Finalize(context.Background(), &kcpcorev1alpha1.LogicalCluster{}) assert.Nil(t, err) } @@ -174,6 +174,6 @@ func TestRemoveInitializer_ManagerError(t *testing.T) { runtimeClient := mocks.NewMockClient(t) r := subroutine.NewRemoveInitializer(mgr, config.Config{InitializerName: "foo.initializer.kcp.dev", SecretWaitingTimeoutInSeconds: 60}, runtimeClient) - _, err := r.Process(context.Background(), &kcpv1alpha1.LogicalCluster{}) + _, err := r.Process(context.Background(), &kcpcorev1alpha1.LogicalCluster{}) assert.NotNil(t, err) } diff --git a/internal/subroutine/worksapce_authorization.go b/internal/subroutine/worksapce_authorization.go index 727206ab..54dcf39f 100644 --- a/internal/subroutine/worksapce_authorization.go +++ b/internal/subroutine/worksapce_authorization.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" kcptenancyv1alphav1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" @@ -46,7 +46,7 @@ func (r *workspaceAuthSubroutine) Finalize(ctx context.Context, instance runtime } func (r *workspaceAuthSubroutine) Process(ctx context.Context, instance runtimeobject.RuntimeObject) (reconcile.Result, errors.OperatorError) { - lc := instance.(*kcpv1alpha1.LogicalCluster) + lc := instance.(*kcpcorev1alpha1.LogicalCluster) workspaceName := getWorkspaceName(lc) if workspaceName == "" { diff --git a/internal/subroutine/workspace_authorization_test.go b/internal/subroutine/workspace_authorization_test.go index 6d968c9b..6197de67 100644 --- a/internal/subroutine/workspace_authorization_test.go +++ b/internal/subroutine/workspace_authorization_test.go @@ -5,7 +5,7 @@ import ( "errors" "testing" - kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" kcptenancyv1alphav1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1" "github.com/platform-mesh/security-operator/internal/config" "github.com/platform-mesh/security-operator/internal/subroutine/mocks" @@ -23,7 +23,7 @@ import ( func TestWorkspaceAuthSubroutine_Process(t *testing.T) { tests := []struct { name string - logicalCluster *kcpv1alpha1.LogicalCluster + logicalCluster *kcpcorev1alpha1.LogicalCluster cfg config.Config setupMocks func(*mocks.MockClient) expectError bool @@ -31,7 +31,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }{ { name: "success - create new WorkspaceAuthenticationConfiguration", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test-workspace", @@ -59,7 +59,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "success - update existing WorkspaceAuthenticationConfiguration", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:existing-workspace", @@ -97,7 +97,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "error - missing workspace path annotation", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{}, }, @@ -109,7 +109,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "error - empty workspace path annotation", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "", @@ -123,7 +123,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "error - create fails", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test-workspace", @@ -143,7 +143,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "error - update fails", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test-workspace", @@ -167,7 +167,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "error - get fails with non-not-found error", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test-workspace", @@ -184,7 +184,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "success - workspace path with single element", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "single-workspace", @@ -209,7 +209,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "success - workspace path with single element and domain CA lookup", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "single-workspace", diff --git a/internal/subroutine/workspace_initializer.go b/internal/subroutine/workspace_initializer.go index 428c4181..bc01ae64 100644 --- a/internal/subroutine/workspace_initializer.go +++ b/internal/subroutine/workspace_initializer.go @@ -6,7 +6,7 @@ import ( "os" "strings" - kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" accountsv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" @@ -58,7 +58,7 @@ func (w *workspaceInitializer) Finalizers(_ runtimeobject.RuntimeObject) []strin func (w *workspaceInitializer) GetName() string { return "WorkspaceInitializer" } func (w *workspaceInitializer) Process(ctx context.Context, instance runtimeobject.RuntimeObject) (ctrl.Result, errors.OperatorError) { - lc := instance.(*kcpv1alpha1.LogicalCluster) + lc := instance.(*kcpcorev1alpha1.LogicalCluster) store := v1alpha1.Store{ ObjectMeta: metav1.ObjectMeta{Name: generateStoreName(lc)}, @@ -111,7 +111,7 @@ func (w *workspaceInitializer) Process(ctx context.Context, instance runtimeobje return ctrl.Result{}, nil } -func generateStoreName(lc *kcpv1alpha1.LogicalCluster) string { +func generateStoreName(lc *kcpcorev1alpha1.LogicalCluster) string { if path, ok := lc.Annotations["kcp.io/path"]; ok { pathElements := strings.Split(path, ":") return pathElements[len(pathElements)-1] From c5b75fabf6835ef0820cd69dfca8c715345fb3a5 Mon Sep 17 00:00:00 2001 From: OlegErshov Date: Fri, 26 Dec 2025 13:49:53 +0100 Subject: [PATCH 5/8] chore: updated go.mod file On-behalf-of: SAP aleh.yarshou@sap.com --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index eb6371fb..2e64de7e 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,6 @@ require ( github.com/spf13/viper v1.21.0 github.com/stretchr/testify v1.11.1 golang.org/x/oauth2 v0.34.0 - golang.org/x/sync v0.19.0 google.golang.org/grpc v1.78.0 google.golang.org/protobuf v1.36.11 k8s.io/api v0.35.0 @@ -108,6 +107,7 @@ require ( golang.org/x/crypto v0.46.0 // indirect golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 // indirect golang.org/x/net v0.48.0 // indirect + golang.org/x/sync v0.19.0 // indirect golang.org/x/sys v0.39.0 // indirect golang.org/x/term v0.38.0 // indirect golang.org/x/text v0.32.0 // indirect From e3bd7fdd1142a2fdcdd5be73b970dba93038dfd4 Mon Sep 17 00:00:00 2001 From: OlegErshov Date: Sun, 28 Dec 2025 14:36:56 +0100 Subject: [PATCH 6/8] chore: added apiExportEndpointSlice name reading from the config On-behalf-of: SAP aleh.yarshou@sap.com --- cmd/model_generator.go | 2 +- cmd/operator.go | 2 +- internal/config/config.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/model_generator.go b/cmd/model_generator.go index e923069b..f334d6d7 100644 --- a/cmd/model_generator.go +++ b/cmd/model_generator.go @@ -75,7 +75,7 @@ var modelGeneratorCmd = &cobra.Command{ setupLog.Error(err, "unable to create provider config") return err } - provider, err := apiexport.New(providerConfig, "core.platform-mesh.io", apiexport.Options{ + provider, err := apiexport.New(providerConfig, operatorCfg.APIExportEndpointSliceName, apiexport.Options{ Scheme: mgrOpts.Scheme, }) if err != nil { diff --git a/cmd/operator.go b/cmd/operator.go index 5ad009ac..ed12df71 100644 --- a/cmd/operator.go +++ b/cmd/operator.go @@ -148,7 +148,7 @@ var operatorCmd = &cobra.Command{ setupLog.Error(err, "unable to create provider config") return err } - provider, err := apiexport.New(providerConfig, "core.platform-mesh.io", apiexport.Options{ + provider, err := apiexport.New(providerConfig, operatorCfg.APIExportEndpointSliceName, apiexport.Options{ Scheme: mgrOpts.Scheme, }) if err != nil { diff --git a/internal/config/config.go b/internal/config/config.go index dc5dd7c8..4004cced 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,7 +14,7 @@ type Config struct { KCP struct { Kubeconfig string `mapstructure:"kcp-kubeconfig" default:"/api-kubeconfig/kubeconfig"` } `mapstructure:",squash"` - APIExportEndpointSliceName string `mapstructure:"api-export-endpoint-slice-name"` + APIExportEndpointSliceName string `mapstructure:"api-export-endpoint-slice-name" default:"core.platform-mesh.io"` CoreModulePath string `mapstructure:"core-module-path"` WorkspaceDir string `mapstructure:"workspace-dir" default:"/operator/"` BaseDomain string `mapstructure:"base-domain" default:"portal.dev.local:8443"` From 46493350e006544b71ad566287c9fe2f7f3ed80b Mon Sep 17 00:00:00 2001 From: OlegErshov Date: Fri, 9 Jan 2026 16:01:20 +0100 Subject: [PATCH 7/8] fixed imports On-behalf-of: SAP aleh.yarshou@sap.com --- internal/subroutine/idp.go | 6 +++--- internal/subroutine/workspace_authorization.go | 4 ++-- internal/subroutine/workspace_authorization_test.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/subroutine/idp.go b/internal/subroutine/idp.go index 25cd77f2..578ba652 100644 --- a/internal/subroutine/idp.go +++ b/internal/subroutine/idp.go @@ -6,7 +6,7 @@ import ( "slices" "strings" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" @@ -56,7 +56,7 @@ func (w *IDPSubroutine) Finalizers(_ runtimeobject.RuntimeObject) []string { func (w *IDPSubroutine) GetName() string { return "IDPSubroutine" } func (w *IDPSubroutine) Process(ctx context.Context, instance runtimeobject.RuntimeObject) (ctrl.Result, errors.OperatorError) { - lc := instance.(*kcpv1alpha1.LogicalCluster) + lc := instance.(*kcpcorev1alpha1.LogicalCluster) workspaceName := getWorkspaceName(lc) if workspaceName == "" { @@ -123,7 +123,7 @@ func (w *IDPSubroutine) Process(ctx context.Context, instance runtimeobject.Runt return ctrl.Result{}, nil } -func getWorkspaceName(lc *kcpv1alpha1.LogicalCluster) string { +func getWorkspaceName(lc *kcpcorev1alpha1.LogicalCluster) string { if path, ok := lc.Annotations["kcp.io/path"]; ok { pathElements := strings.Split(path, ":") return pathElements[len(pathElements)-1] diff --git a/internal/subroutine/workspace_authorization.go b/internal/subroutine/workspace_authorization.go index 411aa3ec..e850785e 100644 --- a/internal/subroutine/workspace_authorization.go +++ b/internal/subroutine/workspace_authorization.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" kcptenancyv1alphav1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" @@ -53,7 +53,7 @@ func (r *workspaceAuthSubroutine) Finalize(ctx context.Context, instance runtime } func (r *workspaceAuthSubroutine) Process(ctx context.Context, instance runtimeobject.RuntimeObject) (reconcile.Result, errors.OperatorError) { - lc := instance.(*kcpv1alpha1.LogicalCluster) + lc := instance.(*kcpcorev1alpha1.LogicalCluster) workspaceName := getWorkspaceName(lc) if workspaceName == "" { diff --git a/internal/subroutine/workspace_authorization_test.go b/internal/subroutine/workspace_authorization_test.go index acba2965..2f4cb119 100644 --- a/internal/subroutine/workspace_authorization_test.go +++ b/internal/subroutine/workspace_authorization_test.go @@ -355,7 +355,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "error - patchWorkspaceType fails for -org", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test-workspace", @@ -382,7 +382,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "error - patchWorkspaceType fails for -acc", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test-workspace", @@ -417,7 +417,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "error - domain CA secret Get fails", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:test-workspace", @@ -439,7 +439,7 @@ func TestWorkspaceAuthSubroutine_Process(t *testing.T) { }, { name: "success - allow unverified emails in development mode", - logicalCluster: &kcpv1alpha1.LogicalCluster{ + logicalCluster: &kcpcorev1alpha1.LogicalCluster{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kcp.io/path": "root:orgs:dev-workspace", From 301efbf568bd673dfb224843017d9708d595c1d2 Mon Sep 17 00:00:00 2001 From: OlegErshov Date: Fri, 9 Jan 2026 16:09:43 +0100 Subject: [PATCH 8/8] fix: more imports fixes On-behalf-of: SAP aleh.yarshou@sap.com --- Taskfile.yaml | 2 +- go.mod | 1 - go.sum | 2 -- internal/subroutine/idp_test.go | 2 +- internal/subroutine/workspace_authorization.go | 2 +- internal/test/integration/suite_test.go | 2 +- 6 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 7f81e10a..35cb7421 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -41,7 +41,7 @@ tasks: setup:kcp-api-gen: internal: true cmds: - - test -s {{.LOCAL_BIN}}/apigen || GOBIN=$(pwd)/{{.LOCAL_BIN}} go install github.com/kcp-dev/kcp/sdk/cmd/apigen@{{.KCP_APIGEN_VERSION}} + - test -s {{.LOCAL_BIN}}/apigen || GOBIN=$(pwd)/{{.LOCAL_BIN}} go install github.com/kcp-dev/sdk/cmd/apigen@{{.KCP_APIGEN_VERSION}} setup:kcp: cmds: - test -s {{.LOCAL_BIN}}/kcp || GOBIN=$(pwd)/{{.LOCAL_BIN}} ./hack/download-tool.sh https://github.com/kcp-dev/kcp/releases/download/v{{ .KCP_VERSION }}/kcp_{{ .KCP_VERSION }}_{{ .GOOS }}_{{ .GOARCH }}.tar.gz kcp {{.KCP_VERSION}} diff --git a/go.mod b/go.mod index 94b56194..9ed0c71f 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/fluxcd/source-controller/api v1.7.4 github.com/go-logr/logr v1.4.3 github.com/google/gnostic-models v0.7.1 - github.com/kcp-dev/kcp/sdk v0.28.1-0.20250926104223-cec2e15f24c6 github.com/kcp-dev/logicalcluster/v3 v3.0.5 github.com/kcp-dev/multicluster-provider v0.3.3 github.com/kcp-dev/sdk v0.28.1-0.20251209130449-436a0347809b diff --git a/go.sum b/go.sum index 83fed5fa..5a7d132d 100644 --- a/go.sum +++ b/go.sum @@ -112,8 +112,6 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983 h1:4hCauFTFMwvIhwL9fqZ5omjeZ+vsOUNO1tLsrCeprxM= github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983/go.mod h1:DOv0iw5tcgzFBhudwLFe2WHCLqtlgNkuO4AcqbZ4zVo= -github.com/kcp-dev/kcp/sdk v0.28.1-0.20250926104223-cec2e15f24c6 h1:bOR4mdLD24VCJRrHxmtTh21AdbbzkBBKkEh0ngL+XTc= -github.com/kcp-dev/kcp/sdk v0.28.1-0.20250926104223-cec2e15f24c6/go.mod h1:aC2BPGPvy8QtkI2gQNH9NfW6xpfGIKZkR93gy9O02BE= github.com/kcp-dev/logicalcluster/v3 v3.0.5 h1:JbYakokb+5Uinz09oTXomSUJVQsqfxEvU4RyHUYxHOU= github.com/kcp-dev/logicalcluster/v3 v3.0.5/go.mod h1:EWBUBxdr49fUB1cLMO4nOdBWmYifLbP1LfoL20KkXYY= github.com/kcp-dev/multicluster-provider v0.3.3 h1:wTu1Zbk6+kVlB/d/K9TM7KPjUEe/Dg8SYzKQsVDiDFY= diff --git a/internal/subroutine/idp_test.go b/internal/subroutine/idp_test.go index e4573c9e..064a6b2f 100644 --- a/internal/subroutine/idp_test.go +++ b/internal/subroutine/idp_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - kcpv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" + kcpv1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" accountv1alpha1 "github.com/platform-mesh/account-operator/api/v1alpha1" "github.com/platform-mesh/golang-commons/logger/testlogger" secopv1alpha1 "github.com/platform-mesh/security-operator/api/v1alpha1" diff --git a/internal/subroutine/workspace_authorization.go b/internal/subroutine/workspace_authorization.go index e850785e..12378940 100644 --- a/internal/subroutine/workspace_authorization.go +++ b/internal/subroutine/workspace_authorization.go @@ -5,7 +5,7 @@ import ( "fmt" kcpcorev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" - kcptenancyv1alphav1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1" + kcptenancyv1alphav1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1" "github.com/platform-mesh/golang-commons/controller/lifecycle/runtimeobject" lifecyclesubroutine "github.com/platform-mesh/golang-commons/controller/lifecycle/subroutine" "github.com/platform-mesh/golang-commons/errors" diff --git a/internal/test/integration/suite_test.go b/internal/test/integration/suite_test.go index ffa35f8f..a5db330e 100644 --- a/internal/test/integration/suite_test.go +++ b/internal/test/integration/suite_test.go @@ -21,7 +21,7 @@ import ( mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager" "sigs.k8s.io/yaml" - "github.com/kcp-dev/kcp/sdk/apis/core" + "github.com/kcp-dev/sdk/apis/core" "github.com/kcp-dev/logicalcluster/v3" "github.com/kcp-dev/multicluster-provider/apiexport" clusterclient "github.com/kcp-dev/multicluster-provider/client"