Skip to content

Commit

Permalink
Merge pull request #2051 from MisterMX/refactor/remove-aws-imports
Browse files Browse the repository at this point in the history
refactor(apis): Remove AWS imports
  • Loading branch information
MisterMX authored Apr 25, 2024
2 parents 4331baa + 086a5b8 commit 7fe0657
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 34 deletions.
11 changes: 5 additions & 6 deletions apis/acm/v1alpha1/certificate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v1alpha1

import (
"github.com/aws/aws-sdk-go-v2/service/acm/types"
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -56,15 +55,15 @@ type CertificateExternalStatus struct {

// Flag to check eligibility for renewal status
// +kubebuilder:validation:Enum=ELIGIBLE;INELIGIBLE
RenewalEligibility types.RenewalEligibility `json:"renewalEligibility,omitempty"`
RenewalEligibility string `json:"renewalEligibility,omitempty"`

// Status of the certificate
// +kubebuilder:validation:Enum=PENDING_VALIDATION;ISSUED;INACTIVE;EXPIRED;VALIDATION_TIMED_OUT;REVOKED;FAILED
Status types.CertificateStatus `json:"status,omitempty"`
Status string `json:"status,omitempty"`

// Type of the certificate
// +kubebuilder:validation:Enum=IMPORTED;AMAZON_ISSUED;PRIVATE
Type types.CertificateType `json:"type,omitempty"`
Type string `json:"type,omitempty"`

// Contains the CNAME record that you add to your DNS database for domain
// validation. For more information, see Use DNS to Validate Domain Ownership
Expand Down Expand Up @@ -127,7 +126,7 @@ type CertificateParameters struct {
// Parameter add the certificate to a certificate transparency log.
// +optional
// +kubebuilder:validation:Enum=ENABLED;DISABLED
CertificateTransparencyLoggingPreference *types.CertificateTransparencyLoggingPreference `json:"certificateTransparencyLoggingPreference,omitempty"`
CertificateTransparencyLoggingPreference *string `json:"certificateTransparencyLoggingPreference,omitempty"`

// Subject Alternative Name extension of the ACM certificate.
// +optional
Expand All @@ -140,7 +139,7 @@ type CertificateParameters struct {
// Method to validate certificate.
// +optional
// +kubebuilder:validation:Enum=DNS;EMAIL
ValidationMethod *types.ValidationMethod `json:"validationMethod,omitempty"`
ValidationMethod *string `json:"validationMethod,omitempty"`

// Flag to renew the certificate
// +optional
Expand Down
5 changes: 2 additions & 3 deletions apis/acm/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions apis/acmpca/v1alpha1/certificateauthority_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v1alpha1

import (
"github.com/aws/aws-sdk-go-v2/service/acmpca/types"
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -29,7 +28,7 @@ type CertificateAuthorityParameters struct {

// Type of the certificate authority
// +kubebuilder:validation:Enum=ROOT;SUBORDINATE
Type types.CertificateAuthorityType `json:"type"`
Type string `json:"type"`

// RevocationConfiguration to associate with the certificateAuthority.
// +optional
Expand Down Expand Up @@ -87,11 +86,11 @@ type CertificateAuthorityConfiguration struct {

// Type of the public key algorithm
// +kubebuilder:validation:Enum=RSA_2048;EC_secp384r1;EC_prime256v1;RSA_4096
KeyAlgorithm types.KeyAlgorithm `json:"keyAlgorithm"`
KeyAlgorithm string `json:"keyAlgorithm"`

// Algorithm that private CA uses to sign certificate requests
// +kubebuilder:validation:Enum=SHA512WITHECDSA;SHA256WITHECDSA;SHA384WITHECDSA;SHA512WITHRSA;SHA256WITHRSA;SHA384WITHRSA
SigningAlgorithm types.SigningAlgorithm `json:"signingAlgorithm"`
SigningAlgorithm string `json:"signingAlgorithm"`

// Subject is information of Certificate Authority
Subject Subject `json:"subject"`
Expand Down
7 changes: 3 additions & 4 deletions apis/acmpca/v1beta1/certificateauthority_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v1beta1

import (
"github.com/aws/aws-sdk-go-v2/service/acmpca/types"
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -29,7 +28,7 @@ type CertificateAuthorityParameters struct {

// Type of the certificate authority
// +kubebuilder:validation:Enum=ROOT;SUBORDINATE
Type types.CertificateAuthorityType `json:"type"`
Type string `json:"type"`

// RevocationConfiguration to associate with the certificateAuthority.
// +optional
Expand Down Expand Up @@ -87,11 +86,11 @@ type CertificateAuthorityConfiguration struct {

// Type of the public key algorithm
// +kubebuilder:validation:Enum=RSA_2048;EC_secp384r1;EC_prime256v1;RSA_4096
KeyAlgorithm types.KeyAlgorithm `json:"keyAlgorithm"`
KeyAlgorithm string `json:"keyAlgorithm"`

// Algorithm that private CA uses to sign certificate requests
// +kubebuilder:validation:Enum=SHA512WITHECDSA;SHA256WITHECDSA;SHA384WITHECDSA;SHA512WITHRSA;SHA256WITHRSA;SHA384WITHRSA
SigningAlgorithm types.SigningAlgorithm `json:"signingAlgorithm"`
SigningAlgorithm string `json:"signingAlgorithm"`

// Subject is information of Certificate Authority
Subject Subject `json:"subject"`
Expand Down
4 changes: 2 additions & 2 deletions apis/apigatewayv2/v1alpha1/referencers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"fmt"
"strings"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/crossplane/crossplane-runtime/pkg/reference"
resource "github.com/crossplane/crossplane-runtime/pkg/resource"
"github.com/pkg/errors"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"

ec2 "github.com/crossplane-contrib/provider-aws/apis/ec2/v1beta1"
Expand Down Expand Up @@ -304,7 +304,7 @@ func IntegrationID() reference.ExtractValueFn {
return ""
}

id := aws.ToString(r.Status.AtProvider.IntegrationID)
id := ptr.Deref(r.Status.AtProvider.IntegrationID, "")

// The Integration ID target requires the integrations/ prefix
if id == "" || strings.HasPrefix(id, "integrations/") {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ require (
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sync v0.7.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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,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.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
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=
Expand Down
10 changes: 5 additions & 5 deletions pkg/clients/acmpca/certificateauthority.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewClient(conf *aws.Config) Client {
// GenerateCreateCertificateAuthorityInput from certificateAuthorityParameters
func GenerateCreateCertificateAuthorityInput(p *v1beta1.CertificateAuthorityParameters) *acmpca.CreateCertificateAuthorityInput {
m := &acmpca.CreateCertificateAuthorityInput{
CertificateAuthorityType: p.Type,
CertificateAuthorityType: types.CertificateAuthorityType(p.Type),
CertificateAuthorityConfiguration: GenerateCertificateAuthorityConfiguration(p.CertificateAuthorityConfiguration),
RevocationConfiguration: GenerateRevocationConfiguration(p.RevocationConfiguration),
}
Expand Down Expand Up @@ -84,8 +84,8 @@ func GenerateCertificateAuthorityConfiguration(p v1beta1.CertificateAuthorityCon
Surname: p.Subject.Surname,
Title: p.Subject.Title,
},
SigningAlgorithm: p.SigningAlgorithm,
KeyAlgorithm: p.KeyAlgorithm,
SigningAlgorithm: types.SigningAlgorithm(p.SigningAlgorithm),
KeyAlgorithm: types.KeyAlgorithm(p.KeyAlgorithm),
}
return m

Expand Down Expand Up @@ -116,8 +116,8 @@ func LateInitializeCertificateAuthority(in *v1beta1.CertificateAuthorityParamete
return
}

if string(in.Type) == "" && string(certificateAuthority.Type) != "" {
in.Type = certificateAuthority.Type
if in.Type == "" && string(certificateAuthority.Type) != "" {
in.Type = string(certificateAuthority.Type)
}

// NOTE(muvaf): Only ACTIVE and DISABLED statuses can be assigned by the user
Expand Down
14 changes: 7 additions & 7 deletions pkg/clients/acmpca/certificateauthority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ func TestGenerateCreateCertificateAuthorityInput(t *testing.T) {
}{
"Filled_Input": {
in: &v1beta1.CertificateAuthorityParameters{
Type: types.CertificateAuthorityTypeRoot,
Type: string(types.CertificateAuthorityTypeRoot),
CertificateAuthorityConfiguration: v1beta1.CertificateAuthorityConfiguration{
SigningAlgorithm: types.SigningAlgorithmSha256withecdsa,
KeyAlgorithm: types.KeyAlgorithmRsa2048,
SigningAlgorithm: string(types.SigningAlgorithmSha256withecdsa),
KeyAlgorithm: string(types.KeyAlgorithmRsa2048),
Subject: v1beta1.Subject{
CommonName: commonName,
Country: country,
Expand Down Expand Up @@ -129,8 +129,8 @@ func TestGenerateCertificateAuthorityConfiguration(t *testing.T) {
}{
"Filled_Input": {
in: v1beta1.CertificateAuthorityConfiguration{
SigningAlgorithm: types.SigningAlgorithmSha256withecdsa,
KeyAlgorithm: types.KeyAlgorithmRsa2048,
SigningAlgorithm: string(types.SigningAlgorithmSha256withecdsa),
KeyAlgorithm: string(types.KeyAlgorithmRsa2048),
Subject: v1beta1.Subject{
CommonName: commonName,
Country: country,
Expand Down Expand Up @@ -227,7 +227,7 @@ func TestLateInitializeCertificateAuthority(t *testing.T) {
"AllFilledNoDiff": {
args: args{
spec: &v1beta1.CertificateAuthorityParameters{
Type: types.CertificateAuthorityTypeRoot,
Type: string(types.CertificateAuthorityTypeRoot),
},
in: &types.CertificateAuthority{
Type: types.CertificateAuthorityTypeRoot,
Expand All @@ -245,7 +245,7 @@ func TestLateInitializeCertificateAuthority(t *testing.T) {
},
},
want: &v1beta1.CertificateAuthorityParameters{
Type: types.CertificateAuthorityTypeRoot,
Type: string(types.CertificateAuthorityTypeRoot),
Status: &status,
CertificateAuthorityConfiguration: v1beta1.CertificateAuthorityConfiguration{
Subject: v1beta1.Subject{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func withCertificateAuthorityArn() certificateAuthorityModifier {

func withCertificateAuthorityType() certificateAuthorityModifier {
return func(r *v1beta1.CertificateAuthority) {
r.Spec.ForProvider.Type = awsacmpcatypes.CertificateAuthorityTypeRoot
r.Spec.ForProvider.Type = string(awsacmpcatypes.CertificateAuthorityTypeRoot)
r.Status.AtProvider.CertificateAuthorityARN = certificateAuthorityArn
meta.SetExternalName(r, certificateAuthorityArn)
}
Expand Down

0 comments on commit 7fe0657

Please sign in to comment.