From 3e2f1cf4be9e6578c8db89428df6a20c5737cc32 Mon Sep 17 00:00:00 2001 From: jhu02 Date: Sun, 27 Feb 2022 10:10:59 -0800 Subject: [PATCH] Changes: align with pr https://github.com/keikoproj/addon-manager/pull/116 Signed-off-by: jhu02 --- {pkg/apis => api}/addon/register.go | 0 .../addon/v1alpha1/addon_types.go | 23 +-- {pkg/apis => api}/addon/v1alpha1/doc.go | 0 {pkg/apis => api}/addon/v1alpha1/register.go | 16 +- .../addon/v1alpha1/zz_generated.deepcopy.go | 33 ++- controllers/addonController.go | 3 +- controllers/addonHandlers.go | 4 +- controllers/addonUpdate.go | 2 +- controllers/addon_types_test.go | 2 +- controllers/controller.go | 4 +- controllers/objects.go | 2 +- controllers/resourceHandlers.go | 4 +- pkg/addon/addon_validator.go | 2 +- pkg/addon/addon_validator_test.go | 2 +- pkg/addon/addon_version_cache.go | 2 +- pkg/addon/addon_version_cache_test.go | 2 +- pkg/addonctl/addonctl.go | 2 +- pkg/apis/addon/v1alpha1/addon_types_test.go | 189 ------------------ pkg/apis/addon/v1alpha1/suite_test.go | 74 ------- .../clientset/versioned/fake/register.go | 2 +- .../clientset/versioned/scheme/register.go | 2 +- .../versioned/typed/addon/v1alpha1/addon.go | 2 +- .../typed/addon/v1alpha1/addon_client.go | 2 +- .../typed/addon/v1alpha1/fake/fake_addon.go | 2 +- .../externalversions/addon/v1alpha1/addon.go | 2 +- .../informers/externalversions/generic.go | 2 +- pkg/client/listers/addon/v1alpha1/addon.go | 2 +- pkg/common/helpers.go | 2 +- pkg/common/scheme.go | 2 +- pkg/workflows/workflow.go | 2 +- pkg/workflows/workflow_test.go | 2 +- 31 files changed, 63 insertions(+), 327 deletions(-) rename {pkg/apis => api}/addon/register.go (100%) rename {pkg/apis => api}/addon/v1alpha1/addon_types.go (97%) rename {pkg/apis => api}/addon/v1alpha1/doc.go (100%) rename {pkg/apis => api}/addon/v1alpha1/register.go (68%) rename {pkg/apis => api}/addon/v1alpha1/zz_generated.deepcopy.go (93%) delete mode 100644 pkg/apis/addon/v1alpha1/addon_types_test.go delete mode 100644 pkg/apis/addon/v1alpha1/suite_test.go diff --git a/pkg/apis/addon/register.go b/api/addon/register.go similarity index 100% rename from pkg/apis/addon/register.go rename to api/addon/register.go diff --git a/pkg/apis/addon/v1alpha1/addon_types.go b/api/addon/v1alpha1/addon_types.go similarity index 97% rename from pkg/apis/addon/v1alpha1/addon_types.go rename to api/addon/v1alpha1/addon_types.go index d8bb8990..3cc3d730 100644 --- a/pkg/apis/addon/v1alpha1/addon_types.go +++ b/api/addon/v1alpha1/addon_types.go @@ -123,6 +123,8 @@ const ( CnabPkg PackageType = "cnab" // CompositePkg is a package type representing a composite package structure, just yamls CompositePkg PackageType = "composite" + // Error used to indicate system error + Error ApplicationAssemblyPhase = "error" ) // CmdType represents a function that can be performed with arguments @@ -151,8 +153,6 @@ const ( Deleting ApplicationAssemblyPhase = "Deleting" // DeleteFailed Used to indicate that delete failed. DeleteFailed ApplicationAssemblyPhase = "Delete Failed" - // Error used to indicate system error - Error ApplicationAssemblyPhase = "error" ) // DeploymentPhase represents the status of observed resources @@ -283,8 +283,8 @@ type AddonStatus struct { StartTime int64 `json:"starttime"` } -// AddonList contains a list of Addon // +kubebuilder:object:root=true + // Addon is the Schema for the addons API // +k8s:openapi-gen=true // +kubebuilder:subresource:status @@ -306,6 +306,7 @@ type Addon struct { // +kubebuilder:object:root=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// AddonList contains a list of Addon type AddonList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` @@ -383,22 +384,6 @@ func (a *Addon) GetInstallStatus() ApplicationAssemblyPhase { return a.Status.Lifecycle.Installed } -// GetInstallStatus returns the install phase for addon -func (a *Addon) GetPrereqStatus() ApplicationAssemblyPhase { - return a.Status.Lifecycle.Prereqs -} - -// NotTriggered indicate the workflow not triggered -// Pending,Running are triggered -func (p ApplicationAssemblyPhase) NotTriggered() bool { - switch p { - case Succeeded, Failed, Error, "": - return true - default: - return false - } -} - func (p ApplicationAssemblyPhase) Succeeded() bool { switch p { case Succeeded: diff --git a/pkg/apis/addon/v1alpha1/doc.go b/api/addon/v1alpha1/doc.go similarity index 100% rename from pkg/apis/addon/v1alpha1/doc.go rename to api/addon/v1alpha1/doc.go diff --git a/pkg/apis/addon/v1alpha1/register.go b/api/addon/v1alpha1/register.go similarity index 68% rename from pkg/apis/addon/v1alpha1/register.go rename to api/addon/v1alpha1/register.go index b693122a..1b5ee52b 100644 --- a/pkg/apis/addon/v1alpha1/register.go +++ b/api/addon/v1alpha1/register.go @@ -1,8 +1,22 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" + runtime "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) diff --git a/pkg/apis/addon/v1alpha1/zz_generated.deepcopy.go b/api/addon/v1alpha1/zz_generated.deepcopy.go similarity index 93% rename from pkg/apis/addon/v1alpha1/zz_generated.deepcopy.go rename to api/addon/v1alpha1/zz_generated.deepcopy.go index 133ea368..fa86f044 100644 --- a/pkg/apis/addon/v1alpha1/zz_generated.deepcopy.go +++ b/api/addon/v1alpha1/zz_generated.deepcopy.go @@ -1,12 +1,26 @@ //go:build !ignore_autogenerated // +build !ignore_autogenerated -// Code generated by deepcopy-gen. DO NOT EDIT. +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Code generated by controller-gen. DO NOT EDIT. package v1alpha1 import ( - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -16,7 +30,6 @@ func (in *Addon) DeepCopyInto(out *Addon) { in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Addon. @@ -49,7 +62,6 @@ func (in *AddonList) DeepCopyInto(out *AddonList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonList. @@ -81,7 +93,6 @@ func (in *AddonOverridesSpec) DeepCopyInto(out *AddonOverridesSpec) { (*out)[key] = val } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonOverridesSpec. @@ -105,7 +116,6 @@ func (in *AddonParams) DeepCopyInto(out *AddonParams) { (*out)[key] = val } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonParams. @@ -133,7 +143,6 @@ func (in *AddonSpec) DeepCopyInto(out *AddonSpec) { } } out.Lifecycle = in.Lifecycle - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonSpec. @@ -155,7 +164,6 @@ func (in *AddonStatus) DeepCopyInto(out *AddonStatus) { *out = make([]ObjectStatus, len(*in)) copy(*out, *in) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonStatus. @@ -171,7 +179,6 @@ func (in *AddonStatus) DeepCopy() *AddonStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AddonStatusLifecycle) DeepCopyInto(out *AddonStatusLifecycle) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonStatusLifecycle. @@ -194,7 +201,6 @@ func (in *ClusterContext) DeepCopyInto(out *ClusterContext) { (*out)[key] = val } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterContext. @@ -230,7 +236,6 @@ func (in *KustomizeSpec) DeepCopyInto(out *KustomizeSpec) { copy(*out, *in) } in.Overlay.DeepCopyInto(&out.Overlay) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KustomizeSpec. @@ -253,7 +258,6 @@ func (in *KustomizeTemplate) DeepCopyInto(out *KustomizeTemplate) { (*out)[key] = val } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KustomizeTemplate. @@ -273,7 +277,6 @@ func (in *LifecycleWorkflowSpec) DeepCopyInto(out *LifecycleWorkflowSpec) { out.Install = in.Install out.Delete = in.Delete out.Validate = in.Validate - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LifecycleWorkflowSpec. @@ -289,7 +292,6 @@ func (in *LifecycleWorkflowSpec) DeepCopy() *LifecycleWorkflowSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ObjectStatus) DeepCopyInto(out *ObjectStatus) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectStatus. @@ -312,7 +314,6 @@ func (in *PackageSpec) DeepCopyInto(out *PackageSpec) { (*out)[key] = val } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageSpec. @@ -333,7 +334,6 @@ func (in *SecretCmdSpec) DeepCopyInto(out *SecretCmdSpec) { *out = make([]string, len(*in)) copy(*out, *in) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretCmdSpec. @@ -349,7 +349,6 @@ func (in *SecretCmdSpec) DeepCopy() *SecretCmdSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WorkflowType) DeepCopyInto(out *WorkflowType) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkflowType. diff --git a/controllers/addonController.go b/controllers/addonController.go index 351608aa..18efeb0f 100644 --- a/controllers/addonController.go +++ b/controllers/addonController.go @@ -10,7 +10,7 @@ import ( "github.com/sirupsen/logrus" - addonapiv1 "github.com/keikoproj/addon-manager/pkg/apis/addon" + addonapiv1 "github.com/keikoproj/addon-manager/api/addon" addonv1versioned "github.com/keikoproj/addon-manager/pkg/client/clientset/versioned" "github.com/keikoproj/addon-manager/pkg/utils" @@ -96,6 +96,7 @@ func Start(namespace string) { } else { kubeClient = utils.GetClient() } + dynCli, err := dynamic.NewForConfig(cfg) if err != nil { panic(err) diff --git a/controllers/addonHandlers.go b/controllers/addonHandlers.go index 1dc5bb29..c0642266 100644 --- a/controllers/addonHandlers.go +++ b/controllers/addonHandlers.go @@ -5,13 +5,13 @@ import ( "fmt" "strings" - addonv1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonv1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" "github.com/keikoproj/addon-manager/pkg/common" "github.com/keikoproj/addon-manager/pkg/workflows" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + addonapiv1 "github.com/keikoproj/addon-manager/api/addon" addoninternal "github.com/keikoproj/addon-manager/pkg/addon" - addonapiv1 "github.com/keikoproj/addon-manager/pkg/apis/addon" ) func (c *Controller) handleAddonCreation(ctx context.Context, addon *addonv1.Addon) error { diff --git a/controllers/addonUpdate.go b/controllers/addonUpdate.go index 1b8aa9b9..c58fe525 100644 --- a/controllers/addonUpdate.go +++ b/controllers/addonUpdate.go @@ -7,7 +7,7 @@ import ( "strings" wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" - addonv1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonv1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" "github.com/keikoproj/addon-manager/pkg/common" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/controllers/addon_types_test.go b/controllers/addon_types_test.go index edd6537c..e3f24ee2 100644 --- a/controllers/addon_types_test.go +++ b/controllers/addon_types_test.go @@ -20,7 +20,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" fakeAddonCli "github.com/keikoproj/addon-manager/pkg/client/clientset/versioned/fake" "golang.org/x/net/context" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/controllers/controller.go b/controllers/controller.go index 4a06d306..8122343d 100644 --- a/controllers/controller.go +++ b/controllers/controller.go @@ -14,8 +14,8 @@ import ( informers "github.com/argoproj/argo-workflows/v3/pkg/client/informers/externalversions" v1alpha1 "github.com/argoproj/argo-workflows/v3/pkg/client/informers/externalversions/workflow/v1alpha1" - "github.com/keikoproj/addon-manager/pkg/apis/addon" - addonv1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + "github.com/keikoproj/addon-manager/api/addon" + addonv1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" addonv1versioned "github.com/keikoproj/addon-manager/pkg/client/clientset/versioned" "github.com/keikoproj/addon-manager/pkg/client/clientset/versioned/scheme" addonv1informers "github.com/keikoproj/addon-manager/pkg/client/informers/externalversions" diff --git a/controllers/objects.go b/controllers/objects.go index 88fcf2ae..f2bd45d8 100644 --- a/controllers/objects.go +++ b/controllers/objects.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client" appsv1 "k8s.io/api/apps/v1" diff --git a/controllers/resourceHandlers.go b/controllers/resourceHandlers.go index 750a957f..d3f5bcdc 100644 --- a/controllers/resourceHandlers.go +++ b/controllers/resourceHandlers.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - addonapiv1 "github.com/keikoproj/addon-manager/pkg/apis/addon" - addonv1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonapiv1 "github.com/keikoproj/addon-manager/api/addon" + addonv1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" appsv1 "k8s.io/api/apps/v1" batch_v1 "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" diff --git a/pkg/addon/addon_validator.go b/pkg/addon/addon_validator.go index 28c2483a..7a4b38b5 100644 --- a/pkg/addon/addon_validator.go +++ b/pkg/addon/addon_validator.go @@ -24,7 +24,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" "github.com/keikoproj/addon-manager/pkg/common" ) diff --git a/pkg/addon/addon_validator_test.go b/pkg/addon/addon_validator_test.go index 2a30adf0..734e1d08 100644 --- a/pkg/addon/addon_validator_test.go +++ b/pkg/addon/addon_validator_test.go @@ -25,7 +25,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/dynamic/fake" - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" ) var dynClient = fake.NewSimpleDynamicClient(runtime.NewScheme()) diff --git a/pkg/addon/addon_version_cache.go b/pkg/addon/addon_version_cache.go index ff7bc207..be89fbef 100644 --- a/pkg/addon/addon_version_cache.go +++ b/pkg/addon/addon_version_cache.go @@ -18,7 +18,7 @@ import ( "sync" "github.com/Masterminds/semver/v3" - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" ) // VersionCacheClient interface clients must implement for addon version cache. diff --git a/pkg/addon/addon_version_cache_test.go b/pkg/addon/addon_version_cache_test.go index d04bbcdf..b16a9e7f 100644 --- a/pkg/addon/addon_version_cache_test.go +++ b/pkg/addon/addon_version_cache_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" ) func TestNewCachedClient(t *testing.T) { diff --git a/pkg/addonctl/addonctl.go b/pkg/addonctl/addonctl.go index a353f25f..85191023 100644 --- a/pkg/addonctl/addonctl.go +++ b/pkg/addonctl/addonctl.go @@ -35,7 +35,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" "github.com/keikoproj/addon-manager/pkg/common" "github.com/keikoproj/addon-manager/pkg/version" "github.com/keikoproj/addon-manager/pkg/workflows" diff --git a/pkg/apis/addon/v1alpha1/addon_types_test.go b/pkg/apis/addon/v1alpha1/addon_types_test.go deleted file mode 100644 index da112213..00000000 --- a/pkg/apis/addon/v1alpha1/addon_types_test.go +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package v1alpha1 - -import ( - "fmt" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "golang.org/x/net/context" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" -) - -var wfSpecTemplate = ` -apiVersion: argoproj.io/v1alpha1 -kind: Workflow -metadata: - generateName: scripts-python- -spec: - entrypoint: python-script-example - templates: - - name: python-script-example - steps: - - - name: generate - template: gen-random-int - - - name: print - template: print-message - arguments: - parameters: - - name: message - value: "{{steps.generate.outputs.result}}" - - - name: gen-random-int - script: - image: python:alpine3.6 - command: [python] - source: | - import random - i = random.randint(1, 100) - print(i) - - name: print-message - inputs: - parameters: - - name: message - container: - image: alpine:latest - command: [sh, -c] - args: ["echo result was: {{inputs.parameters.message}}"] -` - -// These tests are written in BDD-style using Ginkgo framework. Refer to -// http://onsi.github.io/ginkgo to learn more. - -var _ = Describe("Addon", func() { - var ( - key types.NamespacedName - created, fetched *Addon - ) - - BeforeEach(func() { - // Add any setup steps that needs to be executed before each test - }) - - AfterEach(func() { - // Add any teardown steps that needs to be executed after each test - }) - - // Add Tests for OpenAPI validation (or additional CRD features) specified in - // your API definition. - // Avoid adding tests for vanilla CRUD operations because they would - // test Kubernetes API server, which isn't the goal here. - Context("Create API", func() { - - It("should create an object successfully", func() { - - key = types.NamespacedName{ - Name: "foo", - Namespace: "default", - } - created = &Addon{ - ObjectMeta: metav1.ObjectMeta{ - Name: "foo", - Namespace: "default", - }, - Spec: AddonSpec{ - PackageSpec: PackageSpec{ - PkgName: "my-addon", - PkgVersion: "1.0.0", - PkgType: HelmPkg, - PkgDescription: "", - PkgDeps: map[string]string{"core/A": "*", "core/B": "v1.0.0"}, - }, - Selector: metav1.LabelSelector{ - MatchLabels: map[string]string{ - "app": "my-app", - }, - }, - Params: AddonParams{ - Namespace: "foo-ns", - Context: ClusterContext{ - ClusterName: "foo-cluster", - ClusterRegion: "foo-region", - AdditionalConfigs: map[string]FlexString{ - "additional": "config", - }, - }, - Data: map[string]FlexString{ - "foo-param": "val", - }, - }, - Lifecycle: LifecycleWorkflowSpec{ - Prereqs: WorkflowType{ - NamePrefix: "my-prereqs", - Template: wfSpecTemplate, - }, - Install: WorkflowType{ - Template: wfSpecTemplate, - }, - Delete: WorkflowType{ - Template: wfSpecTemplate, - }, - }, - }, - } - - By("creating an API obj") - Expect(k8sClient.Create(context.TODO(), created)).To(Succeed()) - - fetched = &Addon{} - Expect(k8sClient.Get(context.TODO(), key, fetched)).To(Succeed()) - Expect(fetched).To(Equal(created)) - - By("Checking expected fetched values") - pkgSpec := fetched.GetPackageSpec() - Expect(pkgSpec).To(Equal(fetched.Spec.PackageSpec)) - - addonParams := fetched.GetAllAddonParameters() - paramsMap := map[string]string{ - "namespace": "foo-ns", - "clusterName": "foo-cluster", - "clusterRegion": "foo-region", - "additional": "config", - "foo-param": "val", - } - - Expect(addonParams).To(HaveLen(len(paramsMap))) - for name := range paramsMap { - Expect(addonParams[name]).To(Equal(paramsMap[name])) - } - - checksum := fetched.CalculateChecksum() - Expect(checksum).To(Equal("4a77025d")) - - // Update status checksum - fetched.Status.Checksum = checksum - - wfName := fetched.GetFormattedWorkflowName(Install) - Expect(wfName).To(Equal(fmt.Sprintf("foo-install-%s-wf", checksum))) - - By("updating labels") - updated := fetched.DeepCopy() - updated.Labels = map[string]string{"hello": "world"} - Expect(k8sClient.Update(context.TODO(), updated)).To(Succeed()) - - Expect(k8sClient.Get(context.TODO(), key, fetched)).To(Succeed()) - Expect(fetched).To(Equal(updated)) - - By("deleting the created object") - Expect(k8sClient.Delete(context.TODO(), fetched)).To(Succeed()) - Expect(k8sClient.Get(context.TODO(), key, fetched)).ToNot(Succeed()) - }) - - }) - -}) diff --git a/pkg/apis/addon/v1alpha1/suite_test.go b/pkg/apis/addon/v1alpha1/suite_test.go deleted file mode 100644 index 6b97fad0..00000000 --- a/pkg/apis/addon/v1alpha1/suite_test.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package v1alpha1 - -import ( - "path/filepath" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - "sigs.k8s.io/controller-runtime/pkg/envtest/printer" - logf "sigs.k8s.io/controller-runtime/pkg/log" -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment - -func TestAPIs(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecsWithDefaultAndCustomReporters(t, - "v1alpha1 Suite", - []Reporter{printer.NewlineReporter{}}) -} - -var _ = BeforeSuite(func(done Done) { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, - } - - err := SchemeBuilder.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - cfg, err = testEnv.Start() - Expect(err).ToNot(HaveOccurred()) - Expect(cfg).ToNot(BeNil()) - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).ToNot(HaveOccurred()) - Expect(k8sClient).ToNot(BeNil()) - - close(done) -}, 60) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - err := testEnv.Stop() - Expect(err).ToNot(HaveOccurred()) -}) diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index c4b893d1..2e75d9ba 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -3,7 +3,7 @@ package fake import ( - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index bf3e1759..2b2cad95 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -3,7 +3,7 @@ package scheme import ( - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/client/clientset/versioned/typed/addon/v1alpha1/addon.go b/pkg/client/clientset/versioned/typed/addon/v1alpha1/addon.go index c5450f0d..01f186a5 100644 --- a/pkg/client/clientset/versioned/typed/addon/v1alpha1/addon.go +++ b/pkg/client/clientset/versioned/typed/addon/v1alpha1/addon.go @@ -6,7 +6,7 @@ import ( "context" "time" - v1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + v1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" scheme "github.com/keikoproj/addon-manager/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" diff --git a/pkg/client/clientset/versioned/typed/addon/v1alpha1/addon_client.go b/pkg/client/clientset/versioned/typed/addon/v1alpha1/addon_client.go index c8569961..13fa67d0 100644 --- a/pkg/client/clientset/versioned/typed/addon/v1alpha1/addon_client.go +++ b/pkg/client/clientset/versioned/typed/addon/v1alpha1/addon_client.go @@ -3,7 +3,7 @@ package v1alpha1 import ( - v1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + v1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" "github.com/keikoproj/addon-manager/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" ) diff --git a/pkg/client/clientset/versioned/typed/addon/v1alpha1/fake/fake_addon.go b/pkg/client/clientset/versioned/typed/addon/v1alpha1/fake/fake_addon.go index 4b631ae9..02bb9616 100644 --- a/pkg/client/clientset/versioned/typed/addon/v1alpha1/fake/fake_addon.go +++ b/pkg/client/clientset/versioned/typed/addon/v1alpha1/fake/fake_addon.go @@ -5,7 +5,7 @@ package fake import ( "context" - v1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + v1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/client/informers/externalversions/addon/v1alpha1/addon.go b/pkg/client/informers/externalversions/addon/v1alpha1/addon.go index bfa1f79e..cef875a7 100644 --- a/pkg/client/informers/externalversions/addon/v1alpha1/addon.go +++ b/pkg/client/informers/externalversions/addon/v1alpha1/addon.go @@ -6,7 +6,7 @@ import ( "context" time "time" - addonv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" versioned "github.com/keikoproj/addon-manager/pkg/client/clientset/versioned" internalinterfaces "github.com/keikoproj/addon-manager/pkg/client/informers/externalversions/internalinterfaces" v1alpha1 "github.com/keikoproj/addon-manager/pkg/client/listers/addon/v1alpha1" diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 696daece..ea96ddea 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -5,7 +5,7 @@ package externalversions import ( "fmt" - v1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + v1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) diff --git a/pkg/client/listers/addon/v1alpha1/addon.go b/pkg/client/listers/addon/v1alpha1/addon.go index c979241c..6997ebfb 100644 --- a/pkg/client/listers/addon/v1alpha1/addon.go +++ b/pkg/client/listers/addon/v1alpha1/addon.go @@ -3,7 +3,7 @@ package v1alpha1 import ( - v1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + v1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/pkg/common/helpers.go b/pkg/common/helpers.go index 83aa21f6..9675ff95 100644 --- a/pkg/common/helpers.go +++ b/pkg/common/helpers.go @@ -31,7 +31,7 @@ import ( "k8s.io/client-go/tools/clientcmd" wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" - addonv1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonv1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" ) // ContainsString helper function to check string in a slice of strings. diff --git a/pkg/common/scheme.go b/pkg/common/scheme.go index ae23e4f1..24a723e3 100644 --- a/pkg/common/scheme.go +++ b/pkg/common/scheme.go @@ -2,7 +2,7 @@ package common import ( wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" diff --git a/pkg/workflows/workflow.go b/pkg/workflows/workflow.go index 80cb4107..79e7fbc2 100644 --- a/pkg/workflows/workflow.go +++ b/pkg/workflows/workflow.go @@ -36,7 +36,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" - addonmgrv1alpha1 "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1" "github.com/keikoproj/addon-manager/pkg/common" wfclientset "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned" diff --git a/pkg/workflows/workflow_test.go b/pkg/workflows/workflow_test.go index feccb47b..c1304228 100644 --- a/pkg/workflows/workflow_test.go +++ b/pkg/workflows/workflow_test.go @@ -33,7 +33,7 @@ import ( "k8s.io/client-go/tools/record" runtimefake "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/keikoproj/addon-manager/pkg/apis/addon/v1alpha1" + "github.com/keikoproj/addon-manager/api/addon/v1alpha1" "github.com/keikoproj/addon-manager/pkg/common" wfclientsetfake "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned/fake"