Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Amazon MQ service #734

Merged
merged 10 commits into from
Nov 10, 2021
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PROJECT_REPO := github.com/crossplane/$(PROJECT_NAME)
PLATFORMS ?= linux_amd64 linux_arm64

CODE_GENERATOR_COMMIT ?= cac5654b7bb64c8f754ad9af01799ef70d9541b6
GENERATED_SERVICES="apigatewayv2,cloudfront,dynamodb,efs,glue,kafka,kms,lambda,rds,secretsmanager,servicediscovery,sfn,transfer"
GENERATED_SERVICES="apigatewayv2,cloudfront,dynamodb,efs,glue,kafka,kms,lambda,mq,rds,secretsmanager,servicediscovery,sfn,transfer"

# kind-related versions
KIND_VERSION ?= v0.11.1
Expand Down
2 changes: 2 additions & 0 deletions apis/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
kafkav1alpha1 "github.com/crossplane/provider-aws/apis/kafka/v1alpha1"
kmsv1alpha1 "github.com/crossplane/provider-aws/apis/kms/v1alpha1"
lambdav1alpha1 "github.com/crossplane/provider-aws/apis/lambda/v1alpha1"
mqv1alpha1 "github.com/crossplane/provider-aws/apis/mq/v1alpha1"
notificationv1alpha3 "github.com/crossplane/provider-aws/apis/notification/v1alpha1"
rdsv1alpha1 "github.com/crossplane/provider-aws/apis/rds/v1alpha1"
redshiftv1alpha1 "github.com/crossplane/provider-aws/apis/redshift/v1alpha1"
Expand Down Expand Up @@ -99,6 +100,7 @@ func init() {
kafkav1alpha1.SchemeBuilder.AddToScheme,
transferv1alpha1.SchemeBuilder.AddToScheme,
gluev1alpha1.SchemeBuilder.AddToScheme,
mqv1alpha1.SchemeBuilder.AddToScheme,
)
}

Expand Down
72 changes: 72 additions & 0 deletions apis/mq/v1alpha1/custom_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
Copyright 2021 The Crossplane Authors.

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 xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"

// CustomBrokerParameters contains the additional fields for CustomBrokerParameters
type CustomBrokerParameters struct {

// SubnetIDRefs is a list of references to Subnets used to set
// the SubnetIDs.
// +optional
SubnetIDRefs []xpv1.Reference `json:"subnetIDRefs,omitempty"`

// SubnetIDsSelector selects references to Subnets used
// to set the SubnetIDs.
// +optional
SubnetIDSelector *xpv1.Selector `json:"subnetIDSelector,omitempty"`

// SecurityGroupIDRefs is a list of references to SecurityGroups used to set
// the SecurityGroupsIDs.
// +optional
SecurityGroupIDRefs []xpv1.Reference `json:"securityGroupIdRefs,omitempty"`

// SecurityGroupIDsSelector selects references to SecurityGroups used
// to set the SecurityGroupsIDs.
// +optional
SecurityGroupIDSelector *xpv1.Selector `json:"securityGroupIdSelector,omitempty"`

CustomUsers []*CustomUser `json:"users,omitempty"`
}

// CustomUser contains the fields for Users with PasswordSecretRef
type CustomUser struct {
ConsoleAccess *bool `json:"consoleAccess,omitempty"`

Groups []*string `json:"groups,omitempty"`

PasswordSecretRef xpv1.SecretKeySelector `json:"passwordSecretRef,omitempty"`

Username *string `json:"username,omitempty"`
}

