From 43389b2154edae244bceb489f3ee4c47e943419d Mon Sep 17 00:00:00 2001 From: Marco Cadetg Date: Fri, 31 May 2024 15:10:22 +0200 Subject: [PATCH 1/2] fix: mongodbprovider crd name --- api/v1alpha1/mongodbprovider_types.go | 8 ++++---- api/v1alpha1/zz_generated.deepcopy.go | 12 ++++++------ .../crd/bases/crd.lagoon.sh_mongodbdproviders.yaml | 12 ++++++------ config/crd/bases/crd.lagoon.sh_mongodbproviders.yaml | 12 ++++++------ internal/controller/mongodbprovider_controller.go | 6 +++--- .../controller/mongodbprovider_controller_test.go | 6 +++--- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/api/v1alpha1/mongodbprovider_types.go b/api/v1alpha1/mongodbprovider_types.go index 2945648..540553b 100644 --- a/api/v1alpha1/mongodbprovider_types.go +++ b/api/v1alpha1/mongodbprovider_types.go @@ -115,8 +115,8 @@ type MongoDBProviderStatus struct { //+kubebuilder:object:root=true //+kubebuilder:subresource:status -// MongoDBDProvider is the Schema for the mongodbproviders API -type MongoDBDProvider struct { +// MongoDBProvider is the Schema for the mongodbproviders API +type MongoDBProvider struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -130,9 +130,9 @@ type MongoDBDProvider struct { type MongoDBProviderList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []MongoDBDProvider `json:"items"` + Items []MongoDBProvider `json:"items"` } func init() { - SchemeBuilder.Register(&MongoDBDProvider{}, &MongoDBProviderList{}) + SchemeBuilder.Register(&MongoDBProvider{}, &MongoDBProviderList{}) } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 9e4de90..825d9b3 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -271,7 +271,7 @@ func (in *MongoDBConnection) DeepCopy() *MongoDBConnection { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MongoDBDProvider) DeepCopyInto(out *MongoDBDProvider) { +func (in *MongoDBProvider) DeepCopyInto(out *MongoDBProvider) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) @@ -279,18 +279,18 @@ func (in *MongoDBDProvider) DeepCopyInto(out *MongoDBDProvider) { in.Status.DeepCopyInto(&out.Status) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MongoDBDProvider. -func (in *MongoDBDProvider) DeepCopy() *MongoDBDProvider { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MongoDBProvider. +func (in *MongoDBProvider) DeepCopy() *MongoDBProvider { if in == nil { return nil } - out := new(MongoDBDProvider) + out := new(MongoDBProvider) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *MongoDBDProvider) DeepCopyObject() runtime.Object { +func (in *MongoDBProvider) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -304,7 +304,7 @@ func (in *MongoDBProviderList) DeepCopyInto(out *MongoDBProviderList) { in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]MongoDBDProvider, len(*in)) + *out = make([]MongoDBProvider, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } diff --git a/config/crd/bases/crd.lagoon.sh_mongodbdproviders.yaml b/config/crd/bases/crd.lagoon.sh_mongodbdproviders.yaml index fc307f0..aae00c2 100644 --- a/config/crd/bases/crd.lagoon.sh_mongodbdproviders.yaml +++ b/config/crd/bases/crd.lagoon.sh_mongodbdproviders.yaml @@ -4,20 +4,20 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.14.0 - name: mongodbdproviders.crd.lagoon.sh + name: mongodbproviders.crd.lagoon.sh spec: group: crd.lagoon.sh names: - kind: MongoDBDProvider - listKind: MongoDBDProviderList - plural: mongodbdproviders - singular: mongodbdprovider + kind: MongoDBProvider + listKind: MongoDBProviderList + plural: mongodbproviders + singular: mongodbprovider scope: Namespaced versions: - name: v1alpha1 schema: openAPIV3Schema: - description: MongoDBDProvider is the Schema for the mongodbproviders API + description: MongoDBProvider is the Schema for the mongodbproviders API properties: apiVersion: description: |- diff --git a/config/crd/bases/crd.lagoon.sh_mongodbproviders.yaml b/config/crd/bases/crd.lagoon.sh_mongodbproviders.yaml index fc307f0..aae00c2 100644 --- a/config/crd/bases/crd.lagoon.sh_mongodbproviders.yaml +++ b/config/crd/bases/crd.lagoon.sh_mongodbproviders.yaml @@ -4,20 +4,20 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.14.0 - name: mongodbdproviders.crd.lagoon.sh + name: mongodbproviders.crd.lagoon.sh spec: group: crd.lagoon.sh names: - kind: MongoDBDProvider - listKind: MongoDBDProviderList - plural: mongodbdproviders - singular: mongodbdprovider + kind: MongoDBProvider + listKind: MongoDBProviderList + plural: mongodbproviders + singular: mongodbprovider scope: Namespaced versions: - name: v1alpha1 schema: openAPIV3Schema: - description: MongoDBDProvider is the Schema for the mongodbproviders API + description: MongoDBProvider is the Schema for the mongodbproviders API properties: apiVersion: description: |- diff --git a/internal/controller/mongodbprovider_controller.go b/internal/controller/mongodbprovider_controller.go index 28a2d9d..16f9a19 100644 --- a/internal/controller/mongodbprovider_controller.go +++ b/internal/controller/mongodbprovider_controller.go @@ -96,7 +96,7 @@ func (r *MongoDBProviderReconciler) Reconcile(ctx context.Context, req ctrl.Requ logger := log.FromContext(ctx).WithName("mongodbprovider_controller") logger.Info("Reconciling MongoDBProvider") - instance := &crdv1alpha1.MongoDBDProvider{} + instance := &crdv1alpha1.MongoDBProvider{} if err := r.Get(ctx, req.NamespacedName, instance); err != nil { if client.IgnoreNotFound(err) == nil { logger.Info("MongoDBProvider resource not found. Ignoring since object must be deleted") @@ -269,7 +269,7 @@ func (r *MongoDBProviderReconciler) Reconcile(ctx context.Context, req ctrl.Requ func (r *MongoDBProviderReconciler) handleError( ctx context.Context, - instance *crdv1alpha1.MongoDBDProvider, + instance *crdv1alpha1.MongoDBProvider, promErr string, err error, ) (ctrl.Result, error) { @@ -310,7 +310,7 @@ func (r *MongoDBProviderReconciler) SetupWithManager(mgr ctrl.Manager) error { ) r.Recorder = mgr.GetEventRecorderFor("mongodbprovider-controller") return ctrl.NewControllerManagedBy(mgr). - For(&crdv1alpha1.MongoDBDProvider{}). + For(&crdv1alpha1.MongoDBProvider{}). WithEventFilter(predicate.GenerationChangedPredicate{}). // Only allow one reconcile at a time WithOptions(controller.Options{ diff --git a/internal/controller/mongodbprovider_controller_test.go b/internal/controller/mongodbprovider_controller_test.go index 8c44fb1..6159cb3 100644 --- a/internal/controller/mongodbprovider_controller_test.go +++ b/internal/controller/mongodbprovider_controller_test.go @@ -43,7 +43,7 @@ var _ = Describe("MongoDBProvider Controller", func() { Name: resourceName, Namespace: "default", } - mongodbprovider := &crdv1alpha1.MongoDBDProvider{} + mongodbprovider := &crdv1alpha1.MongoDBProvider{} BeforeEach(func() { By("creating the custom resource for the Kind MongoDBProvider") @@ -68,7 +68,7 @@ var _ = Describe("MongoDBProvider Controller", func() { err = k8sClient.Get(ctx, typeNamespacedName, mongodbprovider) if err != nil && errors.IsNotFound(err) { - resource := &crdv1alpha1.MongoDBDProvider{ + resource := &crdv1alpha1.MongoDBProvider{ ObjectMeta: metav1.ObjectMeta{ Name: resourceName, Namespace: "default", @@ -95,7 +95,7 @@ var _ = Describe("MongoDBProvider Controller", func() { AfterEach(func() { // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &crdv1alpha1.MongoDBDProvider{} + resource := &crdv1alpha1.MongoDBProvider{} err := k8sClient.Get(ctx, typeNamespacedName, resource) Expect(err).NotTo(HaveOccurred()) From 9d897659ebb5c03fd19666749041433845239d0e Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Wed, 5 Jun 2024 09:27:25 +1000 Subject: [PATCH 2/2] chore: add build and publish workflow --- .github/workflows/build-and-publish.yaml | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/build-and-publish.yaml diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml new file mode 100644 index 0000000..8bca416 --- /dev/null +++ b/.github/workflows/build-and-publish.yaml @@ -0,0 +1,56 @@ +name: Image Build and Publish + +on: + push: + branches: + - '**' + tags: + - 'v*.*.*' + pull_request: + branches: + - 'main' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + uselagoon/dbaas-controller + ghcr.io/uselagoon/dbaas-controller + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file