diff --git a/Makefile b/Makefile index 649eb632..369c46d2 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ ORG := github.com/operator-framework PKG := $(ORG)/rukpak export IMAGE_REPO ?= quay.io/operator-framework/rukpak -export IMAGE_TAG ?= main +export IMAGE_TAG ?= devel export GO_BUILD_TAGS ?= '' IMAGE?=$(IMAGE_REPO):$(IMAGE_TAG) KIND_CLUSTER_NAME ?= rukpak @@ -111,7 +111,7 @@ test-e2e: $(GINKGO) ## Run the e2e tests $(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) --trace $(FOCUS) test/e2e e2e: KIND_CLUSTER_NAME=rukpak-e2e -e2e: rukpakctl run image-registry local-git kind-load-bundles registry-load-bundles test-e2e ## Run e2e tests against an ephemeral kind cluster +e2e: rukpakctl run image-registry local-git kind-load-bundles registry-load-bundles test-e2e kind-cluster-cleanup ## Run e2e tests against an ephemeral kind cluster kind-cluster: $(KIND) kind-cluster-cleanup ## Standup a kind cluster $(KIND) create cluster --name ${KIND_CLUSTER_NAME} ${KIND_CLUSTER_CONFIG} diff --git a/api/v1alpha1/bundle_types.go b/api/v1alpha2/bundle_types.go similarity index 99% rename from api/v1alpha1/bundle_types.go rename to api/v1alpha2/bundle_types.go index 489d2713..e32de58a 100644 --- a/api/v1alpha1/bundle_types.go +++ b/api/v1alpha2/bundle_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1alpha2 import ( corev1 "k8s.io/api/core/v1" @@ -134,5 +134,3 @@ type Authorization struct { type UploadSource struct{} type ProvisionerID string - - diff --git a/api/v1alpha1/bundledeployment_types.go b/api/v1alpha2/bundledeployment_types.go similarity index 99% rename from api/v1alpha1/bundledeployment_types.go rename to api/v1alpha2/bundledeployment_types.go index ed954532..eb67eb9a 100644 --- a/api/v1alpha1/bundledeployment_types.go +++ b/api/v1alpha2/bundledeployment_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1alpha2 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -59,7 +59,6 @@ type BundleDeploymentSpec struct { Config runtime.RawExtension `json:"config,omitempty"` } - // BundleDeploymentStatus defines the observed state of BundleDeployment type BundleDeploymentStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` diff --git a/api/v1alpha1/groupversion_info.go b/api/v1alpha2/groupversion_info.go similarity index 90% rename from api/v1alpha1/groupversion_info.go rename to api/v1alpha2/groupversion_info.go index 9101801a..8d403954 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/v1alpha2/groupversion_info.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha1 contains API Schema definitions for the core v1alpha1 API group +// Package v1alpha2 contains API Schema definitions for the core v1alpha2 API group // +kubebuilder:object:generate=true // +groupName=core.rukpak.io -package v1alpha1 +package v1alpha2 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "core.rukpak.io", Version: "v1alpha1"} + GroupVersion = schema.GroupVersion{Group: "core.rukpak.io", Version: "v1alpha2"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha2/zz_generated.deepcopy.go similarity index 99% rename from api/v1alpha1/zz_generated.deepcopy.go rename to api/v1alpha2/zz_generated.deepcopy.go index 07daf286..39672b3c 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha2/zz_generated.deepcopy.go @@ -19,7 +19,7 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v1alpha1 +package v1alpha2 import ( "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/cmd/core/main.go b/cmd/core/main.go index 1a35f66a..19318344 100644 --- a/cmd/core/main.go +++ b/cmd/core/main.go @@ -43,7 +43,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/controllers/bundledeployment" "github.com/operator-framework/rukpak/internal/finalizer" "github.com/operator-framework/rukpak/internal/provisioner/plain" @@ -64,7 +64,7 @@ var ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(apiextensionsv1.AddToScheme(scheme)) - utilruntime.Must(rukpakv1alpha1.AddToScheme(scheme)) + utilruntime.Must(rukpakv1alpha2.AddToScheme(scheme)) utilruntime.Must(apiregistration.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -115,7 +115,7 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) setupLog.Info("starting up the core controllers and servers", "git commit", version.String(), "unpacker image", unpackImage) - dependentRequirement, err := labels.NewRequirement(util.CoreOwnerKindKey, selection.In, []string{rukpakv1alpha1.BundleKind, rukpakv1alpha1.BundleDeploymentKind}) + dependentRequirement, err := labels.NewRequirement(util.CoreOwnerKindKey, selection.In, []string{rukpakv1alpha2.BundleKind, rukpakv1alpha2.BundleDeploymentKind}) if err != nil { setupLog.Error(err, "unable to create dependent label selector for cache") os.Exit(1) @@ -144,7 +144,7 @@ func main() { LeaderElectionID: "core.rukpak.io", NewCache: cache.BuilderWithOptions(cache.Options{ SelectorsByObject: cache.SelectorsByObject{ - &rukpakv1alpha1.BundleDeployment{}: {}, + &rukpakv1alpha2.BundleDeployment{}: {}, }, DefaultSelector: cache.ObjectSelector{ Label: dependentSelector, @@ -238,26 +238,25 @@ func main() { bundledeployment.WithStorage(bundleStorage), } - - if err := bundledeployment.SetupWithManager(mgr,systemNsCluster.GetCache(), systemNamespace,append( + if err := bundledeployment.SetupWithManager(mgr, systemNsCluster.GetCache(), systemNamespace, append( commonBDProvisionerOptions, bundledeployment.WithUnpacker(unpacker), bundledeployment.WithProvisionerID(plain.ProvisionerID), - bundledeployment.WithBundleDeplymentProcessor(bundledeployment.BundleDeploymentProcessorFunc(plain.ProcessBundleDeployment)), + bundledeployment.WithBundleDeplymentProcessor(bundledeployment.ProcessorFunc(plain.ProcessBundleDeployment)), bundledeployment.WithHandler(bundledeployment.HandlerFunc(plain.HandleBundleDeployment)), )...); err != nil { - setupLog.Error(err, "unable to create controller", "controller", rukpakv1alpha1.BundleDeploymentKind, "provisionerID", plain.ProvisionerID) + setupLog.Error(err, "unable to create controller", "controller", rukpakv1alpha2.BundleDeploymentKind, "provisionerID", plain.ProvisionerID) os.Exit(1) } - if err := bundledeployment.SetupWithManager(mgr, systemNsCluster.GetCache(), systemNamespace,append( + if err := bundledeployment.SetupWithManager(mgr, systemNsCluster.GetCache(), systemNamespace, append( commonBDProvisionerOptions, bundledeployment.WithUnpacker(unpacker), bundledeployment.WithProvisionerID(registry.ProvisionerID), - bundledeployment.WithBundleDeplymentProcessor(bundledeployment.BundleDeploymentProcessorFunc(registry.ProcessBundleDeployment)), + bundledeployment.WithBundleDeplymentProcessor(bundledeployment.ProcessorFunc(registry.ProcessBundleDeployment)), bundledeployment.WithHandler(bundledeployment.HandlerFunc(plain.HandleBundleDeployment)), )...); err != nil { - setupLog.Error(err, "unable to create controller", "controller", rukpakv1alpha1.BundleDeploymentKind, "provisionerID", plain.ProvisionerID) + setupLog.Error(err, "unable to create controller", "controller", rukpakv1alpha2.BundleDeploymentKind, "provisionerID", plain.ProvisionerID) os.Exit(1) } //+kubebuilder:scaffold:builder diff --git a/cmd/helm/main.go b/cmd/helm/main.go index 682fb2b8..904093a7 100644 --- a/cmd/helm/main.go +++ b/cmd/helm/main.go @@ -37,7 +37,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/controllers/bundledeployment" "github.com/operator-framework/rukpak/internal/finalizer" "github.com/operator-framework/rukpak/internal/provisioner/helm" @@ -55,7 +55,7 @@ var ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(apiextensionsv1.AddToScheme(scheme)) - utilruntime.Must(rukpakv1alpha1.AddToScheme(scheme)) + utilruntime.Must(rukpakv1alpha2.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -98,7 +98,7 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) setupLog.Info("starting up the provisioner", "git commit", version.String()) - dependentRequirement, err := labels.NewRequirement(util.CoreOwnerKindKey, selection.In, []string{rukpakv1alpha1.BundleDeploymentKind}) + dependentRequirement, err := labels.NewRequirement(util.CoreOwnerKindKey, selection.In, []string{rukpakv1alpha2.BundleDeploymentKind}) if err != nil { setupLog.Error(err, "unable to create dependent label selector for cache") os.Exit(1) @@ -126,7 +126,7 @@ func main() { LeaderElectionID: "helm.core.rukpak.io", NewCache: cache.BuilderWithOptions(cache.Options{ SelectorsByObject: cache.SelectorsByObject{ - &rukpakv1alpha1.BundleDeployment{}: {}, + &rukpakv1alpha2.BundleDeployment{}: {}, }, DefaultSelector: cache.ObjectSelector{ Label: dependentSelector, @@ -212,14 +212,14 @@ func main() { bundledeployment.WithStorage(bundleStorage), } - if err := bundledeployment.SetupWithManager(mgr, systemNsCluster.GetCache(), systemNamespace,append( + if err := bundledeployment.SetupWithManager(mgr, systemNsCluster.GetCache(), systemNamespace, append( commonBDProvisionerOptions, bundledeployment.WithProvisionerID(helm.ProvisionerID), bundledeployment.WithUnpacker(unpacker), - bundledeployment.WithBundleDeplymentProcessor(bundledeployment.BundleDeploymentProcessorFunc(helm.ProcessBundleDeployment)), + bundledeployment.WithBundleDeplymentProcessor(bundledeployment.ProcessorFunc(helm.ProcessBundleDeployment)), bundledeployment.WithHandler(bundledeployment.HandlerFunc(helm.HandleBundleDeployment)), )...); err != nil { - setupLog.Error(err, "unable to create controller", "controller", rukpakv1alpha1.BundleDeploymentKind, "provisionerID", helm.ProvisionerID) + setupLog.Error(err, "unable to create controller", "controller", rukpakv1alpha2.BundleDeploymentKind, "provisionerID", helm.ProvisionerID) os.Exit(1) } //+kubebuilder:scaffold:builder diff --git a/cmd/rukpakctl/cmd/content.go b/cmd/rukpakctl/cmd/content.go index 0b9ecfb9..18ba68aa 100644 --- a/cmd/rukpakctl/cmd/content.go +++ b/cmd/rukpakctl/cmd/content.go @@ -36,7 +36,7 @@ import ( runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/util" ) @@ -56,7 +56,7 @@ func newContentCmd() *cobra.Command { Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { sch := runtime.NewScheme() - if err := rukpakv1alpha1.AddToScheme(sch); err != nil { + if err := rukpakv1alpha2.AddToScheme(sch); err != nil { log.Fatalf("failed to add rukpak types to scheme: %v", err) } @@ -121,7 +121,7 @@ func content(ctx context.Context, opt options, args []string) error { return fmt.Errorf("failed to create a service account: %v", err) } - bundledeployment := &rukpakv1alpha1.BundleDeployment{} + bundledeployment := &rukpakv1alpha2.BundleDeployment{} err = opt.Get(ctx, runtimeclient.ObjectKey{Name: args[0]}, bundledeployment) if err != nil { return err diff --git a/cmd/webhooks/main.go b/cmd/webhooks/main.go index 9b374508..7138a5b1 100644 --- a/cmd/webhooks/main.go +++ b/cmd/webhooks/main.go @@ -30,7 +30,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" crwebhook "sigs.k8s.io/controller-runtime/pkg/webhook" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/util" "github.com/operator-framework/rukpak/internal/version" "github.com/operator-framework/rukpak/internal/webhook" @@ -43,7 +43,7 @@ var ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(rukpakv1alpha1.AddToScheme(scheme)) + utilruntime.Must(rukpakv1alpha2.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -108,7 +108,7 @@ func main() { Client: mgr.GetClient(), SystemNamespace: systemNamespace, }).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", rukpakv1alpha1.BundleDeploymentKind) + setupLog.Error(err, "unable to create webhook", "webhook", rukpakv1alpha2.BundleDeploymentKind) os.Exit(1) } if err = (&webhook.ConfigMap{ diff --git a/go.mod b/go.mod index 546fa8e3..67aaceb4 100644 --- a/go.mod +++ b/go.mod @@ -17,8 +17,8 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 - golang.org/x/crypto v0.14.0 - golang.org/x/sync v0.3.0 + golang.org/x/crypto v0.16.0 + golang.org/x/sync v0.5.0 helm.sh/helm/v3 v3.11.1 k8s.io/api v0.26.10 k8s.io/apiextensions-apiserver v0.26.10 @@ -174,14 +174,14 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.17.0 // indirect + golang.org/x/mod v0.14.0 // indirect + golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.13.0 // indirect + golang.org/x/tools v0.16.1 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect diff --git a/go.sum b/go.sum index 6062e620..db29012e 100644 --- a/go.sum +++ b/go.sum @@ -1138,8 +1138,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1177,8 +1177,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1237,8 +1237,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1269,8 +1269,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1372,15 +1372,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1393,8 +1393,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1468,8 +1468,8 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/controllers/bundledeployment/bundledeployment.go b/internal/controllers/bundledeployment/bundledeployment.go index 5fbc4f96..810f4fd0 100644 --- a/internal/controllers/bundledeployment/bundledeployment.go +++ b/internal/controllers/bundledeployment/bundledeployment.go @@ -12,7 +12,6 @@ import ( "time" helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client" - unpackersource "github.com/operator-framework/rukpak/internal/source" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chartutil" @@ -40,7 +39,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/source" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + unpackersource "github.com/operator-framework/rukpak/internal/source" + + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/healthchecks" helmpredicate "github.com/operator-framework/rukpak/internal/helm-operator-plugins/predicate" "github.com/operator-framework/rukpak/internal/storage" @@ -72,7 +73,7 @@ func WithHandler(h Handler) Option { } } -func WithBundleDeplymentProcessor(b BundleDeploymentProcessor) Option { +func WithBundleDeplymentProcessor(b Processor) Option { return func(c *controller) { c.bundleDeploymentProcessor = b } @@ -134,10 +135,10 @@ func SetupWithManager(mgr manager.Manager, systemNsCache cache.Cache, systemName l := mgr.GetLogger().WithName(controllerName) controller, err := ctrl.NewControllerManagedBy(mgr). Named(controllerName). - For(&rukpakv1alpha1.BundleDeployment{}, builder.WithPredicates( + For(&rukpakv1alpha2.BundleDeployment{}, builder.WithPredicates( util.BundleDeploymentProvisionerFilter(c.provisionerID)), ). - Watches(source.NewKindWithCache(&corev1.Pod{}, systemNsCache), util.MapOwneeToOwnerProvisionerHandler(context.Background(), mgr.GetClient(), l, c.provisionerID, &rukpakv1alpha1.BundleDeployment{})). + Watches(source.NewKindWithCache(&corev1.Pod{}, systemNsCache), util.MapOwneeToOwnerProvisionerHandler(context.Background(), mgr.GetClient(), l, c.provisionerID, &rukpakv1alpha2.BundleDeployment{})). Watches(source.NewKindWithCache(&corev1.ConfigMap{}, systemNsCache), util.MapConfigMapToBundleDeploymentHandler(context.Background(), mgr.GetClient(), systemNamespace, c.provisionerID)). Build(c) if err != nil { @@ -149,7 +150,9 @@ func SetupWithManager(mgr manager.Manager, systemNsCache cache.Cache, systemName func (c *controller) setDefaults() { if c.bundleDeploymentProcessor == nil { - c.bundleDeploymentProcessor = BundleDeploymentProcessorFunc(func(_ context.Context, fsys fs.FS, _ *rukpakv1alpha1.BundleDeployment) (fs.FS, error) { return fsys, nil }) + c.bundleDeploymentProcessor = ProcessorFunc(func(_ context.Context, fsys fs.FS, _ *rukpakv1alpha2.BundleDeployment) (fs.FS, error) { + return fsys, nil + }) } } @@ -183,16 +186,16 @@ func (c *controller) validateConfig() error { type controller struct { cl client.Client - handler Handler - bundleDeploymentProcessor BundleDeploymentProcessor - provisionerID string - acg helmclient.ActionClientGetter - storage storage.Storage - releaseNamespace string + handler Handler + bundleDeploymentProcessor Processor + provisionerID string + acg helmclient.ActionClientGetter + storage storage.Storage + releaseNamespace string - unpacker unpackersource.Unpacker + unpacker unpackersource.Unpacker controller crcontroller.Controller - finalizers crfinalizer.Finalizers + finalizers crfinalizer.Finalizers dynamicWatchMutex sync.RWMutex dynamicWatchGVKs map[schema.GroupVersionKind]struct{} } @@ -219,7 +222,7 @@ func (c *controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu l.V(1).Info("starting reconciliation") defer l.V(1).Info("ending reconciliation") - existingBD := &rukpakv1alpha1.BundleDeployment{} + existingBD := &rukpakv1alpha2.BundleDeployment{} if err := c.cl.Get(ctx, req.NamespacedName, existingBD); err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) } @@ -232,7 +235,7 @@ func (c *controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu return res, utilerrors.NewAggregate([]error{reconcileErr, updateErr}) } } - existingBD.Status, reconciledBD.Status = rukpakv1alpha1.BundleDeploymentStatus{}, rukpakv1alpha1.BundleDeploymentStatus{} + existingBD.Status, reconciledBD.Status = rukpakv1alpha2.BundleDeploymentStatus{}, rukpakv1alpha2.BundleDeploymentStatus{} if !equality.Semantic.DeepEqual(existingBD, reconciledBD) { if updateErr := c.cl.Update(ctx, reconciledBD); updateErr != nil { return res, utilerrors.NewAggregate([]error{reconcileErr, updateErr}) @@ -246,7 +249,7 @@ func (c *controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu // Today we always return ctrl.Result{} and an error. // But in the future we might update this function // to return different results (e.g. requeue). -func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDeployment) (ctrl.Result, error) { +func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha2.BundleDeployment) (ctrl.Result, error) { bd.Status.ObservedGeneration = bd.Generation // handle finalizers @@ -257,9 +260,9 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep bd.Status.ResolvedSource = nil bd.Status.ContentURL = "" meta.SetStatusCondition(&bd.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeUnpacked, + Type: rukpakv1alpha2.TypeUnpacked, Status: metav1.ConditionUnknown, - Reason: rukpakv1alpha1.ReasonProcessingFinalizerFailed, + Reason: rukpakv1alpha2.ReasonProcessingFinalizerFailed, Message: err.Error(), }) return ctrl.Result{}, err @@ -287,16 +290,16 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep case unpackersource.StatePending: updateStatusUnpackPending(&bd.Status, unpackResult) // There must a limit to number of retries if status is stuck at - // unpack pending. + // unpack pending. // Forcefully requing here, to ensure that the next reconcile - // is triggered. - // TODO: Caliberate the requeue interval if needed. - return ctrl.Result{RequeueAfter: 5*time.Second}, nil + // is triggered. + // TODO: Caliberate the requeue interval if needed. + return ctrl.Result{RequeueAfter: 5 * time.Second}, nil case unpackersource.StateUnpacking: updateStatusUnpacking(&bd.Status, unpackResult) return ctrl.Result{}, nil case unpackersource.StateUnpacked: - storeFS, err := c.bundleDeploymentProcessor.ProcessBundleDeployment(ctx, unpackResult.Bundle, bd) + storeFS, err := c.bundleDeploymentProcessor.Process(ctx, unpackResult.Bundle, bd) if err != nil { return ctrl.Result{}, updateStatusUnpackFailing(&bd.Status, err) } @@ -316,9 +319,9 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep bundleFS, err := c.storage.Load(ctx, bd) if err != nil { meta.SetStatusCondition(&bd.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeHasValidBundle, + Type: rukpakv1alpha2.TypeHasValidBundle, Status: metav1.ConditionFalse, - Reason: rukpakv1alpha1.ReasonBundleLoadFailed, + Reason: rukpakv1alpha2.ReasonBundleLoadFailed, Message: err.Error(), }) return ctrl.Result{}, err @@ -327,9 +330,9 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep chrt, values, err := c.handler.Handle(ctx, bundleFS, bd) if err != nil { meta.SetStatusCondition(&bd.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeHasValidBundle, + Type: rukpakv1alpha2.TypeHasValidBundle, Status: metav1.ConditionFalse, - Reason: rukpakv1alpha1.ReasonBundleLoadFailed, + Reason: rukpakv1alpha2.ReasonBundleLoadFailed, Message: err.Error(), }) return ctrl.Result{}, err @@ -339,20 +342,20 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep cl, err := c.acg.ActionClientFor(bd) bd.SetNamespace("") if err != nil { - setInstalledAndHealthyFalse(bd, rukpakv1alpha1.ReasonErrorGettingClient, err.Error()) + setInstalledAndHealthyFalse(bd, rukpakv1alpha2.ReasonErrorGettingClient, err.Error()) return ctrl.Result{}, err } post := &postrenderer{ labels: map[string]string{ - util.CoreOwnerKindKey: rukpakv1alpha1.BundleDeploymentKind, + util.CoreOwnerKindKey: rukpakv1alpha2.BundleDeploymentKind, util.CoreOwnerNameKey: bd.GetName(), }, } rel, state, err := c.getReleaseState(cl, bd, chrt, values, post) if err != nil { - setInstalledAndHealthyFalse(bd, rukpakv1alpha1.ReasonErrorGettingReleaseState, err.Error()) + setInstalledAndHealthyFalse(bd, rukpakv1alpha2.ReasonErrorGettingReleaseState, err.Error()) return ctrl.Result{}, err } @@ -372,7 +375,7 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep if isResourceNotFoundErr(err) { err = errRequiredResourceNotFound{err} } - setInstalledAndHealthyFalse(bd, rukpakv1alpha1.ReasonInstallFailed, err.Error()) + setInstalledAndHealthyFalse(bd, rukpakv1alpha2.ReasonInstallFailed, err.Error()) return ctrl.Result{}, err } case stateNeedsUpgrade: @@ -387,7 +390,7 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep if isResourceNotFoundErr(err) { err = errRequiredResourceNotFound{err} } - setInstalledAndHealthyFalse(bd, rukpakv1alpha1.ReasonUpgradeFailed, err.Error()) + setInstalledAndHealthyFalse(bd, rukpakv1alpha2.ReasonUpgradeFailed, err.Error()) return ctrl.Result{}, err } case stateUnchanged: @@ -395,7 +398,7 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep if isResourceNotFoundErr(err) { err = errRequiredResourceNotFound{err} } - setInstalledAndHealthyFalse(bd, rukpakv1alpha1.ReasonReconcileFailed, err.Error()) + setInstalledAndHealthyFalse(bd, rukpakv1alpha2.ReasonReconcileFailed, err.Error()) return ctrl.Result{}, err } default: @@ -404,14 +407,14 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep relObjects, err := util.ManifestObjects(strings.NewReader(rel.Manifest), fmt.Sprintf("%s-release-manifest", rel.Name)) if err != nil { - setInstalledAndHealthyFalse(bd, rukpakv1alpha1.ReasonCreateDynamicWatchFailed, err.Error()) + setInstalledAndHealthyFalse(bd, rukpakv1alpha2.ReasonCreateDynamicWatchFailed, err.Error()) return ctrl.Result{}, err } for _, obj := range relObjects { uMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) if err != nil { - setInstalledAndHealthyFalse(bd, rukpakv1alpha1.ReasonCreateDynamicWatchFailed, err.Error()) + setInstalledAndHealthyFalse(bd, rukpakv1alpha2.ReasonCreateDynamicWatchFailed, err.Error()) return ctrl.Result{}, err } @@ -432,31 +435,31 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep } return nil }(); err != nil { - setInstalledAndHealthyFalse(bd, rukpakv1alpha1.ReasonCreateDynamicWatchFailed, err.Error()) + setInstalledAndHealthyFalse(bd, rukpakv1alpha2.ReasonCreateDynamicWatchFailed, err.Error()) return ctrl.Result{}, err } } meta.SetStatusCondition(&bd.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeInstalled, + Type: rukpakv1alpha2.TypeInstalled, Status: metav1.ConditionTrue, - Reason: rukpakv1alpha1.ReasonInstallationSucceeded, + Reason: rukpakv1alpha2.ReasonInstallationSucceeded, Message: fmt.Sprintf("Instantiated bundle %s successfully", bd.GetName()), }) if features.RukpakFeatureGate.Enabled(features.BundleDeploymentHealth) { if err = healthchecks.AreObjectsHealthy(ctx, c.cl, relObjects); err != nil { meta.SetStatusCondition(&bd.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeHealthy, + Type: rukpakv1alpha2.TypeHealthy, Status: metav1.ConditionFalse, - Reason: rukpakv1alpha1.ReasonUnhealthy, + Reason: rukpakv1alpha2.ReasonUnhealthy, Message: err.Error(), }) return ctrl.Result{}, err } meta.SetStatusCondition(&bd.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeHealthy, + Type: rukpakv1alpha2.TypeHealthy, Status: metav1.ConditionTrue, - Reason: rukpakv1alpha1.ReasonHealthy, + Reason: rukpakv1alpha2.ReasonHealthy, Message: "BundleDeployment is healthy", }) } @@ -466,9 +469,9 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep // setInstalledAndHealthyFalse sets the Installed and if the feature gate is enabled, the Healthy conditions to False, // and allows to set the Installed condition reason and message. -func setInstalledAndHealthyFalse(bd *rukpakv1alpha1.BundleDeployment, installedConditionReason, installedConditionMessage string) { +func setInstalledAndHealthyFalse(bd *rukpakv1alpha2.BundleDeployment, installedConditionReason, installedConditionMessage string) { meta.SetStatusCondition(&bd.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeInstalled, + Type: rukpakv1alpha2.TypeInstalled, Status: metav1.ConditionFalse, Reason: installedConditionReason, Message: installedConditionMessage, @@ -476,32 +479,14 @@ func setInstalledAndHealthyFalse(bd *rukpakv1alpha1.BundleDeployment, installedC if features.RukpakFeatureGate.Enabled(features.BundleDeploymentHealth) { meta.SetStatusCondition(&bd.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeHealthy, + Type: rukpakv1alpha2.TypeHealthy, Status: metav1.ConditionFalse, - Reason: rukpakv1alpha1.ReasonInstallationStatusFalse, + Reason: rukpakv1alpha2.ReasonInstallationStatusFalse, Message: "Installed condition is false", }) } } -// reconcileOldBundles is responsible for garbage collecting any Bundles -// that no longer match the desired Bundle template. -func (c *controller) reconcileOldBundles(ctx context.Context, currBundle *rukpakv1alpha1.BundleDeployment, allBundles *rukpakv1alpha1.BundleDeploymentList) error { - var ( - errors []error - ) - for i := range allBundles.Items { - if allBundles.Items[i].GetName() == currBundle.GetName() { - continue - } - if err := c.cl.Delete(ctx, &allBundles.Items[i]); err != nil { - errors = append(errors, err) - continue - } - } - return utilerrors.NewAggregate(errors) -} - type releaseState string const ( @@ -601,49 +586,47 @@ func (p *postrenderer) Run(renderedManifests *bytes.Buffer) (*bytes.Buffer, erro return &buf, nil } - -func updateStatusUnpackFailing(status *rukpakv1alpha1.BundleDeploymentStatus, err error) error { +func updateStatusUnpackFailing(status *rukpakv1alpha2.BundleDeploymentStatus, err error) error { status.ResolvedSource = nil status.ContentURL = "" meta.SetStatusCondition(&status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeUnpacked, + Type: rukpakv1alpha2.TypeUnpacked, Status: metav1.ConditionFalse, - Reason: rukpakv1alpha1.ReasonUnpackFailed, + Reason: rukpakv1alpha2.ReasonUnpackFailed, Message: err.Error(), }) return err } - -func updateStatusUnpackPending(status *rukpakv1alpha1.BundleDeploymentStatus, result *unpackersource.Result) { +func updateStatusUnpackPending(status *rukpakv1alpha2.BundleDeploymentStatus, result *unpackersource.Result) { status.ResolvedSource = nil status.ContentURL = "" meta.SetStatusCondition(&status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeUnpacked, + Type: rukpakv1alpha2.TypeUnpacked, Status: metav1.ConditionFalse, - Reason: rukpakv1alpha1.ReasonUnpackPending, + Reason: rukpakv1alpha2.ReasonUnpackPending, Message: result.Message, }) } -func updateStatusUnpacking(status *rukpakv1alpha1.BundleDeploymentStatus, result *unpackersource.Result) { +func updateStatusUnpacking(status *rukpakv1alpha2.BundleDeploymentStatus, result *unpackersource.Result) { status.ResolvedSource = nil status.ContentURL = "" meta.SetStatusCondition(&status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeUnpacked, + Type: rukpakv1alpha2.TypeUnpacked, Status: metav1.ConditionFalse, - Reason: rukpakv1alpha1.ReasonUnpacking, + Reason: rukpakv1alpha2.ReasonUnpacking, Message: result.Message, }) } -func updateStatusUnpacked(status *rukpakv1alpha1.BundleDeploymentStatus, result *unpackersource.Result, contentURL string) { +func updateStatusUnpacked(status *rukpakv1alpha2.BundleDeploymentStatus, result *unpackersource.Result, contentURL string) { status.ResolvedSource = result.ResolvedSource status.ContentURL = contentURL meta.SetStatusCondition(&status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeUnpacked, + Type: rukpakv1alpha2.TypeUnpacked, Status: metav1.ConditionTrue, - Reason: rukpakv1alpha1.ReasonUnpackSuccessful, + Reason: rukpakv1alpha2.ReasonUnpackSuccessful, Message: result.Message, }) } diff --git a/internal/controllers/bundledeployment/bundledeployment_test.go b/internal/controllers/bundledeployment/bundledeployment_test.go index bee00e7d..a9a9c929 100644 --- a/internal/controllers/bundledeployment/bundledeployment_test.go +++ b/internal/controllers/bundledeployment/bundledeployment_test.go @@ -12,7 +12,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/util" ) @@ -33,7 +33,7 @@ var _ = Describe("BundleDeployment", func() { BeforeEach(func() { postren = &postrenderer{ labels: map[string]string{ - util.CoreOwnerKindKey: rukpakv1alpha1.BundleDeploymentKind, + util.CoreOwnerKindKey: rukpakv1alpha2.BundleDeploymentKind, util.CoreOwnerNameKey: "test-owner", }, } diff --git a/internal/controllers/bundledeployment/interfaces.go b/internal/controllers/bundledeployment/interfaces.go index bf6b141e..803422ff 100644 --- a/internal/controllers/bundledeployment/interfaces.go +++ b/internal/controllers/bundledeployment/interfaces.go @@ -7,28 +7,28 @@ import ( "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chartutil" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) type Handler interface { - Handle(context.Context, fs.FS, *rukpakv1alpha1.BundleDeployment) (*chart.Chart, chartutil.Values, error) + Handle(context.Context, fs.FS, *rukpakv1alpha2.BundleDeployment) (*chart.Chart, chartutil.Values, error) } -type HandlerFunc func(context.Context, fs.FS, *rukpakv1alpha1.BundleDeployment) (*chart.Chart, chartutil.Values, error) +type HandlerFunc func(context.Context, fs.FS, *rukpakv1alpha2.BundleDeployment) (*chart.Chart, chartutil.Values, error) -func (f HandlerFunc) Handle(ctx context.Context, fsys fs.FS, bd *rukpakv1alpha1.BundleDeployment) (*chart.Chart, chartutil.Values, error) { +func (f HandlerFunc) Handle(ctx context.Context, fsys fs.FS, bd *rukpakv1alpha2.BundleDeployment) (*chart.Chart, chartutil.Values, error) { return f(ctx, fsys, bd) } // TODO: Having two interfaces with same parameters seems unnecessary. This should ideally // be moved to HandleBundleDeployment. With it, we can remove the additional step of loading from -// store. -type BundleDeploymentProcessor interface { - ProcessBundleDeployment(context.Context, fs.FS, *rukpakv1alpha1.BundleDeployment) (fs.FS, error) +// store. +type Processor interface { + Process(context.Context, fs.FS, *rukpakv1alpha2.BundleDeployment) (fs.FS, error) } -type BundleDeploymentProcessorFunc func(context.Context, fs.FS, *rukpakv1alpha1.BundleDeployment) (fs.FS, error) +type ProcessorFunc func(context.Context, fs.FS, *rukpakv1alpha2.BundleDeployment) (fs.FS, error) -func (f BundleDeploymentProcessorFunc) ProcessBundleDeployment(ctx context.Context, fsys fs.FS, b *rukpakv1alpha1.BundleDeployment) (fs.FS, error) { +func (f ProcessorFunc) Process(ctx context.Context, fsys fs.FS, b *rukpakv1alpha2.BundleDeployment) (fs.FS, error) { return f(ctx, fsys, b) } diff --git a/internal/provisioner/helm/helm.go b/internal/provisioner/helm/helm.go index e6ede642..4b0c4832 100644 --- a/internal/provisioner/helm/helm.go +++ b/internal/provisioner/helm/helm.go @@ -12,7 +12,7 @@ import ( "helm.sh/helm/v3/pkg/chart/loader" "helm.sh/helm/v3/pkg/chartutil" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/util" ) @@ -21,7 +21,7 @@ const ( ProvisionerID = "core-rukpak-io-helm" ) -func ProcessBundleDeployment(_ context.Context, fsys fs.FS, _ *rukpakv1alpha1.BundleDeployment) (fs.FS, error) { +func ProcessBundleDeployment(_ context.Context, fsys fs.FS, _ *rukpakv1alpha2.BundleDeployment) (fs.FS, error) { // Helm expects an FS whose root contains a single chart directory. Depending on how // the bundle is sourced, the FS may or may not contain this single chart directory in // its root (e.g. charts uploaded via 'rukpakctl run ') would not. @@ -37,7 +37,7 @@ func ProcessBundleDeployment(_ context.Context, fsys fs.FS, _ *rukpakv1alpha1.Bu return chartFS, nil } -func HandleBundleDeployment(_ context.Context, fsys fs.FS, bd *rukpakv1alpha1.BundleDeployment) (*chart.Chart, chartutil.Values, error) { +func HandleBundleDeployment(_ context.Context, fsys fs.FS, bd *rukpakv1alpha2.BundleDeployment) (*chart.Chart, chartutil.Values, error) { values, err := loadValues(bd) if err != nil { return nil, nil, err @@ -49,7 +49,7 @@ func HandleBundleDeployment(_ context.Context, fsys fs.FS, bd *rukpakv1alpha1.Bu return chart, values, nil } -func loadValues(bd *rukpakv1alpha1.BundleDeployment) (chartutil.Values, error) { +func loadValues(bd *rukpakv1alpha2.BundleDeployment) (chartutil.Values, error) { data, err := json.Marshal(bd.Spec.Config) if err != nil { return nil, fmt.Errorf("marshal JSON for deployment config: %v", err) diff --git a/internal/provisioner/plain/plain.go b/internal/provisioner/plain/plain.go index 387768a2..9516503b 100644 --- a/internal/provisioner/plain/plain.go +++ b/internal/provisioner/plain/plain.go @@ -13,7 +13,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/util" ) @@ -24,14 +24,14 @@ const ( manifestsDir = "manifests" ) -func ProcessBundleDeployment(_ context.Context, fsys fs.FS, _ *rukpakv1alpha1.BundleDeployment) (fs.FS, error) { +func ProcessBundleDeployment(_ context.Context, fsys fs.FS, _ *rukpakv1alpha2.BundleDeployment) (fs.FS, error) { if err := ValidateBundle(fsys); err != nil { return nil, err } return fsys, nil } -func HandleBundleDeployment(_ context.Context, fsys fs.FS, bd *rukpakv1alpha1.BundleDeployment) (*chart.Chart, chartutil.Values, error) { +func HandleBundleDeployment(_ context.Context, fsys fs.FS, bd *rukpakv1alpha2.BundleDeployment) (*chart.Chart, chartutil.Values, error) { chrt, err := chartFromBundle(fsys, bd) if err != nil { return nil, nil, err @@ -81,7 +81,7 @@ func getObjects(bundle fs.FS, manifest fs.DirEntry) ([]client.Object, error) { return util.ManifestObjects(manifestReader, manifestPath) } -func chartFromBundle(fsys fs.FS, bd *rukpakv1alpha1.BundleDeployment) (*chart.Chart, error) { +func chartFromBundle(fsys fs.FS, bd *rukpakv1alpha2.BundleDeployment) (*chart.Chart, error) { objects, err := getBundleObjects(fsys) if err != nil { return nil, fmt.Errorf("read bundle objects from bundle: %v", err) @@ -92,7 +92,7 @@ func chartFromBundle(fsys fs.FS, bd *rukpakv1alpha1.BundleDeployment) (*chart.Ch } for _, obj := range objects { obj.SetLabels(util.MergeMaps(obj.GetLabels(), map[string]string{ - util.CoreOwnerKindKey: rukpakv1alpha1.BundleDeploymentKind, + util.CoreOwnerKindKey: rukpakv1alpha2.BundleDeploymentKind, util.CoreOwnerNameKey: bd.Name, })) yamlData, err := yaml.Marshal(obj) diff --git a/internal/provisioner/registry/registry.go b/internal/provisioner/registry/registry.go index b9c51b06..91d8f827 100644 --- a/internal/provisioner/registry/registry.go +++ b/internal/provisioner/registry/registry.go @@ -5,7 +5,7 @@ import ( "fmt" "io/fs" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/convert" "github.com/operator-framework/rukpak/internal/provisioner/plain" ) @@ -15,7 +15,7 @@ const ( ProvisionerID = "core-rukpak-io-registry" ) -func ProcessBundleDeployment(_ context.Context, fsys fs.FS, _ *rukpakv1alpha1.BundleDeployment) (fs.FS, error) { +func ProcessBundleDeployment(_ context.Context, fsys fs.FS, _ *rukpakv1alpha2.BundleDeployment) (fs.FS, error) { plainFS, err := convert.RegistryV1ToPlain(fsys) if err != nil { return nil, fmt.Errorf("convert registry+v1 bundle to plain+v0 bundle: %v", err) diff --git a/internal/rukpakctl/run.go b/internal/rukpakctl/run.go index ccf5c90b..5eac997b 100644 --- a/internal/rukpakctl/run.go +++ b/internal/rukpakctl/run.go @@ -12,7 +12,7 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/provisioner/plain" "github.com/operator-framework/rukpak/internal/util" ) @@ -46,7 +46,7 @@ func (r *Run) Run(ctx context.Context, bundleDeploymentName string, bundle fs.FS } sch := scheme.Scheme - if err := rukpakv1alpha1.AddToScheme(sch); err != nil { + if err := rukpakv1alpha2.AddToScheme(sch); err != nil { return false, err } cl, err := client.New(r.Config, client.Options{Scheme: sch}) @@ -70,7 +70,6 @@ func (r *Run) Run(ctx context.Context, bundleDeploymentName string, bundle fs.FS } opts.Log("bundledeployment.core.rukpak.io %q applied\n", bundleDeploymentName) - rukpakCA, err := GetClusterCA(ctx, cl, types.NamespacedName{Namespace: r.SystemNamespace, Name: r.CASecretName}) if err != nil { return false, err @@ -101,17 +100,17 @@ func buildBundleDeployment(bdName string, bundleDeploymentLabels map[string]stri // unstructured ensures that the patch contains only what is specified. Using unstructured like this is basically // identical to "kubectl apply -f" return &unstructured.Unstructured{Object: map[string]interface{}{ - "apiVersion": rukpakv1alpha1.GroupVersion.String(), - "kind": rukpakv1alpha1.BundleDeploymentKind, + "apiVersion": rukpakv1alpha2.GroupVersion.String(), + "kind": rukpakv1alpha2.BundleDeploymentKind, "metadata": map[string]interface{}{ - "name": bdName, + "name": bdName, "labels": bundleDeploymentLabels, }, "spec": map[string]interface{}{ "provisionerClassName": biPCN, "source": map[string]interface{}{ - "type": rukpakv1alpha1.SourceTypeUpload, - "upload": &rukpakv1alpha1.UploadSource{}, + "type": rukpakv1alpha2.SourceTypeUpload, + "upload": &rukpakv1alpha2.UploadSource{}, }, }, }} diff --git a/internal/source/configmaps.go b/internal/source/configmaps.go index 6c0d3735..b676f650 100644 --- a/internal/source/configmaps.go +++ b/internal/source/configmaps.go @@ -11,7 +11,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) type ConfigMaps struct { @@ -19,8 +19,8 @@ type ConfigMaps struct { ConfigMapNamespace string } -func (o *ConfigMaps) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment) (*Result, error) { - if bundle.Spec.Source.Type != rukpakv1alpha1.SourceTypeConfigMaps { +func (o *ConfigMaps) Unpack(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment) (*Result, error) { + if bundle.Spec.Source.Type != rukpakv1alpha2.SourceTypeConfigMaps { return nil, fmt.Errorf("bundle source type %q not supported", bundle.Spec.Source.Type) } if bundle.Spec.Source.ConfigMaps == nil { @@ -74,8 +74,8 @@ func (o *ConfigMaps) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDe return nil, utilerrors.NewAggregate(errs) } - resolvedSource := &rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeConfigMaps, + resolvedSource := &rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeConfigMaps, ConfigMaps: bundle.Spec.Source.DeepCopy().ConfigMaps, } diff --git a/internal/source/git.go b/internal/source/git.go index 0a0d8b46..3c2d3ebe 100644 --- a/internal/source/git.go +++ b/internal/source/git.go @@ -24,7 +24,7 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) type Git struct { @@ -32,8 +32,8 @@ type Git struct { SecretNamespace string } -func (r *Git) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment) (*Result, error) { - if bundle.Spec.Source.Type != rukpakv1alpha1.SourceTypeGit { +func (r *Git) Unpack(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment) (*Result, error) { + if bundle.Spec.Source.Type != rukpakv1alpha2.SourceTypeGit { return nil, fmt.Errorf("bundle source type %q not supported", bundle.Spec.Source.Type) } if bundle.Spec.Source.Git == nil { @@ -114,12 +114,12 @@ func (r *Git) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDeploymen } resolvedGit := bundle.Spec.Source.Git.DeepCopy() - resolvedGit.Ref = rukpakv1alpha1.GitRef{ + resolvedGit.Ref = rukpakv1alpha2.GitRef{ Commit: commitHash.String(), } - resolvedSource := &rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, + resolvedSource := &rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, Git: resolvedGit, } @@ -128,7 +128,7 @@ func (r *Git) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDeploymen return &Result{Bundle: bundleFS, ResolvedSource: resolvedSource, State: StateUnpacked, Message: message}, nil } -func (r *Git) configAuth(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment) (transport.AuthMethod, error) { +func (r *Git) configAuth(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment) (transport.AuthMethod, error) { var auth transport.AuthMethod if strings.HasPrefix(bundle.Spec.Source.Git.Repository, "http") { userName, password, err := r.getCredentials(ctx, bundle) @@ -176,7 +176,7 @@ func (r *Git) configAuth(ctx context.Context, bundle *rukpakv1alpha1.BundleDeplo // getCredentials reads credentials from the secret specified in the bundle // It returns the username ane password when they are in the secret -func (r *Git) getCredentials(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment) (string, string, error) { +func (r *Git) getCredentials(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment) (string, string, error) { secret := &corev1.Secret{} err := r.Get(ctx, client.ObjectKey{Namespace: r.SecretNamespace, Name: bundle.Spec.Source.Git.Auth.Secret.Name}, secret) if err != nil { @@ -190,7 +190,7 @@ func (r *Git) getCredentials(ctx context.Context, bundle *rukpakv1alpha1.BundleD // getCertificate reads certificate from the secret specified in the bundle // It returns the privatekey and the entry of the host in known_hosts when they are in the secret -func (r *Git) getCertificate(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment) ([]byte, []byte, error) { +func (r *Git) getCertificate(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment) ([]byte, []byte, error) { secret := &corev1.Secret{} err := r.Get(ctx, client.ObjectKey{Namespace: r.SecretNamespace, Name: bundle.Spec.Source.Git.Auth.Secret.Name}, secret) if err != nil { diff --git a/internal/source/http.go b/internal/source/http.go index b7af6d64..5fb33b95 100644 --- a/internal/source/http.go +++ b/internal/source/http.go @@ -12,7 +12,7 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) // http is a bundle source that sources bundles from the specified url. @@ -22,9 +22,9 @@ type HTTP struct { } // Unpack unpacks a bundle by requesting the bundle contents from a specified URL -func (b *HTTP) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment) (*Result, error) { - if bundle.Spec.Source.Type != rukpakv1alpha1.SourceTypeHTTP { - return nil, fmt.Errorf("cannot unpack source type %q with %q unpacker", bundle.Spec.Source.Type, rukpakv1alpha1.SourceTypeHTTP) +func (b *HTTP) Unpack(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment) (*Result, error) { + if bundle.Spec.Source.Type != rukpakv1alpha2.SourceTypeHTTP { + return nil, fmt.Errorf("cannot unpack source type %q with %q unpacker", bundle.Spec.Source.Type, rukpakv1alpha2.SourceTypeHTTP) } url := bundle.Spec.Source.HTTP.URL @@ -75,7 +75,7 @@ func (b *HTTP) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployme // getCredentials reads credentials from the secret specified in the bundle // It returns the username ane password when they are in the secret -func (b *HTTP) getCredentials(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment) (string, string, error) { +func (b *HTTP) getCredentials(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment) (string, string, error) { secret := &corev1.Secret{} err := b.Get(ctx, client.ObjectKey{Namespace: b.SecretNamespace, Name: bundle.Spec.Source.HTTP.Auth.Secret.Name}, secret) if err != nil { diff --git a/internal/source/image.go b/internal/source/image.go index 757f67c7..60bbfb28 100644 --- a/internal/source/image.go +++ b/internal/source/image.go @@ -21,7 +21,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/util" ) @@ -34,8 +34,8 @@ type Image struct { const imageBundleUnpackContainerName = "bundle" -func (i *Image) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment) (*Result, error) { - if bundle.Spec.Source.Type != rukpakv1alpha1.SourceTypeImage { +func (i *Image) Unpack(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment) (*Result, error) { + if bundle.Spec.Source.Type != rukpakv1alpha2.SourceTypeImage { return nil, fmt.Errorf("bundle source type %q not supported", bundle.Spec.Source.Type) } if bundle.Spec.Source.Image == nil { @@ -64,7 +64,7 @@ func (i *Image) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDeploym } } -func (i *Image) ensureUnpackPod(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment, pod *corev1.Pod) (controllerutil.OperationResult, error) { +func (i *Image) ensureUnpackPod(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment, pod *corev1.Pod) (controllerutil.OperationResult, error) { existingPod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: i.PodNamespace, Name: bundle.Name}} if err := i.Client.Get(ctx, client.ObjectKeyFromObject(existingPod), existingPod); client.IgnoreNotFound(err) != nil { return controllerutil.OperationResultNone, err @@ -99,7 +99,7 @@ func (i *Image) ensureUnpackPod(ctx context.Context, bundle *rukpakv1alpha1.Bund return controllerutil.OperationResultUpdated, nil } -func (i *Image) getDesiredPodApplyConfig(bundle *rukpakv1alpha1.BundleDeployment) *applyconfigurationcorev1.PodApplyConfiguration { +func (i *Image) getDesiredPodApplyConfig(bundle *rukpakv1alpha2.BundleDeployment) *applyconfigurationcorev1.PodApplyConfiguration { // TODO (tyslaton): Address unpacker pod allowing root users for image sources // // In our current implementation, we are creating a pod that uses the image @@ -203,9 +203,9 @@ func (i *Image) succeededPodResult(ctx context.Context, pod *corev1.Pod) (*Resul return nil, fmt.Errorf("get bundle image digest: %v", err) } - resolvedSource := &rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{Ref: digest}, + resolvedSource := &rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{Ref: digest}, } message := generateMessage("image") diff --git a/internal/source/unpacker.go b/internal/source/unpacker.go index 9755870d..9a07d982 100644 --- a/internal/source/unpacker.go +++ b/internal/source/unpacker.go @@ -12,7 +12,7 @@ import ( "k8s.io/client-go/kubernetes" "sigs.k8s.io/controller-runtime/pkg/cluster" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) const ( @@ -35,7 +35,7 @@ const ( // specifications. A source should treat a bundle root directory as an opaque // file tree and delegate bundle format concerns to bundle parsers. type Unpacker interface { - Unpack(context.Context, *rukpakv1alpha1.BundleDeployment) (*Result, error) + Unpack(context.Context, *rukpakv1alpha2.BundleDeployment) (*Result, error) } // Result conveys progress information about unpacking bundle content. @@ -52,7 +52,7 @@ type Result struct { // For example, resolved image sources should reference a container image // digest rather than an image tag, and git sources should reference a // commit hash rather than a branch or tag. - ResolvedSource *rukpakv1alpha1.BundleSource + ResolvedSource *rukpakv1alpha2.BundleSource // State is the current state of unpacking the bundle content. State State @@ -79,16 +79,16 @@ const ( ) type unpacker struct { - sources map[rukpakv1alpha1.SourceType]Unpacker + sources map[rukpakv1alpha2.SourceType]Unpacker } // NewUnpacker returns a new composite Source that unpacks bundles using the source // mapping provided by the configured sources. -func NewUnpacker(sources map[rukpakv1alpha1.SourceType]Unpacker) Unpacker { +func NewUnpacker(sources map[rukpakv1alpha2.SourceType]Unpacker) Unpacker { return &unpacker{sources: sources} } -func (s *unpacker) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment) (*Result, error) { +func (s *unpacker) Unpack(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment) (*Result, error) { source, ok := s.sources[bundle.Spec.Source.Type] if !ok { return nil, fmt.Errorf("source type %q not supported", bundle.Spec.Source.Type) @@ -114,27 +114,27 @@ func NewDefaultUnpacker(systemNsCluster cluster.Cluster, namespace, unpackImage } } httpTransport.TLSClientConfig.RootCAs = rootCAs - return NewUnpacker(map[rukpakv1alpha1.SourceType]Unpacker{ - rukpakv1alpha1.SourceTypeImage: &Image{ + return NewUnpacker(map[rukpakv1alpha2.SourceType]Unpacker{ + rukpakv1alpha2.SourceTypeImage: &Image{ Client: systemNsCluster.GetClient(), KubeClient: kubeClient, PodNamespace: namespace, UnpackImage: unpackImage, }, - rukpakv1alpha1.SourceTypeGit: &Git{ + rukpakv1alpha2.SourceTypeGit: &Git{ Reader: systemNsCluster.GetClient(), SecretNamespace: namespace, }, - rukpakv1alpha1.SourceTypeConfigMaps: &ConfigMaps{ + rukpakv1alpha2.SourceTypeConfigMaps: &ConfigMaps{ Reader: systemNsCluster.GetClient(), ConfigMapNamespace: namespace, }, - rukpakv1alpha1.SourceTypeUpload: &Upload{ + rukpakv1alpha2.SourceTypeUpload: &Upload{ baseDownloadURL: baseUploadManagerURL, bearerToken: systemNsCluster.GetConfig().BearerToken, client: http.Client{Timeout: uploadClientTimeout, Transport: httpTransport}, }, - rukpakv1alpha1.SourceTypeHTTP: &HTTP{ + rukpakv1alpha2.SourceTypeHTTP: &HTTP{ Reader: systemNsCluster.GetClient(), SecretNamespace: namespace, }, diff --git a/internal/source/upload.go b/internal/source/upload.go index 75df0ecd..11119109 100644 --- a/internal/source/upload.go +++ b/internal/source/upload.go @@ -8,7 +8,7 @@ import ( "github.com/nlepage/go-tarfs" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) // Upload is a bundle source that sources bundles from the rukpak upload service. @@ -20,9 +20,9 @@ type Upload struct { // Unpack unpacks an uploaded bundle by requesting the bundle contents from a web server hosted // by rukpak's upload service. -func (b *Upload) Unpack(ctx context.Context, bundle *rukpakv1alpha1.BundleDeployment) (*Result, error) { - if bundle.Spec.Source.Type != rukpakv1alpha1.SourceTypeUpload { - return nil, fmt.Errorf("cannot unpack source type %q with %q unpacker", bundle.Spec.Source.Type, rukpakv1alpha1.SourceTypeUpload) +func (b *Upload) Unpack(ctx context.Context, bundle *rukpakv1alpha2.BundleDeployment) (*Result, error) { + if bundle.Spec.Source.Type != rukpakv1alpha2.SourceTypeUpload { + return nil, fmt.Errorf("cannot unpack source type %q with %q unpacker", bundle.Spec.Source.Type, rukpakv1alpha2.SourceTypeUpload) } url := fmt.Sprintf("%s/uploads/%s.tgz", b.baseDownloadURL, bundle.Name) diff --git a/internal/storage/http.go b/internal/storage/http.go index d80fa559..fa270f67 100644 --- a/internal/storage/http.go +++ b/internal/storage/http.go @@ -13,7 +13,7 @@ import ( "github.com/nlepage/go-tarfs" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) type HTTP struct { @@ -69,7 +69,7 @@ func NewHTTP(opts ...HTTPOption) *HTTP { } func (s *HTTP) Load(ctx context.Context, owner client.Object) (fs.FS, error) { - bundledeployment := owner.(*rukpakv1alpha1.BundleDeployment) + bundledeployment := owner.(*rukpakv1alpha2.BundleDeployment) req, err := http.NewRequestWithContext(ctx, http.MethodGet, bundledeployment.Status.ContentURL, nil) if err != nil { return nil, err diff --git a/internal/storage/http_test.go b/internal/storage/http_test.go index 872bc2c7..26c41d2b 100644 --- a/internal/storage/http_test.go +++ b/internal/storage/http_test.go @@ -17,21 +17,21 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/rand" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/util" ) var _ = Describe("HTTP", func() { var ( - ctx context.Context - bundledeployment *rukpakv1alpha1.BundleDeployment - testFS fs.FS - localStore *LocalDirectory - server *httptest.Server + ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + testFS fs.FS + localStore *LocalDirectory + server *httptest.Server ) BeforeEach(func() { ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ObjectMeta: metav1.ObjectMeta{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ObjectMeta: metav1.ObjectMeta{ Name: util.GenerateBundleName("testbundle", rand.String(8)), }} diff --git a/internal/storage/localdir_test.go b/internal/storage/localdir_test.go index 742cb192..eec00f0b 100644 --- a/internal/storage/localdir_test.go +++ b/internal/storage/localdir_test.go @@ -17,20 +17,20 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/rand" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) var _ = Describe("LocalDirectory", func() { var ( ctx context.Context - owner *rukpakv1alpha1.BundleDeployment + owner *rukpakv1alpha2.BundleDeployment store LocalDirectory testFS fs.FS ) BeforeEach(func() { ctx = context.Background() - owner = &rukpakv1alpha1.BundleDeployment{ + owner = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("test-bundle-%s", rand.String(5)), UID: types.UID(rand.String(8)), diff --git a/internal/storage/storage_test.go b/internal/storage/storage_test.go index 581fa106..6daf94c6 100644 --- a/internal/storage/storage_test.go +++ b/internal/storage/storage_test.go @@ -13,31 +13,31 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/rand" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/util" ) var _ = Describe("WithFallbackLoader", func() { var ( - ctx context.Context - primaryBundleDeployment *rukpakv1alpha1.BundleDeployment - fallbackBundleDeployment *rukpakv1alpha1.BundleDeployment - primaryStore *LocalDirectory - fallbackStore *LocalDirectory - primaryFS fs.FS - fallbackFS fs.FS + ctx context.Context + primaryBundleDeployment *rukpakv1alpha2.BundleDeployment + fallbackBundleDeployment *rukpakv1alpha2.BundleDeployment + primaryStore *LocalDirectory + fallbackStore *LocalDirectory + primaryFS fs.FS + fallbackFS fs.FS store Storage ) BeforeEach(func() { ctx = context.Background() - primaryBundleDeployment = &rukpakv1alpha1.BundleDeployment{ + primaryBundleDeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: util.GenerateBundleName("primary", rand.String(8)), }, } - fallbackBundleDeployment = &rukpakv1alpha1.BundleDeployment{ + fallbackBundleDeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: util.GenerateBundleName("fallback", rand.String(8)), }, @@ -69,7 +69,7 @@ var _ = Describe("WithFallbackLoader", func() { Expect(fsEqual(fallbackFS, loadedTestFS)).To(BeTrue()) }) It("should fail to find unknown bundle", func() { - unknownBundle := &rukpakv1alpha1.BundleDeployment{ + unknownBundle := &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: util.GenerateBundleName("unknown", rand.String(8)), }, diff --git a/internal/uploadmgr/gc.go b/internal/uploadmgr/gc.go index 04fd1774..d6872cc8 100644 --- a/internal/uploadmgr/gc.go +++ b/internal/uploadmgr/gc.go @@ -14,7 +14,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/manager" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) type bundleGC struct { @@ -35,15 +35,15 @@ func NewBundleGC(cache cache.Cache, storageDir string, storageSyncInterval time. // Start implemente the controller-runtime Runnable interface. // It blocks until the context is closed. func (gc *bundleGC) Start(ctx context.Context) error { - bundledeploymentInformer, err := gc.cache.GetInformer(ctx, &rukpakv1alpha1.BundleDeployment{}) + bundledeploymentInformer, err := gc.cache.GetInformer(ctx, &rukpakv1alpha2.BundleDeployment{}) if err != nil { return err } // Ignore the return value _, err = bundledeploymentInformer.AddEventHandler(toolscache.ResourceEventHandlerFuncs{ DeleteFunc: func(obj interface{}) { - bundleDeployment := obj.(*rukpakv1alpha1.BundleDeployment) - if bundleDeployment.Spec.Source.Type != rukpakv1alpha1.SourceTypeUpload { + bundleDeployment := obj.(*rukpakv1alpha2.BundleDeployment) + if bundleDeployment.Spec.Source.Type != rukpakv1alpha2.SourceTypeUpload { return } filename := bundlePath(gc.storageDir, bundleDeployment.Name) @@ -83,13 +83,13 @@ func (gc *bundleGC) Start(ctx context.Context) error { for _, e := range storageDirEntries { existingFiles.Insert(e.Name()) } - bundledeployments := &rukpakv1alpha1.BundleDeploymentList{} + bundledeployments := &rukpakv1alpha2.BundleDeploymentList{} if err := gc.cache.List(ctx, bundledeployments); err != nil { gc.log.Error(err, "failed to list bundles from cache", err) continue } for _, bundle := range bundledeployments.Items { - if bundle.Spec.Source.Type != rukpakv1alpha1.SourceTypeUpload { + if bundle.Spec.Source.Type != rukpakv1alpha2.SourceTypeUpload { continue } existingFiles.Delete(filepath.Base(bundlePath(gc.storageDir, bundle.Name))) diff --git a/internal/uploadmgr/handler.go b/internal/uploadmgr/handler.go index 531c31fc..0dde9dcd 100644 --- a/internal/uploadmgr/handler.go +++ b/internal/uploadmgr/handler.go @@ -17,7 +17,7 @@ import ( "k8s.io/client-go/util/retry" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/util" ) @@ -39,13 +39,13 @@ func newPutHandler(cl client.Client, storageDir string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { bundleName := mux.Vars(r)["bundleName"] - bundledeployment := &rukpakv1alpha1.BundleDeployment{} + bundledeployment := &rukpakv1alpha2.BundleDeployment{} if err := cl.Get(r.Context(), types.NamespacedName{Name: bundleName}, bundledeployment); err != nil { http.Error(w, err.Error(), int(getCode(err))) return } - if bundledeployment.Spec.Source.Type != rukpakv1alpha1.SourceTypeUpload { - http.Error(w, fmt.Sprintf("bundle source type is %q; expected %q", bundledeployment.Spec.Source.Type, rukpakv1alpha1.SourceTypeUpload), http.StatusConflict) + if bundledeployment.Spec.Source.Type != rukpakv1alpha2.SourceTypeUpload { + http.Error(w, fmt.Sprintf("bundle source type is %q; expected %q", bundledeployment.Spec.Source.Type, rukpakv1alpha2.SourceTypeUpload), http.StatusConflict) return } @@ -62,7 +62,6 @@ func newPutHandler(cl client.Client, storageDir string) http.Handler { } } - if isBundleDeploymentUnpacked(bundledeployment) { http.Error(w, "bundle has already been unpacked, cannot change content of existing bundle", http.StatusConflict) return @@ -89,9 +88,9 @@ func newPutHandler(cl client.Client, storageDir string) http.Handler { } meta.SetStatusCondition(&bundledeployment.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha1.TypeUnpacked, + Type: rukpakv1alpha2.TypeUnpacked, Status: metav1.ConditionFalse, - Reason: rukpakv1alpha1.ReasonUnpackPending, + Reason: rukpakv1alpha2.ReasonUnpackPending, Message: "received bundle upload, waiting for provisioner to unpack it.", }) return cl.Status().Update(r.Context(), bundledeployment) @@ -103,14 +102,13 @@ func newPutHandler(cl client.Client, storageDir string) http.Handler { }) } -func isBundleDeploymentUnpacked(bd *rukpakv1alpha1.BundleDeployment) bool { +func isBundleDeploymentUnpacked(bd *rukpakv1alpha2.BundleDeployment) bool { if bd == nil { return false } - condition := meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeUnpacked) + condition := meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeUnpacked) return condition.Status == metav1.ConditionTrue - } func getCode(err error) int32 { diff --git a/internal/util/adopt.go b/internal/util/adopt.go index 9cdc097c..5e2588cc 100644 --- a/internal/util/adopt.go +++ b/internal/util/adopt.go @@ -3,7 +3,7 @@ package util import ( "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/operator-framework/rukpak/api/v1alpha1" + "github.com/operator-framework/rukpak/api/v1alpha2" ) // AdoptObject sets metadata on an object to associate that object with a bundle @@ -36,7 +36,7 @@ func AdoptObject(obj client.Object, systemNamespace, bundleDeploymentName string } labels["app.kubernetes.io/managed-by"] = "Helm" - labels[CoreOwnerKindKey] = v1alpha1.BundleDeploymentKind + labels[CoreOwnerKindKey] = v1alpha2.BundleDeploymentKind labels[CoreOwnerNameKey] = bundleDeploymentName obj.SetLabels(labels) } diff --git a/internal/util/util.go b/internal/util/util.go index 825c90d6..0ecedab1 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -15,7 +15,6 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/selection" @@ -29,11 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" -) - -const ( - maxGeneratedBundleLimit = 4 + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) var ( @@ -43,60 +38,10 @@ var ( ErrMaxGeneratedLimit = errors.New("reached the maximum generated Bundle limit") ) -// reconcileDesiredBundle is responsible for checking whether the desired -// Bundle resource that's specified in the BundleDeployment parameter's -// spec.Template configuration is present on cluster, and if not, creates -// a new Bundle resource matching that desired specification. -func ReconcileDesiredBundleDeployment(ctx context.Context, c client.Client, bd *rukpakv1alpha1.BundleDeployment) (*rukpakv1alpha1.BundleDeployment, *rukpakv1alpha1.BundleDeploymentList, error) { - // get the set of Bundle resources that already exist on cluster, and sort - // by metadata.CreationTimestamp in the case there's multiple Bundles - // that match the label selector. - existingBundleDeployments, err := GetBundlesForBundleDeploymentSelector(ctx, c, bd) - if err != nil { - return nil, nil, err - } - SortBundleDeploymentsByCreation(existingBundleDeployments) - - // check whether there's an existing Bundle that matches the desired Bundle template - // specified in the BI resource, and if not, generate a new Bundle that matches the template. - b, err := CheckExistingBundlesMatchesTemplate(existingBundleDeployments, bd.Spec.Source) - if err != nil { - return nil, nil, err - } - if b == nil { - controllerRef := metav1.NewControllerRef(bd, bd.GroupVersionKind()) - hash, err := DeepHashObject(bd.Spec.Source) - if err != nil { - return nil, nil, err - } - - labels := bd.Labels - if len(labels) == 0 { - labels = make(map[string]string) - } - labels[CoreOwnerKindKey] = rukpakv1alpha1.BundleDeploymentKind - labels[CoreOwnerNameKey] = bd.GetName() - labels[CoreBundleTemplateHashKey] = hash - - b = &rukpakv1alpha1.BundleDeployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: bd.GetName(), - OwnerReferences: []metav1.OwnerReference{*controllerRef}, - Labels: labels, - Annotations: bd.Annotations, - }, - Spec: bd.Spec, - } - if err := c.Create(ctx, b); err != nil { - return nil, nil, err - } - } - return b, existingBundleDeployments, err -} func BundleDeploymentProvisionerFilter(provisionerClassName string) predicate.Predicate { return predicate.NewPredicateFuncs(func(obj client.Object) bool { - b := obj.(*rukpakv1alpha1.BundleDeployment) + b := obj.(*rukpakv1alpha2.BundleDeployment) return b.Spec.ProvisionerClassName == provisionerClassName }) } @@ -164,12 +109,12 @@ func MapOwneeToOwnerProvisionerHandler(ctx context.Context, cl client.Client, lo }) } -func MapConfigMapToBundleDeployment(ctx context.Context, cl client.Client, cmNamespace string, cm corev1.ConfigMap) []*rukpakv1alpha1.BundleDeployment { - bundleDeploymentList := &rukpakv1alpha1.BundleDeploymentList{} +func MapConfigMapToBundleDeployment(ctx context.Context, cl client.Client, cmNamespace string, cm corev1.ConfigMap) []*rukpakv1alpha2.BundleDeployment { + bundleDeploymentList := &rukpakv1alpha2.BundleDeploymentList{} if err := cl.List(ctx, bundleDeploymentList); err != nil { return nil } - var bs []*rukpakv1alpha1.BundleDeployment + var bs []*rukpakv1alpha2.BundleDeployment for _, b := range bundleDeploymentList.Items { b := b for _, cmSource := range b.Spec.Source.ConfigMaps { @@ -199,9 +144,9 @@ func MapConfigMapToBundleDeploymentHandler(ctx context.Context, cl client.Client // GetBundlesForBundleDeploymentSelector is responsible for returning a list of // Bundle resource that exist on cluster that match the label selector specified // in the BD parameter's spec.Selector field. -func GetBundlesForBundleDeploymentSelector(ctx context.Context, c client.Client, bd *rukpakv1alpha1.BundleDeployment) (*rukpakv1alpha1.BundleDeploymentList, error) { +func GetBundlesForBundleDeploymentSelector(ctx context.Context, c client.Client, bd *rukpakv1alpha2.BundleDeployment) (*rukpakv1alpha2.BundleDeploymentList, error) { selector := NewBundleDeploymentLabelSelector(bd) - bundleDeploymentList := &rukpakv1alpha1.BundleDeploymentList{} + bundleDeploymentList := &rukpakv1alpha2.BundleDeploymentList{} if err := c.List(ctx, bundleDeploymentList, &client.ListOptions{ LabelSelector: selector, }); err != nil { @@ -210,47 +155,6 @@ func GetBundlesForBundleDeploymentSelector(ctx context.Context, c client.Client, return bundleDeploymentList, nil } -// CheckExistingBundlesMatchesTemplate evaluates whether the existing list of Bundle objects -// match the desired Bundle template that's specified in a BundleDeployment object. If a match -// is found, that Bundle object is returned, so callers are responsible for nil checking the result. -func CheckExistingBundlesMatchesTemplate(existingBundleDeployments *rukpakv1alpha1.BundleDeploymentList, desiredBundleTemplate rukpakv1alpha1.BundleSource) (*rukpakv1alpha1.BundleDeployment, error) { - for i := range existingBundleDeployments.Items { - ok, err := CheckDesiredBundleTemplate(&existingBundleDeployments.Items[i], desiredBundleTemplate) - if err != nil { - return nil, err - } - if !ok { - continue - } - return existingBundleDeployments.Items[i].DeepCopy(), nil - } - return nil, nil -} - -// CheckDesiredBundleTemplate is responsible for determining whether the existingBundle -// hash is equal to the desiredBundle Bundle template hash. -func CheckDesiredBundleTemplate(existingBundleDeployment *rukpakv1alpha1.BundleDeployment, desiredBundle rukpakv1alpha1.BundleSource) (bool, error) { - if len(existingBundleDeployment.Labels) == 0 { - // Existing Bundle has no labels set, which should never be the case. - // Return false so that the Bundle is forced to be recreated with the expected labels. - return false, nil - } - - existingHash, ok := existingBundleDeployment.Labels[CoreBundleTemplateHashKey] - if !ok { - // Existing Bundle has no template hash associated with it. - // Return false so that the Bundle is forced to be recreated with the template hash label. - return false, nil - } - - // Check whether the hash of the desired bundle template matches the existing bundle on-cluster. - desiredHash, err := DeepHashObject(desiredBundle) - if err != nil { - return false, err - } - return existingHash == desiredHash, nil -} - const ( // maxBundleNameLength must be aligned with the Bundle CRD metadata.name length validation, defined in: // /manifests/base/apis/crds/patches/bundle_validation.yaml @@ -276,7 +180,7 @@ func GenerateBundleName(bdName, hash string) string { // SortBundleDeploymentsByCreation sorts a BundleDeploymentList's items by it's // metadata.CreationTimestamp value. -func SortBundleDeploymentsByCreation(bundles *rukpakv1alpha1.BundleDeploymentList) { +func SortBundleDeploymentsByCreation(bundles *rukpakv1alpha2.BundleDeploymentList) { sort.Slice(bundles.Items, func(a, b int) bool { return bundles.Items[a].CreationTimestamp.Before(&bundles.Items[b].CreationTimestamp) }) @@ -308,8 +212,8 @@ func newLabelSelector(name, kind string) labels.Selector { // NewBundleDeploymentLabelSelector is responsible for constructing a label.Selector // for any underlying resources that are associated with the BundleDeployment parameter. -func NewBundleDeploymentLabelSelector(bd *rukpakv1alpha1.BundleDeployment) labels.Selector { - return newLabelSelector(bd.GetName(), rukpakv1alpha1.BundleDeploymentKind) +func NewBundleDeploymentLabelSelector(bd *rukpakv1alpha2.BundleDeployment) labels.Selector { + return newLabelSelector(bd.GetName(), rukpakv1alpha2.BundleDeploymentKind) } func CreateOrRecreate(ctx context.Context, cl client.Client, obj client.Object, f controllerutil.MutateFn) (controllerutil.OperationResult, error) { diff --git a/internal/webhook/bundledeployment.go b/internal/webhook/bundledeployment.go index b7adbf95..78e63e45 100644 --- a/internal/webhook/bundledeployment.go +++ b/internal/webhook/bundledeployment.go @@ -30,7 +30,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) type Bundle struct { @@ -39,17 +39,17 @@ type Bundle struct { } //+kubebuilder:rbac:groups=core,resources=configmaps,verbs=list;watch -//+kubebuilder:webhook:path=/validate-core-rukpak-io-v1alpha1-bundledeployment,mutating=false,failurePolicy=fail,sideEffects=None,groups=core.rukpak.io,resources=bundles,verbs=create;update,versions=v1alpha1,name=vbundles.core.rukpak.io,admissionReviewVersions=v1 +//+kubebuilder:webhook:path=/validate-core-rukpak-io-v1alpha2-bundledeployment,mutating=false,failurePolicy=fail,sideEffects=None,groups=core.rukpak.io,resources=bundles,verbs=create;update,versions=v1alpha2,name=vbundles.core.rukpak.io,admissionReviewVersions=v1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (b *Bundle) ValidateCreate(ctx context.Context, obj runtime.Object) error { - bundledeployment := obj.(*rukpakv1alpha1.BundleDeployment) + bundledeployment := obj.(*rukpakv1alpha2.BundleDeployment) return b.checkBundleDeploymentSource(ctx, bundledeployment) } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (b *Bundle) ValidateUpdate(ctx context.Context, oldObj runtime.Object, newObj runtime.Object) error { - newBundle := newObj.(*rukpakv1alpha1.BundleDeployment) +func (b *Bundle) ValidateUpdate(ctx context.Context, _ runtime.Object, newObj runtime.Object) error { + newBundle := newObj.(*rukpakv1alpha2.BundleDeployment) return b.checkBundleDeploymentSource(ctx, newBundle) } @@ -58,20 +58,20 @@ func (b *Bundle) ValidateDelete(_ context.Context, _ runtime.Object) error { return nil } -func (b *Bundle) checkBundleDeploymentSource(ctx context.Context, bundledeployment *rukpakv1alpha1.BundleDeployment) error { +func (b *Bundle) checkBundleDeploymentSource(ctx context.Context, bundledeployment *rukpakv1alpha2.BundleDeployment) error { switch typ := bundledeployment.Spec.Source.Type; typ { - case rukpakv1alpha1.SourceTypeImage: + case rukpakv1alpha2.SourceTypeImage: if bundledeployment.Spec.Source.Image == nil { return fmt.Errorf("bundledeployment.spec.source.image must be set for source type \"image\"") } - case rukpakv1alpha1.SourceTypeGit: + case rukpakv1alpha2.SourceTypeGit: if bundledeployment.Spec.Source.Git == nil { return fmt.Errorf("bundledeployment.spec.source.git must be set for source type \"git\"") } if strings.HasPrefix(filepath.Clean(bundledeployment.Spec.Source.Git.Directory), "../") { return fmt.Errorf(`bundledeployment.spec.source.git.directory begins with "../": directory must define path within the repository`) } - case rukpakv1alpha1.SourceTypeConfigMaps: + case rukpakv1alpha2.SourceTypeConfigMaps: if len(bundledeployment.Spec.Source.ConfigMaps) == 0 { return fmt.Errorf(`bundledeployment.spec.source.configmaps must be set for source type "configmaps"`) } @@ -104,7 +104,7 @@ func (b *Bundle) verifyConfigMapImmutable(ctx context.Context, configMapName str } func (b *Bundle) SetupWebhookWithManager(mgr ctrl.Manager) error { - mgr.GetWebhookServer().Register("/validate-core-rukpak-io-v1alpha1-bundledeployment", admission.WithCustomValidator(&rukpakv1alpha1.BundleDeployment{}, b).WithRecoverPanic(true)) + mgr.GetWebhookServer().Register("/validate-core-rukpak-io-v1alpha2-bundledeployment", admission.WithCustomValidator(&rukpakv1alpha2.BundleDeployment{}, b).WithRecoverPanic(true)) return nil } diff --git a/internal/webhook/configmaps.go b/internal/webhook/configmaps.go index a9988553..12ef56e2 100644 --- a/internal/webhook/configmaps.go +++ b/internal/webhook/configmaps.go @@ -11,7 +11,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) //+kubebuilder:rbac:groups=core.rukpak.io,resources=bundles,verbs=list;watch @@ -31,13 +31,13 @@ func (w *ConfigMap) ValidateCreate(ctx context.Context, obj runtime.Object) erro return nil } - bundledeploymentList := &rukpakv1alpha1.BundleDeploymentList{} + bundledeploymentList := &rukpakv1alpha2.BundleDeploymentList{} if err := w.Client.List(ctx, bundledeploymentList); err != nil { return err } bundleReferrers := []string{} for _, bundle := range bundledeploymentList.Items { - if bundle.Spec.Source.Type == rukpakv1alpha1.SourceTypeConfigMaps { + if bundle.Spec.Source.Type == rukpakv1alpha2.SourceTypeConfigMaps { for _, bundleConfigMapRef := range bundle.Spec.Source.ConfigMaps { if bundleConfigMapRef.ConfigMap.Name == cm.Name { bundleReferrers = append(bundleReferrers, bundle.Name) @@ -58,7 +58,7 @@ func (w *ConfigMap) ValidateUpdate(_ context.Context, _, _ runtime.Object) error func (w *ConfigMap) ValidateDelete(ctx context.Context, obj runtime.Object) error { cm := obj.(*corev1.ConfigMap) - bundleList := &rukpakv1alpha1.BundleDeploymentList{} + bundleList := &rukpakv1alpha2.BundleDeploymentList{} if err := w.Client.List(ctx, bundleList); err != nil { return err } diff --git a/manifests/base/apis/crds/core.rukpak.io_bundledeployments.yaml b/manifests/base/apis/crds/core.rukpak.io_bundledeployments.yaml index 81c935f9..146890c8 100644 --- a/manifests/base/apis/crds/core.rukpak.io_bundledeployments.yaml +++ b/manifests/base/apis/crds/core.rukpak.io_bundledeployments.yaml @@ -28,7 +28,7 @@ spec: name: Provisioner priority: 1 type: string - name: v1alpha1 + name: v1alpha2 schema: openAPIV3Schema: description: BundleDeployment is the Schema for the bundledeployments API diff --git a/manifests/base/apis/crds/core.rukpak.io_bundles.yaml b/manifests/base/apis/crds/core.rukpak.io_bundles.yaml deleted file mode 100644 index da7951bb..00000000 --- a/manifests/base/apis/crds/core.rukpak.io_bundles.yaml +++ /dev/null @@ -1,493 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.12.0 - name: bundles.core.rukpak.io -spec: - group: core.rukpak.io - names: - kind: Bundle - listKind: BundleList - plural: bundles - singular: bundle - scope: Cluster - versions: - - additionalPrinterColumns: - - jsonPath: .spec.source.type - name: Type - type: string - - jsonPath: .status.phase - name: Phase - type: string - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - - jsonPath: .spec.provisionerClassName - name: Provisioner - priority: 1 - type: string - - jsonPath: .status.resolvedSource - name: Resolved Source - priority: 1 - type: string - name: v1alpha1 - schema: - openAPIV3Schema: - description: Bundle is the Schema for the bundles API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: BundleSpec defines the desired state of Bundle - properties: - provisionerClassName: - description: ProvisionerClassName sets the name of the provisioner - that should reconcile this BundleDeployment. - pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ - type: string - source: - description: Source defines the configuration for the underlying Bundle - content. - properties: - configMaps: - description: ConfigMaps is a list of config map references and - their relative directory paths that represent a bundle filesystem. - items: - properties: - configMap: - description: ConfigMap is a reference to a configmap in - the rukpak system namespace - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - x-kubernetes-map-type: atomic - path: - description: Path is the relative directory path within - the bundle where the files from the configmap will be - present when the bundle is unpacked. - type: string - required: - - configMap - type: object - type: array - git: - description: Git is the git repository that backs the content - of this Bundle. - properties: - auth: - description: Auth configures the authorization method if necessary. - properties: - insecureSkipVerify: - description: InsecureSkipVerify controls whether a client - verifies the server's certificate chain and host name. - If InsecureSkipVerify is true, the clone operation will - accept any certificate presented by the server and any - host name in that certificate. In this mode, TLS is - susceptible to machine-in-the-middle attacks unless - custom verification is used. This should be used only - for testing. - type: boolean - secret: - description: Secret contains reference to the secret that - has authorization information and is in the namespace - that the provisioner is deployed. The secret is expected - to contain `data.username` and `data.password` for the - username and password, respectively for http(s) scheme. - Refer to https://kubernetes.io/docs/concepts/configuration/secret/#basic-authentication-secret - For the ssh authorization of the GitSource, the secret - is expected to contain `data.ssh-privatekey` and `data.ssh-knownhosts` - for the ssh privatekey and the host entry in the known_hosts - file respectively. Refer to https://kubernetes.io/docs/concepts/configuration/secret/#ssh-authentication-secrets - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - type: object - x-kubernetes-map-type: atomic - type: object - directory: - description: Directory refers to the location of the bundle - within the git repository. Directory is optional and if - not set defaults to ./manifests. - type: string - ref: - description: Ref configures the git source to clone a specific - branch, tag, or commit from the specified repo. Ref is required, - and exactly one field within Ref is required. Setting more - than one field or zero fields will result in an error. - properties: - branch: - description: Branch refers to the branch to checkout from - the repository. The Branch should contain the bundle - manifests in the specified directory. - type: string - commit: - description: Commit refers to the commit to checkout from - the repository. The Commit should contain the bundle - manifests in the specified directory. - type: string - tag: - description: Tag refers to the tag to checkout from the - repository. The Tag should contain the bundle manifests - in the specified directory. - type: string - type: object - repository: - description: Repository is a URL link to the git repository - containing the bundle. Repository is required and the URL - should be parsable by a standard git tool. - type: string - required: - - ref - - repository - type: object - http: - description: HTTP is the remote location that backs the content - of this Bundle. - properties: - auth: - description: Auth configures the authorization method if necessary. - properties: - insecureSkipVerify: - description: InsecureSkipVerify controls whether a client - verifies the server's certificate chain and host name. - If InsecureSkipVerify is true, the clone operation will - accept any certificate presented by the server and any - host name in that certificate. In this mode, TLS is - susceptible to machine-in-the-middle attacks unless - custom verification is used. This should be used only - for testing. - type: boolean - secret: - description: Secret contains reference to the secret that - has authorization information and is in the namespace - that the provisioner is deployed. The secret is expected - to contain `data.username` and `data.password` for the - username and password, respectively for http(s) scheme. - Refer to https://kubernetes.io/docs/concepts/configuration/secret/#basic-authentication-secret - For the ssh authorization of the GitSource, the secret - is expected to contain `data.ssh-privatekey` and `data.ssh-knownhosts` - for the ssh privatekey and the host entry in the known_hosts - file respectively. Refer to https://kubernetes.io/docs/concepts/configuration/secret/#ssh-authentication-secrets - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - type: object - x-kubernetes-map-type: atomic - type: object - url: - description: URL is where the bundle contents is. - type: string - required: - - url - type: object - image: - description: Image is the bundle image that backs the content - of this bundle. - properties: - pullSecret: - description: ImagePullSecretName contains the name of the - image pull secret in the namespace that the provisioner - is deployed. - type: string - ref: - description: Ref contains the reference to a container image - containing Bundle contents. - type: string - required: - - ref - type: object - type: - description: Type defines the kind of Bundle content being sourced. - type: string - upload: - description: Upload is a source that enables this Bundle's content - to be uploaded via Rukpak's bundle upload service. This source - type is primarily useful with bundle development workflows because - it enables bundle developers to inject a local bundle directly - into the cluster. - type: object - required: - - type - type: object - required: - - provisionerClassName - - source - type: object - status: - description: BundleStatus defines the observed state of Bundle - properties: - conditions: - items: - description: "Condition contains details for one aspect of the current - state of this API Resource. --- This struct is intended for direct - use as an array at the field path .status.conditions. For example, - \n type FooStatus struct{ // Represents the observations of a - foo's current state. // Known .status.conditions.type are: \"Available\", - \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge - // +listType=map // +listMapKey=type Conditions []metav1.Condition - `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" - protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition - transitioned from one status to another. This should be when - the underlying condition changed. If that is not known, then - using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating - details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation - that the condition was set based upon. For instance, if .metadata.generation - is currently 12, but the .status.conditions[x].observedGeneration - is 9, the condition is out of date with respect to the current - state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating - the reason for the condition's last transition. Producers - of specific condition types may define expected values and - meanings for this field, and whether the values are considered - a guaranteed API. The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - --- Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - contentURL: - type: string - observedGeneration: - format: int64 - type: integer - phase: - type: string - resolvedSource: - properties: - configMaps: - description: ConfigMaps is a list of config map references and - their relative directory paths that represent a bundle filesystem. - items: - properties: - configMap: - description: ConfigMap is a reference to a configmap in - the rukpak system namespace - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - x-kubernetes-map-type: atomic - path: - description: Path is the relative directory path within - the bundle where the files from the configmap will be - present when the bundle is unpacked. - type: string - required: - - configMap - type: object - type: array - git: - description: Git is the git repository that backs the content - of this Bundle. - properties: - auth: - description: Auth configures the authorization method if necessary. - properties: - insecureSkipVerify: - description: InsecureSkipVerify controls whether a client - verifies the server's certificate chain and host name. - If InsecureSkipVerify is true, the clone operation will - accept any certificate presented by the server and any - host name in that certificate. In this mode, TLS is - susceptible to machine-in-the-middle attacks unless - custom verification is used. This should be used only - for testing. - type: boolean - secret: - description: Secret contains reference to the secret that - has authorization information and is in the namespace - that the provisioner is deployed. The secret is expected - to contain `data.username` and `data.password` for the - username and password, respectively for http(s) scheme. - Refer to https://kubernetes.io/docs/concepts/configuration/secret/#basic-authentication-secret - For the ssh authorization of the GitSource, the secret - is expected to contain `data.ssh-privatekey` and `data.ssh-knownhosts` - for the ssh privatekey and the host entry in the known_hosts - file respectively. Refer to https://kubernetes.io/docs/concepts/configuration/secret/#ssh-authentication-secrets - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - type: object - x-kubernetes-map-type: atomic - type: object - directory: - description: Directory refers to the location of the bundle - within the git repository. Directory is optional and if - not set defaults to ./manifests. - type: string - ref: - description: Ref configures the git source to clone a specific - branch, tag, or commit from the specified repo. Ref is required, - and exactly one field within Ref is required. Setting more - than one field or zero fields will result in an error. - properties: - branch: - description: Branch refers to the branch to checkout from - the repository. The Branch should contain the bundle - manifests in the specified directory. - type: string - commit: - description: Commit refers to the commit to checkout from - the repository. The Commit should contain the bundle - manifests in the specified directory. - type: string - tag: - description: Tag refers to the tag to checkout from the - repository. The Tag should contain the bundle manifests - in the specified directory. - type: string - type: object - repository: - description: Repository is a URL link to the git repository - containing the bundle. Repository is required and the URL - should be parsable by a standard git tool. - type: string - required: - - ref - - repository - type: object - http: - description: HTTP is the remote location that backs the content - of this Bundle. - properties: - auth: - description: Auth configures the authorization method if necessary. - properties: - insecureSkipVerify: - description: InsecureSkipVerify controls whether a client - verifies the server's certificate chain and host name. - If InsecureSkipVerify is true, the clone operation will - accept any certificate presented by the server and any - host name in that certificate. In this mode, TLS is - susceptible to machine-in-the-middle attacks unless - custom verification is used. This should be used only - for testing. - type: boolean - secret: - description: Secret contains reference to the secret that - has authorization information and is in the namespace - that the provisioner is deployed. The secret is expected - to contain `data.username` and `data.password` for the - username and password, respectively for http(s) scheme. - Refer to https://kubernetes.io/docs/concepts/configuration/secret/#basic-authentication-secret - For the ssh authorization of the GitSource, the secret - is expected to contain `data.ssh-privatekey` and `data.ssh-knownhosts` - for the ssh privatekey and the host entry in the known_hosts - file respectively. Refer to https://kubernetes.io/docs/concepts/configuration/secret/#ssh-authentication-secrets - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - type: object - x-kubernetes-map-type: atomic - type: object - url: - description: URL is where the bundle contents is. - type: string - required: - - url - type: object - image: - description: Image is the bundle image that backs the content - of this bundle. - properties: - pullSecret: - description: ImagePullSecretName contains the name of the - image pull secret in the namespace that the provisioner - is deployed. - type: string - ref: - description: Ref contains the reference to a container image - containing Bundle contents. - type: string - required: - - ref - type: object - type: - description: Type defines the kind of Bundle content being sourced. - type: string - upload: - description: Upload is a source that enables this Bundle's content - to be uploaded via Rukpak's bundle upload service. This source - type is primarily useful with bundle development workflows because - it enables bundle developers to inject a local bundle directly - into the cluster. - type: object - required: - - type - type: object - type: object - required: - - spec - type: object - served: true - storage: true - subresources: - status: {} diff --git a/manifests/base/apis/crds/kustomization.yml b/manifests/base/apis/crds/kustomization.yml index fe14eea1..e106c727 100644 --- a/manifests/base/apis/crds/kustomization.yml +++ b/manifests/base/apis/crds/kustomization.yml @@ -1,13 +1,6 @@ resources: -- core.rukpak.io_bundles.yaml - core.rukpak.io_bundledeployments.yaml patches: -- path: patches/bundle_validation.yaml - target: - group: apiextensions.k8s.io - version: v1 - kind: CustomResourceDefinition - name: bundles.core.rukpak.io - path: patches/bundledeployment_validation.yaml target: group: apiextensions.k8s.io diff --git a/manifests/base/apis/crds/patches/bundle_validation.yaml b/manifests/base/apis/crds/patches/bundle_validation.yaml deleted file mode 100644 index 050c7eb0..00000000 --- a/manifests/base/apis/crds/patches/bundle_validation.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# the max bundle name up to 52 -# it allows extra 11 letters for related resource names -- op: add - path: /spec/versions/0/schema/openAPIV3Schema/properties/metadata/properties - value: - name: - type: string - maxLength: 52 -# Union source type -- op: add - path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/source/oneOf - value: - - required: - - git - - required: - - image - - required: - - configMaps - - required: - - upload - - required: - - http - -# Union git ref -- op: add - path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/source/properties/git/properties/ref/oneOf - value: - - required: - - branch - - required: - - commit - - required: - - tag diff --git a/manifests/base/apis/webhooks/resources/deployment.yaml b/manifests/base/apis/webhooks/resources/deployment.yaml index 13af812e..ed8a069a 100644 --- a/manifests/base/apis/webhooks/resources/deployment.yaml +++ b/manifests/base/apis/webhooks/resources/deployment.yaml @@ -27,7 +27,7 @@ spec: capabilities: drop: [ "ALL" ] command: ["/webhooks"] - image: quay.io/operator-framework/rukpak:main + image: quay.io/operator-framework/rukpak:devel imagePullPolicy: IfNotPresent ports: - containerPort: 8080 diff --git a/manifests/base/apis/webhooks/resources/webhook.yaml b/manifests/base/apis/webhooks/resources/webhook.yaml index ea8ce98f..29d0bb90 100644 --- a/manifests/base/apis/webhooks/resources/webhook.yaml +++ b/manifests/base/apis/webhooks/resources/webhook.yaml @@ -10,14 +10,14 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-core-rukpak-io-v1alpha1-bundledeployment + path: /validate-core-rukpak-io-v1alpha2-bundledeployment failurePolicy: Fail name: vbundles.core.rukpak.io rules: - apiGroups: - core.rukpak.io apiVersions: - - v1alpha1 + - v1alpha2 operations: - CREATE - UPDATE diff --git a/manifests/base/core/resources/deployment.yaml b/manifests/base/core/resources/deployment.yaml index 13ed56a6..56315655 100644 --- a/manifests/base/core/resources/deployment.yaml +++ b/manifests/base/core/resources/deployment.yaml @@ -50,11 +50,11 @@ spec: allowPrivilegeEscalation: false capabilities: drop: ["ALL"] - image: quay.io/operator-framework/rukpak:main + image: quay.io/operator-framework/rukpak:devel imagePullPolicy: IfNotPresent command: ["/core"] args: - - "--unpack-image=quay.io/operator-framework/rukpak:main" + - "--unpack-image=quay.io/operator-framework/rukpak:devel" - "--base-upload-manager-url=https://$(CORE_SERVICE_NAME).$(CORE_SERVICE_NAMESPACE).svc" - "--provisioner-storage-dir=/var/cache/bundles" - "--upload-storage-dir=/var/cache/uploads" diff --git a/manifests/base/crdvalidator/05_deployment.yaml b/manifests/base/crdvalidator/05_deployment.yaml index aab4c725..8e0f6b5d 100644 --- a/manifests/base/crdvalidator/05_deployment.yaml +++ b/manifests/base/crdvalidator/05_deployment.yaml @@ -14,7 +14,7 @@ spec: spec: serviceAccountName: crd-validation-webhook containers: - - image: quay.io/operator-framework/rukpak:main + - image: quay.io/operator-framework/rukpak:devel imagePullPolicy: IfNotPresent command: ["/crdvalidator"] name: crd-validation-webhook diff --git a/manifests/base/provisioners/helm/resources/deployment.yaml b/manifests/base/provisioners/helm/resources/deployment.yaml index 72789c34..d4d71b02 100644 --- a/manifests/base/provisioners/helm/resources/deployment.yaml +++ b/manifests/base/provisioners/helm/resources/deployment.yaml @@ -50,11 +50,11 @@ spec: allowPrivilegeEscalation: false capabilities: drop: [ "ALL" ] - image: quay.io/operator-framework/rukpak:main + image: quay.io/operator-framework/rukpak:devel imagePullPolicy: IfNotPresent command: ["/helm"] args: - - "--unpack-image=quay.io/operator-framework/rukpak:main" + - "--unpack-image=quay.io/operator-framework/rukpak:devel" - "--base-upload-manager-url=https://$(CORE_SERVICE_NAME).$(CORE_SERVICE_NAMESPACE).svc" - "--storage-dir=/var/cache/bundles" - "--http-bind-address=127.0.0.1:8080" diff --git a/sample-bundledeployment.yaml b/sample-bundledeployment.yaml deleted file mode 100644 index 66a63159..00000000 --- a/sample-bundledeployment.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: core.rukpak.io/v1alpha1 -kind: BundleDeployment -metadata: - name: prometheus -spec: - provisionerClassName: core-rukpak-io-plain - source: - type: image - image: - ref: quay.io/operatorhubio/prometheus:v0.65.0 diff --git a/test/e2e/api_validation_test.go b/test/e2e/api_validation_test.go index 612bfbc7..b6314ca4 100644 --- a/test/e2e/api_validation_test.go +++ b/test/e2e/api_validation_test.go @@ -11,29 +11,29 @@ import ( "k8s.io/apimachinery/pkg/util/rand" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/provisioner/plain" ) var _ = Describe("bundle api validation", func() { When("the bundle name is too long", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context - err error + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context + err error ) BeforeEach(func() { ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: "olm-crds-too-long-name-for-the-bundle-1234567890-1234567890", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: "localhost/testdata/bundles/plain-v0:valid", }, }, @@ -52,28 +52,28 @@ var _ = Describe("bundle api validation", func() { }) When("the bundle deployment with multiple sources", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context - err error + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context + err error ) BeforeEach(func() { By("creating the Bundle resource") ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: "bundlenamegit", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ + Source: rukpakv1alpha2.BundleSource{ Type: "invalid source", - Image: &rukpakv1alpha1.ImageSource{ + Image: &rukpakv1alpha2.ImageSource{ Ref: "localhost/testdata/bundles/plain-v0:valid", }, - Git: &rukpakv1alpha1.GitSource{ + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/exdx/combo-bundle", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Commit: "9e3ab7f1a36302ef512294d5c9f2e9b9566b811e", Tag: "v0.0.1", }, @@ -95,21 +95,21 @@ var _ = Describe("bundle api validation", func() { When("the bundle with no sources", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context - err error + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context + err error ) BeforeEach(func() { By("creating the Bundle resource") ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: "bundlenamegit", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ + Source: rukpakv1alpha2.BundleSource{ Type: "invalid source", }, }, @@ -128,25 +128,25 @@ var _ = Describe("bundle api validation", func() { When("the bundle source type is git and more than 1 refs are set", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context - err error + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context + err error ) BeforeEach(func() { By("creating the Bundle resource") ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: "bundlenamemorerefs", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/exdx/combo-bundle", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Commit: "9e3ab7f1a36302ef512294d5c9f2e9b9566b811e", Tag: "v0.0.1", }, @@ -168,25 +168,25 @@ var _ = Describe("bundle api validation", func() { When("the bundle source type is git and no refs are set", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context - err error + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context + err error ) BeforeEach(func() { By("creating the Bundle resource") ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: "bundlenamemorerefs", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/exdx/combo-bundle", - Ref: rukpakv1alpha1.GitRef{}, + Ref: rukpakv1alpha2.GitRef{}, }, }, }, @@ -204,28 +204,28 @@ var _ = Describe("bundle api validation", func() { }) When("a Bundle references an invalid provisioner class name", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) BeforeEach(func() { ctx = context.Background() }) AfterEach(func() { By("ensuring the testing Bundle does not exist") - err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), &rukpakv1alpha1.BundleDeployment{}) + err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), &rukpakv1alpha2.BundleDeployment{}) Expect(err).To(WithTransform(apierrors.IsNotFound, BeTrue()), fmt.Sprintf("error was: %v", err)) }) It("should fail validation", func() { By("creating the testing Bundle resource") - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("bundle-invalid-%s", rand.String(6)), }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: "invalid/class-name", - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: "localhost/testdata/bundles/plain-v0:valid", }, }, @@ -241,7 +241,7 @@ var _ = Describe("bundle api validation", func() { }) When("a BundleDeployment references an invalid provisioner class name", func() { var ( - bd *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment ctx context.Context ) BeforeEach(func() { @@ -249,20 +249,20 @@ var _ = Describe("bundle api validation", func() { }) AfterEach(func() { By("ensuring the testing Bundle does not exist") - err := c.Get(ctx, client.ObjectKeyFromObject(bd), &rukpakv1alpha1.BundleDeployment{}) + err := c.Get(ctx, client.ObjectKeyFromObject(bd), &rukpakv1alpha2.BundleDeployment{}) Expect(err).To(WithTransform(apierrors.IsNotFound, BeTrue()), fmt.Sprintf("error was: %v", err)) }) It("should fail validation", func() { By("creating the testing BundleDeployment resource") - bd = &rukpakv1alpha1.BundleDeployment{ + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("bd-invalid-%s", rand.String(6)), }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: "invalid/class-name", - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: "localhost/testdata/bundles/plain-v0:valid", }, }, diff --git a/test/e2e/crdvalidator_test.go b/test/e2e/crdvalidator_test.go index 99deadd3..ea0ff256 100644 --- a/test/e2e/crdvalidator_test.go +++ b/test/e2e/crdvalidator_test.go @@ -8,7 +8,7 @@ import ( apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/cmd/crdvalidator/annotation" "github.com/operator-framework/rukpak/internal/util" "github.com/operator-framework/rukpak/test/testutil" @@ -28,7 +28,7 @@ var _ = Describe("crdvalidator", func() { crd = testutil.NewTestingCRD("", testutil.DefaultGroup, []apiextensionsv1.CustomResourceDefinitionVersion{ { - Name: "v1alpha1", + Name: "v1alpha2", Served: true, Storage: true, Schema: &apiextensionsv1.CustomResourceValidation{ @@ -95,7 +95,7 @@ var _ = Describe("crdvalidator", func() { }, }) - crd.Labels = map[string]string{util.CoreOwnerKindKey: rukpakv1alpha1.BundleDeploymentKind} + crd.Labels = map[string]string{util.CoreOwnerKindKey: rukpakv1alpha2.BundleDeploymentKind} return c.Update(ctx, crd) }).Should(Succeed()) @@ -108,7 +108,7 @@ var _ = Describe("crdvalidator", func() { BeforeEach(func() { crd = testutil.NewTestingCRD("", testutil.DefaultGroup, []apiextensionsv1.CustomResourceDefinitionVersion{{ - Name: "v1alpha1", + Name: "v1alpha2", Served: true, Storage: true, Schema: &apiextensionsv1.CustomResourceValidation{ @@ -123,14 +123,14 @@ var _ = Describe("crdvalidator", func() { }}, ) - crd.Labels = map[string]string{util.CoreOwnerKindKey: rukpakv1alpha1.BundleDeploymentKind} + crd.Labels = map[string]string{util.CoreOwnerKindKey: rukpakv1alpha2.BundleDeploymentKind} Eventually(func() error { return c.Create(ctx, crd) }).Should(Succeed(), "should be able to create a safe crd but was not") // Build up a CR to create out of unstructured.Unstructured - sampleCR := testutil.NewTestingCR(testutil.DefaultCrName, testutil.DefaultGroup, "v1alpha1", crd.Spec.Names.Singular) + sampleCR := testutil.NewTestingCR(testutil.DefaultCrName, testutil.DefaultGroup, "v1alpha2", crd.Spec.Names.Singular) Eventually(func() error { return c.Create(ctx, sampleCR) }).Should(Succeed(), "should be able to create a cr for the sample crd but was not") @@ -148,7 +148,7 @@ var _ = Describe("crdvalidator", func() { return err.Error() } - // Update the v1alpha1 schema to invalidate existing CR created in BeforeEach() + // Update the v1alpha2 schema to invalidate existing CR created in BeforeEach() crd.Spec.Versions[0].Schema.OpenAPIV3Schema.Required = []string{"sampleProperty"} err := c.Update(ctx, crd) @@ -169,7 +169,7 @@ var _ = Describe("crdvalidator", func() { crd.Labels = map[string]string{} Expect(c.Update(ctx, crd)).To(Succeed()) - // Update the v1alpha1 schema to invalidate existing CR created in BeforeEach() + // Update the v1alpha2 schema to invalidate existing CR created in BeforeEach() crd.Spec.Versions[0].Schema.OpenAPIV3Schema.Required = []string{"sampleProperty"} return c.Update(ctx, crd) @@ -186,7 +186,7 @@ var _ = Describe("crdvalidator", func() { crd.Annotations = map[string]string{annotation.ValidationKey: annotation.Disabled} Expect(c.Update(ctx, crd)).To(Succeed()) - // Update the v1alpha1 schema to invalidate existing CR created in BeforeEach() + // Update the v1alpha2 schema to invalidate existing CR created in BeforeEach() crd.Spec.Versions[0].Schema.OpenAPIV3Schema.Required = []string{"sampleProperty"} return c.Update(ctx, crd) @@ -210,7 +210,7 @@ var _ = Describe("crdvalidator", func() { crd = testutil.NewTestingCRD("", testutil.DefaultGroup, []apiextensionsv1.CustomResourceDefinitionVersion{ { - Name: "v1alpha1", + Name: "v1alpha2", Served: true, Storage: true, Schema: &apiextensionsv1.CustomResourceValidation{ diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 2b92da4d..fde6f869 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -18,7 +18,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" ) var ( @@ -38,7 +38,7 @@ var _ = BeforeSuite(func() { cfg = ctrl.GetConfigOrDie() scheme := runtime.NewScheme() - Expect(rukpakv1alpha1.AddToScheme(scheme)).To(Succeed()) + Expect(rukpakv1alpha2.AddToScheme(scheme)).To(Succeed()) Expect(rbacv1.AddToScheme(scheme)).To(Succeed()) Expect(batchv1.AddToScheme(scheme)).To(Succeed()) Expect(operatorsv1.AddToScheme(scheme)).To(Succeed()) diff --git a/test/e2e/helm_provisioner_test.go b/test/e2e/helm_provisioner_test.go index 16920c58..77440a88 100644 --- a/test/e2e/helm_provisioner_test.go +++ b/test/e2e/helm_provisioner_test.go @@ -13,35 +13,34 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/provisioner/helm" ) var _ = Describe("helm provisioner bundledeployment", func() { When("a BundleDeployment targets a valid Bundle", func() { var ( - bd *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment ctx context.Context ) BeforeEach(func() { ctx = context.Background() - bd = &rukpakv1alpha1.BundleDeployment{ + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "ahoy-", Labels: map[string]string{ "app.kubernetes.io/name": "ahoy", }, }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: helm.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeHTTP, - HTTP: &rukpakv1alpha1.HTTPSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeHTTP, + HTTP: &rukpakv1alpha2.HTTPSource{ URL: "https://github.com/helm/examples/releases/download/hello-world-0.1.0/hello-world-0.1.0.tgz", }, }, - }, } err := c.Create(ctx, bd) @@ -58,12 +57,12 @@ var _ = Describe("helm provisioner bundledeployment", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { return nil, err } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallationSucceeded)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), )) }) @@ -125,24 +124,24 @@ var _ = Describe("helm provisioner bundledeployment", func() { When("a BundleDeployment targets a Bundle with an invalid url", func() { var ( - bd *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment ctx context.Context ) BeforeEach(func() { ctx = context.Background() - bd = &rukpakv1alpha1.BundleDeployment{ + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "ahoy-", Labels: map[string]string{ "app.kubernetes.io/name": "ahoy", }, }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: helm.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeHTTP, - HTTP: &rukpakv1alpha1.HTTPSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeHTTP, + HTTP: &rukpakv1alpha2.HTTPSource{ URL: "https://github.com/helm/examples/releases/download/hello-world-0.1.0/xxx", }, }, @@ -162,35 +161,35 @@ var _ = Describe("helm provisioner bundledeployment", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { return nil, err } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring(`unexpected status "404 Not Found"`)), )) }) }) When("a BundleDeployment targets a Bundle with a none-tgz file url", func() { var ( - bd *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment ctx context.Context ) BeforeEach(func() { ctx = context.Background() - bd = &rukpakv1alpha1.BundleDeployment{ + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "ahoy-", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: helm.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeHTTP, - HTTP: &rukpakv1alpha1.HTTPSource{ - URL: "https://raw.githubusercontent.com/helm/examples/main/LICENSE", - }, + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeHTTP, + HTTP: &rukpakv1alpha2.HTTPSource{ + URL: "https://raw.githubusercontent.com/helm/examples/main/LICENSE", + }, }, }, } @@ -208,36 +207,36 @@ var _ = Describe("helm provisioner bundledeployment", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { return nil, err } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("gzip: invalid header")), )) }) }) When("a BundleDeployment targets a Bundle with a none chart tgz url", func() { var ( - bd *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment ctx context.Context ) BeforeEach(func() { ctx = context.Background() - bd = &rukpakv1alpha1.BundleDeployment{ + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "ahoy-", Labels: map[string]string{ "app.kubernetes.io/name": "ahoy", }, }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: helm.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeHTTP, - HTTP: &rukpakv1alpha1.HTTPSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeHTTP, + HTTP: &rukpakv1alpha2.HTTPSource{ URL: "https://github.com/helm/examples/archive/refs/tags/hello-world-0.1.0.tar.gz", }, }, @@ -257,43 +256,43 @@ var _ = Describe("helm provisioner bundledeployment", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { return nil, err } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Chart.yaml file is missing")), )) }) }) When("a BundleDeployment targets a valid Bundle in Github", func() { var ( - bd *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment ctx context.Context ) BeforeEach(func() { ctx = context.Background() - bd = &rukpakv1alpha1.BundleDeployment{ + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "ahoy-", Labels: map[string]string{ "app.kubernetes.io/name": "ahoy", }, }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: helm.ProvisionerID, - Source:rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/helm/examples", Directory: "./charts", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Branch: "main", }, }, - } , + }, }, } err := c.Create(ctx, bd) @@ -310,12 +309,12 @@ var _ = Describe("helm provisioner bundledeployment", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { return nil, err } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallationSucceeded)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), )) }) @@ -383,27 +382,27 @@ var _ = Describe("helm provisioner bundledeployment", func() { }) When("a BundleDeployment targets a valid Bundle with no chart directory in Github", func() { var ( - bd *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment ctx context.Context ) BeforeEach(func() { ctx = context.Background() - bd = &rukpakv1alpha1.BundleDeployment{ + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "ahoy-", Labels: map[string]string{ "app.kubernetes.io/name": "ahoy", }, }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: helm.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/helm/examples", Directory: "./charts/hello-world", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Branch: "main", }, }, @@ -424,37 +423,37 @@ var _ = Describe("helm provisioner bundledeployment", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { return nil, err } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallationSucceeded)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), )) }) }) When("a BundleDeployment targets a valid Bundle with values", func() { var ( - bd *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment ctx context.Context ) BeforeEach(func() { ctx = context.Background() - bd = &rukpakv1alpha1.BundleDeployment{ + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "ahoy-", - Labels: map[string]string{ + Labels: map[string]string{ "app.kubernetes.io/name": "ahoy", }, }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: helm.ProvisionerID, Config: runtime.RawExtension{Raw: []byte(`{"values": "# Default values for hello-world.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\nreplicaCount: 1\nimage:\n repository: nginx\n pullPolicy: IfNotPresent\n # Overrides the image tag whose default is the chart appVersion.\n tag: \"\"\nnameOverride: \"fromvalues\"\nfullnameOverride: \"\"\nserviceAccount:\n # Specifies whether a service account should be created\n create: true\n # Annotations to add to the service account\n annotations: {}\n # The name of the service account to use.\n # If not set and create is true, a name is generated using the fullname template\n name: \"\"\nservice:\n type: ClusterIP\n port: 80\n"}`)}, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeHTTP, - HTTP: &rukpakv1alpha1.HTTPSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeHTTP, + HTTP: &rukpakv1alpha2.HTTPSource{ URL: "https://github.com/helm/examples/releases/download/hello-world-0.1.0/hello-world-0.1.0.tgz", }, }, @@ -474,12 +473,12 @@ var _ = Describe("helm provisioner bundledeployment", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { return nil, err } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallationSucceeded)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), )) diff --git a/test/e2e/plain_provisioner_test.go b/test/e2e/plain_provisioner_test.go index 2613e637..a202018d 100644 --- a/test/e2e/plain_provisioner_test.go +++ b/test/e2e/plain_provisioner_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/provisioner/plain" "github.com/operator-framework/rukpak/internal/rukpakctl" "github.com/operator-framework/rukpak/internal/storage" @@ -51,22 +51,22 @@ func Logf(f string, v ...interface{}) { var _ = Describe("plain provisioner bundle", func() { When("a valid Bundle references the wrong unique provisioner ID", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) BeforeEach(func() { ctx = context.Background() By("creating the testing Bundle resource") - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "olm-crds-valid", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: "non-existent-class-name", - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:valid"), }, }, @@ -91,22 +91,22 @@ var _ = Describe("plain provisioner bundle", func() { }) When("a valid Bundle Deployment referencing a remote container image is created", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) BeforeEach(func() { ctx = context.Background() By("creating the testing Bundle resource") - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "olm-crds-valid", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:valid"), }, }, @@ -124,17 +124,17 @@ var _ = Describe("plain provisioner bundle", func() { It("should eventually report a successful state", func() { By("eventually writing a non-empty image digest to the status", func() { - Eventually(func() (*rukpakv1alpha1.BundleSource, error) { + Eventually(func() (*rukpakv1alpha2.BundleSource, error) { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } return bundledeployment.Status.ResolvedSource, nil }).Should(And( Not(BeNil()), - WithTransform(func(s *rukpakv1alpha1.BundleSource) rukpakv1alpha1.SourceType { return s.Type }, Equal(rukpakv1alpha1.SourceTypeImage)), - WithTransform(func(s *rukpakv1alpha1.BundleSource) *rukpakv1alpha1.ImageSource { return s.Image }, And( + WithTransform(func(s *rukpakv1alpha2.BundleSource) rukpakv1alpha2.SourceType { return s.Type }, Equal(rukpakv1alpha2.SourceTypeImage)), + WithTransform(func(s *rukpakv1alpha2.BundleSource) *rukpakv1alpha2.ImageSource { return s.Image }, And( Not(BeNil()), - WithTransform(func(i *rukpakv1alpha1.ImageSource) string { return i.Ref }, Not(Equal(""))), + WithTransform(func(i *rukpakv1alpha2.ImageSource) string { return i.Ref }, Not(Equal(""))), )), )) }) @@ -179,22 +179,22 @@ var _ = Describe("plain provisioner bundle", func() { When("a valid Bundle Deployment referencing a remote private container image is created", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) BeforeEach(func() { ctx = context.Background() By("creating the testing Bundle resource") - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "olm-crds-valid", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: "docker-registry.rukpak-e2e.svc.cluster.local:5000/bundles/plain-v0:valid", ImagePullSecretName: "registrysecret", }, @@ -212,32 +212,32 @@ var _ = Describe("plain provisioner bundle", func() { It("should eventually report a successful state", func() { By("eventually reporting an Unpacked phase", func() { - Eventually(func() (*metav1.Condition, error){ + Eventually(func() (*metav1.Condition, error) { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { - return nil, err - } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil + return nil, err + } + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallationSucceeded)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), )) }) By("eventually writing a non-empty image digest to the status", func() { - Eventually(func() (*rukpakv1alpha1.BundleSource, error) { + Eventually(func() (*rukpakv1alpha2.BundleSource, error) { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } return bundledeployment.Status.ResolvedSource, nil }).Should(And( Not(BeNil()), - WithTransform(func(s *rukpakv1alpha1.BundleSource) rukpakv1alpha1.SourceType { return s.Type }, Equal(rukpakv1alpha1.SourceTypeImage)), - WithTransform(func(s *rukpakv1alpha1.BundleSource) *rukpakv1alpha1.ImageSource { return s.Image }, And( + WithTransform(func(s *rukpakv1alpha2.BundleSource) rukpakv1alpha2.SourceType { return s.Type }, Equal(rukpakv1alpha2.SourceTypeImage)), + WithTransform(func(s *rukpakv1alpha2.BundleSource) *rukpakv1alpha2.ImageSource { return s.Image }, And( Not(BeNil()), - WithTransform(func(i *rukpakv1alpha1.ImageSource) string { return i.Ref }, Not(Equal(""))), + WithTransform(func(i *rukpakv1alpha2.ImageSource) string { return i.Ref }, Not(Equal(""))), )), )) }) @@ -246,22 +246,22 @@ var _ = Describe("plain provisioner bundle", func() { When("an invalid Bundle Deployment referencing a remote container image is created", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) BeforeEach(func() { ctx = context.Background() By("creating the testing Bundle resource") - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "olm-crds-invalid", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:non-existent-tag"), }, }, @@ -303,7 +303,7 @@ var _ = Describe("plain provisioner bundle", func() { if err != nil { return false } - unpackPending := meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.PhaseUnpacked) + unpackPending := meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.PhaseUnpacked) if unpackPending == nil { return false } @@ -317,22 +317,22 @@ var _ = Describe("plain provisioner bundle", func() { When("a bundle deployment containing no manifests is created", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) BeforeEach(func() { ctx = context.Background() By("creating the testing Bundle resource") - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "olm-crds-unsupported", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:empty"), }, }, @@ -353,12 +353,12 @@ var _ = Describe("plain provisioner bundle", func() { if err != nil { return nil, err } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring(`readdir manifests: file does not exist`)), )) }) @@ -366,22 +366,22 @@ var _ = Describe("plain provisioner bundle", func() { When("a bundle containing an empty manifests directory is created", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) BeforeEach(func() { ctx = context.Background() By("creating the testing Bundle resource") - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "olm-crds-unsupported", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:no-manifests"), }, }, @@ -402,12 +402,12 @@ var _ = Describe("plain provisioner bundle", func() { if err != nil { return nil, err } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring(`found zero objects: plain+v0 bundles are required to contain at least one object`)), )) }) @@ -424,20 +424,20 @@ var _ = Describe("plain provisioner bundle", func() { When("the bundle is backed by a git commit", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment + bundledeployment *rukpakv1alpha2.BundleDeployment ) BeforeEach(func() { - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-git-commit", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/exdx/combo-bundle", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Commit: "9e3ab7f1a36302ef512294d5c9f2e9b9566b811e", }, }, @@ -473,20 +473,20 @@ var _ = Describe("plain provisioner bundle", func() { }) When("the bundle deployment is backed by a git tag", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment + bundledeployment *rukpakv1alpha2.BundleDeployment ) BeforeEach(func() { - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-git-tag", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/exdx/combo-bundle", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Tag: "v0.0.1", }, }, @@ -522,17 +522,17 @@ var _ = Describe("plain provisioner bundle", func() { }) By("eventually writing a non-empty commit hash to the status", func() { - Eventually(func() (*rukpakv1alpha1.BundleSource, error) { + Eventually(func() (*rukpakv1alpha2.BundleSource, error) { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } return bundledeployment.Status.ResolvedSource, nil }).Should(And( Not(BeNil()), - WithTransform(func(s *rukpakv1alpha1.BundleSource) rukpakv1alpha1.SourceType { return s.Type }, Equal(rukpakv1alpha1.SourceTypeGit)), - WithTransform(func(s *rukpakv1alpha1.BundleSource) *rukpakv1alpha1.GitSource { return s.Git }, And( + WithTransform(func(s *rukpakv1alpha2.BundleSource) rukpakv1alpha2.SourceType { return s.Type }, Equal(rukpakv1alpha2.SourceTypeGit)), + WithTransform(func(s *rukpakv1alpha2.BundleSource) *rukpakv1alpha2.GitSource { return s.Git }, And( Not(BeNil()), - WithTransform(func(i *rukpakv1alpha1.GitSource) string { return i.Ref.Commit }, Not(Equal(""))), + WithTransform(func(i *rukpakv1alpha2.GitSource) string { return i.Ref.Commit }, Not(Equal(""))), )), )) }) @@ -541,20 +541,20 @@ var _ = Describe("plain provisioner bundle", func() { When("the bundle deployment is backed by a git branch", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment + bundledeployment *rukpakv1alpha2.BundleDeployment ) BeforeEach(func() { - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-git-branch", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/exdx/combo-bundle.git", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Branch: "main", }, }, @@ -590,17 +590,17 @@ var _ = Describe("plain provisioner bundle", func() { }) By("eventually writing a non-empty commit hash to the status", func() { - Eventually(func() (*rukpakv1alpha1.BundleSource, error) { + Eventually(func() (*rukpakv1alpha2.BundleSource, error) { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } return bundledeployment.Status.ResolvedSource, nil }).Should(And( Not(BeNil()), - WithTransform(func(s *rukpakv1alpha1.BundleSource) rukpakv1alpha1.SourceType { return s.Type }, Equal(rukpakv1alpha1.SourceTypeGit)), - WithTransform(func(s *rukpakv1alpha1.BundleSource) *rukpakv1alpha1.GitSource { return s.Git }, And( + WithTransform(func(s *rukpakv1alpha2.BundleSource) rukpakv1alpha2.SourceType { return s.Type }, Equal(rukpakv1alpha2.SourceTypeGit)), + WithTransform(func(s *rukpakv1alpha2.BundleSource) *rukpakv1alpha2.GitSource { return s.Git }, And( Not(BeNil()), - WithTransform(func(i *rukpakv1alpha1.GitSource) string { return i.Ref.Commit }, Not(Equal(""))), + WithTransform(func(i *rukpakv1alpha2.GitSource) string { return i.Ref.Commit }, Not(Equal(""))), )), )) }) @@ -609,21 +609,21 @@ var _ = Describe("plain provisioner bundle", func() { When("the bundle deployment has a custom manifests directory", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment + bundledeployment *rukpakv1alpha2.BundleDeployment ) BeforeEach(func() { - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-git-custom-dir", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/exdx/combo-bundle", Directory: "./dev/deploy", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Branch: "main", }, }, @@ -660,9 +660,9 @@ var _ = Describe("plain provisioner bundle", func() { When("the bundle deployment is backed by a private repository", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - secret *corev1.Secret - privateRepo string + bundledeployment *rukpakv1alpha2.BundleDeployment + secret *corev1.Secret + privateRepo string ) BeforeEach(func() { privateRepo = os.Getenv("PRIVATE_GIT_REPO") @@ -683,20 +683,20 @@ var _ = Describe("plain provisioner bundle", func() { } err := c.Create(ctx, secret) Expect(err).ToNot(HaveOccurred()) - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-git-branch", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: privateRepo, - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Branch: "main", }, - Auth: rukpakv1alpha1.Authorization{ + Auth: rukpakv1alpha2.Authorization{ Secret: corev1.LocalObjectReference{ Name: secret.Name, }, @@ -737,25 +737,25 @@ var _ = Describe("plain provisioner bundle", func() { When("the bundle deployment is backed by a local git repository", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - privateRepo string + bundledeployment *rukpakv1alpha2.BundleDeployment + privateRepo string ) BeforeEach(func() { privateRepo = "ssh://git@local-git.rukpak-e2e.svc.cluster.local:2222/git-server/repos/combo" - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-git-branch", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: privateRepo, - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Branch: "main", }, - Auth: rukpakv1alpha1.Authorization{ + Auth: rukpakv1alpha2.Authorization{ Secret: corev1.LocalObjectReference{ Name: "gitsecret", }, @@ -796,9 +796,9 @@ var _ = Describe("plain provisioner bundle", func() { When("the bundle deployment is backed by a configmap", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - configmap *corev1.ConfigMap - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + configmap *corev1.ConfigMap + ctx context.Context ) BeforeEach(func() { @@ -830,15 +830,15 @@ var _ = Describe("plain provisioner bundle", func() { } err = c.Create(ctx, configmap) Expect(err).ToNot(HaveOccurred()) - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-local-", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeConfigMaps, - ConfigMaps: []rukpakv1alpha1.ConfigMapSource{{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeConfigMaps, + ConfigMaps: []rukpakv1alpha2.ConfigMapSource{{ ConfigMap: corev1.LocalObjectReference{Name: configmap.ObjectMeta.Name}, Path: "manifests", }}, @@ -858,31 +858,28 @@ var _ = Describe("plain provisioner bundle", func() { It("Can create and unpack the bundle successfully", func() { Eventually(func() error { - if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { - return err - } - return nil + return c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment) }).Should(BeNil()) }) }) When("the bundle is backed by a non-existent configmap", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) BeforeEach(func() { ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-local-", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeConfigMaps, - ConfigMaps: []rukpakv1alpha1.ConfigMapSource{{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeConfigMaps, + ConfigMaps: []rukpakv1alpha2.ConfigMapSource{{ ConfigMap: corev1.LocalObjectReference{Name: "non-exist"}, Path: "manifests", }}, @@ -903,12 +900,12 @@ var _ = Describe("plain provisioner bundle", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring(fmt.Sprintf("source bundle content: get configmap %[1]s/%[2]s: ConfigMap %[2]q not found", defaultSystemNamespace, "non-exist"))), )) @@ -917,9 +914,9 @@ var _ = Describe("plain provisioner bundle", func() { When("the bundle is backed by an invalid configmap", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - configmap *corev1.ConfigMap - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + configmap *corev1.ConfigMap + ctx context.Context ) BeforeEach(func() { @@ -950,15 +947,15 @@ var _ = Describe("plain provisioner bundle", func() { } err = c.Create(ctx, configmap) Expect(err).ToNot(HaveOccurred()) - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-local-", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeConfigMaps, - ConfigMaps: []rukpakv1alpha1.ConfigMapSource{{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeConfigMaps, + ConfigMaps: []rukpakv1alpha2.ConfigMapSource{{ ConfigMap: corev1.LocalObjectReference{Name: configmap.ObjectMeta.Name}, Path: "manifests", }}, @@ -981,12 +978,12 @@ var _ = Describe("plain provisioner bundle", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("json: cannot unmarshal string into Go value")), )) }) @@ -994,23 +991,23 @@ var _ = Describe("plain provisioner bundle", func() { When("the bundle deployment is uploaded", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) BeforeEach(func() { ctx = context.Background() bundleFS := os.DirFS(filepath.Join(testdataDir, "bundles/plain-v0/valid")) - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("valid-upload-%s", rand.String(8)), }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeUpload, - Upload: &rukpakv1alpha1.UploadSource{}, + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeUpload, + Upload: &rukpakv1alpha2.UploadSource{}, }, }, } @@ -1038,16 +1035,16 @@ var _ = Describe("plain provisioner bundle", func() { }) It("can unpack the bundle successfully", func() { - Eventually(func() (*metav1.Condition, error){ + Eventually(func() (*metav1.Condition, error) { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { - return nil, err - } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil + return nil, err + } + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallationSucceeded)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), )) }) @@ -1055,8 +1052,8 @@ var _ = Describe("plain provisioner bundle", func() { When("the bundle deployment is backed by an invalid upload", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) const ( manifestsDir = "manifests" @@ -1066,15 +1063,15 @@ var _ = Describe("plain provisioner bundle", func() { ctx = context.Background() bundleFS := os.DirFS(filepath.Join(testdataDir, "bundles/plain-v0/subdir")) - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("invalid-upload-%s", rand.String(8)), }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeUpload, - Upload: &rukpakv1alpha1.UploadSource{}, + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeUpload, + Upload: &rukpakv1alpha2.UploadSource{}, }, }, } @@ -1105,12 +1102,12 @@ var _ = Describe("plain provisioner bundle", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring(fmt.Sprintf("subdirectories are not allowed within the %q directory of the bundle image filesystem: found %q", manifestsDir, filepath.Join(manifestsDir, subdirName)))), )) @@ -1119,8 +1116,8 @@ var _ = Describe("plain provisioner bundle", func() { When("a bundle deployment containing nested directory is created", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context ) const ( manifestsDir = "manifests" @@ -1130,15 +1127,15 @@ var _ = Describe("plain provisioner bundle", func() { ctx = context.Background() By("creating the testing Bundle resource") - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "namespace-subdirs", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:subdir"), }, }, @@ -1158,12 +1155,12 @@ var _ = Describe("plain provisioner bundle", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring(fmt.Sprintf("subdirectories are not allowed within the %q directory of the bundle image filesystem: found %q", manifestsDir, filepath.Join(manifestsDir, subdirName)))), )) @@ -1173,22 +1170,22 @@ var _ = Describe("plain provisioner bundle", func() { When("valid bundle is created", func() { var ( - ctx context.Context - bundledeployment *rukpakv1alpha1.BundleDeployment + ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment ) BeforeEach(func() { ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-git-commit", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/exdx/combo-bundle", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Commit: "9e3ab7f1a36302ef512294d5c9f2e9b9566b811e", }, }, @@ -1198,16 +1195,16 @@ var _ = Describe("plain provisioner bundle", func() { err := c.Create(ctx, bundledeployment) Expect(err).ToNot(HaveOccurred()) By("eventually reporting an Unpacked phase", func() { - Eventually(func() (*metav1.Condition, error){ + Eventually(func() (*metav1.Condition, error) { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { - return nil, err - } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return nil, err + } + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackSuccessful)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackSuccessful)), )) }) @@ -1333,214 +1330,214 @@ var _ = Describe("plain provisioner bundle", func() { }) var _ = Describe("plain provisioner bundledeployment", func() { - When("a BundleDeployment is dependent on another BundleDeployment", func() { - var ( - ctx context.Context - dependentBD *rukpakv1alpha1.BundleDeployment - ) - BeforeEach(func() { - ctx = context.Background() - By("creating the testing dependent BundleDeployment resource") - dependentBD = &rukpakv1alpha1.BundleDeployment{ - ObjectMeta: metav1.ObjectMeta{ - GenerateName: "e2e-bd-dependent-", - }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ - ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ - Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:dependent"), + When("a BundleDeployment is dependent on another BundleDeployment", func() { + var ( + ctx context.Context + dependentBD *rukpakv1alpha2.BundleDeployment + ) + BeforeEach(func() { + ctx = context.Background() + By("creating the testing dependent BundleDeployment resource") + dependentBD = &rukpakv1alpha2.BundleDeployment{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "e2e-bd-dependent-", + }, + Spec: rukpakv1alpha2.BundleDeploymentSpec{ + ProvisionerClassName: plain.ProvisionerID, + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ + Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:dependent"), + }, }, }, - }, - } - err := c.Create(ctx, dependentBD) - Expect(err).ToNot(HaveOccurred()) - }) - AfterEach(func() { - By("deleting the testing dependent BundleDeployment resource") - Expect(client.IgnoreNotFound(c.Delete(ctx, dependentBD))).To(Succeed()) + } + err := c.Create(ctx, dependentBD) + Expect(err).ToNot(HaveOccurred()) + }) + AfterEach(func() { + By("deleting the testing dependent BundleDeployment resource") + Expect(client.IgnoreNotFound(c.Delete(ctx, dependentBD))).To(Succeed()) - }) - When("the providing BundleDeployment does not exist", func() { - It("should eventually project a failed installation for the dependent BundleDeployment", func() { - Eventually(func() (*metav1.Condition, error) { - if err := c.Get(ctx, client.ObjectKeyFromObject(dependentBD), dependentBD); err != nil { - return nil, err + }) + When("the providing BundleDeployment does not exist", func() { + It("should eventually project a failed installation for the dependent BundleDeployment", func() { + Eventually(func() (*metav1.Condition, error) { + if err := c.Get(ctx, client.ObjectKeyFromObject(dependentBD), dependentBD); err != nil { + return nil, err + } + return meta.FindStatusCondition(dependentBD.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil + }).Should(And( + Not(BeNil()), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), + WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Message }, + ContainSubstring(`required resource not found`)), + )) + }) + }) + When("the providing BundleDeployment is created", func() { + var ( + providesBD *rukpakv1alpha2.BundleDeployment + ) + BeforeEach(func() { + ctx = context.Background() + + By("creating the testing providing BD resource") + providesBD = &rukpakv1alpha2.BundleDeployment{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "e2e-bd-providing-", + }, + Spec: rukpakv1alpha2.BundleDeploymentSpec{ + ProvisionerClassName: plain.ProvisionerID, + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ + Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:provides"), + }, + }, + }, } - return meta.FindStatusCondition(dependentBD.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil - }).Should(And( - Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), - WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallFailed)), - WithTransform(func(c *metav1.Condition) string { return c.Message }, - ContainSubstring(`required resource not found`)), - )) + err := c.Create(ctx, providesBD) + Expect(err).ToNot(HaveOccurred()) + }) + AfterEach(func() { + By("deleting the testing providing BundleDeployment resource") + Expect(client.IgnoreNotFound(c.Delete(ctx, providesBD))).To(Succeed()) + + }) + It("should eventually project a successful installation for the dependent BundleDeployment", func() { + Eventually(func() (*metav1.Condition, error) { + if err := c.Get(ctx, client.ObjectKeyFromObject(dependentBD), dependentBD); err != nil { + return nil, err + } + return meta.FindStatusCondition(dependentBD.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil + }).Should(And( + Not(BeNil()), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), + WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallationSucceeded)), + WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), + )) + }) }) }) - When("the providing BundleDeployment is created", func() { + + When("a BundleDeployment targets a Bundle that contains CRDs and instances of those CRDs", func() { var ( - providesBD *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment + ctx context.Context ) BeforeEach(func() { ctx = context.Background() - By("creating the testing providing BD resource") - providesBD = &rukpakv1alpha1.BundleDeployment{ + By("creating the testing BD resource") + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ - GenerateName: "e2e-bd-providing-", + GenerateName: "e2e-bd-crds-and-crs-", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ - Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:provides"), + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ + Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:invalid-crds-and-crs"), }, }, }, } - err := c.Create(ctx, providesBD) + err := c.Create(ctx, bd) Expect(err).ToNot(HaveOccurred()) }) AfterEach(func() { - By("deleting the testing providing BundleDeployment resource") - Expect(client.IgnoreNotFound(c.Delete(ctx, providesBD))).To(Succeed()) - + By("deleting the testing BD resource") + Expect(c.Delete(ctx, bd)).To(Succeed()) }) - It("should eventually project a successful installation for the dependent BundleDeployment", func() { + It("eventually reports a failed installation state due to missing APIs on the cluster", func() { Eventually(func() (*metav1.Condition, error) { - if err := c.Get(ctx, client.ObjectKeyFromObject(dependentBD), dependentBD); err != nil { + if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { return nil, err } - return meta.FindStatusCondition(dependentBD.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), - WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), - WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), + WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring(`no matches for kind "CatalogSource" in version "operators.coreos.com/v1alpha2"`)), )) }) }) }) - When("a BundleDeployment targets a Bundle that contains CRDs and instances of those CRDs", func() { - var ( - bd *rukpakv1alpha1.BundleDeployment - ctx context.Context - ) - BeforeEach(func() { - ctx = context.Background() - - By("creating the testing BD resource") - bd = &rukpakv1alpha1.BundleDeployment{ - ObjectMeta: metav1.ObjectMeta{ - GenerateName: "e2e-bd-crds-and-crs-", - }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ - ProvisionerClassName: plain.ProvisionerID, - Source:rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ - Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:invalid-crds-and-crs"), - }, - }, - }, - } - err := c.Create(ctx, bd) - Expect(err).ToNot(HaveOccurred()) - }) - AfterEach(func() { - By("deleting the testing BD resource") - Expect(c.Delete(ctx, bd)).To(Succeed()) - }) - It("eventually reports a failed installation state due to missing APIs on the cluster", func() { - Eventually(func() (*metav1.Condition, error) { - if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { - return nil, err - } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil - }).Should(And( - Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), - WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallFailed)), - WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring(`no matches for kind "CatalogSource" in version "operators.coreos.com/v1alpha1"`)), - )) - }) - }) -}) - -var _ = Describe("plain provisioner garbage collection", func() { + var _ = Describe("plain provisioner garbage collection", func() { - When("a BundleDeployment has been deleted", func() { - var ( - ctx context.Context - bd *rukpakv1alpha1.BundleDeployment - ) - BeforeEach(func() { - ctx = context.Background() + When("a BundleDeployment has been deleted", func() { + var ( + ctx context.Context + bd *rukpakv1alpha2.BundleDeployment + ) + BeforeEach(func() { + ctx = context.Background() - By("creating the testing BD resource") - bd = &rukpakv1alpha1.BundleDeployment{ - ObjectMeta: metav1.ObjectMeta{ - GenerateName: "e2e-ownerref-bd-valid-", - Labels: map[string]string{ - "app.kubernetes.io/name": "e2e-ownerref-bundle-valid", + By("creating the testing BD resource") + bd = &rukpakv1alpha2.BundleDeployment{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "e2e-ownerref-bd-valid-", + Labels: map[string]string{ + "app.kubernetes.io/name": "e2e-ownerref-bundle-valid", + }, }, - }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ - ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ - Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:valid"), + Spec: rukpakv1alpha2.BundleDeploymentSpec{ + ProvisionerClassName: plain.ProvisionerID, + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ + Ref: fmt.Sprintf("%v/%v", ImageRepo, "plain-v0:valid"), + }, }, }, - }, - } - Expect(c.Create(ctx, bd)).To(Succeed()) - - By("waiting for the BD to eventually report a successful install status") - Eventually(func() (*metav1.Condition, error) { - if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { - return nil, err } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil - }).Should(And( - Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), - WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), - WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), - )) - }) - AfterEach(func() { - By("deleting the testing BD resource") - Expect(c.Get(ctx, client.ObjectKeyFromObject(bd), &rukpakv1alpha1.BundleDeployment{})).To(WithTransform(apierrors.IsNotFound, BeTrue())) - }) - It("should eventually result in the installed CRDs being deleted", func() { - By("deleting the testing BD resource") - Expect(c.Delete(ctx, bd)).To(Succeed()) + Expect(c.Create(ctx, bd)).To(Succeed()) - By("waiting until all the installed CRDs have been deleted") - selector := util.NewBundleDeploymentLabelSelector(bd) - Eventually(func() bool { - crds := &apiextensionsv1.CustomResourceDefinitionList{} - if err := c.List(ctx, crds, &client.ListOptions{ - LabelSelector: selector, - }); err != nil { - return false - } - return len(crds.Items) == 0 - }).Should(BeTrue()) + By("waiting for the BD to eventually report a successful install status") + Eventually(func() (*metav1.Condition, error) { + if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { + return nil, err + } + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil + }).Should(And( + Not(BeNil()), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), + WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallationSucceeded)), + WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), + )) + }) + AfterEach(func() { + By("deleting the testing BD resource") + Expect(c.Get(ctx, client.ObjectKeyFromObject(bd), &rukpakv1alpha2.BundleDeployment{})).To(WithTransform(apierrors.IsNotFound, BeTrue())) + }) + It("should eventually result in the installed CRDs being deleted", func() { + By("deleting the testing BD resource") + Expect(c.Delete(ctx, bd)).To(Succeed()) + + By("waiting until all the installed CRDs have been deleted") + selector := util.NewBundleDeploymentLabelSelector(bd) + Eventually(func() bool { + crds := &apiextensionsv1.CustomResourceDefinitionList{} + if err := c.List(ctx, crds, &client.ListOptions{ + LabelSelector: selector, + }); err != nil { + return false + } + return len(crds.Items) == 0 + }).Should(BeTrue()) + }) }) }) }) -}) func checkProvisionerBundleDeployment(ctx context.Context, object client.Object, provisionerPodName string) error { req := kubeClient.CoreV1().RESTClient().Post(). diff --git a/test/e2e/registry_provisioner_test.go b/test/e2e/registry_provisioner_test.go index 2839aa98..e2184453 100644 --- a/test/e2e/registry_provisioner_test.go +++ b/test/e2e/registry_provisioner_test.go @@ -10,31 +10,31 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" registryprovisioner "github.com/operator-framework/rukpak/internal/provisioner/registry" ) var _ = Describe("registry provisioner bundle", func() { When("a BundleDeployment targets a registry+v1 Bundle", func() { var ( - bd *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment ctx context.Context ) BeforeEach(func() { ctx = context.Background() - bd = &rukpakv1alpha1.BundleDeployment{ + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "prometheus", Labels: map[string]string{ "app.kubernetes.io/name": "prometheus", }, }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: registryprovisioner.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: fmt.Sprintf("%v/%v", ImageRepo, "registry:valid"), }, }, @@ -54,36 +54,36 @@ var _ = Describe("registry provisioner bundle", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { return nil, err } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallationSucceeded)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("Instantiated bundle")), )) }) }) When("a BundleDeployment targets an invalid registry+v1 Bundle", func() { var ( - bd *rukpakv1alpha1.BundleDeployment + bd *rukpakv1alpha2.BundleDeployment ctx context.Context ) BeforeEach(func() { ctx = context.Background() - bd = &rukpakv1alpha1.BundleDeployment{ + bd = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "cincinnati", Labels: map[string]string{ "app.kubernetes.io/name": "cincinnati", }, }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: registryprovisioner.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: fmt.Sprintf("%v/%v", ImageRepo, "registry:invalid"), }, }, @@ -102,12 +102,12 @@ var _ = Describe("registry provisioner bundle", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bd), bd); err != nil { return nil, err } - return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), WithTransform(func(c *metav1.Condition) string { return c.Message }, ContainSubstring("convert registry+v1 bundle to plain+v0 bundle: AllNamespace install mode must be enabled")), )) }) diff --git a/test/e2e/rukpakctl_test.go b/test/e2e/rukpakctl_test.go index 966549cf..3a03224e 100644 --- a/test/e2e/rukpakctl_test.go +++ b/test/e2e/rukpakctl_test.go @@ -13,7 +13,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/provisioner/plain" ) @@ -28,7 +28,7 @@ var _ = Describe("rukpakctl run subcommand", func() { ctx context.Context bundlename string bundledeploymentname string - bundledeployment *rukpakv1alpha1.BundleDeployment + bundledeployment *rukpakv1alpha2.BundleDeployment ) BeforeEach(func() { ctx = context.Background() @@ -40,7 +40,7 @@ var _ = Describe("rukpakctl run subcommand", func() { Expect(c.Delete(ctx, bundledeployment)).To(Succeed()) }) It("should eventually report a successful state", func() { - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: bundledeploymentname, }, @@ -50,12 +50,12 @@ var _ = Describe("rukpakctl run subcommand", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackSuccessful)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackSuccessful)), )) }) By("eventually reporting Installed", func() { @@ -63,12 +63,12 @@ var _ = Describe("rukpakctl run subcommand", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeInstalled), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeInstalled)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonInstallationSucceeded)), )) }) }) @@ -91,7 +91,7 @@ var _ = Describe("rukpakctl run subcommand", func() { ctx context.Context bundlename string bundledeploymentname string - bundledeployment *rukpakv1alpha1.BundleDeployment + bundledeployment *rukpakv1alpha2.BundleDeployment ) BeforeEach(func() { ctx = context.Background() @@ -103,7 +103,7 @@ var _ = Describe("rukpakctl run subcommand", func() { Expect(c.Delete(ctx, bundledeployment)).To(Succeed()) }) It("should eventually report unpack fail", func() { - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: bundledeploymentname, }, @@ -113,12 +113,12 @@ var _ = Describe("rukpakctl run subcommand", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionFalse)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackFailed)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackFailed)), )) }) }) @@ -128,23 +128,23 @@ var _ = Describe("rukpakctl run subcommand", func() { var _ = Describe("rukpakctl content subcommand", func() { When("content executed with a valid bundle", func() { var ( - ctx context.Context - bundledeployment *rukpakv1alpha1.BundleDeployment - output string + ctx context.Context + bundledeployment *rukpakv1alpha2.BundleDeployment + output string ) BeforeEach(func() { ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "combo-git-commit", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/exdx/combo-bundle", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Commit: "9e3ab7f1a36302ef512294d5c9f2e9b9566b811e", }, }, @@ -158,12 +158,12 @@ var _ = Describe("rukpakctl content subcommand", func() { if err := c.Get(ctx, client.ObjectKeyFromObject(bundledeployment), bundledeployment); err != nil { return nil, err } - return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha1.TypeUnpacked), nil + return meta.FindStatusCondition(bundledeployment.Status.Conditions, rukpakv1alpha2.TypeUnpacked), nil }).Should(And( Not(BeNil()), - WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeUnpacked)), + WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha2.TypeUnpacked)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), - WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonUnpackSuccessful)), + WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha2.ReasonUnpackSuccessful)), )) }) out, err := exec.Command("sh", "-c", rukpakctlcmd+"content "+bundledeployment.ObjectMeta.Name).Output() // nolint:gosec diff --git a/test/e2e/webhook_test.go b/test/e2e/webhook_test.go index 06a07107..e2c2a50a 100644 --- a/test/e2e/webhook_test.go +++ b/test/e2e/webhook_test.go @@ -8,31 +8,31 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1" + rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" "github.com/operator-framework/rukpak/internal/provisioner/plain" ) var _ = Describe("bundle deployment api validating webhook", func() { When("Bundle Deployment is valid", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context - err error + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context + err error ) BeforeEach(func() { By("creating the valid Bundle resource") ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "valid-bundle-", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Image: &rukpakv1alpha2.ImageSource{ Ref: "localhost/testdata/bundles/plain-v0:valid", }, }, @@ -51,23 +51,23 @@ var _ = Describe("bundle deployment api validating webhook", func() { }) When("the bundle source type is git and git properties are not set", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context - err error + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context + err error ) BeforeEach(func() { By("creating the Bundle resource") ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: "bundlenamegit", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeGit, - Image: &rukpakv1alpha1.ImageSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeGit, + Image: &rukpakv1alpha2.ImageSource{ Ref: "localhost/testdata/bundles/plain-v0:valid", }, }, @@ -86,25 +86,25 @@ var _ = Describe("bundle deployment api validating webhook", func() { }) When("the bundle source type is image and image properties are not set", func() { var ( - bundledeployment *rukpakv1alpha1.BundleDeployment - ctx context.Context - err error + bundledeployment *rukpakv1alpha2.BundleDeployment + ctx context.Context + err error ) BeforeEach(func() { By("creating the Bundle resource") ctx = context.Background() - bundledeployment = &rukpakv1alpha1.BundleDeployment{ + bundledeployment = &rukpakv1alpha2.BundleDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: "bundlenameimage", }, - Spec: rukpakv1alpha1.BundleDeploymentSpec{ + Spec: rukpakv1alpha2.BundleDeploymentSpec{ ProvisionerClassName: plain.ProvisionerID, - Source: rukpakv1alpha1.BundleSource{ - Type: rukpakv1alpha1.SourceTypeImage, - Git: &rukpakv1alpha1.GitSource{ + Source: rukpakv1alpha2.BundleSource{ + Type: rukpakv1alpha2.SourceTypeImage, + Git: &rukpakv1alpha2.GitSource{ Repository: "https://github.com/exdx/combo-bundle", - Ref: rukpakv1alpha1.GitRef{ + Ref: rukpakv1alpha2.GitRef{ Commit: "9e3ab7f1a36302ef512294d5c9f2e9b9566b811e", }, },