// CustomUserParameters contains the additional fields for CustomUserParameters
type CustomUserParameters struct {
// +optional
BrokerID *string `json:"brokerID,omitempty"`

// BrokerIDRef is a reference to a Broker used to set BrokerID.
// +optional
BrokerIDRef *xpv1.Reference `json:"brokerIDRef,omitempty"`

// BrokerIDSelector selects a reference to a Broker used to set BrokerID.
// +optional
BrokerIDSelector *xpv1.Selector `json:"brokerIDSelector,omitempty"`

PasswordSecretRef xpv1.SecretKeySelector `json:"passwordSecretRef,omitempty"`
}
praveenghuge marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions apis/mq/v1alpha1/generator-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ignore:
field_paths:
- CreateBrokerRequest.Users
- CreateBrokerRequest.BrokerName
- CreateUserRequest.Username
- CreateUserRequest.BrokerId
- CreateUserRequest.Password
resource_names:
- Configuration
84 changes: 84 additions & 0 deletions apis/mq/v1alpha1/referencers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
Copyright 2021 The Crossplane Authors.

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 (
"context"

"github.com/crossplane/crossplane-runtime/pkg/reference"

"github.com/pkg/errors"
"sigs.k8s.io/controller-runtime/pkg/client"

ec2 "github.com/crossplane/provider-aws/apis/ec2/v1beta1"
)

// ResolveReferences of this Broker
func (mg *Broker) ResolveReferences(ctx context.Context, c client.Reader) error {
r := reference.NewAPIResolver(c, mg)

// Resolve spec.forProvider.SubnetIds
mrsp, err := r.ResolveMultiple(ctx, reference.MultiResolutionRequest{
CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.SubnetIDs),
References: mg.Spec.ForProvider.SubnetIDRefs,
Selector: mg.Spec.ForProvider.SubnetIDSelector,
To: reference.To{Managed: &ec2.Subnet{}, List: &ec2.SubnetList{}},
Extract: reference.ExternalName(),
})
if err != nil {
return errors.Wrap(err, "spec.forProvider.SubnetIDs")
}
mg.Spec.ForProvider.SubnetIDs = reference.ToPtrValues(mrsp.ResolvedValues)
mg.Spec.ForProvider.SubnetIDRefs = mrsp.ResolvedReferences

// Resolve spec.forProvider.SecurityGroups
mrsp, err = r.ResolveMultiple(ctx, reference.MultiResolutionRequest{
CurrentValues: reference.FromPtrValues(mg.Spec.ForProvider.SecurityGroups),
References: mg.Spec.ForProvider.SecurityGroupIDRefs,
Selector: mg.Spec.ForProvider.SecurityGroupIDSelector,
To: reference.To{Managed: &ec2.SecurityGroup{}, List: &ec2.SecurityGroupList{}},
Extract: reference.ExternalName(),
})
if err != nil {
return errors.Wrap(err, "spec.forProvider.SecurityGroups")
}
mg.Spec.ForProvider.SecurityGroups = reference.ToPtrValues(mrsp.ResolvedValues)
mg.Spec.ForProvider.SecurityGroupIDRefs = mrsp.ResolvedReferences

return nil
}

// ResolveReferences of this User
func (mg *User) ResolveReferences(ctx context.Context, c client.Reader) error {
r := reference.NewAPIResolver(c, mg)

// Resolve spec.forProvider.brokerID
rsp, err := r.Resolve(ctx, reference.ResolutionRequest{
CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.BrokerID),
Reference: mg.Spec.ForProvider.BrokerIDRef,
Selector: mg.Spec.ForProvider.BrokerIDSelector,
To: reference.To{Managed: &Broker{}, List: &BrokerList{}},
Extract: reference.ExternalName(),
})
if err != nil {
return errors.Wrap(err, "spec.forProvider.brokerID")
}
mg.Spec.ForProvider.BrokerID = reference.ToPtrValue(rsp.ResolvedValue)
mg.Spec.ForProvider.BrokerIDRef = rsp.ResolvedReference

return nil
}
122 changes: 122 additions & 0 deletions apis/mq/v1alpha1/zz_broker.go

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

24 changes: 24 additions & 0 deletions apis/mq/v1alpha1/zz_doc.go

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

Loading