diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 339c610..a39eaf8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,9 @@ env: # Common users. We can't run a step 'if secrets.XXX != ""' but we can run a # step 'if env.XXX != ""', so we copy these to succinctly test whether # credentials have been provided before trying to run steps that need them. - UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} + REGISTRY_ORGS: ${{ secrets.REGISTRY_ORGS }} + XPKG_REG_ORGS: ${{ secrets.XPKG_REG_ORGS }} + XPKG_REG_ORGS_NO_PROMOTE: ${{ secrets.XPKG_REG_ORGS_NO_PROMOTE }} jobs: detect-noop: @@ -256,13 +258,11 @@ jobs: version: ${{ env.DOCKER_BUILDX_VERSION }} install: true - - name: Login to Upbound + - name: Login to Docker.io uses: docker/login-action@v2 - if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != '' with: - registry: xpkg.upbound.io - username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} - password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Checkout uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3 diff --git a/.golangci.yml b/.golangci.yml index 494a907..c08fc6f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -38,7 +38,7 @@ linters-settings: goimports: # put imports beginning with prefix after 3rd-party packages; # it's a comma-separated list of prefixes - local-prefixes: github.com/upbound/upjet-provider-template + local-prefixes: saagie.io/provider-mailgun gocyclo: # minimal code complexity to report, 30 by default (but we recommend 10-20) diff --git a/LICENSE b/LICENSE index 5695f4d..b51c1dc 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [YEAR] Upbound Inc. All rights reserved. + Copyright 2023 Upbound Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Makefile b/Makefile index a9c9cdd..80fb784 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,17 @@ # ==================================================================================== # Setup Project -PROJECT_NAME ?= upjet-provider-template -PROJECT_REPO ?= github.com/upbound/$(PROJECT_NAME) +PROJECT_NAME ?= provider-mailgun +PROJECT_REPO ?= saagie.io/$(PROJECT_NAME) export TERRAFORM_VERSION ?= 1.2.1 -export TERRAFORM_PROVIDER_SOURCE ?= hashicorp/null -export TERRAFORM_PROVIDER_REPO ?= https://github.com/hashicorp/terraform-provider-null -export TERRAFORM_PROVIDER_VERSION ?= 3.1.0 -export TERRAFORM_PROVIDER_DOWNLOAD_NAME ?= terraform-provider-null +export TERRAFORM_PROVIDER_SOURCE ?= wgebis/mailgun +export TERRAFORM_PROVIDER_REPO ?= https://github.com/wgebis/terraform-provider-mailgun +export TERRAFORM_PROVIDER_VERSION ?= 0.7.5 +export TERRAFORM_PROVIDER_DOWNLOAD_NAME ?= terraform-provider-mailgun export TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX ?= https://releases.hashicorp.com/$(TERRAFORM_PROVIDER_DOWNLOAD_NAME)/$(TERRAFORM_PROVIDER_VERSION) -export TERRAFORM_NATIVE_PROVIDER_BINARY ?= terraform-provider-null_v3.1.0_x5 +export TERRAFORM_NATIVE_PROVIDER_BINARY ?= terraform-provider-mailgun_v0.7.5_x5 export TERRAFORM_DOCS_PATH ?= docs/resources @@ -89,7 +89,7 @@ fallthrough: submodules # NOTE(hasheddan): we force image building to happen prior to xpkg build so that # we ensure image is present in daemon. -xpkg.build.upjet-provider-template: do.build.images +xpkg.build.provider-mailgun: do.build.images # NOTE(hasheddan): we ensure up is installed prior to running platform-specific # build steps in parallel to avoid encountering an installation race condition. @@ -169,7 +169,7 @@ CROSSPLANE_NAMESPACE = upbound-system # This target requires the following environment variables to be set: # - UPTEST_EXAMPLE_LIST, a comma-separated list of examples to test # To ensure the proper functioning of the end-to-end test resource pre-deletion hook, it is crucial to arrange your resources appropriately. -# You can check the basic implementation here: https://github.com/upbound/uptest/blob/main/internal/templates/01-delete.yaml.tmpl. +# You can check the basic implementation here: https://github.com/upbound/uptest/blob/main/internal/mailguns/01-delete.yaml.tmpl. # - UPTEST_CLOUD_CREDENTIALS (optional), multiple sets of AWS IAM User credentials specified as key=value pairs. # The support keys are currently `DEFAULT` and `PEER`. So, an example for the value of this env. variable is: # DEFAULT='[default] diff --git a/OWNERS.md b/OWNERS.md index 599b40e..52e22ad 100644 --- a/OWNERS.md +++ b/OWNERS.md @@ -1,13 +1,14 @@ # OWNERS -This page lists all maintainers for **this** repository. Each repository in the [Upbound -organization](https://github.com/upbound/) will list their repository maintainers in their own +This page lists all maintainers for **this** repository. Each repository in the [Crossplane +organization](https://github.com/crossplane/) will list their repository maintainers in their own `OWNERS.md` file. +Please see the Crossplane +[GOVERNANCE.md](https://github.com/crossplane/crossplane/blob/master/GOVERNANCE.md) for governance +guidelines and responsibilities for the steering committee and maintainers. ## Maintainers -* Alper Ulucinar ([ulucinar](https://github.com/ulucinar)) -* Sergen Yalcin ([sergenyalcin](https://github.com/sergenyalcin)) - -See [CODEOWNERS](./CODEOWNERS) for automatic PR assignment. +* Maintainer 1 ([maintainer1](https://github.com/maintainer1)) +* Maintainer 2 ([maintainer1](https://github.com/maintainer2)) diff --git a/README.md b/README.md index e57c399..5d9e037 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -# Provider Template +# Provider Mailgun -`upjet-provider-template` is a [Crossplane](https://crossplane.io/) provider that +`provider-mailgun` is a [Crossplane](https://crossplane.io/) provider that is built using [Upjet](https://github.com/crossplane/upjet) code generation tools and exposes XRM-conformant managed resources for the -Template API. +Mailgun API. ## Getting Started Install the provider by using the following command after changing the image tag -to the [latest release](https://marketplace.upbound.io/providers/upbound/upjet-provider-template): +to the [latest release](https://marketplace.upbound.io/providers/saagie/provider-mailgun): ``` -up ctp provider install upbound/upjet-provider-template:v0.1.0 +up ctp provider install saagie/provider-mailgun:v0.1.0 ``` Alternatively, you can use declarative installation: @@ -19,15 +19,15 @@ cat < +// +// SPDX-License-Identifier: Apache-2.0 + +/* +Copyright 2022 Upbound Inc. +*/ + +// Code generated by upjet. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +) + +type CredentialInitParameters struct { + + // The domain to add credential of Mailgun. + Domain *string `json:"domain,omitempty" tf:"domain,omitempty"` + + // The local-part of the email address to create. + Login *string `json:"login,omitempty" tf:"login,omitempty"` + + // The region where domain will be created. Default value is us. + Region *string `json:"region,omitempty" tf:"region,omitempty"` +} + +type CredentialObservation struct { + + // The domain to add credential of Mailgun. + Domain *string `json:"domain,omitempty" tf:"domain,omitempty"` + + ID *string `json:"id,omitempty" tf:"id,omitempty"` + + // The local-part of the email address to create. + Login *string `json:"login,omitempty" tf:"login,omitempty"` + + // The region where domain will be created. Default value is us. + Region *string `json:"region,omitempty" tf:"region,omitempty"` +} + +type CredentialParameters struct { + + // The domain to add credential of Mailgun. + // +kubebuilder:validation:Optional + Domain *string `json:"domain,omitempty" tf:"domain,omitempty"` + + // The local-part of the email address to create. + // +kubebuilder:validation:Optional + Login *string `json:"login,omitempty" tf:"login,omitempty"` + + // Password for user authentication. + // +kubebuilder:validation:Optional + PasswordSecretRef v1.SecretKeySelector `json:"passwordSecretRef" tf:"-"` + + // The region where domain will be created. Default value is us. + // +kubebuilder:validation:Optional + Region *string `json:"region,omitempty" tf:"region,omitempty"` +} + +// CredentialSpec defines the desired state of Credential +type CredentialSpec struct { + v1.ResourceSpec `json:",inline"` + ForProvider CredentialParameters `json:"forProvider"` + // THIS IS A BETA FIELD. It will be honored + // unless the Management Policies feature flag is disabled. + // InitProvider holds the same fields as ForProvider, with the exception + // of Identifier and other resource reference fields. The fields that are + // in InitProvider are merged into ForProvider when the resource is created. + // The same fields are also added to the terraform ignore_changes hook, to + // avoid updating them after creation. This is useful for fields that are + // required on creation, but we do not desire to update them after creation, + // for example because of an external controller is managing them, like an + // autoscaler. + InitProvider CredentialInitParameters `json:"initProvider,omitempty"` +} + +// CredentialStatus defines the observed state of Credential. +type CredentialStatus struct { + v1.ResourceStatus `json:",inline"` + AtProvider CredentialObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true + +// Credential is the Schema for the Credentials API. +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,mailgun} +type Credential struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.domain) || (has(self.initProvider) && has(self.initProvider.domain))",message="spec.forProvider.domain is a required parameter" + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.login) || (has(self.initProvider) && has(self.initProvider.login))",message="spec.forProvider.login is a required parameter" + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.passwordSecretRef)",message="spec.forProvider.passwordSecretRef is a required parameter" + Spec CredentialSpec `json:"spec"` + Status CredentialStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// CredentialList contains a list of Credentials +type CredentialList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Credential `json:"items"` +} + +// Repository type metadata. +var ( + Credential_Kind = "Credential" + Credential_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: Credential_Kind}.String() + Credential_KindAPIVersion = Credential_Kind + "." + CRDGroupVersion.String() + Credential_GroupVersionKind = CRDGroupVersion.WithKind(Credential_Kind) +) + +func init() { + SchemeBuilder.Register(&Credential{}, &CredentialList{}) +} diff --git a/apis/null/v1alpha1/zz_generated.deepcopy.go b/apis/credential/v1alpha1/zz_generated.deepcopy.go similarity index 54% rename from apis/null/v1alpha1/zz_generated.deepcopy.go rename to apis/credential/v1alpha1/zz_generated.deepcopy.go index 1af19ad..05b4cea 100644 --- a/apis/null/v1alpha1/zz_generated.deepcopy.go +++ b/apis/credential/v1alpha1/zz_generated.deepcopy.go @@ -13,7 +13,7 @@ import ( ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Resource) DeepCopyInto(out *Resource) { +func (in *Credential) DeepCopyInto(out *Credential) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) @@ -21,18 +21,18 @@ func (in *Resource) DeepCopyInto(out *Resource) { in.Status.DeepCopyInto(&out.Status) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Resource. -func (in *Resource) DeepCopy() *Resource { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Credential. +func (in *Credential) DeepCopy() *Credential { if in == nil { return nil } - out := new(Resource) + out := new(Credential) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Resource) DeepCopyObject() runtime.Object { +func (in *Credential) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -40,62 +40,61 @@ func (in *Resource) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceInitParameters) DeepCopyInto(out *ResourceInitParameters) { +func (in *CredentialInitParameters) DeepCopyInto(out *CredentialInitParameters) { *out = *in - if in.Triggers != nil { - in, out := &in.Triggers, &out.Triggers - *out = make(map[string]*string, len(*in)) - for key, val := range *in { - var outVal *string - if val == nil { - (*out)[key] = nil - } else { - inVal := (*in)[key] - in, out := &inVal, &outVal - *out = new(string) - **out = **in - } - (*out)[key] = outVal - } + if in.Domain != nil { + in, out := &in.Domain, &out.Domain + *out = new(string) + **out = **in + } + if in.Login != nil { + in, out := &in.Login, &out.Login + *out = new(string) + **out = **in + } + if in.Region != nil { + in, out := &in.Region, &out.Region + *out = new(string) + **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceInitParameters. -func (in *ResourceInitParameters) DeepCopy() *ResourceInitParameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialInitParameters. +func (in *CredentialInitParameters) DeepCopy() *CredentialInitParameters { if in == nil { return nil } - out := new(ResourceInitParameters) + out := new(CredentialInitParameters) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceList) DeepCopyInto(out *ResourceList) { +func (in *CredentialList) DeepCopyInto(out *CredentialList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]Resource, len(*in)) + *out = make([]Credential, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceList. -func (in *ResourceList) DeepCopy() *ResourceList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialList. +func (in *CredentialList) DeepCopy() *CredentialList { if in == nil { return nil } - out := new(ResourceList) + out := new(CredentialList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ResourceList) DeepCopyObject() runtime.Object { +func (in *CredentialList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -103,103 +102,102 @@ func (in *ResourceList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceObservation) DeepCopyInto(out *ResourceObservation) { +func (in *CredentialObservation) DeepCopyInto(out *CredentialObservation) { *out = *in + if in.Domain != nil { + in, out := &in.Domain, &out.Domain + *out = new(string) + **out = **in + } if in.ID != nil { in, out := &in.ID, &out.ID *out = new(string) **out = **in } - if in.Triggers != nil { - in, out := &in.Triggers, &out.Triggers - *out = make(map[string]*string, len(*in)) - for key, val := range *in { - var outVal *string - if val == nil { - (*out)[key] = nil - } else { - inVal := (*in)[key] - in, out := &inVal, &outVal - *out = new(string) - **out = **in - } - (*out)[key] = outVal - } + if in.Login != nil { + in, out := &in.Login, &out.Login + *out = new(string) + **out = **in + } + if in.Region != nil { + in, out := &in.Region, &out.Region + *out = new(string) + **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceObservation. -func (in *ResourceObservation) DeepCopy() *ResourceObservation { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialObservation. +func (in *CredentialObservation) DeepCopy() *CredentialObservation { if in == nil { return nil } - out := new(ResourceObservation) + out := new(CredentialObservation) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceParameters) DeepCopyInto(out *ResourceParameters) { +func (in *CredentialParameters) DeepCopyInto(out *CredentialParameters) { *out = *in - if in.Triggers != nil { - in, out := &in.Triggers, &out.Triggers - *out = make(map[string]*string, len(*in)) - for key, val := range *in { - var outVal *string - if val == nil { - (*out)[key] = nil - } else { - inVal := (*in)[key] - in, out := &inVal, &outVal - *out = new(string) - **out = **in - } - (*out)[key] = outVal - } + if in.Domain != nil { + in, out := &in.Domain, &out.Domain + *out = new(string) + **out = **in + } + if in.Login != nil { + in, out := &in.Login, &out.Login + *out = new(string) + **out = **in + } + out.PasswordSecretRef = in.PasswordSecretRef + if in.Region != nil { + in, out := &in.Region, &out.Region + *out = new(string) + **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceParameters. -func (in *ResourceParameters) DeepCopy() *ResourceParameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialParameters. +func (in *CredentialParameters) DeepCopy() *CredentialParameters { if in == nil { return nil } - out := new(ResourceParameters) + out := new(CredentialParameters) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceSpec) DeepCopyInto(out *ResourceSpec) { +func (in *CredentialSpec) DeepCopyInto(out *CredentialSpec) { *out = *in in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) in.ForProvider.DeepCopyInto(&out.ForProvider) in.InitProvider.DeepCopyInto(&out.InitProvider) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceSpec. -func (in *ResourceSpec) DeepCopy() *ResourceSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialSpec. +func (in *CredentialSpec) DeepCopy() *CredentialSpec { if in == nil { return nil } - out := new(ResourceSpec) + out := new(CredentialSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceStatus) DeepCopyInto(out *ResourceStatus) { +func (in *CredentialStatus) DeepCopyInto(out *CredentialStatus) { *out = *in in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) in.AtProvider.DeepCopyInto(&out.AtProvider) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceStatus. -func (in *ResourceStatus) DeepCopy() *ResourceStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CredentialStatus. +func (in *CredentialStatus) DeepCopy() *CredentialStatus { if in == nil { return nil } - out := new(ResourceStatus) + out := new(CredentialStatus) in.DeepCopyInto(out) return out } diff --git a/apis/credential/v1alpha1/zz_generated.managed.go b/apis/credential/v1alpha1/zz_generated.managed.go new file mode 100644 index 0000000..89c141d --- /dev/null +++ b/apis/credential/v1alpha1/zz_generated.managed.go @@ -0,0 +1,68 @@ +/* +Copyright 2022 Upbound Inc. +*/ +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + +// GetCondition of this Credential. +func (mg *Credential) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this Credential. +func (mg *Credential) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this Credential. +func (mg *Credential) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this Credential. +func (mg *Credential) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +// GetPublishConnectionDetailsTo of this Credential. +func (mg *Credential) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this Credential. +func (mg *Credential) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this Credential. +func (mg *Credential) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this Credential. +func (mg *Credential) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this Credential. +func (mg *Credential) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this Credential. +func (mg *Credential) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +// SetPublishConnectionDetailsTo of this Credential. +func (mg *Credential) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this Credential. +func (mg *Credential) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} diff --git a/apis/null/v1alpha1/zz_generated.managedlist.go b/apis/credential/v1alpha1/zz_generated.managedlist.go similarity index 75% rename from apis/null/v1alpha1/zz_generated.managedlist.go rename to apis/credential/v1alpha1/zz_generated.managedlist.go index c589209..6b000c7 100644 --- a/apis/null/v1alpha1/zz_generated.managedlist.go +++ b/apis/credential/v1alpha1/zz_generated.managedlist.go @@ -7,8 +7,8 @@ package v1alpha1 import resource "github.com/crossplane/crossplane-runtime/pkg/resource" -// GetItems of this ResourceList. -func (l *ResourceList) GetItems() []resource.Managed { +// GetItems of this CredentialList. +func (l *CredentialList) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) for i := range l.Items { items[i] = &l.Items[i] diff --git a/apis/null/v1alpha1/zz_generated_terraformed.go b/apis/credential/v1alpha1/zz_generated_terraformed.go similarity index 61% rename from apis/null/v1alpha1/zz_generated_terraformed.go rename to apis/credential/v1alpha1/zz_generated_terraformed.go index 3c32037..0c2275d 100755 --- a/apis/null/v1alpha1/zz_generated_terraformed.go +++ b/apis/credential/v1alpha1/zz_generated_terraformed.go @@ -17,18 +17,18 @@ import ( "github.com/crossplane/upjet/pkg/resource/json" ) -// GetTerraformResourceType returns Terraform resource type for this Resource -func (mg *Resource) GetTerraformResourceType() string { - return "null_resource" +// GetTerraformResourceType returns Terraform resource type for this Credential +func (mg *Credential) GetTerraformResourceType() string { + return "mailgun_domain_credential" } -// GetConnectionDetailsMapping for this Resource -func (tr *Resource) GetConnectionDetailsMapping() map[string]string { - return nil +// GetConnectionDetailsMapping for this Credential +func (tr *Credential) GetConnectionDetailsMapping() map[string]string { + return map[string]string{"password": "spec.forProvider.passwordSecretRef"} } -// GetObservation of this Resource -func (tr *Resource) GetObservation() (map[string]any, error) { +// GetObservation of this Credential +func (tr *Credential) GetObservation() (map[string]any, error) { o, err := json.TFParser.Marshal(tr.Status.AtProvider) if err != nil { return nil, err @@ -37,8 +37,8 @@ func (tr *Resource) GetObservation() (map[string]any, error) { return base, json.TFParser.Unmarshal(o, &base) } -// SetObservation for this Resource -func (tr *Resource) SetObservation(obs map[string]any) error { +// SetObservation for this Credential +func (tr *Credential) SetObservation(obs map[string]any) error { p, err := json.TFParser.Marshal(obs) if err != nil { return err @@ -46,16 +46,16 @@ func (tr *Resource) SetObservation(obs map[string]any) error { return json.TFParser.Unmarshal(p, &tr.Status.AtProvider) } -// GetID returns ID of underlying Terraform resource of this Resource -func (tr *Resource) GetID() string { +// GetID returns ID of underlying Terraform resource of this Credential +func (tr *Credential) GetID() string { if tr.Status.AtProvider.ID == nil { return "" } return *tr.Status.AtProvider.ID } -// GetParameters of this Resource -func (tr *Resource) GetParameters() (map[string]any, error) { +// GetParameters of this Credential +func (tr *Credential) GetParameters() (map[string]any, error) { p, err := json.TFParser.Marshal(tr.Spec.ForProvider) if err != nil { return nil, err @@ -64,8 +64,8 @@ func (tr *Resource) GetParameters() (map[string]any, error) { return base, json.TFParser.Unmarshal(p, &base) } -// SetParameters for this Resource -func (tr *Resource) SetParameters(params map[string]any) error { +// SetParameters for this Credential +func (tr *Credential) SetParameters(params map[string]any) error { p, err := json.TFParser.Marshal(params) if err != nil { return err @@ -73,8 +73,8 @@ func (tr *Resource) SetParameters(params map[string]any) error { return json.TFParser.Unmarshal(p, &tr.Spec.ForProvider) } -// GetInitParameters of this Resource -func (tr *Resource) GetInitParameters() (map[string]any, error) { +// GetInitParameters of this Credential +func (tr *Credential) GetInitParameters() (map[string]any, error) { p, err := json.TFParser.Marshal(tr.Spec.InitProvider) if err != nil { return nil, err @@ -83,10 +83,10 @@ func (tr *Resource) GetInitParameters() (map[string]any, error) { return base, json.TFParser.Unmarshal(p, &base) } -// LateInitialize this Resource using its observed tfState. +// LateInitialize this Credential using its observed tfState. // returns True if there are any spec changes for the resource. -func (tr *Resource) LateInitialize(attrs []byte) (bool, error) { - params := &ResourceParameters{} +func (tr *Credential) LateInitialize(attrs []byte) (bool, error) { + params := &CredentialParameters{} if err := json.TFParser.Unmarshal(attrs, params); err != nil { return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") } @@ -97,6 +97,6 @@ func (tr *Resource) LateInitialize(attrs []byte) (bool, error) { } // GetTerraformSchemaVersion returns the associated Terraform schema version -func (tr *Resource) GetTerraformSchemaVersion() int { +func (tr *Credential) GetTerraformSchemaVersion() int { return 0 } diff --git a/apis/null/v1alpha1/zz_groupversion_info.go b/apis/credential/v1alpha1/zz_groupversion_info.go similarity index 89% rename from apis/null/v1alpha1/zz_groupversion_info.go rename to apis/credential/v1alpha1/zz_groupversion_info.go index 3b570c9..70798f9 100755 --- a/apis/null/v1alpha1/zz_groupversion_info.go +++ b/apis/credential/v1alpha1/zz_groupversion_info.go @@ -9,7 +9,7 @@ Copyright 2022 Upbound Inc. // Code generated by upjet. DO NOT EDIT. // +kubebuilder:object:generate=true -// +groupName=null.template.upbound.io +// +groupName=credential.domain.mailgun.saagie.io // +versionName=v1alpha1 package v1alpha1 @@ -20,7 +20,7 @@ import ( // Package type metadata. const ( - CRDGroup = "null.template.upbound.io" + CRDGroup = "credential.domain.mailgun.saagie.io" CRDVersion = "v1alpha1" ) diff --git a/apis/generate.go b/apis/generate.go index 233d170..67de6a7 100644 --- a/apis/generate.go +++ b/apis/generate.go @@ -19,7 +19,7 @@ Copyright 2021 Upbound Inc. //go:generate rm -rf ../examples-generated // Generate documentation from Terraform docs. -//go:generate go run github.com/crossplane/upjet/cmd/scraper -n ${TERRAFORM_PROVIDER_SOURCE} -r ../.work/${TERRAFORM_PROVIDER_SOURCE}/${TERRAFORM_DOCS_PATH} -o ../config/provider-metadata.yaml +//go:generate go run github.com/crossplane/upjet/cmd/scraper -n ${TERRAFORM_PROVIDER_SOURCE} -r ../.work/${TERRAFORM_PROVIDER_SOURCE}/${TERRAFORM_DOCS_PATH} -o ../config/provider-metadata.yaml --prelude-xpath "//text()[contains(., \"page_title\")]" // Run Upjet generator //go:generate go run ../cmd/generator/main.go .. diff --git a/apis/null/v1alpha1/zz_generated.managed.go b/apis/null/v1alpha1/zz_generated.managed.go deleted file mode 100644 index 74df9c5..0000000 --- a/apis/null/v1alpha1/zz_generated.managed.go +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright 2022 Upbound Inc. -*/ -// Code generated by angryjet. DO NOT EDIT. - -package v1alpha1 - -import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" - -// GetCondition of this Resource. -func (mg *Resource) GetCondition(ct xpv1.ConditionType) xpv1.Condition { - return mg.Status.GetCondition(ct) -} - -// GetDeletionPolicy of this Resource. -func (mg *Resource) GetDeletionPolicy() xpv1.DeletionPolicy { - return mg.Spec.DeletionPolicy -} - -// GetManagementPolicies of this Resource. -func (mg *Resource) GetManagementPolicies() xpv1.ManagementPolicies { - return mg.Spec.ManagementPolicies -} - -// GetProviderConfigReference of this Resource. -func (mg *Resource) GetProviderConfigReference() *xpv1.Reference { - return mg.Spec.ProviderConfigReference -} - -// GetPublishConnectionDetailsTo of this Resource. -func (mg *Resource) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { - return mg.Spec.PublishConnectionDetailsTo -} - -// GetWriteConnectionSecretToReference of this Resource. -func (mg *Resource) GetWriteConnectionSecretToReference() *xpv1.SecretReference { - return mg.Spec.WriteConnectionSecretToReference -} - -// SetConditions of this Resource. -func (mg *Resource) SetConditions(c ...xpv1.Condition) { - mg.Status.SetConditions(c...) -} - -// SetDeletionPolicy of this Resource. -func (mg *Resource) SetDeletionPolicy(r xpv1.DeletionPolicy) { - mg.Spec.DeletionPolicy = r -} - -// SetManagementPolicies of this Resource. -func (mg *Resource) SetManagementPolicies(r xpv1.ManagementPolicies) { - mg.Spec.ManagementPolicies = r -} - -// SetProviderConfigReference of this Resource. -func (mg *Resource) SetProviderConfigReference(r *xpv1.Reference) { - mg.Spec.ProviderConfigReference = r -} - -// SetPublishConnectionDetailsTo of this Resource. -func (mg *Resource) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { - mg.Spec.PublishConnectionDetailsTo = r -} - -// SetWriteConnectionSecretToReference of this Resource. -func (mg *Resource) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { - mg.Spec.WriteConnectionSecretToReference = r -} diff --git a/apis/null/v1alpha1/zz_resource_types.go b/apis/null/v1alpha1/zz_resource_types.go deleted file mode 100755 index 7801a3b..0000000 --- a/apis/null/v1alpha1/zz_resource_types.go +++ /dev/null @@ -1,98 +0,0 @@ -// SPDX-FileCopyrightText: 2023 The Crossplane Authors -// -// SPDX-License-Identifier: Apache-2.0 - -/* -Copyright 2022 Upbound Inc. -*/ - -// Code generated by upjet. DO NOT EDIT. - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - - v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" -) - -type ResourceInitParameters struct { - - // A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. - Triggers map[string]*string `json:"triggers,omitempty" tf:"triggers,omitempty"` -} - -type ResourceObservation struct { - ID *string `json:"id,omitempty" tf:"id,omitempty"` - - // A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. - Triggers map[string]*string `json:"triggers,omitempty" tf:"triggers,omitempty"` -} - -type ResourceParameters struct { - - // A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. - // +kubebuilder:validation:Optional - Triggers map[string]*string `json:"triggers,omitempty" tf:"triggers,omitempty"` -} - -// ResourceSpec defines the desired state of Resource -type ResourceSpec struct { - v1.ResourceSpec `json:",inline"` - ForProvider ResourceParameters `json:"forProvider"` - // THIS IS A BETA FIELD. It will be honored - // unless the Management Policies feature flag is disabled. - // InitProvider holds the same fields as ForProvider, with the exception - // of Identifier and other resource reference fields. The fields that are - // in InitProvider are merged into ForProvider when the resource is created. - // The same fields are also added to the terraform ignore_changes hook, to - // avoid updating them after creation. This is useful for fields that are - // required on creation, but we do not desire to update them after creation, - // for example because of an external controller is managing them, like an - // autoscaler. - InitProvider ResourceInitParameters `json:"initProvider,omitempty"` -} - -// ResourceStatus defines the observed state of Resource. -type ResourceStatus struct { - v1.ResourceStatus `json:",inline"` - AtProvider ResourceObservation `json:"atProvider,omitempty"` -} - -// +kubebuilder:object:root=true - -// Resource is the Schema for the Resources API. The null_resource resource implements the standard resource lifecycle but takes no further action. The triggers argument allows specifying an arbitrary set of values that, when changed, will cause the resource to be replaced. -// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" -// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" -// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" -// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" -// +kubebuilder:subresource:status -// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,template} -type Resource struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - Spec ResourceSpec `json:"spec"` - Status ResourceStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// ResourceList contains a list of Resources -type ResourceList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Resource `json:"items"` -} - -// Repository type metadata. -var ( - Resource_Kind = "Resource" - Resource_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: Resource_Kind}.String() - Resource_KindAPIVersion = Resource_Kind + "." + CRDGroupVersion.String() - Resource_GroupVersionKind = CRDGroupVersion.WithKind(Resource_Kind) -) - -func init() { - SchemeBuilder.Register(&Resource{}, &ResourceList{}) -} diff --git a/apis/v1alpha1/doc.go b/apis/v1alpha1/doc.go index 468ffa7..225c906 100644 --- a/apis/v1alpha1/doc.go +++ b/apis/v1alpha1/doc.go @@ -2,8 +2,8 @@ Copyright 2021 Upbound Inc. */ -// Package v1alpha1 contains the core resources of the template jet provider. +// Package v1alpha1 contains the core resources of the mailgun jet provider. // +kubebuilder:object:generate=true -// +groupName=template.upbound.io +// +groupName=mailgun.saagie.io // +versionName=v1alpha1 package v1alpha1 diff --git a/apis/v1alpha1/register.go b/apis/v1alpha1/register.go index 038d8b3..0e75c84 100644 --- a/apis/v1alpha1/register.go +++ b/apis/v1alpha1/register.go @@ -13,7 +13,7 @@ import ( // Package type metadata. const ( - Group = "template.upbound.io" + Group = "mailgun.saagie.io" Version = "v1alpha1" ) diff --git a/apis/v1alpha1/types.go b/apis/v1alpha1/types.go index 3f8f25a..ccb9ed0 100644 --- a/apis/v1alpha1/types.go +++ b/apis/v1alpha1/types.go @@ -22,11 +22,11 @@ type StoreConfigStatus struct { // +kubebuilder:object:root=true -// A StoreConfig configures how template controller should store connection details. +// A StoreConfig configures how mailgun controller should store connection details. // +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" // +kubebuilder:printcolumn:name="TYPE",type="string",JSONPath=".spec.type" // +kubebuilder:printcolumn:name="DEFAULT-SCOPE",type="string",JSONPath=".spec.defaultScope" -// +kubebuilder:resource:scope=Cluster,categories={crossplane,store,template} +// +kubebuilder:resource:scope=Cluster,categories={crossplane,store,mailgun} // +kubebuilder:subresource:status type StoreConfig struct { metav1.TypeMeta `json:",inline"` diff --git a/apis/v1beta1/doc.go b/apis/v1beta1/doc.go index 71a80b6..01e5f51 100644 --- a/apis/v1beta1/doc.go +++ b/apis/v1beta1/doc.go @@ -2,8 +2,8 @@ Copyright 2022 Upbound Inc. */ -// Package v1beta1 contains the core resources of the template upjet provider. +// Package v1beta1 contains the core resources of the mailgun upjet provider. // +kubebuilder:object:generate=true -// +groupName=template.upbound.io +// +groupName=mailgun.saagie.io // +versionName=v1beta1 package v1beta1 diff --git a/apis/v1beta1/register.go b/apis/v1beta1/register.go index a99c36e..5388264 100644 --- a/apis/v1beta1/register.go +++ b/apis/v1beta1/register.go @@ -13,7 +13,7 @@ import ( // Package type metadata. const ( - Group = "template.upbound.io" + Group = "mailgun.saagie.io" Version = "v1beta1" ) diff --git a/apis/v1beta1/types.go b/apis/v1beta1/types.go index 110474a..c874f5e 100644 --- a/apis/v1beta1/types.go +++ b/apis/v1beta1/types.go @@ -32,12 +32,12 @@ type ProviderConfigStatus struct { // +kubebuilder:object:root=true -// A ProviderConfig configures a Template provider. +// A ProviderConfig configures a Mailgun provider. // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" // +kubebuilder:printcolumn:name="SECRET-NAME",type="string",JSONPath=".spec.credentials.secretRef.name",priority=1 // +kubebuilder:resource:scope=Cluster -// +kubebuilder:resource:scope=Cluster,categories={crossplane,provider,template} +// +kubebuilder:resource:scope=Cluster,categories={crossplane,provider,mailgun} type ProviderConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -62,7 +62,7 @@ type ProviderConfigList struct { // +kubebuilder:printcolumn:name="CONFIG-NAME",type="string",JSONPath=".providerConfigRef.name" // +kubebuilder:printcolumn:name="RESOURCE-KIND",type="string",JSONPath=".resourceRef.kind" // +kubebuilder:printcolumn:name="RESOURCE-NAME",type="string",JSONPath=".resourceRef.name" -// +kubebuilder:resource:scope=Cluster,categories={crossplane,provider,template} +// +kubebuilder:resource:scope=Cluster,categories={crossplane,provider,mailgun} type ProviderConfigUsage struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/apis/zz_register.go b/apis/zz_register.go index 9a6d212..c6ddbf6 100755 --- a/apis/zz_register.go +++ b/apis/zz_register.go @@ -14,9 +14,9 @@ package apis import ( "k8s.io/apimachinery/pkg/runtime" - v1alpha1 "github.com/upbound/upjet-provider-template/apis/null/v1alpha1" - v1alpha1apis "github.com/upbound/upjet-provider-template/apis/v1alpha1" - v1beta1 "github.com/upbound/upjet-provider-template/apis/v1beta1" + v1alpha1 "saagie.io/provider-mailgun/apis/credential/v1alpha1" + v1alpha1apis "saagie.io/provider-mailgun/apis/v1alpha1" + v1beta1 "saagie.io/provider-mailgun/apis/v1beta1" ) func init() { diff --git a/cluster/images/upjet-provider-template/Dockerfile b/cluster/images/provider-mailgun/Dockerfile similarity index 100% rename from cluster/images/upjet-provider-template/Dockerfile rename to cluster/images/provider-mailgun/Dockerfile diff --git a/cluster/images/upjet-provider-template/Makefile b/cluster/images/provider-mailgun/Makefile similarity index 100% rename from cluster/images/upjet-provider-template/Makefile rename to cluster/images/provider-mailgun/Makefile diff --git a/cluster/images/upjet-provider-template/terraformrc.hcl b/cluster/images/provider-mailgun/terraformrc.hcl similarity index 100% rename from cluster/images/upjet-provider-template/terraformrc.hcl rename to cluster/images/provider-mailgun/terraformrc.hcl diff --git a/cluster/test/setup.sh b/cluster/test/setup.sh index f1138cc..5b3df75 100755 --- a/cluster/test/setup.sh +++ b/cluster/test/setup.sh @@ -13,7 +13,7 @@ ${KUBECTL} -n upbound-system wait --for=condition=Available deployment --all --t echo "Creating a default provider config..." cat <