From 5d59c2110406708fea71e77ad9df19cea986ab27 Mon Sep 17 00:00:00 2001 From: cite Date: Sat, 26 Aug 2023 11:51:21 +0200 Subject: [PATCH] feat(globalaccelerator): Add support for accelerator, listener and endpointgroups Signed-off-by: cite --- CODE_GENERATION.md | 64 +- apis/aws.go | 2 + apis/cognitoidentity/v1alpha1/zz_doc.go | 2 +- apis/globalaccelerator/generator-config.yaml | 28 + .../v1alpha1/custom_types.go | 64 + .../globalaccelerator/v1alpha1/referencers.go | 31 + .../v1alpha1/zz_accelerator.go | 169 ++ apis/globalaccelerator/v1alpha1/zz_doc.go | 24 + .../v1alpha1/zz_endpoint_group.go | 133 ++ apis/globalaccelerator/v1alpha1/zz_enums.go | 107 ++ .../v1alpha1/zz_generated.deepcopy.go | 1517 +++++++++++++++++ .../v1alpha1/zz_generated.managed.go | 249 +++ .../v1alpha1/zz_generated.managedlist.go | 48 + .../v1alpha1/zz_generated.resolvers.go | 78 + .../v1alpha1/zz_groupversion_info.go | 41 + .../globalaccelerator/v1alpha1/zz_listener.go | 115 ++ apis/globalaccelerator/v1alpha1/zz_types.go | 276 +++ examples/globalaccelerator/accelerator.yaml | 37 + ...erator.aws.crossplane.io_accelerators.yaml | 442 +++++ ...ator.aws.crossplane.io_endpointgroups.yaml | 496 ++++++ ...celerator.aws.crossplane.io_listeners.yaml | 441 +++++ pkg/controller/aws.go | 2 + .../globalaccelerator/accelerator/setup.go | 147 ++ .../accelerator/zz_controller.go | 309 ++++ .../accelerator/zz_conversions.go | 213 +++ .../globalaccelerator/endpointgroup/setup.go | 93 + .../endpointgroup/zz_controller.go | 303 ++++ .../endpointgroup/zz_conversions.go | 267 +++ .../globalaccelerator/listener/setup.go | 131 ++ .../listener/zz_controller.go | 253 +++ .../listener/zz_conversions.go | 156 ++ pkg/controller/globalaccelerator/setup.go | 35 + 32 files changed, 6269 insertions(+), 4 deletions(-) create mode 100644 apis/globalaccelerator/generator-config.yaml create mode 100644 apis/globalaccelerator/v1alpha1/custom_types.go create mode 100644 apis/globalaccelerator/v1alpha1/referencers.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_accelerator.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_doc.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_endpoint_group.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_enums.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_generated.deepcopy.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_generated.managed.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_generated.managedlist.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_generated.resolvers.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_groupversion_info.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_listener.go create mode 100644 apis/globalaccelerator/v1alpha1/zz_types.go create mode 100644 examples/globalaccelerator/accelerator.yaml create mode 100644 package/crds/globalaccelerator.aws.crossplane.io_accelerators.yaml create mode 100644 package/crds/globalaccelerator.aws.crossplane.io_endpointgroups.yaml create mode 100644 package/crds/globalaccelerator.aws.crossplane.io_listeners.yaml create mode 100644 pkg/controller/globalaccelerator/accelerator/setup.go create mode 100644 pkg/controller/globalaccelerator/accelerator/zz_controller.go create mode 100644 pkg/controller/globalaccelerator/accelerator/zz_conversions.go create mode 100644 pkg/controller/globalaccelerator/endpointgroup/setup.go create mode 100644 pkg/controller/globalaccelerator/endpointgroup/zz_controller.go create mode 100644 pkg/controller/globalaccelerator/endpointgroup/zz_conversions.go create mode 100644 pkg/controller/globalaccelerator/listener/setup.go create mode 100644 pkg/controller/globalaccelerator/listener/zz_controller.go create mode 100644 pkg/controller/globalaccelerator/listener/zz_conversions.go create mode 100644 pkg/controller/globalaccelerator/setup.go diff --git a/CODE_GENERATION.md b/CODE_GENERATION.md index fc503d4e58..0ada97a8a1 100644 --- a/CODE_GENERATION.md +++ b/CODE_GENERATION.md @@ -100,6 +100,39 @@ files that help CRD structs satisfy the Go interfaces we use in crossplane-runti There are a few things we need to implement manually since there is no support for their generation yet. +### Setup Api Group + +If a new group of api's has been introduced, we will need write a `Setup` function to satisfy +the interface which we will need to register the contollers. For example, if you added `globalaccelerator` +api group, we will need a file in `pkg/controller/globalaccelerator/setup.go with following contents: + +```golang +package globalaccelerator + +import ( + ctrl "sigs.k8s.io/controller-runtime" + + "github.com/crossplane/crossplane-runtime/pkg/controller" + + "github.com/crossplane-contrib/provider-aws/pkg/controller/globalaccelerator/accelerator" + "github.com/crossplane-contrib/provider-aws/pkg/controller/globalaccelerator/listener" + "github.com/crossplane-contrib/provider-aws/pkg/controller/globalaccelerator/endpointgroup" + "github.com/crossplane-contrib/provider-aws/pkg/utils/setup" +) + +// Setup athena controllers. +func Setup(mgr ctrl.Manager, o controller.Options) error { + return setup.SetupControllers( + mgr, o, + accelerator.SetupAccelerator, + listener.SetupListener, + endpointgroup.SetupEndpointGroup, + ) +} +``` + +Now you need to make sure this function is called in setup phase [here](https://github.com/crossplane-contrib/provider-aws/blob/2e52b0a8b9ca9efa132e82549b9a48c13345dd27/pkg/controller/aws.go#L81). + ### Setup Controller The generated controller needs to be registered with the main controller manager @@ -130,8 +163,6 @@ func SetupStage(mgr ctrl.Manager, o controller.Options) error { } ``` -Now you need to make sure this function is called in setup phase [here](https://github.com/crossplane/provider-aws/blob/483058c/pkg/controller/aws.go#L84). - #### Register CRD If the group didn't exist before, we need to register its schema [here](https://github.com/crossplane/provider-aws/blob/master/apis/aws.go). @@ -210,6 +241,9 @@ external name of the referenced object, you can use the following comment marker You can add the package prefix for `type` and `extractor` configurations if they live in a different Go package. +Be aware that once you customize the extractor, you will need to implement it yourself. +An example can be found [here](https://github.com/crossplane-contrib/provider-aws/blob/72a6950/apis/lambda/v1beta1/referencers.go#L35). + ### External Name Crossplane has the notion of external name that we put under annotations. It corresponds @@ -274,9 +308,33 @@ func preDelete(_ context.Context, cr *svcapitypes.Stage, obj *svcsdk.DeleteStage If the external-name is decided by AWS after the creation (like in most EC2 resources such as `vpc-id` of `VPC`), then you need to inject `postCreate` to set the crossplane resource external-name to the unique identifier of the -resource, for eg see [`apigatewayv2`](https://github.com/crossplane/provider-aws/blob/master/pkg/controller/apigatewayv2/api/setup.go#L77) +resource, for eg see [`apigatewayv2`](https://github.com/crossplane/provider-aws/blob/72a6950/pkg/controller/apigatewayv2/api/setup.go#L85) You can discover what you can inject by inspecting `zz_controller.go` file. +### Errors On Observe + +In some situations aws api returns an error in cases where the resource does not exist. +It will be noticeable when the resource never gets created but you see an error from the api +which describes the object. You should see `return ok && awsErr.Code() == "ResourceNotFoundException"` in +the `IsNotFound`-function of `zz_conversion.go`. + +To tell ack which error indicates that the resource is not present, add a similar config to `generator-config.yaml`: + +``` +resources: + Table: + fields: + PointInTimeRecoveryEnabled: + from: + operation: UpdateContinuousBackups + path: PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled + exceptions: + errors: + 404: + code: ResourceNotFoundException +``` + + ### Readiness Check Every managed resource needs to report its readiness. We'll do that in `postObserve` diff --git a/apis/aws.go b/apis/aws.go index 5284583235..44d4847561 100644 --- a/apis/aws.go +++ b/apis/aws.go @@ -58,6 +58,7 @@ import ( elbv2manualv1alpha1 "github.com/crossplane-contrib/provider-aws/apis/elbv2/manualv1alpha1" elbv2v1alpha1 "github.com/crossplane-contrib/provider-aws/apis/elbv2/v1alpha1" emrcontainersv1alpah1 "github.com/crossplane-contrib/provider-aws/apis/emrcontainers/v1alpha1" + globalacceleratorv1alpha1 "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1" gluev1alpha1 "github.com/crossplane-contrib/provider-aws/apis/glue/v1alpha1" iamv1alpha1 "github.com/crossplane-contrib/provider-aws/apis/iam/v1alpha1" iamv1beta1 "github.com/crossplane-contrib/provider-aws/apis/iam/v1beta1" @@ -148,6 +149,7 @@ func init() { kafkav1alpha1.SchemeBuilder.AddToScheme, transferv1alpha1.SchemeBuilder.AddToScheme, gluev1alpha1.SchemeBuilder.AddToScheme, + globalacceleratorv1alpha1.SchemeBuilder.AddToScheme, mqv1alpha1.SchemeBuilder.AddToScheme, mwaav1alpha1.SchemeBuilder.AddToScheme, cloudwatchlogsv1alpha1.SchemeBuilder.AddToScheme, diff --git a/apis/cognitoidentity/v1alpha1/zz_doc.go b/apis/cognitoidentity/v1alpha1/zz_doc.go index bab0336742..8f8436e046 100644 --- a/apis/cognitoidentity/v1alpha1/zz_doc.go +++ b/apis/cognitoidentity/v1alpha1/zz_doc.go @@ -21,4 +21,4 @@ limitations under the License. // +groupName=cognitoidentity.aws.crossplane.io // +versionName=v1alpha1 -package v1alpha1 \ No newline at end of file +package v1alpha1 diff --git a/apis/globalaccelerator/generator-config.yaml b/apis/globalaccelerator/generator-config.yaml new file mode 100644 index 0000000000..33d2e9d94b --- /dev/null +++ b/apis/globalaccelerator/generator-config.yaml @@ -0,0 +1,28 @@ +ignore: + field_paths: + - "CreateAcceleratorInput.IdempotencyToken" + - "CreateListenerInput.AcceleratorArn" + - "CreateListenerInput.IdempotencyToken" + - "CreateEndpointGroupInput.ListenerArn" + - "CreateEndpointGroupInput.IdempotencyToken" + resource_names: + - "CustomRoutingAccelerator" + - "CustomRoutingEndpointGroup" + - "CustomRoutingListener" + +resources: + Accelerator: + exceptions: + errors: + 404: + code: AcceleratorNotFoundException + Listener: + exceptions: + errors: + 404: + code: ListenerNotFoundException + EndpointGroup: + exceptions: + errors: + 404: + code: EndpointGroupNotFoundException diff --git a/apis/globalaccelerator/v1alpha1/custom_types.go b/apis/globalaccelerator/v1alpha1/custom_types.go new file mode 100644 index 0000000000..0690bd90f0 --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/custom_types.go @@ -0,0 +1,64 @@ +/* +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" + +// CustomAcceleratorParameters contains the additional fields for AcceleratorParameters +type CustomAcceleratorParameters struct{} + +// CustomEndpointGroupParameters contains the additional fields for EndpointGroupParameters +type CustomEndpointGroupParameters struct { + // ListenerArn is the ARN for the Listener. + // +immutable + // +crossplane:generate:reference:type=Listener + // +crossplane:generate:reference:extractor=ListenerARN() + // +crossplane:generate:reference:refFieldName=ListenerArnRef + // +crossplane:generate:reference:selectorFieldName=ListenerArnSelector + ListenerARN *string `json:"listenerArn,omitempty"` + + // ListenerArnRef is a reference to an ARN used to set + // the ListenerArn. + // +optional + ListenerArnRef *xpv1.Reference `json:"listenerArnRef,omitempty"` + + // ListenerArnSelector selects references to Listener used + // to set the Arn. + // +optional + ListenerArnSelector *xpv1.Selector `json:"listenerArnSelector,omitempty"` +} + +// CustomListenerParameters contains the additional fields for ListenerParameters +type CustomListenerParameters struct { + // AcceleratorArn is the ARN for the Accelerator. + // +immutable + // +crossplane:generate:reference:type=Accelerator + // +crossplane:generate:reference:extractor=AcceleratorARN() + // +crossplane:generate:reference:refFieldName=AcceleratorArnRef + // +crossplane:generate:reference:selectorFieldName=AcceleratorArnSelector + AcceleratorArn *string `json:"acceleratorArn,omitempty"` + + // AcceleratorArnRef is a reference to an ARN used to set + // the AcceleratorArn. + // +optional + AcceleratorArnRef *xpv1.Reference `json:"acceleratorArnRef,omitempty"` + + // AcceleratorArnSelector selects references to Accelerator used + // to set the Arn. + // +optional + AcceleratorArnSelector *xpv1.Selector `json:"acceleratorArnSelector,omitempty"` +} diff --git a/apis/globalaccelerator/v1alpha1/referencers.go b/apis/globalaccelerator/v1alpha1/referencers.go new file mode 100644 index 0000000000..bb5ff9171a --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/referencers.go @@ -0,0 +1,31 @@ +package v1alpha1 + +import ( + "github.com/crossplane/crossplane-runtime/pkg/reference" + "github.com/crossplane/crossplane-runtime/pkg/resource" + "k8s.io/utils/pointer" +) + +// AcceleratorARN returns the status.atProvider.ARN of an Accelerator +func AcceleratorARN() reference.ExtractValueFn { + return func(mg resource.Managed) string { + r, ok := mg.(*Accelerator) + if !ok { + return "" + } + + return pointer.StringDeref(r.Status.AtProvider.AcceleratorARN, "") + } +} + +// ListenerARN returns the status.atProvider.ARN of an Listener +func ListenerARN() reference.ExtractValueFn { + return func(mg resource.Managed) string { + r, ok := mg.(*Listener) + if !ok { + return "" + } + + return pointer.StringDeref(r.Status.AtProvider.ListenerARN, "") + } +} diff --git a/apis/globalaccelerator/v1alpha1/zz_accelerator.go b/apis/globalaccelerator/v1alpha1/zz_accelerator.go new file mode 100644 index 0000000000..3f856abf93 --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_accelerator.go @@ -0,0 +1,169 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package v1alpha1 + +import ( + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// AcceleratorParameters defines the desired state of Accelerator +type AcceleratorParameters struct { + // Region is which region the Accelerator will be created. + // +kubebuilder:validation:Required + Region string `json:"region"` + // Indicates whether an accelerator is enabled. The value is true or false. + // The default value is true. + // + // If the value is set to true, an accelerator cannot be deleted. If set to + // false, the accelerator can be deleted. + Enabled *bool `json:"enabled,omitempty"` + // The IP address type that an accelerator supports. For a standard accelerator, + // the value can be IPV4 or DUAL_STACK. + IPAddressType *string `json:"ipAddressType,omitempty"` + // Optionally, if you've added your own IP address pool to Global Accelerator + // (BYOIP), you can choose an IPv4 address from your own pool to use for the + // accelerator's static IPv4 address when you create an accelerator. + // + // After you bring an address range to Amazon Web Services, it appears in your + // account as an address pool. When you create an accelerator, you can assign + // one IPv4 address from your range to it. Global Accelerator assigns you a + // second static IPv4 address from an Amazon IP address range. If you bring + // two IPv4 address ranges to Amazon Web Services, you can assign one IPv4 address + // from each range to your accelerator. This restriction is because Global Accelerator + // assigns each address range to a different network zone, for high availability. + // + // You can specify one or two addresses, separated by a space. Do not include + // the /32 suffix. + // + // Note that you can't update IP addresses for an existing accelerator. To change + // them, you must create a new accelerator with the new addresses. + // + // For more information, see Bring your own IP addresses (BYOIP) (https://docs.aws.amazon.com/global-accelerator/latest/dg/using-byoip.html) + // in the Global Accelerator Developer Guide. + IPAddresses []*string `json:"ipAddresses,omitempty"` + // The name of the accelerator. The name can have a maximum of 64 characters, + // must contain only alphanumeric characters, periods (.), or hyphens (-), and + // must not begin or end with a hyphen or period. + // +kubebuilder:validation:Required + Name *string `json:"name"` + // Create tags for an accelerator. + // + // For more information, see Tagging in Global Accelerator (https://docs.aws.amazon.com/global-accelerator/latest/dg/tagging-in-global-accelerator.html) + // in the Global Accelerator Developer Guide. + Tags []*Tag `json:"tags,omitempty"` + CustomAcceleratorParameters `json:",inline"` +} + +// AcceleratorSpec defines the desired state of Accelerator +type AcceleratorSpec struct { + xpv1.ResourceSpec `json:",inline"` + ForProvider AcceleratorParameters `json:"forProvider"` +} + +// AcceleratorObservation defines the observed state of Accelerator +type AcceleratorObservation struct { + // The Amazon Resource Name (ARN) of the accelerator. + AcceleratorARN *string `json:"acceleratorARN,omitempty"` + // The date and time that the accelerator was created. + CreatedTime *metav1.Time `json:"createdTime,omitempty"` + // The Domain Name System (DNS) name that Global Accelerator creates that points + // to an accelerator's static IPv4 addresses. + // + // The naming convention for the DNS name for an accelerator is the following: + // A lowercase letter a, followed by a 16-bit random hex string, followed by + // .awsglobalaccelerator.com. For example: a1234567890abcdef.awsglobalaccelerator.com. + // + // If you have a dual-stack accelerator, you also have a second DNS name, DualStackDnsName, + // that points to both the A record and the AAAA record for all four static + // addresses for the accelerator: two IPv4 addresses and two IPv6 addresses. + // + // For more information about the default DNS name, see Support for DNS addressing + // in Global Accelerator (https://docs.aws.amazon.com/global-accelerator/latest/dg/dns-addressing-custom-domains.dns-addressing.html) + // in the Global Accelerator Developer Guide. + DNSName *string `json:"dnsName,omitempty"` + // The Domain Name System (DNS) name that Global Accelerator creates that points + // to a dual-stack accelerator's four static IP addresses: two IPv4 addresses + // and two IPv6 addresses. + // + // The naming convention for the dual-stack DNS name is the following: A lowercase + // letter a, followed by a 16-bit random hex string, followed by .dualstack.awsglobalaccelerator.com. + // For example: a1234567890abcdef.dualstack.awsglobalaccelerator.com. + // + // Note: Global Accelerator also assigns a default DNS name, DnsName, to your + // accelerator that points just to the static IPv4 addresses. + // + // For more information, see Support for DNS addressing in Global Accelerator + // (https://docs.aws.amazon.com/global-accelerator/latest/dg/about-accelerators.html#about-accelerators.dns-addressing) + // in the Global Accelerator Developer Guide. + DualStackDNSName *string `json:"dualStackDNSName,omitempty"` + // A history of changes that you make to an accelerator in Global Accelerator. + Events []*AcceleratorEvent `json:"events,omitempty"` + // The static IP addresses that Global Accelerator associates with the accelerator. + IPSets []*IPSet `json:"ipSets,omitempty"` + // The date and time that the accelerator was last modified. + LastModifiedTime *metav1.Time `json:"lastModifiedTime,omitempty"` + // Describes the deployment status of the accelerator. + Status *string `json:"status,omitempty"` +} + +// AcceleratorStatus defines the observed state of Accelerator. +type AcceleratorStatus struct { + xpv1.ResourceStatus `json:",inline"` + AtProvider AcceleratorObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true + +// Accelerator is the Schema for the Accelerators 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:storageversion +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,aws} +type Accelerator struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec AcceleratorSpec `json:"spec"` + Status AcceleratorStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// AcceleratorList contains a list of Accelerators +type AcceleratorList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Accelerator `json:"items"` +} + +// Repository type metadata. +var ( + AcceleratorKind = "Accelerator" + AcceleratorGroupKind = schema.GroupKind{Group: CRDGroup, Kind: AcceleratorKind}.String() + AcceleratorKindAPIVersion = AcceleratorKind + "." + GroupVersion.String() + AcceleratorGroupVersionKind = GroupVersion.WithKind(AcceleratorKind) +) + +func init() { + SchemeBuilder.Register(&Accelerator{}, &AcceleratorList{}) +} diff --git a/apis/globalaccelerator/v1alpha1/zz_doc.go b/apis/globalaccelerator/v1alpha1/zz_doc.go new file mode 100644 index 0000000000..b53a194633 --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_doc.go @@ -0,0 +1,24 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +// +kubebuilder:object:generate=true +// Package v1alpha1 is the v1alpha1 version of the globalaccelerator.aws.crossplane.io API. +// +groupName=globalaccelerator.aws.crossplane.io +// +versionName=v1alpha1 + +package v1alpha1 diff --git a/apis/globalaccelerator/v1alpha1/zz_endpoint_group.go b/apis/globalaccelerator/v1alpha1/zz_endpoint_group.go new file mode 100644 index 0000000000..516178fb7c --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_endpoint_group.go @@ -0,0 +1,133 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package v1alpha1 + +import ( + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// EndpointGroupParameters defines the desired state of EndpointGroup +type EndpointGroupParameters struct { + // Region is which region the EndpointGroup will be created. + // +kubebuilder:validation:Required + Region string `json:"region"` + // The list of endpoint objects. + EndpointConfigurations []*EndpointConfiguration `json:"endpointConfigurations,omitempty"` + // The Amazon Web Services Region where the endpoint group is located. A listener + // can have only one endpoint group in a specific Region. + // +kubebuilder:validation:Required + EndpointGroupRegion *string `json:"endpointGroupRegion"` + // The time—10 seconds or 30 seconds—between each health check for an endpoint. + // The default value is 30. + HealthCheckIntervalSeconds *int64 `json:"healthCheckIntervalSeconds,omitempty"` + // If the protocol is HTTP/S, then this specifies the path that is the destination + // for health check targets. The default value is slash (/). + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + // The port that Global Accelerator uses to check the health of endpoints that + // are part of this endpoint group. The default port is the listener port that + // this endpoint group is associated with. If listener port is a list of ports, + // Global Accelerator uses the first port in the list. + HealthCheckPort *int64 `json:"healthCheckPort,omitempty"` + // The protocol that Global Accelerator uses to check the health of endpoints + // that are part of this endpoint group. The default value is TCP. + HealthCheckProtocol *string `json:"healthCheckProtocol,omitempty"` + // Override specific listener ports used to route traffic to endpoints that + // are part of this endpoint group. For example, you can create a port override + // in which the listener receives user traffic on ports 80 and 443, but your + // accelerator routes that traffic to ports 1080 and 1443, respectively, on + // the endpoints. + // + // For more information, see Overriding listener ports (https://docs.aws.amazon.com/global-accelerator/latest/dg/about-endpoint-groups-port-override.html) + // in the Global Accelerator Developer Guide. + PortOverrides []*PortOverride `json:"portOverrides,omitempty"` + // The number of consecutive health checks required to set the state of a healthy + // endpoint to unhealthy, or to set an unhealthy endpoint to healthy. The default + // value is 3. + ThresholdCount *int64 `json:"thresholdCount,omitempty"` + // The percentage of traffic to send to an Amazon Web Services Region. Additional + // traffic is distributed to other endpoint groups for this listener. + // + // Use this action to increase (dial up) or decrease (dial down) traffic to + // a specific Region. The percentage is applied to the traffic that would otherwise + // have been routed to the Region based on optimal routing. + // + // The default value is 100. + TrafficDialPercentage *float64 `json:"trafficDialPercentage,omitempty"` + CustomEndpointGroupParameters `json:",inline"` +} + +// EndpointGroupSpec defines the desired state of EndpointGroup +type EndpointGroupSpec struct { + xpv1.ResourceSpec `json:",inline"` + ForProvider EndpointGroupParameters `json:"forProvider"` +} + +// EndpointGroupObservation defines the observed state of EndpointGroup +type EndpointGroupObservation struct { + // The list of endpoint objects. + EndpointDescriptions []*EndpointDescription `json:"endpointDescriptions,omitempty"` + // The Amazon Resource Name (ARN) of the endpoint group. + EndpointGroupARN *string `json:"endpointGroupARN,omitempty"` +} + +// EndpointGroupStatus defines the observed state of EndpointGroup. +type EndpointGroupStatus struct { + xpv1.ResourceStatus `json:",inline"` + AtProvider EndpointGroupObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true + +// EndpointGroup is the Schema for the EndpointGroups 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:storageversion +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,aws} +type EndpointGroup struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec EndpointGroupSpec `json:"spec"` + Status EndpointGroupStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// EndpointGroupList contains a list of EndpointGroups +type EndpointGroupList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []EndpointGroup `json:"items"` +} + +// Repository type metadata. +var ( + EndpointGroupKind = "EndpointGroup" + EndpointGroupGroupKind = schema.GroupKind{Group: CRDGroup, Kind: EndpointGroupKind}.String() + EndpointGroupKindAPIVersion = EndpointGroupKind + "." + GroupVersion.String() + EndpointGroupGroupVersionKind = GroupVersion.WithKind(EndpointGroupKind) +) + +func init() { + SchemeBuilder.Register(&EndpointGroup{}, &EndpointGroupList{}) +} diff --git a/apis/globalaccelerator/v1alpha1/zz_enums.go b/apis/globalaccelerator/v1alpha1/zz_enums.go new file mode 100644 index 0000000000..d4f4835ae4 --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_enums.go @@ -0,0 +1,107 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package v1alpha1 + +type AcceleratorStatus_SDK string + +const ( + AcceleratorStatus_SDK_DEPLOYED AcceleratorStatus_SDK = "DEPLOYED" + AcceleratorStatus_SDK_IN_PROGRESS AcceleratorStatus_SDK = "IN_PROGRESS" +) + +type ByoipCIDRState string + +const ( + ByoipCIDRState_PENDING_PROVISIONING ByoipCIDRState = "PENDING_PROVISIONING" + ByoipCIDRState_READY ByoipCIDRState = "READY" + ByoipCIDRState_PENDING_ADVERTISING ByoipCIDRState = "PENDING_ADVERTISING" + ByoipCIDRState_ADVERTISING ByoipCIDRState = "ADVERTISING" + ByoipCIDRState_PENDING_WITHDRAWING ByoipCIDRState = "PENDING_WITHDRAWING" + ByoipCIDRState_PENDING_DEPROVISIONING ByoipCIDRState = "PENDING_DEPROVISIONING" + ByoipCIDRState_DEPROVISIONED ByoipCIDRState = "DEPROVISIONED" + ByoipCIDRState_FAILED_PROVISION ByoipCIDRState = "FAILED_PROVISION" + ByoipCIDRState_FAILED_ADVERTISING ByoipCIDRState = "FAILED_ADVERTISING" + ByoipCIDRState_FAILED_WITHDRAW ByoipCIDRState = "FAILED_WITHDRAW" + ByoipCIDRState_FAILED_DEPROVISION ByoipCIDRState = "FAILED_DEPROVISION" +) + +type ClientAffinity string + +const ( + ClientAffinity_NONE ClientAffinity = "NONE" + ClientAffinity_SOURCE_IP ClientAffinity = "SOURCE_IP" +) + +type CustomRoutingAcceleratorStatus string + +const ( + CustomRoutingAcceleratorStatus_DEPLOYED CustomRoutingAcceleratorStatus = "DEPLOYED" + CustomRoutingAcceleratorStatus_IN_PROGRESS CustomRoutingAcceleratorStatus = "IN_PROGRESS" +) + +type CustomRoutingDestinationTrafficState string + +const ( + CustomRoutingDestinationTrafficState_ALLOW CustomRoutingDestinationTrafficState = "ALLOW" + CustomRoutingDestinationTrafficState_DENY CustomRoutingDestinationTrafficState = "DENY" +) + +type CustomRoutingProtocol string + +const ( + CustomRoutingProtocol_TCP CustomRoutingProtocol = "TCP" + CustomRoutingProtocol_UDP CustomRoutingProtocol = "UDP" +) + +type HealthCheckProtocol string + +const ( + HealthCheckProtocol_TCP HealthCheckProtocol = "TCP" + HealthCheckProtocol_HTTP HealthCheckProtocol = "HTTP" + HealthCheckProtocol_HTTPS HealthCheckProtocol = "HTTPS" +) + +type HealthState string + +const ( + HealthState_INITIAL HealthState = "INITIAL" + HealthState_HEALTHY HealthState = "HEALTHY" + HealthState_UNHEALTHY HealthState = "UNHEALTHY" +) + +type IPAddressFamily string + +const ( + IPAddressFamily_IPv4 IPAddressFamily = "IPv4" + IPAddressFamily_IPv6 IPAddressFamily = "IPv6" +) + +type IPAddressType string + +const ( + IPAddressType_IPV4 IPAddressType = "IPV4" + IPAddressType_DUAL_STACK IPAddressType = "DUAL_STACK" +) + +type Protocol string + +const ( + Protocol_TCP Protocol = "TCP" + Protocol_UDP Protocol = "UDP" +) diff --git a/apis/globalaccelerator/v1alpha1/zz_generated.deepcopy.go b/apis/globalaccelerator/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..75a7cdbea7 --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,1517 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +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. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "github.com/crossplane/crossplane-runtime/apis/common/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Accelerator) DeepCopyInto(out *Accelerator) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Accelerator. +func (in *Accelerator) DeepCopy() *Accelerator { + if in == nil { + return nil + } + out := new(Accelerator) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Accelerator) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AcceleratorAttributes) DeepCopyInto(out *AcceleratorAttributes) { + *out = *in + if in.FlowLogsEnabled != nil { + in, out := &in.FlowLogsEnabled, &out.FlowLogsEnabled + *out = new(bool) + **out = **in + } + if in.FlowLogsS3Bucket != nil { + in, out := &in.FlowLogsS3Bucket, &out.FlowLogsS3Bucket + *out = new(string) + **out = **in + } + if in.FlowLogsS3Prefix != nil { + in, out := &in.FlowLogsS3Prefix, &out.FlowLogsS3Prefix + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AcceleratorAttributes. +func (in *AcceleratorAttributes) DeepCopy() *AcceleratorAttributes { + if in == nil { + return nil + } + out := new(AcceleratorAttributes) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AcceleratorEvent) DeepCopyInto(out *AcceleratorEvent) { + *out = *in + if in.Message != nil { + in, out := &in.Message, &out.Message + *out = new(string) + **out = **in + } + if in.Timestamp != nil { + in, out := &in.Timestamp, &out.Timestamp + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AcceleratorEvent. +func (in *AcceleratorEvent) DeepCopy() *AcceleratorEvent { + if in == nil { + return nil + } + out := new(AcceleratorEvent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AcceleratorList) DeepCopyInto(out *AcceleratorList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Accelerator, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AcceleratorList. +func (in *AcceleratorList) DeepCopy() *AcceleratorList { + if in == nil { + return nil + } + out := new(AcceleratorList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AcceleratorList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AcceleratorObservation) DeepCopyInto(out *AcceleratorObservation) { + *out = *in + if in.AcceleratorARN != nil { + in, out := &in.AcceleratorARN, &out.AcceleratorARN + *out = new(string) + **out = **in + } + if in.CreatedTime != nil { + in, out := &in.CreatedTime, &out.CreatedTime + *out = (*in).DeepCopy() + } + if in.DNSName != nil { + in, out := &in.DNSName, &out.DNSName + *out = new(string) + **out = **in + } + if in.DualStackDNSName != nil { + in, out := &in.DualStackDNSName, &out.DualStackDNSName + *out = new(string) + **out = **in + } + if in.Events != nil { + in, out := &in.Events, &out.Events + *out = make([]*AcceleratorEvent, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(AcceleratorEvent) + (*in).DeepCopyInto(*out) + } + } + } + if in.IPSets != nil { + in, out := &in.IPSets, &out.IPSets + *out = make([]*IPSet, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(IPSet) + (*in).DeepCopyInto(*out) + } + } + } + if in.LastModifiedTime != nil { + in, out := &in.LastModifiedTime, &out.LastModifiedTime + *out = (*in).DeepCopy() + } + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AcceleratorObservation. +func (in *AcceleratorObservation) DeepCopy() *AcceleratorObservation { + if in == nil { + return nil + } + out := new(AcceleratorObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AcceleratorParameters) DeepCopyInto(out *AcceleratorParameters) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.IPAddressType != nil { + in, out := &in.IPAddressType, &out.IPAddressType + *out = new(string) + **out = **in + } + if in.IPAddresses != nil { + in, out := &in.IPAddresses, &out.IPAddresses + *out = make([]*string, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(string) + **out = **in + } + } + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make([]*Tag, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(Tag) + (*in).DeepCopyInto(*out) + } + } + } + out.CustomAcceleratorParameters = in.CustomAcceleratorParameters +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AcceleratorParameters. +func (in *AcceleratorParameters) DeepCopy() *AcceleratorParameters { + if in == nil { + return nil + } + out := new(AcceleratorParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AcceleratorSpec) DeepCopyInto(out *AcceleratorSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AcceleratorSpec. +func (in *AcceleratorSpec) DeepCopy() *AcceleratorSpec { + if in == nil { + return nil + } + out := new(AcceleratorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AcceleratorStatus) DeepCopyInto(out *AcceleratorStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AcceleratorStatus. +func (in *AcceleratorStatus) DeepCopy() *AcceleratorStatus { + if in == nil { + return nil + } + out := new(AcceleratorStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Accelerator_SDK) DeepCopyInto(out *Accelerator_SDK) { + *out = *in + if in.AcceleratorARN != nil { + in, out := &in.AcceleratorARN, &out.AcceleratorARN + *out = new(string) + **out = **in + } + if in.CreatedTime != nil { + in, out := &in.CreatedTime, &out.CreatedTime + *out = (*in).DeepCopy() + } + if in.DNSName != nil { + in, out := &in.DNSName, &out.DNSName + *out = new(string) + **out = **in + } + if in.DualStackDNSName != nil { + in, out := &in.DualStackDNSName, &out.DualStackDNSName + *out = new(string) + **out = **in + } + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.Events != nil { + in, out := &in.Events, &out.Events + *out = make([]*AcceleratorEvent, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(AcceleratorEvent) + (*in).DeepCopyInto(*out) + } + } + } + if in.IPAddressType != nil { + in, out := &in.IPAddressType, &out.IPAddressType + *out = new(string) + **out = **in + } + if in.IPSets != nil { + in, out := &in.IPSets, &out.IPSets + *out = make([]*IPSet, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(IPSet) + (*in).DeepCopyInto(*out) + } + } + } + if in.LastModifiedTime != nil { + in, out := &in.LastModifiedTime, &out.LastModifiedTime + *out = (*in).DeepCopy() + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Accelerator_SDK. +func (in *Accelerator_SDK) DeepCopy() *Accelerator_SDK { + if in == nil { + return nil + } + out := new(Accelerator_SDK) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ByoipCIDR) DeepCopyInto(out *ByoipCIDR) { + *out = *in + if in.CIDR != nil { + in, out := &in.CIDR, &out.CIDR + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ByoipCIDR. +func (in *ByoipCIDR) DeepCopy() *ByoipCIDR { + if in == nil { + return nil + } + out := new(ByoipCIDR) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ByoipCIDREvent) DeepCopyInto(out *ByoipCIDREvent) { + *out = *in + if in.Message != nil { + in, out := &in.Message, &out.Message + *out = new(string) + **out = **in + } + if in.Timestamp != nil { + in, out := &in.Timestamp, &out.Timestamp + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ByoipCIDREvent. +func (in *ByoipCIDREvent) DeepCopy() *ByoipCIDREvent { + if in == nil { + return nil + } + out := new(ByoipCIDREvent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CIDRAuthorizationContext) DeepCopyInto(out *CIDRAuthorizationContext) { + *out = *in + if in.Message != nil { + in, out := &in.Message, &out.Message + *out = new(string) + **out = **in + } + if in.Signature != nil { + in, out := &in.Signature, &out.Signature + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CIDRAuthorizationContext. +func (in *CIDRAuthorizationContext) DeepCopy() *CIDRAuthorizationContext { + if in == nil { + return nil + } + out := new(CIDRAuthorizationContext) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomAcceleratorParameters) DeepCopyInto(out *CustomAcceleratorParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomAcceleratorParameters. +func (in *CustomAcceleratorParameters) DeepCopy() *CustomAcceleratorParameters { + if in == nil { + return nil + } + out := new(CustomAcceleratorParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomEndpointGroupParameters) DeepCopyInto(out *CustomEndpointGroupParameters) { + *out = *in + if in.ListenerARN != nil { + in, out := &in.ListenerARN, &out.ListenerARN + *out = new(string) + **out = **in + } + if in.ListenerArnRef != nil { + in, out := &in.ListenerArnRef, &out.ListenerArnRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.ListenerArnSelector != nil { + in, out := &in.ListenerArnSelector, &out.ListenerArnSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomEndpointGroupParameters. +func (in *CustomEndpointGroupParameters) DeepCopy() *CustomEndpointGroupParameters { + if in == nil { + return nil + } + out := new(CustomEndpointGroupParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomListenerParameters) DeepCopyInto(out *CustomListenerParameters) { + *out = *in + if in.AcceleratorArn != nil { + in, out := &in.AcceleratorArn, &out.AcceleratorArn + *out = new(string) + **out = **in + } + if in.AcceleratorArnRef != nil { + in, out := &in.AcceleratorArnRef, &out.AcceleratorArnRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.AcceleratorArnSelector != nil { + in, out := &in.AcceleratorArnSelector, &out.AcceleratorArnSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomListenerParameters. +func (in *CustomListenerParameters) DeepCopy() *CustomListenerParameters { + if in == nil { + return nil + } + out := new(CustomListenerParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomRoutingAccelerator) DeepCopyInto(out *CustomRoutingAccelerator) { + *out = *in + if in.AcceleratorARN != nil { + in, out := &in.AcceleratorARN, &out.AcceleratorARN + *out = new(string) + **out = **in + } + if in.CreatedTime != nil { + in, out := &in.CreatedTime, &out.CreatedTime + *out = (*in).DeepCopy() + } + if in.DNSName != nil { + in, out := &in.DNSName, &out.DNSName + *out = new(string) + **out = **in + } + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.IPAddressType != nil { + in, out := &in.IPAddressType, &out.IPAddressType + *out = new(string) + **out = **in + } + if in.IPSets != nil { + in, out := &in.IPSets, &out.IPSets + *out = make([]*IPSet, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(IPSet) + (*in).DeepCopyInto(*out) + } + } + } + if in.LastModifiedTime != nil { + in, out := &in.LastModifiedTime, &out.LastModifiedTime + *out = (*in).DeepCopy() + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRoutingAccelerator. +func (in *CustomRoutingAccelerator) DeepCopy() *CustomRoutingAccelerator { + if in == nil { + return nil + } + out := new(CustomRoutingAccelerator) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomRoutingAcceleratorAttributes) DeepCopyInto(out *CustomRoutingAcceleratorAttributes) { + *out = *in + if in.FlowLogsEnabled != nil { + in, out := &in.FlowLogsEnabled, &out.FlowLogsEnabled + *out = new(bool) + **out = **in + } + if in.FlowLogsS3Bucket != nil { + in, out := &in.FlowLogsS3Bucket, &out.FlowLogsS3Bucket + *out = new(string) + **out = **in + } + if in.FlowLogsS3Prefix != nil { + in, out := &in.FlowLogsS3Prefix, &out.FlowLogsS3Prefix + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRoutingAcceleratorAttributes. +func (in *CustomRoutingAcceleratorAttributes) DeepCopy() *CustomRoutingAcceleratorAttributes { + if in == nil { + return nil + } + out := new(CustomRoutingAcceleratorAttributes) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomRoutingDestinationConfiguration) DeepCopyInto(out *CustomRoutingDestinationConfiguration) { + *out = *in + if in.FromPort != nil { + in, out := &in.FromPort, &out.FromPort + *out = new(int64) + **out = **in + } + if in.ToPort != nil { + in, out := &in.ToPort, &out.ToPort + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRoutingDestinationConfiguration. +func (in *CustomRoutingDestinationConfiguration) DeepCopy() *CustomRoutingDestinationConfiguration { + if in == nil { + return nil + } + out := new(CustomRoutingDestinationConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomRoutingDestinationDescription) DeepCopyInto(out *CustomRoutingDestinationDescription) { + *out = *in + if in.FromPort != nil { + in, out := &in.FromPort, &out.FromPort + *out = new(int64) + **out = **in + } + if in.ToPort != nil { + in, out := &in.ToPort, &out.ToPort + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRoutingDestinationDescription. +func (in *CustomRoutingDestinationDescription) DeepCopy() *CustomRoutingDestinationDescription { + if in == nil { + return nil + } + out := new(CustomRoutingDestinationDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomRoutingEndpointConfiguration) DeepCopyInto(out *CustomRoutingEndpointConfiguration) { + *out = *in + if in.EndpointID != nil { + in, out := &in.EndpointID, &out.EndpointID + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRoutingEndpointConfiguration. +func (in *CustomRoutingEndpointConfiguration) DeepCopy() *CustomRoutingEndpointConfiguration { + if in == nil { + return nil + } + out := new(CustomRoutingEndpointConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomRoutingEndpointDescription) DeepCopyInto(out *CustomRoutingEndpointDescription) { + *out = *in + if in.EndpointID != nil { + in, out := &in.EndpointID, &out.EndpointID + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRoutingEndpointDescription. +func (in *CustomRoutingEndpointDescription) DeepCopy() *CustomRoutingEndpointDescription { + if in == nil { + return nil + } + out := new(CustomRoutingEndpointDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomRoutingEndpointGroup) DeepCopyInto(out *CustomRoutingEndpointGroup) { + *out = *in + if in.EndpointGroupARN != nil { + in, out := &in.EndpointGroupARN, &out.EndpointGroupARN + *out = new(string) + **out = **in + } + if in.EndpointGroupRegion != nil { + in, out := &in.EndpointGroupRegion, &out.EndpointGroupRegion + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRoutingEndpointGroup. +func (in *CustomRoutingEndpointGroup) DeepCopy() *CustomRoutingEndpointGroup { + if in == nil { + return nil + } + out := new(CustomRoutingEndpointGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomRoutingListener) DeepCopyInto(out *CustomRoutingListener) { + *out = *in + if in.ListenerARN != nil { + in, out := &in.ListenerARN, &out.ListenerARN + *out = new(string) + **out = **in + } + if in.PortRanges != nil { + in, out := &in.PortRanges, &out.PortRanges + *out = make([]*PortRange, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(PortRange) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRoutingListener. +func (in *CustomRoutingListener) DeepCopy() *CustomRoutingListener { + if in == nil { + return nil + } + out := new(CustomRoutingListener) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DestinationPortMapping) DeepCopyInto(out *DestinationPortMapping) { + *out = *in + if in.AcceleratorARN != nil { + in, out := &in.AcceleratorARN, &out.AcceleratorARN + *out = new(string) + **out = **in + } + if in.EndpointGroupARN != nil { + in, out := &in.EndpointGroupARN, &out.EndpointGroupARN + *out = new(string) + **out = **in + } + if in.EndpointGroupRegion != nil { + in, out := &in.EndpointGroupRegion, &out.EndpointGroupRegion + *out = new(string) + **out = **in + } + if in.EndpointID != nil { + in, out := &in.EndpointID, &out.EndpointID + *out = new(string) + **out = **in + } + if in.IPAddressType != nil { + in, out := &in.IPAddressType, &out.IPAddressType + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DestinationPortMapping. +func (in *DestinationPortMapping) DeepCopy() *DestinationPortMapping { + if in == nil { + return nil + } + out := new(DestinationPortMapping) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointConfiguration) DeepCopyInto(out *EndpointConfiguration) { + *out = *in + if in.ClientIPPreservationEnabled != nil { + in, out := &in.ClientIPPreservationEnabled, &out.ClientIPPreservationEnabled + *out = new(bool) + **out = **in + } + if in.EndpointID != nil { + in, out := &in.EndpointID, &out.EndpointID + *out = new(string) + **out = **in + } + if in.Weight != nil { + in, out := &in.Weight, &out.Weight + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointConfiguration. +func (in *EndpointConfiguration) DeepCopy() *EndpointConfiguration { + if in == nil { + return nil + } + out := new(EndpointConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointDescription) DeepCopyInto(out *EndpointDescription) { + *out = *in + if in.ClientIPPreservationEnabled != nil { + in, out := &in.ClientIPPreservationEnabled, &out.ClientIPPreservationEnabled + *out = new(bool) + **out = **in + } + if in.EndpointID != nil { + in, out := &in.EndpointID, &out.EndpointID + *out = new(string) + **out = **in + } + if in.HealthReason != nil { + in, out := &in.HealthReason, &out.HealthReason + *out = new(string) + **out = **in + } + if in.HealthState != nil { + in, out := &in.HealthState, &out.HealthState + *out = new(string) + **out = **in + } + if in.Weight != nil { + in, out := &in.Weight, &out.Weight + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointDescription. +func (in *EndpointDescription) DeepCopy() *EndpointDescription { + if in == nil { + return nil + } + out := new(EndpointDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointGroup) DeepCopyInto(out *EndpointGroup) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointGroup. +func (in *EndpointGroup) DeepCopy() *EndpointGroup { + if in == nil { + return nil + } + out := new(EndpointGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *EndpointGroup) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointGroupList) DeepCopyInto(out *EndpointGroupList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]EndpointGroup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointGroupList. +func (in *EndpointGroupList) DeepCopy() *EndpointGroupList { + if in == nil { + return nil + } + out := new(EndpointGroupList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *EndpointGroupList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointGroupObservation) DeepCopyInto(out *EndpointGroupObservation) { + *out = *in + if in.EndpointDescriptions != nil { + in, out := &in.EndpointDescriptions, &out.EndpointDescriptions + *out = make([]*EndpointDescription, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(EndpointDescription) + (*in).DeepCopyInto(*out) + } + } + } + if in.EndpointGroupARN != nil { + in, out := &in.EndpointGroupARN, &out.EndpointGroupARN + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointGroupObservation. +func (in *EndpointGroupObservation) DeepCopy() *EndpointGroupObservation { + if in == nil { + return nil + } + out := new(EndpointGroupObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointGroupParameters) DeepCopyInto(out *EndpointGroupParameters) { + *out = *in + if in.EndpointConfigurations != nil { + in, out := &in.EndpointConfigurations, &out.EndpointConfigurations + *out = make([]*EndpointConfiguration, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(EndpointConfiguration) + (*in).DeepCopyInto(*out) + } + } + } + if in.EndpointGroupRegion != nil { + in, out := &in.EndpointGroupRegion, &out.EndpointGroupRegion + *out = new(string) + **out = **in + } + if in.HealthCheckIntervalSeconds != nil { + in, out := &in.HealthCheckIntervalSeconds, &out.HealthCheckIntervalSeconds + *out = new(int64) + **out = **in + } + if in.HealthCheckPath != nil { + in, out := &in.HealthCheckPath, &out.HealthCheckPath + *out = new(string) + **out = **in + } + if in.HealthCheckPort != nil { + in, out := &in.HealthCheckPort, &out.HealthCheckPort + *out = new(int64) + **out = **in + } + if in.HealthCheckProtocol != nil { + in, out := &in.HealthCheckProtocol, &out.HealthCheckProtocol + *out = new(string) + **out = **in + } + if in.PortOverrides != nil { + in, out := &in.PortOverrides, &out.PortOverrides + *out = make([]*PortOverride, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(PortOverride) + (*in).DeepCopyInto(*out) + } + } + } + if in.ThresholdCount != nil { + in, out := &in.ThresholdCount, &out.ThresholdCount + *out = new(int64) + **out = **in + } + if in.TrafficDialPercentage != nil { + in, out := &in.TrafficDialPercentage, &out.TrafficDialPercentage + *out = new(float64) + **out = **in + } + in.CustomEndpointGroupParameters.DeepCopyInto(&out.CustomEndpointGroupParameters) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointGroupParameters. +func (in *EndpointGroupParameters) DeepCopy() *EndpointGroupParameters { + if in == nil { + return nil + } + out := new(EndpointGroupParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointGroupSpec) DeepCopyInto(out *EndpointGroupSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointGroupSpec. +func (in *EndpointGroupSpec) DeepCopy() *EndpointGroupSpec { + if in == nil { + return nil + } + out := new(EndpointGroupSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointGroupStatus) DeepCopyInto(out *EndpointGroupStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointGroupStatus. +func (in *EndpointGroupStatus) DeepCopy() *EndpointGroupStatus { + if in == nil { + return nil + } + out := new(EndpointGroupStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointGroup_SDK) DeepCopyInto(out *EndpointGroup_SDK) { + *out = *in + if in.EndpointDescriptions != nil { + in, out := &in.EndpointDescriptions, &out.EndpointDescriptions + *out = make([]*EndpointDescription, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(EndpointDescription) + (*in).DeepCopyInto(*out) + } + } + } + if in.EndpointGroupARN != nil { + in, out := &in.EndpointGroupARN, &out.EndpointGroupARN + *out = new(string) + **out = **in + } + if in.EndpointGroupRegion != nil { + in, out := &in.EndpointGroupRegion, &out.EndpointGroupRegion + *out = new(string) + **out = **in + } + if in.HealthCheckIntervalSeconds != nil { + in, out := &in.HealthCheckIntervalSeconds, &out.HealthCheckIntervalSeconds + *out = new(int64) + **out = **in + } + if in.HealthCheckPath != nil { + in, out := &in.HealthCheckPath, &out.HealthCheckPath + *out = new(string) + **out = **in + } + if in.HealthCheckPort != nil { + in, out := &in.HealthCheckPort, &out.HealthCheckPort + *out = new(int64) + **out = **in + } + if in.HealthCheckProtocol != nil { + in, out := &in.HealthCheckProtocol, &out.HealthCheckProtocol + *out = new(string) + **out = **in + } + if in.PortOverrides != nil { + in, out := &in.PortOverrides, &out.PortOverrides + *out = make([]*PortOverride, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(PortOverride) + (*in).DeepCopyInto(*out) + } + } + } + if in.ThresholdCount != nil { + in, out := &in.ThresholdCount, &out.ThresholdCount + *out = new(int64) + **out = **in + } + if in.TrafficDialPercentage != nil { + in, out := &in.TrafficDialPercentage, &out.TrafficDialPercentage + *out = new(float64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointGroup_SDK. +func (in *EndpointGroup_SDK) DeepCopy() *EndpointGroup_SDK { + if in == nil { + return nil + } + out := new(EndpointGroup_SDK) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointIdentifier) DeepCopyInto(out *EndpointIdentifier) { + *out = *in + if in.ClientIPPreservationEnabled != nil { + in, out := &in.ClientIPPreservationEnabled, &out.ClientIPPreservationEnabled + *out = new(bool) + **out = **in + } + if in.EndpointID != nil { + in, out := &in.EndpointID, &out.EndpointID + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointIdentifier. +func (in *EndpointIdentifier) DeepCopy() *EndpointIdentifier { + if in == nil { + return nil + } + out := new(EndpointIdentifier) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPSet) DeepCopyInto(out *IPSet) { + *out = *in + if in.IPAddressFamily != nil { + in, out := &in.IPAddressFamily, &out.IPAddressFamily + *out = new(string) + **out = **in + } + if in.IPAddresses != nil { + in, out := &in.IPAddresses, &out.IPAddresses + *out = make([]*string, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(string) + **out = **in + } + } + } + if in.IPFamily != nil { + in, out := &in.IPFamily, &out.IPFamily + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPSet. +func (in *IPSet) DeepCopy() *IPSet { + if in == nil { + return nil + } + out := new(IPSet) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Listener) DeepCopyInto(out *Listener) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Listener. +func (in *Listener) DeepCopy() *Listener { + if in == nil { + return nil + } + out := new(Listener) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Listener) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ListenerList) DeepCopyInto(out *ListenerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Listener, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ListenerList. +func (in *ListenerList) DeepCopy() *ListenerList { + if in == nil { + return nil + } + out := new(ListenerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ListenerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ListenerObservation) DeepCopyInto(out *ListenerObservation) { + *out = *in + if in.ListenerARN != nil { + in, out := &in.ListenerARN, &out.ListenerARN + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ListenerObservation. +func (in *ListenerObservation) DeepCopy() *ListenerObservation { + if in == nil { + return nil + } + out := new(ListenerObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ListenerParameters) DeepCopyInto(out *ListenerParameters) { + *out = *in + if in.ClientAffinity != nil { + in, out := &in.ClientAffinity, &out.ClientAffinity + *out = new(string) + **out = **in + } + if in.PortRanges != nil { + in, out := &in.PortRanges, &out.PortRanges + *out = make([]*PortRange, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(PortRange) + (*in).DeepCopyInto(*out) + } + } + } + if in.Protocol != nil { + in, out := &in.Protocol, &out.Protocol + *out = new(string) + **out = **in + } + in.CustomListenerParameters.DeepCopyInto(&out.CustomListenerParameters) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ListenerParameters. +func (in *ListenerParameters) DeepCopy() *ListenerParameters { + if in == nil { + return nil + } + out := new(ListenerParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ListenerSpec) DeepCopyInto(out *ListenerSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ListenerSpec. +func (in *ListenerSpec) DeepCopy() *ListenerSpec { + if in == nil { + return nil + } + out := new(ListenerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ListenerStatus) DeepCopyInto(out *ListenerStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ListenerStatus. +func (in *ListenerStatus) DeepCopy() *ListenerStatus { + if in == nil { + return nil + } + out := new(ListenerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Listener_SDK) DeepCopyInto(out *Listener_SDK) { + *out = *in + if in.ClientAffinity != nil { + in, out := &in.ClientAffinity, &out.ClientAffinity + *out = new(string) + **out = **in + } + if in.ListenerARN != nil { + in, out := &in.ListenerARN, &out.ListenerARN + *out = new(string) + **out = **in + } + if in.PortRanges != nil { + in, out := &in.PortRanges, &out.PortRanges + *out = make([]*PortRange, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(PortRange) + (*in).DeepCopyInto(*out) + } + } + } + if in.Protocol != nil { + in, out := &in.Protocol, &out.Protocol + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Listener_SDK. +func (in *Listener_SDK) DeepCopy() *Listener_SDK { + if in == nil { + return nil + } + out := new(Listener_SDK) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PortMapping) DeepCopyInto(out *PortMapping) { + *out = *in + if in.AcceleratorPort != nil { + in, out := &in.AcceleratorPort, &out.AcceleratorPort + *out = new(int64) + **out = **in + } + if in.EndpointGroupARN != nil { + in, out := &in.EndpointGroupARN, &out.EndpointGroupARN + *out = new(string) + **out = **in + } + if in.EndpointID != nil { + in, out := &in.EndpointID, &out.EndpointID + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortMapping. +func (in *PortMapping) DeepCopy() *PortMapping { + if in == nil { + return nil + } + out := new(PortMapping) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PortOverride) DeepCopyInto(out *PortOverride) { + *out = *in + if in.EndpointPort != nil { + in, out := &in.EndpointPort, &out.EndpointPort + *out = new(int64) + **out = **in + } + if in.ListenerPort != nil { + in, out := &in.ListenerPort, &out.ListenerPort + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortOverride. +func (in *PortOverride) DeepCopy() *PortOverride { + if in == nil { + return nil + } + out := new(PortOverride) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PortRange) DeepCopyInto(out *PortRange) { + *out = *in + if in.FromPort != nil { + in, out := &in.FromPort, &out.FromPort + *out = new(int64) + **out = **in + } + if in.ToPort != nil { + in, out := &in.ToPort, &out.ToPort + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortRange. +func (in *PortRange) DeepCopy() *PortRange { + if in == nil { + return nil + } + out := new(PortRange) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SocketAddress) DeepCopyInto(out *SocketAddress) { + *out = *in + if in.IPAddress != nil { + in, out := &in.IPAddress, &out.IPAddress + *out = new(string) + **out = **in + } + if in.Port != nil { + in, out := &in.Port, &out.Port + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SocketAddress. +func (in *SocketAddress) DeepCopy() *SocketAddress { + if in == nil { + return nil + } + out := new(SocketAddress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Tag) DeepCopyInto(out *Tag) { + *out = *in + if in.Key != nil { + in, out := &in.Key, &out.Key + *out = new(string) + **out = **in + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Tag. +func (in *Tag) DeepCopy() *Tag { + if in == nil { + return nil + } + out := new(Tag) + in.DeepCopyInto(out) + return out +} diff --git a/apis/globalaccelerator/v1alpha1/zz_generated.managed.go b/apis/globalaccelerator/v1alpha1/zz_generated.managed.go new file mode 100644 index 0000000000..5149330097 --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_generated.managed.go @@ -0,0 +1,249 @@ +/* +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. +*/ + +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + +// GetCondition of this Accelerator. +func (mg *Accelerator) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this Accelerator. +func (mg *Accelerator) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this Accelerator. +func (mg *Accelerator) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this Accelerator. +func (mg *Accelerator) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +/* +GetProviderReference of this Accelerator. +Deprecated: Use GetProviderConfigReference. +*/ +func (mg *Accelerator) GetProviderReference() *xpv1.Reference { + return mg.Spec.ProviderReference +} + +// GetPublishConnectionDetailsTo of this Accelerator. +func (mg *Accelerator) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this Accelerator. +func (mg *Accelerator) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this Accelerator. +func (mg *Accelerator) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this Accelerator. +func (mg *Accelerator) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this Accelerator. +func (mg *Accelerator) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this Accelerator. +func (mg *Accelerator) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +/* +SetProviderReference of this Accelerator. +Deprecated: Use SetProviderConfigReference. +*/ +func (mg *Accelerator) SetProviderReference(r *xpv1.Reference) { + mg.Spec.ProviderReference = r +} + +// SetPublishConnectionDetailsTo of this Accelerator. +func (mg *Accelerator) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this Accelerator. +func (mg *Accelerator) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + +// GetCondition of this EndpointGroup. +func (mg *EndpointGroup) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this EndpointGroup. +func (mg *EndpointGroup) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this EndpointGroup. +func (mg *EndpointGroup) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this EndpointGroup. +func (mg *EndpointGroup) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +/* +GetProviderReference of this EndpointGroup. +Deprecated: Use GetProviderConfigReference. +*/ +func (mg *EndpointGroup) GetProviderReference() *xpv1.Reference { + return mg.Spec.ProviderReference +} + +// GetPublishConnectionDetailsTo of this EndpointGroup. +func (mg *EndpointGroup) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this EndpointGroup. +func (mg *EndpointGroup) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this EndpointGroup. +func (mg *EndpointGroup) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this EndpointGroup. +func (mg *EndpointGroup) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this EndpointGroup. +func (mg *EndpointGroup) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this EndpointGroup. +func (mg *EndpointGroup) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +/* +SetProviderReference of this EndpointGroup. +Deprecated: Use SetProviderConfigReference. +*/ +func (mg *EndpointGroup) SetProviderReference(r *xpv1.Reference) { + mg.Spec.ProviderReference = r +} + +// SetPublishConnectionDetailsTo of this EndpointGroup. +func (mg *EndpointGroup) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this EndpointGroup. +func (mg *EndpointGroup) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + +// GetCondition of this Listener. +func (mg *Listener) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this Listener. +func (mg *Listener) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this Listener. +func (mg *Listener) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this Listener. +func (mg *Listener) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +/* +GetProviderReference of this Listener. +Deprecated: Use GetProviderConfigReference. +*/ +func (mg *Listener) GetProviderReference() *xpv1.Reference { + return mg.Spec.ProviderReference +} + +// GetPublishConnectionDetailsTo of this Listener. +func (mg *Listener) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this Listener. +func (mg *Listener) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this Listener. +func (mg *Listener) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this Listener. +func (mg *Listener) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this Listener. +func (mg *Listener) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this Listener. +func (mg *Listener) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +/* +SetProviderReference of this Listener. +Deprecated: Use SetProviderConfigReference. +*/ +func (mg *Listener) SetProviderReference(r *xpv1.Reference) { + mg.Spec.ProviderReference = r +} + +// SetPublishConnectionDetailsTo of this Listener. +func (mg *Listener) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this Listener. +func (mg *Listener) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} diff --git a/apis/globalaccelerator/v1alpha1/zz_generated.managedlist.go b/apis/globalaccelerator/v1alpha1/zz_generated.managedlist.go new file mode 100644 index 0000000000..267c52bec5 --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_generated.managedlist.go @@ -0,0 +1,48 @@ +/* +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. +*/ + +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import resource "github.com/crossplane/crossplane-runtime/pkg/resource" + +// GetItems of this AcceleratorList. +func (l *AcceleratorList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + +// GetItems of this EndpointGroupList. +func (l *EndpointGroupList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + +// GetItems of this ListenerList. +func (l *ListenerList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} diff --git a/apis/globalaccelerator/v1alpha1/zz_generated.resolvers.go b/apis/globalaccelerator/v1alpha1/zz_generated.resolvers.go new file mode 100644 index 0000000000..30dfb575ec --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_generated.resolvers.go @@ -0,0 +1,78 @@ +/* +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. +*/ + +// Code generated by angryjet. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + reference "github.com/crossplane/crossplane-runtime/pkg/reference" + errors "github.com/pkg/errors" + client "sigs.k8s.io/controller-runtime/pkg/client" +) + +// ResolveReferences of this EndpointGroup. +func (mg *EndpointGroup) ResolveReferences(ctx context.Context, c client.Reader) error { + r := reference.NewAPIResolver(c, mg) + + var rsp reference.ResolutionResponse + var err error + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.CustomEndpointGroupParameters.ListenerARN), + Extract: ListenerARN(), + Reference: mg.Spec.ForProvider.CustomEndpointGroupParameters.ListenerArnRef, + Selector: mg.Spec.ForProvider.CustomEndpointGroupParameters.ListenerArnSelector, + To: reference.To{ + List: &ListenerList{}, + Managed: &Listener{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.CustomEndpointGroupParameters.ListenerARN") + } + mg.Spec.ForProvider.CustomEndpointGroupParameters.ListenerARN = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.CustomEndpointGroupParameters.ListenerArnRef = rsp.ResolvedReference + + return nil +} + +// ResolveReferences of this Listener. +func (mg *Listener) ResolveReferences(ctx context.Context, c client.Reader) error { + r := reference.NewAPIResolver(c, mg) + + var rsp reference.ResolutionResponse + var err error + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.CustomListenerParameters.AcceleratorArn), + Extract: AcceleratorARN(), + Reference: mg.Spec.ForProvider.CustomListenerParameters.AcceleratorArnRef, + Selector: mg.Spec.ForProvider.CustomListenerParameters.AcceleratorArnSelector, + To: reference.To{ + List: &AcceleratorList{}, + Managed: &Accelerator{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.CustomListenerParameters.AcceleratorArn") + } + mg.Spec.ForProvider.CustomListenerParameters.AcceleratorArn = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.CustomListenerParameters.AcceleratorArnRef = rsp.ResolvedReference + + return nil +} diff --git a/apis/globalaccelerator/v1alpha1/zz_groupversion_info.go b/apis/globalaccelerator/v1alpha1/zz_groupversion_info.go new file mode 100644 index 0000000000..007cbc0cd9 --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_groupversion_info.go @@ -0,0 +1,41 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +// Package type metadata. +const ( + CRDGroup = "globalaccelerator.aws.crossplane.io" + CRDVersion = "v1alpha1" +) + +var ( + // GroupVersion is the API Group Version used to register the objects + GroupVersion = schema.GroupVersion{Group: CRDGroup, Version: CRDVersion} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/apis/globalaccelerator/v1alpha1/zz_listener.go b/apis/globalaccelerator/v1alpha1/zz_listener.go new file mode 100644 index 0000000000..01438c60e5 --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_listener.go @@ -0,0 +1,115 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package v1alpha1 + +import ( + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// ListenerParameters defines the desired state of Listener +type ListenerParameters struct { + // Region is which region the Listener will be created. + // +kubebuilder:validation:Required + Region string `json:"region"` + // Client affinity lets you direct all requests from a user to the same endpoint, + // if you have stateful applications, regardless of the port and protocol of + // the client request. Client affinity gives you control over whether to always + // route each client to the same specific endpoint. + // + // Global Accelerator uses a consistent-flow hashing algorithm to choose the + // optimal endpoint for a connection. If client affinity is NONE, Global Accelerator + // uses the "five-tuple" (5-tuple) properties—source IP address, source port, + // destination IP address, destination port, and protocol—to select the hash + // value, and then chooses the best endpoint. However, with this setting, if + // someone uses different ports to connect to Global Accelerator, their connections + // might not be always routed to the same endpoint because the hash value changes. + // + // If you want a given client to always be routed to the same endpoint, set + // client affinity to SOURCE_IP instead. When you use the SOURCE_IP setting, + // Global Accelerator uses the "two-tuple" (2-tuple) properties— source (client) + // IP address and destination IP address—to select the hash value. + // + // The default value is NONE. + ClientAffinity *string `json:"clientAffinity,omitempty"` + // The list of port ranges to support for connections from clients to your accelerator. + // +kubebuilder:validation:Required + PortRanges []*PortRange `json:"portRanges"` + // The protocol for connections from clients to your accelerator. + // +kubebuilder:validation:Required + Protocol *string `json:"protocol"` + CustomListenerParameters `json:",inline"` +} + +// ListenerSpec defines the desired state of Listener +type ListenerSpec struct { + xpv1.ResourceSpec `json:",inline"` + ForProvider ListenerParameters `json:"forProvider"` +} + +// ListenerObservation defines the observed state of Listener +type ListenerObservation struct { + // The Amazon Resource Name (ARN) of the listener. + ListenerARN *string `json:"listenerARN,omitempty"` +} + +// ListenerStatus defines the observed state of Listener. +type ListenerStatus struct { + xpv1.ResourceStatus `json:",inline"` + AtProvider ListenerObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true + +// Listener is the Schema for the Listeners 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:storageversion +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,aws} +type Listener struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec ListenerSpec `json:"spec"` + Status ListenerStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// ListenerList contains a list of Listeners +type ListenerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Listener `json:"items"` +} + +// Repository type metadata. +var ( + ListenerKind = "Listener" + ListenerGroupKind = schema.GroupKind{Group: CRDGroup, Kind: ListenerKind}.String() + ListenerKindAPIVersion = ListenerKind + "." + GroupVersion.String() + ListenerGroupVersionKind = GroupVersion.WithKind(ListenerKind) +) + +func init() { + SchemeBuilder.Register(&Listener{}, &ListenerList{}) +} diff --git a/apis/globalaccelerator/v1alpha1/zz_types.go b/apis/globalaccelerator/v1alpha1/zz_types.go new file mode 100644 index 0000000000..6939219298 --- /dev/null +++ b/apis/globalaccelerator/v1alpha1/zz_types.go @@ -0,0 +1,276 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// Hack to avoid import errors during build... +var ( + _ = &metav1.Time{} +) + +// +kubebuilder:skipversion +type AcceleratorAttributes struct { + FlowLogsEnabled *bool `json:"flowLogsEnabled,omitempty"` + + FlowLogsS3Bucket *string `json:"flowLogsS3Bucket,omitempty"` + + FlowLogsS3Prefix *string `json:"flowLogsS3Prefix,omitempty"` +} + +// +kubebuilder:skipversion +type AcceleratorEvent struct { + Message *string `json:"message,omitempty"` + + Timestamp *metav1.Time `json:"timestamp,omitempty"` +} + +// +kubebuilder:skipversion +type Accelerator_SDK struct { + AcceleratorARN *string `json:"acceleratorARN,omitempty"` + + CreatedTime *metav1.Time `json:"createdTime,omitempty"` + + DNSName *string `json:"dnsName,omitempty"` + + DualStackDNSName *string `json:"dualStackDNSName,omitempty"` + + Enabled *bool `json:"enabled,omitempty"` + + Events []*AcceleratorEvent `json:"events,omitempty"` + + IPAddressType *string `json:"ipAddressType,omitempty"` + + IPSets []*IPSet `json:"ipSets,omitempty"` + + LastModifiedTime *metav1.Time `json:"lastModifiedTime,omitempty"` + + Name *string `json:"name,omitempty"` + + Status *string `json:"status,omitempty"` +} + +// +kubebuilder:skipversion +type ByoipCIDR struct { + CIDR *string `json:"cidr,omitempty"` +} + +// +kubebuilder:skipversion +type ByoipCIDREvent struct { + Message *string `json:"message,omitempty"` + + Timestamp *metav1.Time `json:"timestamp,omitempty"` +} + +// +kubebuilder:skipversion +type CIDRAuthorizationContext struct { + Message *string `json:"message,omitempty"` + + Signature *string `json:"signature,omitempty"` +} + +// +kubebuilder:skipversion +type CustomRoutingAccelerator struct { + AcceleratorARN *string `json:"acceleratorARN,omitempty"` + + CreatedTime *metav1.Time `json:"createdTime,omitempty"` + + DNSName *string `json:"dnsName,omitempty"` + + Enabled *bool `json:"enabled,omitempty"` + + IPAddressType *string `json:"ipAddressType,omitempty"` + + IPSets []*IPSet `json:"ipSets,omitempty"` + + LastModifiedTime *metav1.Time `json:"lastModifiedTime,omitempty"` + + Name *string `json:"name,omitempty"` +} + +// +kubebuilder:skipversion +type CustomRoutingAcceleratorAttributes struct { + FlowLogsEnabled *bool `json:"flowLogsEnabled,omitempty"` + + FlowLogsS3Bucket *string `json:"flowLogsS3Bucket,omitempty"` + + FlowLogsS3Prefix *string `json:"flowLogsS3Prefix,omitempty"` +} + +// +kubebuilder:skipversion +type CustomRoutingDestinationConfiguration struct { + FromPort *int64 `json:"fromPort,omitempty"` + + ToPort *int64 `json:"toPort,omitempty"` +} + +// +kubebuilder:skipversion +type CustomRoutingDestinationDescription struct { + FromPort *int64 `json:"fromPort,omitempty"` + + ToPort *int64 `json:"toPort,omitempty"` +} + +// +kubebuilder:skipversion +type CustomRoutingEndpointConfiguration struct { + EndpointID *string `json:"endpointID,omitempty"` +} + +// +kubebuilder:skipversion +type CustomRoutingEndpointDescription struct { + EndpointID *string `json:"endpointID,omitempty"` +} + +// +kubebuilder:skipversion +type CustomRoutingEndpointGroup struct { + EndpointGroupARN *string `json:"endpointGroupARN,omitempty"` + + EndpointGroupRegion *string `json:"endpointGroupRegion,omitempty"` +} + +// +kubebuilder:skipversion +type CustomRoutingListener struct { + ListenerARN *string `json:"listenerARN,omitempty"` + + PortRanges []*PortRange `json:"portRanges,omitempty"` +} + +// +kubebuilder:skipversion +type DestinationPortMapping struct { + AcceleratorARN *string `json:"acceleratorARN,omitempty"` + + EndpointGroupARN *string `json:"endpointGroupARN,omitempty"` + + EndpointGroupRegion *string `json:"endpointGroupRegion,omitempty"` + + EndpointID *string `json:"endpointID,omitempty"` + + IPAddressType *string `json:"ipAddressType,omitempty"` +} + +// +kubebuilder:skipversion +type EndpointConfiguration struct { + ClientIPPreservationEnabled *bool `json:"clientIPPreservationEnabled,omitempty"` + + EndpointID *string `json:"endpointID,omitempty"` + + Weight *int64 `json:"weight,omitempty"` +} + +// +kubebuilder:skipversion +type EndpointDescription struct { + ClientIPPreservationEnabled *bool `json:"clientIPPreservationEnabled,omitempty"` + + EndpointID *string `json:"endpointID,omitempty"` + + HealthReason *string `json:"healthReason,omitempty"` + + HealthState *string `json:"healthState,omitempty"` + + Weight *int64 `json:"weight,omitempty"` +} + +// +kubebuilder:skipversion +type EndpointGroup_SDK struct { + EndpointDescriptions []*EndpointDescription `json:"endpointDescriptions,omitempty"` + + EndpointGroupARN *string `json:"endpointGroupARN,omitempty"` + + EndpointGroupRegion *string `json:"endpointGroupRegion,omitempty"` + + HealthCheckIntervalSeconds *int64 `json:"healthCheckIntervalSeconds,omitempty"` + + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + + HealthCheckPort *int64 `json:"healthCheckPort,omitempty"` + + HealthCheckProtocol *string `json:"healthCheckProtocol,omitempty"` + + PortOverrides []*PortOverride `json:"portOverrides,omitempty"` + + ThresholdCount *int64 `json:"thresholdCount,omitempty"` + + TrafficDialPercentage *float64 `json:"trafficDialPercentage,omitempty"` +} + +// +kubebuilder:skipversion +type EndpointIdentifier struct { + ClientIPPreservationEnabled *bool `json:"clientIPPreservationEnabled,omitempty"` + + EndpointID *string `json:"endpointID,omitempty"` +} + +// +kubebuilder:skipversion +type IPSet struct { + IPAddressFamily *string `json:"ipAddressFamily,omitempty"` + + IPAddresses []*string `json:"ipAddresses,omitempty"` + + IPFamily *string `json:"ipFamily,omitempty"` +} + +// +kubebuilder:skipversion +type Listener_SDK struct { + ClientAffinity *string `json:"clientAffinity,omitempty"` + + ListenerARN *string `json:"listenerARN,omitempty"` + + PortRanges []*PortRange `json:"portRanges,omitempty"` + + Protocol *string `json:"protocol,omitempty"` +} + +// +kubebuilder:skipversion +type PortMapping struct { + AcceleratorPort *int64 `json:"acceleratorPort,omitempty"` + + EndpointGroupARN *string `json:"endpointGroupARN,omitempty"` + + EndpointID *string `json:"endpointID,omitempty"` +} + +// +kubebuilder:skipversion +type PortOverride struct { + EndpointPort *int64 `json:"endpointPort,omitempty"` + + ListenerPort *int64 `json:"listenerPort,omitempty"` +} + +// +kubebuilder:skipversion +type PortRange struct { + FromPort *int64 `json:"fromPort,omitempty"` + + ToPort *int64 `json:"toPort,omitempty"` +} + +// +kubebuilder:skipversion +type SocketAddress struct { + IPAddress *string `json:"ipAddress,omitempty"` + + Port *int64 `json:"port,omitempty"` +} + +// +kubebuilder:skipversion +type Tag struct { + Key *string `json:"key,omitempty"` + + Value *string `json:"value,omitempty"` +} diff --git a/examples/globalaccelerator/accelerator.yaml b/examples/globalaccelerator/accelerator.yaml new file mode 100644 index 0000000000..815fd1d64a --- /dev/null +++ b/examples/globalaccelerator/accelerator.yaml @@ -0,0 +1,37 @@ +apiVersion: globalaccelerator.aws.crossplane.io/v1alpha1 +kind: Accelerator +metadata: + name: sample-accelerator +spec: + forProvider: + name: sample-accelerator + region: us-west-2 + enabled: true +--- +apiVersion: globalaccelerator.aws.crossplane.io/v1alpha1 +kind: Listener +metadata: + name: sample-listener +spec: + forProvider: + acceleratorArnRef: + name: sample-accelerator + region: us-west-2 + clientAffinity: SOURCE_IP + portRanges: + - fromPort: 443 + toPort: 443 + protocol: TCP + + +--- +apiVersion: globalaccelerator.aws.crossplane.io/v1alpha1 +kind: EndpointGroup +metadata: + name: sample-epg +spec: + forProvider: + region: us-west-2 + listenerArnRef: + name: sample-listener + endpointGroupRegion: eu-central-1 diff --git a/package/crds/globalaccelerator.aws.crossplane.io_accelerators.yaml b/package/crds/globalaccelerator.aws.crossplane.io_accelerators.yaml new file mode 100644 index 0000000000..d56f4eadf8 --- /dev/null +++ b/package/crds/globalaccelerator.aws.crossplane.io_accelerators.yaml @@ -0,0 +1,442 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.1 + name: accelerators.globalaccelerator.aws.crossplane.io +spec: + group: globalaccelerator.aws.crossplane.io + names: + categories: + - crossplane + - managed + - aws + kind: Accelerator + listKind: AcceleratorList + plural: accelerators + singular: accelerator + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: Accelerator is the Schema for the Accelerators API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: AcceleratorSpec defines the desired state of Accelerator + properties: + deletionPolicy: + default: Delete + description: 'DeletionPolicy specifies what will happen to the underlying + external when this managed resource is deleted - either "Delete" + or "Orphan" the external resource. This field is planned to be deprecated + in favor of the ManagementPolicies field in a future release. Currently, + both could be set independently and non-default values would be + honored if the feature flag is enabled. See the design doc for more + information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223' + enum: + - Orphan + - Delete + type: string + forProvider: + description: AcceleratorParameters defines the desired state of Accelerator + properties: + enabled: + description: "Indicates whether an accelerator is enabled. The + value is true or false. The default value is true. \n If the + value is set to true, an accelerator cannot be deleted. If set + to false, the accelerator can be deleted." + type: boolean + ipAddressType: + description: The IP address type that an accelerator supports. + For a standard accelerator, the value can be IPV4 or DUAL_STACK. + type: string + ipAddresses: + description: "Optionally, if you've added your own IP address + pool to Global Accelerator (BYOIP), you can choose an IPv4 address + from your own pool to use for the accelerator's static IPv4 + address when you create an accelerator. \n After you bring an + address range to Amazon Web Services, it appears in your account + as an address pool. When you create an accelerator, you can + assign one IPv4 address from your range to it. Global Accelerator + assigns you a second static IPv4 address from an Amazon IP address + range. If you bring two IPv4 address ranges to Amazon Web Services, + you can assign one IPv4 address from each range to your accelerator. + This restriction is because Global Accelerator assigns each + address range to a different network zone, for high availability. + \n You can specify one or two addresses, separated by a space. + Do not include the /32 suffix. \n Note that you can't update + IP addresses for an existing accelerator. To change them, you + must create a new accelerator with the new addresses. \n For + more information, see Bring your own IP addresses (BYOIP) (https://docs.aws.amazon.com/global-accelerator/latest/dg/using-byoip.html) + in the Global Accelerator Developer Guide." + items: + type: string + type: array + name: + description: The name of the accelerator. The name can have a + maximum of 64 characters, must contain only alphanumeric characters, + periods (.), or hyphens (-), and must not begin or end with + a hyphen or period. + type: string + region: + description: Region is which region the Accelerator will be created. + type: string + tags: + description: "Create tags for an accelerator. \n For more information, + see Tagging in Global Accelerator (https://docs.aws.amazon.com/global-accelerator/latest/dg/tagging-in-global-accelerator.html) + in the Global Accelerator Developer Guide." + items: + properties: + key: + type: string + value: + type: string + type: object + type: array + required: + - name + - region + type: object + managementPolicies: + default: + - '*' + description: 'THIS IS AN ALPHA FIELD. Do not use it in production. + It is not honored unless the relevant Crossplane feature flag is + enabled, and may be changed or removed without notice. ManagementPolicies + specify the array of actions Crossplane is allowed to take on the + managed and external resources. This field is planned to replace + the DeletionPolicy field in a future release. Currently, both could + be set independently and non-default values would be honored if + the feature flag is enabled. If both are custom, the DeletionPolicy + field will be ignored. See the design doc for more information: + https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md' + items: + description: A ManagementAction represents an action that the Crossplane + controllers can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: ProviderConfigReference specifies how the provider that + will be used to create, observe, update, and delete this managed + resource should be configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + providerRef: + description: 'ProviderReference specifies the provider that will be + used to create, observe, update, and delete this managed resource. + Deprecated: Please use ProviderConfigReference, i.e. `providerConfigRef`' + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: PublishConnectionDetailsTo specifies the connection secret + config which contains a name, metadata and a reference to secret + store config to which any connection details for this managed resource + should be written. Connection details frequently include the endpoint, + username, and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: SecretStoreConfigRef specifies which secret store + config should be used for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the annotations to be added to + connection secret. - For Kubernetes secrets, this will be + used as "metadata.annotations". - It is up to Secret Store + implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: Labels are the labels/tags to be added to connection + secret. - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store + types. + type: object + type: + description: Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: WriteConnectionSecretToReference specifies the namespace + and name of a Secret to which any connection details for this managed + resource should be written. Connection details frequently include + the endpoint, username, and password required to connect to the + managed resource. This field is planned to be replaced in a future + release in favor of PublishConnectionDetailsTo. Currently, both + could be set independently and connection details would be published + to both without affecting each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + status: + description: AcceleratorStatus defines the observed state of Accelerator. + properties: + atProvider: + description: AcceleratorObservation defines the observed state of + Accelerator + properties: + acceleratorARN: + description: The Amazon Resource Name (ARN) of the accelerator. + type: string + createdTime: + description: The date and time that the accelerator was created. + format: date-time + type: string + dnsName: + description: "The Domain Name System (DNS) name that Global Accelerator + creates that points to an accelerator's static IPv4 addresses. + \n The naming convention for the DNS name for an accelerator + is the following: A lowercase letter a, followed by a 16-bit + random hex string, followed by .awsglobalaccelerator.com. For + example: a1234567890abcdef.awsglobalaccelerator.com. \n If you + have a dual-stack accelerator, you also have a second DNS name, + DualStackDnsName, that points to both the A record and the AAAA + record for all four static addresses for the accelerator: two + IPv4 addresses and two IPv6 addresses. \n For more information + about the default DNS name, see Support for DNS addressing in + Global Accelerator (https://docs.aws.amazon.com/global-accelerator/latest/dg/dns-addressing-custom-domains.dns-addressing.html) + in the Global Accelerator Developer Guide." + type: string + dualStackDNSName: + description: "The Domain Name System (DNS) name that Global Accelerator + creates that points to a dual-stack accelerator's four static + IP addresses: two IPv4 addresses and two IPv6 addresses. \n + The naming convention for the dual-stack DNS name is the following: + A lowercase letter a, followed by a 16-bit random hex string, + followed by .dualstack.awsglobalaccelerator.com. For example: + a1234567890abcdef.dualstack.awsglobalaccelerator.com. \n Note: + Global Accelerator also assigns a default DNS name, DnsName, + to your accelerator that points just to the static IPv4 addresses. + \n For more information, see Support for DNS addressing in Global + Accelerator (https://docs.aws.amazon.com/global-accelerator/latest/dg/about-accelerators.html#about-accelerators.dns-addressing) + in the Global Accelerator Developer Guide." + type: string + events: + description: A history of changes that you make to an accelerator + in Global Accelerator. + items: + properties: + message: + type: string + timestamp: + format: date-time + type: string + type: object + type: array + ipSets: + description: The static IP addresses that Global Accelerator associates + with the accelerator. + items: + properties: + ipAddressFamily: + type: string + ipAddresses: + items: + type: string + type: array + ipFamily: + type: string + type: object + type: array + lastModifiedTime: + description: The date and time that the accelerator was last modified. + format: date-time + type: string + status: + description: Describes the deployment status of the accelerator. + type: string + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition + transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's + last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition + type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/package/crds/globalaccelerator.aws.crossplane.io_endpointgroups.yaml b/package/crds/globalaccelerator.aws.crossplane.io_endpointgroups.yaml new file mode 100644 index 0000000000..5307feda9a --- /dev/null +++ b/package/crds/globalaccelerator.aws.crossplane.io_endpointgroups.yaml @@ -0,0 +1,496 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.1 + name: endpointgroups.globalaccelerator.aws.crossplane.io +spec: + group: globalaccelerator.aws.crossplane.io + names: + categories: + - crossplane + - managed + - aws + kind: EndpointGroup + listKind: EndpointGroupList + plural: endpointgroups + singular: endpointgroup + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: EndpointGroup is the Schema for the EndpointGroups API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: EndpointGroupSpec defines the desired state of EndpointGroup + properties: + deletionPolicy: + default: Delete + description: 'DeletionPolicy specifies what will happen to the underlying + external when this managed resource is deleted - either "Delete" + or "Orphan" the external resource. This field is planned to be deprecated + in favor of the ManagementPolicies field in a future release. Currently, + both could be set independently and non-default values would be + honored if the feature flag is enabled. See the design doc for more + information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223' + enum: + - Orphan + - Delete + type: string + forProvider: + description: EndpointGroupParameters defines the desired state of + EndpointGroup + properties: + endpointConfigurations: + description: The list of endpoint objects. + items: + properties: + clientIPPreservationEnabled: + type: boolean + endpointID: + type: string + weight: + format: int64 + type: integer + type: object + type: array + endpointGroupRegion: + description: The Amazon Web Services Region where the endpoint + group is located. A listener can have only one endpoint group + in a specific Region. + type: string + healthCheckIntervalSeconds: + description: The time—10 seconds or 30 seconds—between each health + check for an endpoint. The default value is 30. + format: int64 + type: integer + healthCheckPath: + description: If the protocol is HTTP/S, then this specifies the + path that is the destination for health check targets. The default + value is slash (/). + type: string + healthCheckPort: + description: The port that Global Accelerator uses to check the + health of endpoints that are part of this endpoint group. The + default port is the listener port that this endpoint group is + associated with. If listener port is a list of ports, Global + Accelerator uses the first port in the list. + format: int64 + type: integer + healthCheckProtocol: + description: The protocol that Global Accelerator uses to check + the health of endpoints that are part of this endpoint group. + The default value is TCP. + type: string + listenerArn: + description: ListenerArn is the ARN for the Listener. + type: string + listenerArnRef: + description: ListenerArnRef is a reference to an ARN used to set + the ListenerArn. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + listenerArnSelector: + description: ListenerArnSelector selects references to Listener + used to set the Arn. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + portOverrides: + description: "Override specific listener ports used to route traffic + to endpoints that are part of this endpoint group. For example, + you can create a port override in which the listener receives + user traffic on ports 80 and 443, but your accelerator routes + that traffic to ports 1080 and 1443, respectively, on the endpoints. + \n For more information, see Overriding listener ports (https://docs.aws.amazon.com/global-accelerator/latest/dg/about-endpoint-groups-port-override.html) + in the Global Accelerator Developer Guide." + items: + properties: + endpointPort: + format: int64 + type: integer + listenerPort: + format: int64 + type: integer + type: object + type: array + region: + description: Region is which region the EndpointGroup will be + created. + type: string + thresholdCount: + description: The number of consecutive health checks required + to set the state of a healthy endpoint to unhealthy, or to set + an unhealthy endpoint to healthy. The default value is 3. + format: int64 + type: integer + trafficDialPercentage: + description: "The percentage of traffic to send to an Amazon Web + Services Region. Additional traffic is distributed to other + endpoint groups for this listener. \n Use this action to increase + (dial up) or decrease (dial down) traffic to a specific Region. + The percentage is applied to the traffic that would otherwise + have been routed to the Region based on optimal routing. \n + The default value is 100." + type: number + required: + - endpointGroupRegion + - region + type: object + managementPolicies: + default: + - '*' + description: 'THIS IS AN ALPHA FIELD. Do not use it in production. + It is not honored unless the relevant Crossplane feature flag is + enabled, and may be changed or removed without notice. ManagementPolicies + specify the array of actions Crossplane is allowed to take on the + managed and external resources. This field is planned to replace + the DeletionPolicy field in a future release. Currently, both could + be set independently and non-default values would be honored if + the feature flag is enabled. If both are custom, the DeletionPolicy + field will be ignored. See the design doc for more information: + https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md' + items: + description: A ManagementAction represents an action that the Crossplane + controllers can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: ProviderConfigReference specifies how the provider that + will be used to create, observe, update, and delete this managed + resource should be configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + providerRef: + description: 'ProviderReference specifies the provider that will be + used to create, observe, update, and delete this managed resource. + Deprecated: Please use ProviderConfigReference, i.e. `providerConfigRef`' + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: PublishConnectionDetailsTo specifies the connection secret + config which contains a name, metadata and a reference to secret + store config to which any connection details for this managed resource + should be written. Connection details frequently include the endpoint, + username, and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: SecretStoreConfigRef specifies which secret store + config should be used for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the annotations to be added to + connection secret. - For Kubernetes secrets, this will be + used as "metadata.annotations". - It is up to Secret Store + implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: Labels are the labels/tags to be added to connection + secret. - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store + types. + type: object + type: + description: Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: WriteConnectionSecretToReference specifies the namespace + and name of a Secret to which any connection details for this managed + resource should be written. Connection details frequently include + the endpoint, username, and password required to connect to the + managed resource. This field is planned to be replaced in a future + release in favor of PublishConnectionDetailsTo. Currently, both + could be set independently and connection details would be published + to both without affecting each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + status: + description: EndpointGroupStatus defines the observed state of EndpointGroup. + properties: + atProvider: + description: EndpointGroupObservation defines the observed state of + EndpointGroup + properties: + endpointDescriptions: + description: The list of endpoint objects. + items: + properties: + clientIPPreservationEnabled: + type: boolean + endpointID: + type: string + healthReason: + type: string + healthState: + type: string + weight: + format: int64 + type: integer + type: object + type: array + endpointGroupARN: + description: The Amazon Resource Name (ARN) of the endpoint group. + type: string + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition + transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's + last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition + type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/package/crds/globalaccelerator.aws.crossplane.io_listeners.yaml b/package/crds/globalaccelerator.aws.crossplane.io_listeners.yaml new file mode 100644 index 0000000000..17d11127c3 --- /dev/null +++ b/package/crds/globalaccelerator.aws.crossplane.io_listeners.yaml @@ -0,0 +1,441 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.1 + name: listeners.globalaccelerator.aws.crossplane.io +spec: + group: globalaccelerator.aws.crossplane.io + names: + categories: + - crossplane + - managed + - aws + kind: Listener + listKind: ListenerList + plural: listeners + singular: listener + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: Listener is the Schema for the Listeners API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ListenerSpec defines the desired state of Listener + properties: + deletionPolicy: + default: Delete + description: 'DeletionPolicy specifies what will happen to the underlying + external when this managed resource is deleted - either "Delete" + or "Orphan" the external resource. This field is planned to be deprecated + in favor of the ManagementPolicies field in a future release. Currently, + both could be set independently and non-default values would be + honored if the feature flag is enabled. See the design doc for more + information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223' + enum: + - Orphan + - Delete + type: string + forProvider: + description: ListenerParameters defines the desired state of Listener + properties: + acceleratorArn: + description: AcceleratorArn is the ARN for the Accelerator. + type: string + acceleratorArnRef: + description: AcceleratorArnRef is a reference to an ARN used to + set the AcceleratorArn. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + acceleratorArnSelector: + description: AcceleratorArnSelector selects references to Accelerator + used to set the Arn. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + clientAffinity: + description: "Client affinity lets you direct all requests from + a user to the same endpoint, if you have stateful applications, + regardless of the port and protocol of the client request. Client + affinity gives you control over whether to always route each + client to the same specific endpoint. \n Global Accelerator + uses a consistent-flow hashing algorithm to choose the optimal + endpoint for a connection. If client affinity is NONE, Global + Accelerator uses the \"five-tuple\" (5-tuple) properties—source + IP address, source port, destination IP address, destination + port, and protocol—to select the hash value, and then chooses + the best endpoint. However, with this setting, if someone uses + different ports to connect to Global Accelerator, their connections + might not be always routed to the same endpoint because the + hash value changes. \n If you want a given client to always + be routed to the same endpoint, set client affinity to SOURCE_IP + instead. When you use the SOURCE_IP setting, Global Accelerator + uses the \"two-tuple\" (2-tuple) properties— source (client) + IP address and destination IP address—to select the hash value. + \n The default value is NONE." + type: string + portRanges: + description: The list of port ranges to support for connections + from clients to your accelerator. + items: + properties: + fromPort: + format: int64 + type: integer + toPort: + format: int64 + type: integer + type: object + type: array + protocol: + description: The protocol for connections from clients to your + accelerator. + type: string + region: + description: Region is which region the Listener will be created. + type: string + required: + - portRanges + - protocol + - region + type: object + managementPolicies: + default: + - '*' + description: 'THIS IS AN ALPHA FIELD. Do not use it in production. + It is not honored unless the relevant Crossplane feature flag is + enabled, and may be changed or removed without notice. ManagementPolicies + specify the array of actions Crossplane is allowed to take on the + managed and external resources. This field is planned to replace + the DeletionPolicy field in a future release. Currently, both could + be set independently and non-default values would be honored if + the feature flag is enabled. If both are custom, the DeletionPolicy + field will be ignored. See the design doc for more information: + https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md' + items: + description: A ManagementAction represents an action that the Crossplane + controllers can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: ProviderConfigReference specifies how the provider that + will be used to create, observe, update, and delete this managed + resource should be configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + providerRef: + description: 'ProviderReference specifies the provider that will be + used to create, observe, update, and delete this managed resource. + Deprecated: Please use ProviderConfigReference, i.e. `providerConfigRef`' + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: PublishConnectionDetailsTo specifies the connection secret + config which contains a name, metadata and a reference to secret + store config to which any connection details for this managed resource + should be written. Connection details frequently include the endpoint, + username, and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: SecretStoreConfigRef specifies which secret store + config should be used for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the annotations to be added to + connection secret. - For Kubernetes secrets, this will be + used as "metadata.annotations". - It is up to Secret Store + implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: Labels are the labels/tags to be added to connection + secret. - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store + types. + type: object + type: + description: Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: WriteConnectionSecretToReference specifies the namespace + and name of a Secret to which any connection details for this managed + resource should be written. Connection details frequently include + the endpoint, username, and password required to connect to the + managed resource. This field is planned to be replaced in a future + release in favor of PublishConnectionDetailsTo. Currently, both + could be set independently and connection details would be published + to both without affecting each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + status: + description: ListenerStatus defines the observed state of Listener. + properties: + atProvider: + description: ListenerObservation defines the observed state of Listener + properties: + listenerARN: + description: The Amazon Resource Name (ARN) of the listener. + type: string + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition + transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's + last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition + type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/pkg/controller/aws.go b/pkg/controller/aws.go index 5d2caf7b78..00ccada293 100644 --- a/pkg/controller/aws.go +++ b/pkg/controller/aws.go @@ -46,6 +46,7 @@ import ( "github.com/crossplane-contrib/provider-aws/pkg/controller/elasticloadbalancing" "github.com/crossplane-contrib/provider-aws/pkg/controller/elbv2" "github.com/crossplane-contrib/provider-aws/pkg/controller/emrcontainers" + "github.com/crossplane-contrib/provider-aws/pkg/controller/globalaccelerator" "github.com/crossplane-contrib/provider-aws/pkg/controller/glue" "github.com/crossplane-contrib/provider-aws/pkg/controller/iam" "github.com/crossplane-contrib/provider-aws/pkg/controller/iot" @@ -106,6 +107,7 @@ func Setup(mgr ctrl.Manager, o controller.Options) error { elbv2.Setup, emrcontainers.Setup, glue.Setup, + globalaccelerator.Setup, iam.Setup, iot.Setup, kafka.Setup, diff --git a/pkg/controller/globalaccelerator/accelerator/setup.go b/pkg/controller/globalaccelerator/accelerator/setup.go new file mode 100644 index 0000000000..ac1f6ab04a --- /dev/null +++ b/pkg/controller/globalaccelerator/accelerator/setup.go @@ -0,0 +1,147 @@ +package accelerator + +import ( + "context" + + "github.com/aws/aws-sdk-go/aws" + svcsdk "github.com/aws/aws-sdk-go/service/globalaccelerator" + svcsdkapi "github.com/aws/aws-sdk-go/service/globalaccelerator/globalacceleratoriface" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/controller" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/meta" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + "github.com/crossplane/crossplane-runtime/pkg/resource" + "k8s.io/utils/pointer" + ctrl "sigs.k8s.io/controller-runtime" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1" + "github.com/crossplane-contrib/provider-aws/apis/v1alpha1" + "github.com/crossplane-contrib/provider-aws/pkg/features" + + awsclients "github.com/crossplane-contrib/provider-aws/pkg/clients" +) + +// SetupAccelerator adds a controller that reconciles an Accelerator. +func SetupAccelerator(mgr ctrl.Manager, o controller.Options) error { + name := managed.ControllerName(svcapitypes.AcceleratorGroupKind) + opts := []option{ + func(e *external) { + e.isUpToDate = isUpToDate + c := &gaClient{client: e.client} + e.preDelete = c.preDelete + e.preCreate = preCreate + e.postCreate = postCreate + e.postObserve = postObserve + e.preObserve = preObserve + }, + } + + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.Features.Enabled(features.EnableAlphaExternalSecretStores) { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), v1alpha1.StoreConfigGroupVersionKind)) + } + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(resource.DesiredStateChanged()). + For(&svcapitypes.Accelerator{}). + Complete(managed.NewReconciler(mgr, + resource.ManagedKind(svcapitypes.AcceleratorGroupVersionKind), + managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), opts: opts}), + managed.WithPollInterval(o.PollInterval), + managed.WithInitializers(), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithConnectionPublishers(cps...))) +} + +type gaClient struct { + client svcsdkapi.GlobalAcceleratorAPI +} + +func preObserve(ctx context.Context, cr *svcapitypes.Accelerator, obj *svcsdk.DescribeAcceleratorInput) error { + obj.AcceleratorArn = awsclients.String(meta.GetExternalName(cr)) + return nil +} + +func preCreate(_ context.Context, cr *svcapitypes.Accelerator, obj *svcsdk.CreateAcceleratorInput) error { + obj.Name = cr.Spec.ForProvider.Name + obj.IdempotencyToken = awsclients.String(string(cr.UID)) + return nil +} + +func (d gaClient) preDelete(ctx context.Context, cr *svcapitypes.Accelerator, obj *svcsdk.DeleteAcceleratorInput) (bool, error) { + accArn := meta.GetExternalName(cr) + obj.AcceleratorArn = awsclients.String(accArn) + + // we need to check first if the accelerator is already disabled on remote + // because sending an update request will bring it into pending state and + // sending delete requests against an accelerator in pending state will result + // in a AcceleratorNotDisabledException + descReq := &svcsdk.DescribeAcceleratorInput{ + AcceleratorArn: awsclients.String(accArn), + } + + descResp, err := d.client.DescribeAccelerator(descReq) + if err != nil { + return false, err + } + + if pointer.BoolDeref(descResp.Accelerator.Enabled, true) && pointer.StringDeref(descResp.Accelerator.Status, "") != svcsdk.AcceleratorStatusInProgress { + enabled := false + updReq := &svcsdk.UpdateAcceleratorInput{ + Enabled: &enabled, + AcceleratorArn: awsclients.String(meta.GetExternalName(cr)), + Name: cr.Spec.ForProvider.Name, + IpAddressType: cr.Spec.ForProvider.IPAddressType, + } + + _, err := d.client.UpdateAcceleratorWithContext(ctx, updReq) + if err != nil { + return false, err + } + } + + return false, nil +} + +func postObserve(_ context.Context, cr *svcapitypes.Accelerator, resp *svcsdk.DescribeAcceleratorOutput, obs managed.ExternalObservation, err error) (managed.ExternalObservation, error) { + if err != nil { + return managed.ExternalObservation{}, err + } + + switch aws.StringValue(resp.Accelerator.Status) { + case string(svcapitypes.AcceleratorStatus_SDK_DEPLOYED): + cr.SetConditions(xpv1.Available()) + case string(svcapitypes.AcceleratorStatus_SDK_IN_PROGRESS): + cr.SetConditions(xpv1.Creating()) + default: + cr.SetConditions(xpv1.Unavailable()) + } + + return obs, nil +} + +func postCreate(_ context.Context, cr *svcapitypes.Accelerator, resp *svcsdk.CreateAcceleratorOutput, cre managed.ExternalCreation, err error) (managed.ExternalCreation, error) { + if err != nil { + return managed.ExternalCreation{}, err + } + + meta.SetExternalName(cr, awsclients.StringValue(resp.Accelerator.AcceleratorArn)) + return cre, nil +} + +func isUpToDate(_ context.Context, cr *svcapitypes.Accelerator, resp *svcsdk.DescribeAcceleratorOutput) (bool, string, error) { + if pointer.BoolDeref(cr.Spec.ForProvider.Enabled, false) != pointer.BoolDeref(resp.Accelerator.Enabled, false) { + return false, "", nil + } + + if pointer.StringDeref(cr.Spec.ForProvider.Name, "") != pointer.StringDeref(resp.Accelerator.Name, "") { + return false, "", nil + } + + return true, "", nil +} diff --git a/pkg/controller/globalaccelerator/accelerator/zz_controller.go b/pkg/controller/globalaccelerator/accelerator/zz_controller.go new file mode 100644 index 0000000000..2f2f10104c --- /dev/null +++ b/pkg/controller/globalaccelerator/accelerator/zz_controller.go @@ -0,0 +1,309 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package accelerator + +import ( + "context" + + svcapi "github.com/aws/aws-sdk-go/service/globalaccelerator" + svcsdk "github.com/aws/aws-sdk-go/service/globalaccelerator" + svcsdkapi "github.com/aws/aws-sdk-go/service/globalaccelerator/globalacceleratoriface" + "github.com/google/go-cmp/cmp" + "github.com/pkg/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/meta" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + cpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1" + awsclient "github.com/crossplane-contrib/provider-aws/pkg/clients" +) + +const ( + errUnexpectedObject = "managed resource is not an Accelerator resource" + + errCreateSession = "cannot create a new session" + errCreate = "cannot create Accelerator in AWS" + errUpdate = "cannot update Accelerator in AWS" + errDescribe = "failed to describe Accelerator" + errDelete = "failed to delete Accelerator" +) + +type connector struct { + kube client.Client + opts []option +} + +func (c *connector) Connect(ctx context.Context, mg cpresource.Managed) (managed.ExternalClient, error) { + cr, ok := mg.(*svcapitypes.Accelerator) + if !ok { + return nil, errors.New(errUnexpectedObject) + } + sess, err := awsclient.GetConfigV1(ctx, c.kube, mg, cr.Spec.ForProvider.Region) + if err != nil { + return nil, errors.Wrap(err, errCreateSession) + } + return newExternal(c.kube, svcapi.New(sess), c.opts), nil +} + +func (e *external) Observe(ctx context.Context, mg cpresource.Managed) (managed.ExternalObservation, error) { + cr, ok := mg.(*svcapitypes.Accelerator) + if !ok { + return managed.ExternalObservation{}, errors.New(errUnexpectedObject) + } + if meta.GetExternalName(cr) == "" { + return managed.ExternalObservation{ + ResourceExists: false, + }, nil + } + input := GenerateDescribeAcceleratorInput(cr) + if err := e.preObserve(ctx, cr, input); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "pre-observe failed") + } + resp, err := e.client.DescribeAcceleratorWithContext(ctx, input) + if err != nil { + return managed.ExternalObservation{ResourceExists: false}, awsclient.Wrap(cpresource.Ignore(IsNotFound, err), errDescribe) + } + currentSpec := cr.Spec.ForProvider.DeepCopy() + if err := e.lateInitialize(&cr.Spec.ForProvider, resp); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "late-init failed") + } + GenerateAccelerator(resp).Status.AtProvider.DeepCopyInto(&cr.Status.AtProvider) + + upToDate, diff, err := e.isUpToDate(ctx, cr, resp) + if err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "isUpToDate check failed") + } + return e.postObserve(ctx, cr, resp, managed.ExternalObservation{ + ResourceExists: true, + ResourceUpToDate: upToDate, + Diff: diff, + ResourceLateInitialized: !cmp.Equal(&cr.Spec.ForProvider, currentSpec), + }, nil) +} + +func (e *external) Create(ctx context.Context, mg cpresource.Managed) (managed.ExternalCreation, error) { + cr, ok := mg.(*svcapitypes.Accelerator) + if !ok { + return managed.ExternalCreation{}, errors.New(errUnexpectedObject) + } + cr.Status.SetConditions(xpv1.Creating()) + input := GenerateCreateAcceleratorInput(cr) + if err := e.preCreate(ctx, cr, input); err != nil { + return managed.ExternalCreation{}, errors.Wrap(err, "pre-create failed") + } + resp, err := e.client.CreateAcceleratorWithContext(ctx, input) + if err != nil { + return managed.ExternalCreation{}, awsclient.Wrap(err, errCreate) + } + + if resp.Accelerator.AcceleratorArn != nil { + cr.Status.AtProvider.AcceleratorARN = resp.Accelerator.AcceleratorArn + } else { + cr.Status.AtProvider.AcceleratorARN = nil + } + if resp.Accelerator.CreatedTime != nil { + cr.Status.AtProvider.CreatedTime = &metav1.Time{*resp.Accelerator.CreatedTime} + } else { + cr.Status.AtProvider.CreatedTime = nil + } + if resp.Accelerator.DnsName != nil { + cr.Status.AtProvider.DNSName = resp.Accelerator.DnsName + } else { + cr.Status.AtProvider.DNSName = nil + } + if resp.Accelerator.DualStackDnsName != nil { + cr.Status.AtProvider.DualStackDNSName = resp.Accelerator.DualStackDnsName + } else { + cr.Status.AtProvider.DualStackDNSName = nil + } + if resp.Accelerator.Enabled != nil { + cr.Spec.ForProvider.Enabled = resp.Accelerator.Enabled + } else { + cr.Spec.ForProvider.Enabled = nil + } + if resp.Accelerator.Events != nil { + f5 := []*svcapitypes.AcceleratorEvent{} + for _, f5iter := range resp.Accelerator.Events { + f5elem := &svcapitypes.AcceleratorEvent{} + if f5iter.Message != nil { + f5elem.Message = f5iter.Message + } + if f5iter.Timestamp != nil { + f5elem.Timestamp = &metav1.Time{*f5iter.Timestamp} + } + f5 = append(f5, f5elem) + } + cr.Status.AtProvider.Events = f5 + } else { + cr.Status.AtProvider.Events = nil + } + if resp.Accelerator.IpAddressType != nil { + cr.Spec.ForProvider.IPAddressType = resp.Accelerator.IpAddressType + } else { + cr.Spec.ForProvider.IPAddressType = nil + } + if resp.Accelerator.IpSets != nil { + f7 := []*svcapitypes.IPSet{} + for _, f7iter := range resp.Accelerator.IpSets { + f7elem := &svcapitypes.IPSet{} + if f7iter.IpAddressFamily != nil { + f7elem.IPAddressFamily = f7iter.IpAddressFamily + } + if f7iter.IpAddresses != nil { + f7elemf1 := []*string{} + for _, f7elemf1iter := range f7iter.IpAddresses { + var f7elemf1elem string + f7elemf1elem = *f7elemf1iter + f7elemf1 = append(f7elemf1, &f7elemf1elem) + } + f7elem.IPAddresses = f7elemf1 + } + if f7iter.IpFamily != nil { + f7elem.IPFamily = f7iter.IpFamily + } + f7 = append(f7, f7elem) + } + cr.Status.AtProvider.IPSets = f7 + } else { + cr.Status.AtProvider.IPSets = nil + } + if resp.Accelerator.LastModifiedTime != nil { + cr.Status.AtProvider.LastModifiedTime = &metav1.Time{*resp.Accelerator.LastModifiedTime} + } else { + cr.Status.AtProvider.LastModifiedTime = nil + } + if resp.Accelerator.Name != nil { + cr.Spec.ForProvider.Name = resp.Accelerator.Name + } else { + cr.Spec.ForProvider.Name = nil + } + if resp.Accelerator.Status != nil { + cr.Status.AtProvider.Status = resp.Accelerator.Status + } else { + cr.Status.AtProvider.Status = nil + } + + return e.postCreate(ctx, cr, resp, managed.ExternalCreation{}, err) +} + +func (e *external) Update(ctx context.Context, mg cpresource.Managed) (managed.ExternalUpdate, error) { + cr, ok := mg.(*svcapitypes.Accelerator) + if !ok { + return managed.ExternalUpdate{}, errors.New(errUnexpectedObject) + } + input := GenerateUpdateAcceleratorInput(cr) + if err := e.preUpdate(ctx, cr, input); err != nil { + return managed.ExternalUpdate{}, errors.Wrap(err, "pre-update failed") + } + resp, err := e.client.UpdateAcceleratorWithContext(ctx, input) + return e.postUpdate(ctx, cr, resp, managed.ExternalUpdate{}, awsclient.Wrap(err, errUpdate)) +} + +func (e *external) Delete(ctx context.Context, mg cpresource.Managed) error { + cr, ok := mg.(*svcapitypes.Accelerator) + if !ok { + return errors.New(errUnexpectedObject) + } + cr.Status.SetConditions(xpv1.Deleting()) + input := GenerateDeleteAcceleratorInput(cr) + ignore, err := e.preDelete(ctx, cr, input) + if err != nil { + return errors.Wrap(err, "pre-delete failed") + } + if ignore { + return nil + } + resp, err := e.client.DeleteAcceleratorWithContext(ctx, input) + return e.postDelete(ctx, cr, resp, awsclient.Wrap(cpresource.Ignore(IsNotFound, err), errDelete)) +} + +type option func(*external) + +func newExternal(kube client.Client, client svcsdkapi.GlobalAcceleratorAPI, opts []option) *external { + e := &external{ + kube: kube, + client: client, + preObserve: nopPreObserve, + postObserve: nopPostObserve, + lateInitialize: nopLateInitialize, + isUpToDate: alwaysUpToDate, + preCreate: nopPreCreate, + postCreate: nopPostCreate, + preDelete: nopPreDelete, + postDelete: nopPostDelete, + preUpdate: nopPreUpdate, + postUpdate: nopPostUpdate, + } + for _, f := range opts { + f(e) + } + return e +} + +type external struct { + kube client.Client + client svcsdkapi.GlobalAcceleratorAPI + preObserve func(context.Context, *svcapitypes.Accelerator, *svcsdk.DescribeAcceleratorInput) error + postObserve func(context.Context, *svcapitypes.Accelerator, *svcsdk.DescribeAcceleratorOutput, managed.ExternalObservation, error) (managed.ExternalObservation, error) + lateInitialize func(*svcapitypes.AcceleratorParameters, *svcsdk.DescribeAcceleratorOutput) error + isUpToDate func(context.Context, *svcapitypes.Accelerator, *svcsdk.DescribeAcceleratorOutput) (bool, string, error) + preCreate func(context.Context, *svcapitypes.Accelerator, *svcsdk.CreateAcceleratorInput) error + postCreate func(context.Context, *svcapitypes.Accelerator, *svcsdk.CreateAcceleratorOutput, managed.ExternalCreation, error) (managed.ExternalCreation, error) + preDelete func(context.Context, *svcapitypes.Accelerator, *svcsdk.DeleteAcceleratorInput) (bool, error) + postDelete func(context.Context, *svcapitypes.Accelerator, *svcsdk.DeleteAcceleratorOutput, error) error + preUpdate func(context.Context, *svcapitypes.Accelerator, *svcsdk.UpdateAcceleratorInput) error + postUpdate func(context.Context, *svcapitypes.Accelerator, *svcsdk.UpdateAcceleratorOutput, managed.ExternalUpdate, error) (managed.ExternalUpdate, error) +} + +func nopPreObserve(context.Context, *svcapitypes.Accelerator, *svcsdk.DescribeAcceleratorInput) error { + return nil +} + +func nopPostObserve(_ context.Context, _ *svcapitypes.Accelerator, _ *svcsdk.DescribeAcceleratorOutput, obs managed.ExternalObservation, err error) (managed.ExternalObservation, error) { + return obs, err +} +func nopLateInitialize(*svcapitypes.AcceleratorParameters, *svcsdk.DescribeAcceleratorOutput) error { + return nil +} +func alwaysUpToDate(context.Context, *svcapitypes.Accelerator, *svcsdk.DescribeAcceleratorOutput) (bool, string, error) { + return true, "", nil +} + +func nopPreCreate(context.Context, *svcapitypes.Accelerator, *svcsdk.CreateAcceleratorInput) error { + return nil +} +func nopPostCreate(_ context.Context, _ *svcapitypes.Accelerator, _ *svcsdk.CreateAcceleratorOutput, cre managed.ExternalCreation, err error) (managed.ExternalCreation, error) { + return cre, err +} +func nopPreDelete(context.Context, *svcapitypes.Accelerator, *svcsdk.DeleteAcceleratorInput) (bool, error) { + return false, nil +} +func nopPostDelete(_ context.Context, _ *svcapitypes.Accelerator, _ *svcsdk.DeleteAcceleratorOutput, err error) error { + return err +} +func nopPreUpdate(context.Context, *svcapitypes.Accelerator, *svcsdk.UpdateAcceleratorInput) error { + return nil +} +func nopPostUpdate(_ context.Context, _ *svcapitypes.Accelerator, _ *svcsdk.UpdateAcceleratorOutput, upd managed.ExternalUpdate, err error) (managed.ExternalUpdate, error) { + return upd, err +} diff --git a/pkg/controller/globalaccelerator/accelerator/zz_conversions.go b/pkg/controller/globalaccelerator/accelerator/zz_conversions.go new file mode 100644 index 0000000000..5bfa7513d6 --- /dev/null +++ b/pkg/controller/globalaccelerator/accelerator/zz_conversions.go @@ -0,0 +1,213 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package accelerator + +import ( + "github.com/aws/aws-sdk-go/aws/awserr" + svcsdk "github.com/aws/aws-sdk-go/service/globalaccelerator" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1" +) + +// NOTE(muvaf): We return pointers in case the function needs to start with an +// empty object, hence need to return a new pointer. + +// GenerateDescribeAcceleratorInput returns input for read +// operation. +func GenerateDescribeAcceleratorInput(cr *svcapitypes.Accelerator) *svcsdk.DescribeAcceleratorInput { + res := &svcsdk.DescribeAcceleratorInput{} + + if cr.Status.AtProvider.AcceleratorARN != nil { + res.SetAcceleratorArn(*cr.Status.AtProvider.AcceleratorARN) + } + + return res +} + +// GenerateAccelerator returns the current state in the form of *svcapitypes.Accelerator. +func GenerateAccelerator(resp *svcsdk.DescribeAcceleratorOutput) *svcapitypes.Accelerator { + cr := &svcapitypes.Accelerator{} + + if resp.Accelerator.AcceleratorArn != nil { + cr.Status.AtProvider.AcceleratorARN = resp.Accelerator.AcceleratorArn + } else { + cr.Status.AtProvider.AcceleratorARN = nil + } + if resp.Accelerator.CreatedTime != nil { + cr.Status.AtProvider.CreatedTime = &metav1.Time{*resp.Accelerator.CreatedTime} + } else { + cr.Status.AtProvider.CreatedTime = nil + } + if resp.Accelerator.DnsName != nil { + cr.Status.AtProvider.DNSName = resp.Accelerator.DnsName + } else { + cr.Status.AtProvider.DNSName = nil + } + if resp.Accelerator.DualStackDnsName != nil { + cr.Status.AtProvider.DualStackDNSName = resp.Accelerator.DualStackDnsName + } else { + cr.Status.AtProvider.DualStackDNSName = nil + } + if resp.Accelerator.Enabled != nil { + cr.Spec.ForProvider.Enabled = resp.Accelerator.Enabled + } else { + cr.Spec.ForProvider.Enabled = nil + } + if resp.Accelerator.Events != nil { + f5 := []*svcapitypes.AcceleratorEvent{} + for _, f5iter := range resp.Accelerator.Events { + f5elem := &svcapitypes.AcceleratorEvent{} + if f5iter.Message != nil { + f5elem.Message = f5iter.Message + } + if f5iter.Timestamp != nil { + f5elem.Timestamp = &metav1.Time{*f5iter.Timestamp} + } + f5 = append(f5, f5elem) + } + cr.Status.AtProvider.Events = f5 + } else { + cr.Status.AtProvider.Events = nil + } + if resp.Accelerator.IpAddressType != nil { + cr.Spec.ForProvider.IPAddressType = resp.Accelerator.IpAddressType + } else { + cr.Spec.ForProvider.IPAddressType = nil + } + if resp.Accelerator.IpSets != nil { + f7 := []*svcapitypes.IPSet{} + for _, f7iter := range resp.Accelerator.IpSets { + f7elem := &svcapitypes.IPSet{} + if f7iter.IpAddressFamily != nil { + f7elem.IPAddressFamily = f7iter.IpAddressFamily + } + if f7iter.IpAddresses != nil { + f7elemf1 := []*string{} + for _, f7elemf1iter := range f7iter.IpAddresses { + var f7elemf1elem string + f7elemf1elem = *f7elemf1iter + f7elemf1 = append(f7elemf1, &f7elemf1elem) + } + f7elem.IPAddresses = f7elemf1 + } + if f7iter.IpFamily != nil { + f7elem.IPFamily = f7iter.IpFamily + } + f7 = append(f7, f7elem) + } + cr.Status.AtProvider.IPSets = f7 + } else { + cr.Status.AtProvider.IPSets = nil + } + if resp.Accelerator.LastModifiedTime != nil { + cr.Status.AtProvider.LastModifiedTime = &metav1.Time{*resp.Accelerator.LastModifiedTime} + } else { + cr.Status.AtProvider.LastModifiedTime = nil + } + if resp.Accelerator.Name != nil { + cr.Spec.ForProvider.Name = resp.Accelerator.Name + } else { + cr.Spec.ForProvider.Name = nil + } + if resp.Accelerator.Status != nil { + cr.Status.AtProvider.Status = resp.Accelerator.Status + } else { + cr.Status.AtProvider.Status = nil + } + + return cr +} + +// GenerateCreateAcceleratorInput returns a create input. +func GenerateCreateAcceleratorInput(cr *svcapitypes.Accelerator) *svcsdk.CreateAcceleratorInput { + res := &svcsdk.CreateAcceleratorInput{} + + if cr.Spec.ForProvider.Enabled != nil { + res.SetEnabled(*cr.Spec.ForProvider.Enabled) + } + if cr.Spec.ForProvider.IPAddressType != nil { + res.SetIpAddressType(*cr.Spec.ForProvider.IPAddressType) + } + if cr.Spec.ForProvider.IPAddresses != nil { + f2 := []*string{} + for _, f2iter := range cr.Spec.ForProvider.IPAddresses { + var f2elem string + f2elem = *f2iter + f2 = append(f2, &f2elem) + } + res.SetIpAddresses(f2) + } + if cr.Spec.ForProvider.Name != nil { + res.SetName(*cr.Spec.ForProvider.Name) + } + if cr.Spec.ForProvider.Tags != nil { + f4 := []*svcsdk.Tag{} + for _, f4iter := range cr.Spec.ForProvider.Tags { + f4elem := &svcsdk.Tag{} + if f4iter.Key != nil { + f4elem.SetKey(*f4iter.Key) + } + if f4iter.Value != nil { + f4elem.SetValue(*f4iter.Value) + } + f4 = append(f4, f4elem) + } + res.SetTags(f4) + } + + return res +} + +// GenerateUpdateAcceleratorInput returns an update input. +func GenerateUpdateAcceleratorInput(cr *svcapitypes.Accelerator) *svcsdk.UpdateAcceleratorInput { + res := &svcsdk.UpdateAcceleratorInput{} + + if cr.Status.AtProvider.AcceleratorARN != nil { + res.SetAcceleratorArn(*cr.Status.AtProvider.AcceleratorARN) + } + if cr.Spec.ForProvider.Enabled != nil { + res.SetEnabled(*cr.Spec.ForProvider.Enabled) + } + if cr.Spec.ForProvider.IPAddressType != nil { + res.SetIpAddressType(*cr.Spec.ForProvider.IPAddressType) + } + if cr.Spec.ForProvider.Name != nil { + res.SetName(*cr.Spec.ForProvider.Name) + } + + return res +} + +// GenerateDeleteAcceleratorInput returns a deletion input. +func GenerateDeleteAcceleratorInput(cr *svcapitypes.Accelerator) *svcsdk.DeleteAcceleratorInput { + res := &svcsdk.DeleteAcceleratorInput{} + + if cr.Status.AtProvider.AcceleratorARN != nil { + res.SetAcceleratorArn(*cr.Status.AtProvider.AcceleratorARN) + } + + return res +} + +// IsNotFound returns whether the given error is of type NotFound or not. +func IsNotFound(err error) bool { + awsErr, ok := err.(awserr.Error) + return ok && awsErr.Code() == "AcceleratorNotFoundException" +} diff --git a/pkg/controller/globalaccelerator/endpointgroup/setup.go b/pkg/controller/globalaccelerator/endpointgroup/setup.go new file mode 100644 index 0000000000..d87f71a62b --- /dev/null +++ b/pkg/controller/globalaccelerator/endpointgroup/setup.go @@ -0,0 +1,93 @@ +package endpointgroup + +import ( + "context" + "fmt" + + "github.com/aws/aws-sdk-go/aws" + svcsdk "github.com/aws/aws-sdk-go/service/globalaccelerator" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/controller" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/meta" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + "github.com/crossplane/crossplane-runtime/pkg/resource" + "k8s.io/utils/pointer" + ctrl "sigs.k8s.io/controller-runtime" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1" + "github.com/crossplane-contrib/provider-aws/apis/v1alpha1" + "github.com/crossplane-contrib/provider-aws/pkg/features" +) + +// SetupEndpointGroup adds a controller that reconciles an EndpointGroup. +func SetupEndpointGroup(mgr ctrl.Manager, o controller.Options) error { + fmt.Println("Setup endpointgroup") + name := managed.ControllerName(svcapitypes.EndpointGroupGroupKind) + opts := []option{ + func(e *external) { + e.preObserve = preObserve + e.postObserve = postObserve + e.preUpdate = preUpdate + e.preCreate = preCreate + e.postCreate = postCreate + e.preDelete = preDelete + }, + } + + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.Features.Enabled(features.EnableAlphaExternalSecretStores) { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), v1alpha1.StoreConfigGroupVersionKind)) + } + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(resource.DesiredStateChanged()). + For(&svcapitypes.EndpointGroup{}). + Complete(managed.NewReconciler(mgr, + resource.ManagedKind(svcapitypes.EndpointGroupGroupVersionKind), + managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), opts: opts}), + managed.WithInitializers(), + managed.WithInitializers(managed.NewDefaultProviderConfig(mgr.GetClient())), + managed.WithPollInterval(o.PollInterval), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithConnectionPublishers(cps...))) +} + +func preObserve(ctx context.Context, cr *svcapitypes.EndpointGroup, obj *svcsdk.DescribeEndpointGroupInput) error { + obj.EndpointGroupArn = aws.String(meta.GetExternalName(cr)) + return nil +} + +func preCreate(_ context.Context, cr *svcapitypes.EndpointGroup, obj *svcsdk.CreateEndpointGroupInput) error { + obj.ListenerArn = aws.String(pointer.StringDeref(cr.Spec.ForProvider.CustomEndpointGroupParameters.ListenerARN, "")) + obj.IdempotencyToken = aws.String(string(cr.UID)) + return nil +} + +func preUpdate(_ context.Context, cr *svcapitypes.EndpointGroup, obj *svcsdk.UpdateEndpointGroupInput) error { + obj.EndpointGroupArn = aws.String(meta.GetExternalName(cr)) + return nil +} + +func preDelete(_ context.Context, cr *svcapitypes.EndpointGroup, obj *svcsdk.DeleteEndpointGroupInput) (bool, error) { + obj.EndpointGroupArn = aws.String(meta.GetExternalName(cr)) + return false, nil +} + +func postObserve(_ context.Context, cr *svcapitypes.EndpointGroup, resp *svcsdk.DescribeEndpointGroupOutput, obs managed.ExternalObservation, err error) (managed.ExternalObservation, error) { + if err != nil { + return managed.ExternalObservation{}, err + } + cr.SetConditions(xpv1.Available()) + return obs, nil +} + +func postCreate(_ context.Context, cr *svcapitypes.EndpointGroup, resp *svcsdk.CreateEndpointGroupOutput, cre managed.ExternalCreation, err error) (managed.ExternalCreation, error) { + meta.SetExternalName(cr, aws.StringValue(resp.EndpointGroup.EndpointGroupArn)) + + return cre, err +} diff --git a/pkg/controller/globalaccelerator/endpointgroup/zz_controller.go b/pkg/controller/globalaccelerator/endpointgroup/zz_controller.go new file mode 100644 index 0000000000..cc8d536e72 --- /dev/null +++ b/pkg/controller/globalaccelerator/endpointgroup/zz_controller.go @@ -0,0 +1,303 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package endpointgroup + +import ( + "context" + + svcapi "github.com/aws/aws-sdk-go/service/globalaccelerator" + svcsdk "github.com/aws/aws-sdk-go/service/globalaccelerator" + svcsdkapi "github.com/aws/aws-sdk-go/service/globalaccelerator/globalacceleratoriface" + "github.com/google/go-cmp/cmp" + "github.com/pkg/errors" + "sigs.k8s.io/controller-runtime/pkg/client" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/meta" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + cpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1" + awsclient "github.com/crossplane-contrib/provider-aws/pkg/clients" +) + +const ( + errUnexpectedObject = "managed resource is not an EndpointGroup resource" + + errCreateSession = "cannot create a new session" + errCreate = "cannot create EndpointGroup in AWS" + errUpdate = "cannot update EndpointGroup in AWS" + errDescribe = "failed to describe EndpointGroup" + errDelete = "failed to delete EndpointGroup" +) + +type connector struct { + kube client.Client + opts []option +} + +func (c *connector) Connect(ctx context.Context, mg cpresource.Managed) (managed.ExternalClient, error) { + cr, ok := mg.(*svcapitypes.EndpointGroup) + if !ok { + return nil, errors.New(errUnexpectedObject) + } + sess, err := awsclient.GetConfigV1(ctx, c.kube, mg, cr.Spec.ForProvider.Region) + if err != nil { + return nil, errors.Wrap(err, errCreateSession) + } + return newExternal(c.kube, svcapi.New(sess), c.opts), nil +} + +func (e *external) Observe(ctx context.Context, mg cpresource.Managed) (managed.ExternalObservation, error) { + cr, ok := mg.(*svcapitypes.EndpointGroup) + if !ok { + return managed.ExternalObservation{}, errors.New(errUnexpectedObject) + } + if meta.GetExternalName(cr) == "" { + return managed.ExternalObservation{ + ResourceExists: false, + }, nil + } + input := GenerateDescribeEndpointGroupInput(cr) + if err := e.preObserve(ctx, cr, input); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "pre-observe failed") + } + resp, err := e.client.DescribeEndpointGroupWithContext(ctx, input) + if err != nil { + return managed.ExternalObservation{ResourceExists: false}, awsclient.Wrap(cpresource.Ignore(IsNotFound, err), errDescribe) + } + currentSpec := cr.Spec.ForProvider.DeepCopy() + if err := e.lateInitialize(&cr.Spec.ForProvider, resp); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "late-init failed") + } + GenerateEndpointGroup(resp).Status.AtProvider.DeepCopyInto(&cr.Status.AtProvider) + + upToDate, diff, err := e.isUpToDate(ctx, cr, resp) + if err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "isUpToDate check failed") + } + return e.postObserve(ctx, cr, resp, managed.ExternalObservation{ + ResourceExists: true, + ResourceUpToDate: upToDate, + Diff: diff, + ResourceLateInitialized: !cmp.Equal(&cr.Spec.ForProvider, currentSpec), + }, nil) +} + +func (e *external) Create(ctx context.Context, mg cpresource.Managed) (managed.ExternalCreation, error) { + cr, ok := mg.(*svcapitypes.EndpointGroup) + if !ok { + return managed.ExternalCreation{}, errors.New(errUnexpectedObject) + } + cr.Status.SetConditions(xpv1.Creating()) + input := GenerateCreateEndpointGroupInput(cr) + if err := e.preCreate(ctx, cr, input); err != nil { + return managed.ExternalCreation{}, errors.Wrap(err, "pre-create failed") + } + resp, err := e.client.CreateEndpointGroupWithContext(ctx, input) + if err != nil { + return managed.ExternalCreation{}, awsclient.Wrap(err, errCreate) + } + + if resp.EndpointGroup.EndpointDescriptions != nil { + f0 := []*svcapitypes.EndpointDescription{} + for _, f0iter := range resp.EndpointGroup.EndpointDescriptions { + f0elem := &svcapitypes.EndpointDescription{} + if f0iter.ClientIPPreservationEnabled != nil { + f0elem.ClientIPPreservationEnabled = f0iter.ClientIPPreservationEnabled + } + if f0iter.EndpointId != nil { + f0elem.EndpointID = f0iter.EndpointId + } + if f0iter.HealthReason != nil { + f0elem.HealthReason = f0iter.HealthReason + } + if f0iter.HealthState != nil { + f0elem.HealthState = f0iter.HealthState + } + if f0iter.Weight != nil { + f0elem.Weight = f0iter.Weight + } + f0 = append(f0, f0elem) + } + cr.Status.AtProvider.EndpointDescriptions = f0 + } else { + cr.Status.AtProvider.EndpointDescriptions = nil + } + if resp.EndpointGroup.EndpointGroupArn != nil { + cr.Status.AtProvider.EndpointGroupARN = resp.EndpointGroup.EndpointGroupArn + } else { + cr.Status.AtProvider.EndpointGroupARN = nil + } + if resp.EndpointGroup.EndpointGroupRegion != nil { + cr.Spec.ForProvider.EndpointGroupRegion = resp.EndpointGroup.EndpointGroupRegion + } else { + cr.Spec.ForProvider.EndpointGroupRegion = nil + } + if resp.EndpointGroup.HealthCheckIntervalSeconds != nil { + cr.Spec.ForProvider.HealthCheckIntervalSeconds = resp.EndpointGroup.HealthCheckIntervalSeconds + } else { + cr.Spec.ForProvider.HealthCheckIntervalSeconds = nil + } + if resp.EndpointGroup.HealthCheckPath != nil { + cr.Spec.ForProvider.HealthCheckPath = resp.EndpointGroup.HealthCheckPath + } else { + cr.Spec.ForProvider.HealthCheckPath = nil + } + if resp.EndpointGroup.HealthCheckPort != nil { + cr.Spec.ForProvider.HealthCheckPort = resp.EndpointGroup.HealthCheckPort + } else { + cr.Spec.ForProvider.HealthCheckPort = nil + } + if resp.EndpointGroup.HealthCheckProtocol != nil { + cr.Spec.ForProvider.HealthCheckProtocol = resp.EndpointGroup.HealthCheckProtocol + } else { + cr.Spec.ForProvider.HealthCheckProtocol = nil + } + if resp.EndpointGroup.PortOverrides != nil { + f7 := []*svcapitypes.PortOverride{} + for _, f7iter := range resp.EndpointGroup.PortOverrides { + f7elem := &svcapitypes.PortOverride{} + if f7iter.EndpointPort != nil { + f7elem.EndpointPort = f7iter.EndpointPort + } + if f7iter.ListenerPort != nil { + f7elem.ListenerPort = f7iter.ListenerPort + } + f7 = append(f7, f7elem) + } + cr.Spec.ForProvider.PortOverrides = f7 + } else { + cr.Spec.ForProvider.PortOverrides = nil + } + if resp.EndpointGroup.ThresholdCount != nil { + cr.Spec.ForProvider.ThresholdCount = resp.EndpointGroup.ThresholdCount + } else { + cr.Spec.ForProvider.ThresholdCount = nil + } + if resp.EndpointGroup.TrafficDialPercentage != nil { + cr.Spec.ForProvider.TrafficDialPercentage = resp.EndpointGroup.TrafficDialPercentage + } else { + cr.Spec.ForProvider.TrafficDialPercentage = nil + } + + return e.postCreate(ctx, cr, resp, managed.ExternalCreation{}, err) +} + +func (e *external) Update(ctx context.Context, mg cpresource.Managed) (managed.ExternalUpdate, error) { + cr, ok := mg.(*svcapitypes.EndpointGroup) + if !ok { + return managed.ExternalUpdate{}, errors.New(errUnexpectedObject) + } + input := GenerateUpdateEndpointGroupInput(cr) + if err := e.preUpdate(ctx, cr, input); err != nil { + return managed.ExternalUpdate{}, errors.Wrap(err, "pre-update failed") + } + resp, err := e.client.UpdateEndpointGroupWithContext(ctx, input) + return e.postUpdate(ctx, cr, resp, managed.ExternalUpdate{}, awsclient.Wrap(err, errUpdate)) +} + +func (e *external) Delete(ctx context.Context, mg cpresource.Managed) error { + cr, ok := mg.(*svcapitypes.EndpointGroup) + if !ok { + return errors.New(errUnexpectedObject) + } + cr.Status.SetConditions(xpv1.Deleting()) + input := GenerateDeleteEndpointGroupInput(cr) + ignore, err := e.preDelete(ctx, cr, input) + if err != nil { + return errors.Wrap(err, "pre-delete failed") + } + if ignore { + return nil + } + resp, err := e.client.DeleteEndpointGroupWithContext(ctx, input) + return e.postDelete(ctx, cr, resp, awsclient.Wrap(cpresource.Ignore(IsNotFound, err), errDelete)) +} + +type option func(*external) + +func newExternal(kube client.Client, client svcsdkapi.GlobalAcceleratorAPI, opts []option) *external { + e := &external{ + kube: kube, + client: client, + preObserve: nopPreObserve, + postObserve: nopPostObserve, + lateInitialize: nopLateInitialize, + isUpToDate: alwaysUpToDate, + preCreate: nopPreCreate, + postCreate: nopPostCreate, + preDelete: nopPreDelete, + postDelete: nopPostDelete, + preUpdate: nopPreUpdate, + postUpdate: nopPostUpdate, + } + for _, f := range opts { + f(e) + } + return e +} + +type external struct { + kube client.Client + client svcsdkapi.GlobalAcceleratorAPI + preObserve func(context.Context, *svcapitypes.EndpointGroup, *svcsdk.DescribeEndpointGroupInput) error + postObserve func(context.Context, *svcapitypes.EndpointGroup, *svcsdk.DescribeEndpointGroupOutput, managed.ExternalObservation, error) (managed.ExternalObservation, error) + lateInitialize func(*svcapitypes.EndpointGroupParameters, *svcsdk.DescribeEndpointGroupOutput) error + isUpToDate func(context.Context, *svcapitypes.EndpointGroup, *svcsdk.DescribeEndpointGroupOutput) (bool, string, error) + preCreate func(context.Context, *svcapitypes.EndpointGroup, *svcsdk.CreateEndpointGroupInput) error + postCreate func(context.Context, *svcapitypes.EndpointGroup, *svcsdk.CreateEndpointGroupOutput, managed.ExternalCreation, error) (managed.ExternalCreation, error) + preDelete func(context.Context, *svcapitypes.EndpointGroup, *svcsdk.DeleteEndpointGroupInput) (bool, error) + postDelete func(context.Context, *svcapitypes.EndpointGroup, *svcsdk.DeleteEndpointGroupOutput, error) error + preUpdate func(context.Context, *svcapitypes.EndpointGroup, *svcsdk.UpdateEndpointGroupInput) error + postUpdate func(context.Context, *svcapitypes.EndpointGroup, *svcsdk.UpdateEndpointGroupOutput, managed.ExternalUpdate, error) (managed.ExternalUpdate, error) +} + +func nopPreObserve(context.Context, *svcapitypes.EndpointGroup, *svcsdk.DescribeEndpointGroupInput) error { + return nil +} + +func nopPostObserve(_ context.Context, _ *svcapitypes.EndpointGroup, _ *svcsdk.DescribeEndpointGroupOutput, obs managed.ExternalObservation, err error) (managed.ExternalObservation, error) { + return obs, err +} +func nopLateInitialize(*svcapitypes.EndpointGroupParameters, *svcsdk.DescribeEndpointGroupOutput) error { + return nil +} +func alwaysUpToDate(context.Context, *svcapitypes.EndpointGroup, *svcsdk.DescribeEndpointGroupOutput) (bool, string, error) { + return true, "", nil +} + +func nopPreCreate(context.Context, *svcapitypes.EndpointGroup, *svcsdk.CreateEndpointGroupInput) error { + return nil +} +func nopPostCreate(_ context.Context, _ *svcapitypes.EndpointGroup, _ *svcsdk.CreateEndpointGroupOutput, cre managed.ExternalCreation, err error) (managed.ExternalCreation, error) { + return cre, err +} +func nopPreDelete(context.Context, *svcapitypes.EndpointGroup, *svcsdk.DeleteEndpointGroupInput) (bool, error) { + return false, nil +} +func nopPostDelete(_ context.Context, _ *svcapitypes.EndpointGroup, _ *svcsdk.DeleteEndpointGroupOutput, err error) error { + return err +} +func nopPreUpdate(context.Context, *svcapitypes.EndpointGroup, *svcsdk.UpdateEndpointGroupInput) error { + return nil +} +func nopPostUpdate(_ context.Context, _ *svcapitypes.EndpointGroup, _ *svcsdk.UpdateEndpointGroupOutput, upd managed.ExternalUpdate, err error) (managed.ExternalUpdate, error) { + return upd, err +} diff --git a/pkg/controller/globalaccelerator/endpointgroup/zz_conversions.go b/pkg/controller/globalaccelerator/endpointgroup/zz_conversions.go new file mode 100644 index 0000000000..bdebf0f506 --- /dev/null +++ b/pkg/controller/globalaccelerator/endpointgroup/zz_conversions.go @@ -0,0 +1,267 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package endpointgroup + +import ( + "github.com/aws/aws-sdk-go/aws/awserr" + svcsdk "github.com/aws/aws-sdk-go/service/globalaccelerator" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1" +) + +// NOTE(muvaf): We return pointers in case the function needs to start with an +// empty object, hence need to return a new pointer. + +// GenerateDescribeEndpointGroupInput returns input for read +// operation. +func GenerateDescribeEndpointGroupInput(cr *svcapitypes.EndpointGroup) *svcsdk.DescribeEndpointGroupInput { + res := &svcsdk.DescribeEndpointGroupInput{} + + if cr.Status.AtProvider.EndpointGroupARN != nil { + res.SetEndpointGroupArn(*cr.Status.AtProvider.EndpointGroupARN) + } + + return res +} + +// GenerateEndpointGroup returns the current state in the form of *svcapitypes.EndpointGroup. +func GenerateEndpointGroup(resp *svcsdk.DescribeEndpointGroupOutput) *svcapitypes.EndpointGroup { + cr := &svcapitypes.EndpointGroup{} + + if resp.EndpointGroup.EndpointDescriptions != nil { + f0 := []*svcapitypes.EndpointDescription{} + for _, f0iter := range resp.EndpointGroup.EndpointDescriptions { + f0elem := &svcapitypes.EndpointDescription{} + if f0iter.ClientIPPreservationEnabled != nil { + f0elem.ClientIPPreservationEnabled = f0iter.ClientIPPreservationEnabled + } + if f0iter.EndpointId != nil { + f0elem.EndpointID = f0iter.EndpointId + } + if f0iter.HealthReason != nil { + f0elem.HealthReason = f0iter.HealthReason + } + if f0iter.HealthState != nil { + f0elem.HealthState = f0iter.HealthState + } + if f0iter.Weight != nil { + f0elem.Weight = f0iter.Weight + } + f0 = append(f0, f0elem) + } + cr.Status.AtProvider.EndpointDescriptions = f0 + } else { + cr.Status.AtProvider.EndpointDescriptions = nil + } + if resp.EndpointGroup.EndpointGroupArn != nil { + cr.Status.AtProvider.EndpointGroupARN = resp.EndpointGroup.EndpointGroupArn + } else { + cr.Status.AtProvider.EndpointGroupARN = nil + } + if resp.EndpointGroup.EndpointGroupRegion != nil { + cr.Spec.ForProvider.EndpointGroupRegion = resp.EndpointGroup.EndpointGroupRegion + } else { + cr.Spec.ForProvider.EndpointGroupRegion = nil + } + if resp.EndpointGroup.HealthCheckIntervalSeconds != nil { + cr.Spec.ForProvider.HealthCheckIntervalSeconds = resp.EndpointGroup.HealthCheckIntervalSeconds + } else { + cr.Spec.ForProvider.HealthCheckIntervalSeconds = nil + } + if resp.EndpointGroup.HealthCheckPath != nil { + cr.Spec.ForProvider.HealthCheckPath = resp.EndpointGroup.HealthCheckPath + } else { + cr.Spec.ForProvider.HealthCheckPath = nil + } + if resp.EndpointGroup.HealthCheckPort != nil { + cr.Spec.ForProvider.HealthCheckPort = resp.EndpointGroup.HealthCheckPort + } else { + cr.Spec.ForProvider.HealthCheckPort = nil + } + if resp.EndpointGroup.HealthCheckProtocol != nil { + cr.Spec.ForProvider.HealthCheckProtocol = resp.EndpointGroup.HealthCheckProtocol + } else { + cr.Spec.ForProvider.HealthCheckProtocol = nil + } + if resp.EndpointGroup.PortOverrides != nil { + f7 := []*svcapitypes.PortOverride{} + for _, f7iter := range resp.EndpointGroup.PortOverrides { + f7elem := &svcapitypes.PortOverride{} + if f7iter.EndpointPort != nil { + f7elem.EndpointPort = f7iter.EndpointPort + } + if f7iter.ListenerPort != nil { + f7elem.ListenerPort = f7iter.ListenerPort + } + f7 = append(f7, f7elem) + } + cr.Spec.ForProvider.PortOverrides = f7 + } else { + cr.Spec.ForProvider.PortOverrides = nil + } + if resp.EndpointGroup.ThresholdCount != nil { + cr.Spec.ForProvider.ThresholdCount = resp.EndpointGroup.ThresholdCount + } else { + cr.Spec.ForProvider.ThresholdCount = nil + } + if resp.EndpointGroup.TrafficDialPercentage != nil { + cr.Spec.ForProvider.TrafficDialPercentage = resp.EndpointGroup.TrafficDialPercentage + } else { + cr.Spec.ForProvider.TrafficDialPercentage = nil + } + + return cr +} + +// GenerateCreateEndpointGroupInput returns a create input. +func GenerateCreateEndpointGroupInput(cr *svcapitypes.EndpointGroup) *svcsdk.CreateEndpointGroupInput { + res := &svcsdk.CreateEndpointGroupInput{} + + if cr.Spec.ForProvider.EndpointConfigurations != nil { + f0 := []*svcsdk.EndpointConfiguration{} + for _, f0iter := range cr.Spec.ForProvider.EndpointConfigurations { + f0elem := &svcsdk.EndpointConfiguration{} + if f0iter.ClientIPPreservationEnabled != nil { + f0elem.SetClientIPPreservationEnabled(*f0iter.ClientIPPreservationEnabled) + } + if f0iter.EndpointID != nil { + f0elem.SetEndpointId(*f0iter.EndpointID) + } + if f0iter.Weight != nil { + f0elem.SetWeight(*f0iter.Weight) + } + f0 = append(f0, f0elem) + } + res.SetEndpointConfigurations(f0) + } + if cr.Spec.ForProvider.EndpointGroupRegion != nil { + res.SetEndpointGroupRegion(*cr.Spec.ForProvider.EndpointGroupRegion) + } + if cr.Spec.ForProvider.HealthCheckIntervalSeconds != nil { + res.SetHealthCheckIntervalSeconds(*cr.Spec.ForProvider.HealthCheckIntervalSeconds) + } + if cr.Spec.ForProvider.HealthCheckPath != nil { + res.SetHealthCheckPath(*cr.Spec.ForProvider.HealthCheckPath) + } + if cr.Spec.ForProvider.HealthCheckPort != nil { + res.SetHealthCheckPort(*cr.Spec.ForProvider.HealthCheckPort) + } + if cr.Spec.ForProvider.HealthCheckProtocol != nil { + res.SetHealthCheckProtocol(*cr.Spec.ForProvider.HealthCheckProtocol) + } + if cr.Spec.ForProvider.PortOverrides != nil { + f6 := []*svcsdk.PortOverride{} + for _, f6iter := range cr.Spec.ForProvider.PortOverrides { + f6elem := &svcsdk.PortOverride{} + if f6iter.EndpointPort != nil { + f6elem.SetEndpointPort(*f6iter.EndpointPort) + } + if f6iter.ListenerPort != nil { + f6elem.SetListenerPort(*f6iter.ListenerPort) + } + f6 = append(f6, f6elem) + } + res.SetPortOverrides(f6) + } + if cr.Spec.ForProvider.ThresholdCount != nil { + res.SetThresholdCount(*cr.Spec.ForProvider.ThresholdCount) + } + if cr.Spec.ForProvider.TrafficDialPercentage != nil { + res.SetTrafficDialPercentage(*cr.Spec.ForProvider.TrafficDialPercentage) + } + + return res +} + +// GenerateUpdateEndpointGroupInput returns an update input. +func GenerateUpdateEndpointGroupInput(cr *svcapitypes.EndpointGroup) *svcsdk.UpdateEndpointGroupInput { + res := &svcsdk.UpdateEndpointGroupInput{} + + if cr.Spec.ForProvider.EndpointConfigurations != nil { + f0 := []*svcsdk.EndpointConfiguration{} + for _, f0iter := range cr.Spec.ForProvider.EndpointConfigurations { + f0elem := &svcsdk.EndpointConfiguration{} + if f0iter.ClientIPPreservationEnabled != nil { + f0elem.SetClientIPPreservationEnabled(*f0iter.ClientIPPreservationEnabled) + } + if f0iter.EndpointID != nil { + f0elem.SetEndpointId(*f0iter.EndpointID) + } + if f0iter.Weight != nil { + f0elem.SetWeight(*f0iter.Weight) + } + f0 = append(f0, f0elem) + } + res.SetEndpointConfigurations(f0) + } + if cr.Status.AtProvider.EndpointGroupARN != nil { + res.SetEndpointGroupArn(*cr.Status.AtProvider.EndpointGroupARN) + } + if cr.Spec.ForProvider.HealthCheckIntervalSeconds != nil { + res.SetHealthCheckIntervalSeconds(*cr.Spec.ForProvider.HealthCheckIntervalSeconds) + } + if cr.Spec.ForProvider.HealthCheckPath != nil { + res.SetHealthCheckPath(*cr.Spec.ForProvider.HealthCheckPath) + } + if cr.Spec.ForProvider.HealthCheckPort != nil { + res.SetHealthCheckPort(*cr.Spec.ForProvider.HealthCheckPort) + } + if cr.Spec.ForProvider.HealthCheckProtocol != nil { + res.SetHealthCheckProtocol(*cr.Spec.ForProvider.HealthCheckProtocol) + } + if cr.Spec.ForProvider.PortOverrides != nil { + f6 := []*svcsdk.PortOverride{} + for _, f6iter := range cr.Spec.ForProvider.PortOverrides { + f6elem := &svcsdk.PortOverride{} + if f6iter.EndpointPort != nil { + f6elem.SetEndpointPort(*f6iter.EndpointPort) + } + if f6iter.ListenerPort != nil { + f6elem.SetListenerPort(*f6iter.ListenerPort) + } + f6 = append(f6, f6elem) + } + res.SetPortOverrides(f6) + } + if cr.Spec.ForProvider.ThresholdCount != nil { + res.SetThresholdCount(*cr.Spec.ForProvider.ThresholdCount) + } + if cr.Spec.ForProvider.TrafficDialPercentage != nil { + res.SetTrafficDialPercentage(*cr.Spec.ForProvider.TrafficDialPercentage) + } + + return res +} + +// GenerateDeleteEndpointGroupInput returns a deletion input. +func GenerateDeleteEndpointGroupInput(cr *svcapitypes.EndpointGroup) *svcsdk.DeleteEndpointGroupInput { + res := &svcsdk.DeleteEndpointGroupInput{} + + if cr.Status.AtProvider.EndpointGroupARN != nil { + res.SetEndpointGroupArn(*cr.Status.AtProvider.EndpointGroupARN) + } + + return res +} + +// IsNotFound returns whether the given error is of type NotFound or not. +func IsNotFound(err error) bool { + awsErr, ok := err.(awserr.Error) + return ok && awsErr.Code() == "EndpointGroupNotFoundException" +} diff --git a/pkg/controller/globalaccelerator/listener/setup.go b/pkg/controller/globalaccelerator/listener/setup.go new file mode 100644 index 0000000000..e8a575569f --- /dev/null +++ b/pkg/controller/globalaccelerator/listener/setup.go @@ -0,0 +1,131 @@ +package listener + +import ( + "context" + "sort" + + "github.com/aws/aws-sdk-go/aws" + svcsdk "github.com/aws/aws-sdk-go/service/globalaccelerator" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/controller" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/meta" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + "github.com/crossplane/crossplane-runtime/pkg/resource" + "k8s.io/utils/pointer" + ctrl "sigs.k8s.io/controller-runtime" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1" + "github.com/crossplane-contrib/provider-aws/apis/v1alpha1" + "github.com/crossplane-contrib/provider-aws/pkg/features" +) + +// SetupListener adds a controller that reconciles Listener. +func SetupListener(mgr ctrl.Manager, o controller.Options) error { + name := managed.ControllerName(svcapitypes.ListenerGroupKind) + opts := []option{ + func(e *external) { + e.preObserve = preObserve + e.preCreate = preCreate + e.preUpdate = preUpdate + e.postObserve = postObserve + e.postCreate = postCreate + e.isUpToDate = isUpToDate + }, + } + + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.Features.Enabled(features.EnableAlphaExternalSecretStores) { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), v1alpha1.StoreConfigGroupVersionKind)) + } + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(resource.DesiredStateChanged()). + For(&svcapitypes.Listener{}). + Complete(managed.NewReconciler(mgr, + resource.ManagedKind(svcapitypes.ListenerGroupVersionKind), + managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), opts: opts}), + managed.WithInitializers(), + managed.WithPollInterval(o.PollInterval), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithConnectionPublishers(cps...))) +} + +func preObserve(ctx context.Context, cr *svcapitypes.Listener, obj *svcsdk.DescribeListenerInput) error { + obj.ListenerArn = aws.String(meta.GetExternalName(cr)) + return nil +} + +func preCreate(_ context.Context, cr *svcapitypes.Listener, obj *svcsdk.CreateListenerInput) error { + obj.AcceleratorArn = aws.String(pointer.StringDeref(cr.Spec.ForProvider.CustomListenerParameters.AcceleratorArn, "")) + obj.IdempotencyToken = aws.String(string(cr.UID)) + return nil +} + +func preUpdate(_ context.Context, cr *svcapitypes.Listener, obj *svcsdk.UpdateListenerInput) error { + obj.ListenerArn = aws.String(meta.GetExternalName(cr)) + return nil +} + +func postObserve(_ context.Context, cr *svcapitypes.Listener, resp *svcsdk.DescribeListenerOutput, obs managed.ExternalObservation, err error) (managed.ExternalObservation, error) { + if err != nil { + return managed.ExternalObservation{}, err + } + cr.SetConditions(xpv1.Available()) + return obs, nil +} + +func postCreate(_ context.Context, cr *svcapitypes.Listener, resp *svcsdk.CreateListenerOutput, cre managed.ExternalCreation, err error) (managed.ExternalCreation, error) { + meta.SetExternalName(cr, aws.StringValue(resp.Listener.ListenerArn)) + return cre, err +} + +func isUpToDate(_ context.Context, cr *svcapitypes.Listener, resp *svcsdk.DescribeListenerOutput) (bool, string, error) { + // unequal amount of port-ranges, resource not up to date + if len(cr.Spec.ForProvider.PortRanges) != len(resp.Listener.PortRanges) { + return false, "", nil + } + portRangesCpy := svcapitypes.ListenerParameters{} + + // In order to compare the ports, we first sort both the cr and api response + // We copy the cr parameters to not alter them + cr.Spec.ForProvider.DeepCopyInto(&portRangesCpy) + + sort.Slice(portRangesCpy.PortRanges, func(i, j int) bool { + if *portRangesCpy.PortRanges[i].FromPort != *portRangesCpy.PortRanges[j].FromPort { + return *portRangesCpy.PortRanges[i].FromPort < *portRangesCpy.PortRanges[j].FromPort + } + return *portRangesCpy.PortRanges[i].ToPort < *portRangesCpy.PortRanges[j].ToPort + }) + + sort.Slice(resp.Listener.PortRanges, func(i, j int) bool { + if *resp.Listener.PortRanges[i].FromPort != *resp.Listener.PortRanges[j].FromPort { + return *resp.Listener.PortRanges[i].FromPort < *resp.Listener.PortRanges[j].FromPort + } + return *resp.Listener.PortRanges[i].ToPort < *resp.Listener.PortRanges[j].ToPort + }) + + for i := range portRangesCpy.PortRanges { + if *resp.Listener.PortRanges[i].FromPort != *portRangesCpy.PortRanges[i].FromPort { + return false, "", nil + } + if *resp.Listener.PortRanges[i].ToPort != *portRangesCpy.PortRanges[i].ToPort { + return false, "", nil + } + } + + if pointer.StringDeref(cr.Spec.ForProvider.ClientAffinity, "") != *resp.Listener.ClientAffinity { + return false, "", nil + } + + if pointer.StringDeref(cr.Spec.ForProvider.Protocol, "") != *resp.Listener.Protocol { + return false, "", nil + } + + return true, "", nil +} diff --git a/pkg/controller/globalaccelerator/listener/zz_controller.go b/pkg/controller/globalaccelerator/listener/zz_controller.go new file mode 100644 index 0000000000..00997f6638 --- /dev/null +++ b/pkg/controller/globalaccelerator/listener/zz_controller.go @@ -0,0 +1,253 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package listener + +import ( + "context" + + svcapi "github.com/aws/aws-sdk-go/service/globalaccelerator" + svcsdk "github.com/aws/aws-sdk-go/service/globalaccelerator" + svcsdkapi "github.com/aws/aws-sdk-go/service/globalaccelerator/globalacceleratoriface" + "github.com/google/go-cmp/cmp" + "github.com/pkg/errors" + "sigs.k8s.io/controller-runtime/pkg/client" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/meta" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + cpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1" + awsclient "github.com/crossplane-contrib/provider-aws/pkg/clients" +) + +const ( + errUnexpectedObject = "managed resource is not an Listener resource" + + errCreateSession = "cannot create a new session" + errCreate = "cannot create Listener in AWS" + errUpdate = "cannot update Listener in AWS" + errDescribe = "failed to describe Listener" + errDelete = "failed to delete Listener" +) + +type connector struct { + kube client.Client + opts []option +} + +func (c *connector) Connect(ctx context.Context, mg cpresource.Managed) (managed.ExternalClient, error) { + cr, ok := mg.(*svcapitypes.Listener) + if !ok { + return nil, errors.New(errUnexpectedObject) + } + sess, err := awsclient.GetConfigV1(ctx, c.kube, mg, cr.Spec.ForProvider.Region) + if err != nil { + return nil, errors.Wrap(err, errCreateSession) + } + return newExternal(c.kube, svcapi.New(sess), c.opts), nil +} + +func (e *external) Observe(ctx context.Context, mg cpresource.Managed) (managed.ExternalObservation, error) { + cr, ok := mg.(*svcapitypes.Listener) + if !ok { + return managed.ExternalObservation{}, errors.New(errUnexpectedObject) + } + if meta.GetExternalName(cr) == "" { + return managed.ExternalObservation{ + ResourceExists: false, + }, nil + } + input := GenerateDescribeListenerInput(cr) + if err := e.preObserve(ctx, cr, input); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "pre-observe failed") + } + resp, err := e.client.DescribeListenerWithContext(ctx, input) + if err != nil { + return managed.ExternalObservation{ResourceExists: false}, awsclient.Wrap(cpresource.Ignore(IsNotFound, err), errDescribe) + } + currentSpec := cr.Spec.ForProvider.DeepCopy() + if err := e.lateInitialize(&cr.Spec.ForProvider, resp); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "late-init failed") + } + GenerateListener(resp).Status.AtProvider.DeepCopyInto(&cr.Status.AtProvider) + + upToDate, diff, err := e.isUpToDate(ctx, cr, resp) + if err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "isUpToDate check failed") + } + return e.postObserve(ctx, cr, resp, managed.ExternalObservation{ + ResourceExists: true, + ResourceUpToDate: upToDate, + Diff: diff, + ResourceLateInitialized: !cmp.Equal(&cr.Spec.ForProvider, currentSpec), + }, nil) +} + +func (e *external) Create(ctx context.Context, mg cpresource.Managed) (managed.ExternalCreation, error) { + cr, ok := mg.(*svcapitypes.Listener) + if !ok { + return managed.ExternalCreation{}, errors.New(errUnexpectedObject) + } + cr.Status.SetConditions(xpv1.Creating()) + input := GenerateCreateListenerInput(cr) + if err := e.preCreate(ctx, cr, input); err != nil { + return managed.ExternalCreation{}, errors.Wrap(err, "pre-create failed") + } + resp, err := e.client.CreateListenerWithContext(ctx, input) + if err != nil { + return managed.ExternalCreation{}, awsclient.Wrap(err, errCreate) + } + + if resp.Listener.ClientAffinity != nil { + cr.Spec.ForProvider.ClientAffinity = resp.Listener.ClientAffinity + } else { + cr.Spec.ForProvider.ClientAffinity = nil + } + if resp.Listener.ListenerArn != nil { + cr.Status.AtProvider.ListenerARN = resp.Listener.ListenerArn + } else { + cr.Status.AtProvider.ListenerARN = nil + } + if resp.Listener.PortRanges != nil { + f2 := []*svcapitypes.PortRange{} + for _, f2iter := range resp.Listener.PortRanges { + f2elem := &svcapitypes.PortRange{} + if f2iter.FromPort != nil { + f2elem.FromPort = f2iter.FromPort + } + if f2iter.ToPort != nil { + f2elem.ToPort = f2iter.ToPort + } + f2 = append(f2, f2elem) + } + cr.Spec.ForProvider.PortRanges = f2 + } else { + cr.Spec.ForProvider.PortRanges = nil + } + if resp.Listener.Protocol != nil { + cr.Spec.ForProvider.Protocol = resp.Listener.Protocol + } else { + cr.Spec.ForProvider.Protocol = nil + } + + return e.postCreate(ctx, cr, resp, managed.ExternalCreation{}, err) +} + +func (e *external) Update(ctx context.Context, mg cpresource.Managed) (managed.ExternalUpdate, error) { + cr, ok := mg.(*svcapitypes.Listener) + if !ok { + return managed.ExternalUpdate{}, errors.New(errUnexpectedObject) + } + input := GenerateUpdateListenerInput(cr) + if err := e.preUpdate(ctx, cr, input); err != nil { + return managed.ExternalUpdate{}, errors.Wrap(err, "pre-update failed") + } + resp, err := e.client.UpdateListenerWithContext(ctx, input) + return e.postUpdate(ctx, cr, resp, managed.ExternalUpdate{}, awsclient.Wrap(err, errUpdate)) +} + +func (e *external) Delete(ctx context.Context, mg cpresource.Managed) error { + cr, ok := mg.(*svcapitypes.Listener) + if !ok { + return errors.New(errUnexpectedObject) + } + cr.Status.SetConditions(xpv1.Deleting()) + input := GenerateDeleteListenerInput(cr) + ignore, err := e.preDelete(ctx, cr, input) + if err != nil { + return errors.Wrap(err, "pre-delete failed") + } + if ignore { + return nil + } + resp, err := e.client.DeleteListenerWithContext(ctx, input) + return e.postDelete(ctx, cr, resp, awsclient.Wrap(cpresource.Ignore(IsNotFound, err), errDelete)) +} + +type option func(*external) + +func newExternal(kube client.Client, client svcsdkapi.GlobalAcceleratorAPI, opts []option) *external { + e := &external{ + kube: kube, + client: client, + preObserve: nopPreObserve, + postObserve: nopPostObserve, + lateInitialize: nopLateInitialize, + isUpToDate: alwaysUpToDate, + preCreate: nopPreCreate, + postCreate: nopPostCreate, + preDelete: nopPreDelete, + postDelete: nopPostDelete, + preUpdate: nopPreUpdate, + postUpdate: nopPostUpdate, + } + for _, f := range opts { + f(e) + } + return e +} + +type external struct { + kube client.Client + client svcsdkapi.GlobalAcceleratorAPI + preObserve func(context.Context, *svcapitypes.Listener, *svcsdk.DescribeListenerInput) error + postObserve func(context.Context, *svcapitypes.Listener, *svcsdk.DescribeListenerOutput, managed.ExternalObservation, error) (managed.ExternalObservation, error) + lateInitialize func(*svcapitypes.ListenerParameters, *svcsdk.DescribeListenerOutput) error + isUpToDate func(context.Context, *svcapitypes.Listener, *svcsdk.DescribeListenerOutput) (bool, string, error) + preCreate func(context.Context, *svcapitypes.Listener, *svcsdk.CreateListenerInput) error + postCreate func(context.Context, *svcapitypes.Listener, *svcsdk.CreateListenerOutput, managed.ExternalCreation, error) (managed.ExternalCreation, error) + preDelete func(context.Context, *svcapitypes.Listener, *svcsdk.DeleteListenerInput) (bool, error) + postDelete func(context.Context, *svcapitypes.Listener, *svcsdk.DeleteListenerOutput, error) error + preUpdate func(context.Context, *svcapitypes.Listener, *svcsdk.UpdateListenerInput) error + postUpdate func(context.Context, *svcapitypes.Listener, *svcsdk.UpdateListenerOutput, managed.ExternalUpdate, error) (managed.ExternalUpdate, error) +} + +func nopPreObserve(context.Context, *svcapitypes.Listener, *svcsdk.DescribeListenerInput) error { + return nil +} + +func nopPostObserve(_ context.Context, _ *svcapitypes.Listener, _ *svcsdk.DescribeListenerOutput, obs managed.ExternalObservation, err error) (managed.ExternalObservation, error) { + return obs, err +} +func nopLateInitialize(*svcapitypes.ListenerParameters, *svcsdk.DescribeListenerOutput) error { + return nil +} +func alwaysUpToDate(context.Context, *svcapitypes.Listener, *svcsdk.DescribeListenerOutput) (bool, string, error) { + return true, "", nil +} + +func nopPreCreate(context.Context, *svcapitypes.Listener, *svcsdk.CreateListenerInput) error { + return nil +} +func nopPostCreate(_ context.Context, _ *svcapitypes.Listener, _ *svcsdk.CreateListenerOutput, cre managed.ExternalCreation, err error) (managed.ExternalCreation, error) { + return cre, err +} +func nopPreDelete(context.Context, *svcapitypes.Listener, *svcsdk.DeleteListenerInput) (bool, error) { + return false, nil +} +func nopPostDelete(_ context.Context, _ *svcapitypes.Listener, _ *svcsdk.DeleteListenerOutput, err error) error { + return err +} +func nopPreUpdate(context.Context, *svcapitypes.Listener, *svcsdk.UpdateListenerInput) error { + return nil +} +func nopPostUpdate(_ context.Context, _ *svcapitypes.Listener, _ *svcsdk.UpdateListenerOutput, upd managed.ExternalUpdate, err error) (managed.ExternalUpdate, error) { + return upd, err +} diff --git a/pkg/controller/globalaccelerator/listener/zz_conversions.go b/pkg/controller/globalaccelerator/listener/zz_conversions.go new file mode 100644 index 0000000000..64b72ebabb --- /dev/null +++ b/pkg/controller/globalaccelerator/listener/zz_conversions.go @@ -0,0 +1,156 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package listener + +import ( + "github.com/aws/aws-sdk-go/aws/awserr" + svcsdk "github.com/aws/aws-sdk-go/service/globalaccelerator" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1" +) + +// NOTE(muvaf): We return pointers in case the function needs to start with an +// empty object, hence need to return a new pointer. + +// GenerateDescribeListenerInput returns input for read +// operation. +func GenerateDescribeListenerInput(cr *svcapitypes.Listener) *svcsdk.DescribeListenerInput { + res := &svcsdk.DescribeListenerInput{} + + if cr.Status.AtProvider.ListenerARN != nil { + res.SetListenerArn(*cr.Status.AtProvider.ListenerARN) + } + + return res +} + +// GenerateListener returns the current state in the form of *svcapitypes.Listener. +func GenerateListener(resp *svcsdk.DescribeListenerOutput) *svcapitypes.Listener { + cr := &svcapitypes.Listener{} + + if resp.Listener.ClientAffinity != nil { + cr.Spec.ForProvider.ClientAffinity = resp.Listener.ClientAffinity + } else { + cr.Spec.ForProvider.ClientAffinity = nil + } + if resp.Listener.ListenerArn != nil { + cr.Status.AtProvider.ListenerARN = resp.Listener.ListenerArn + } else { + cr.Status.AtProvider.ListenerARN = nil + } + if resp.Listener.PortRanges != nil { + f2 := []*svcapitypes.PortRange{} + for _, f2iter := range resp.Listener.PortRanges { + f2elem := &svcapitypes.PortRange{} + if f2iter.FromPort != nil { + f2elem.FromPort = f2iter.FromPort + } + if f2iter.ToPort != nil { + f2elem.ToPort = f2iter.ToPort + } + f2 = append(f2, f2elem) + } + cr.Spec.ForProvider.PortRanges = f2 + } else { + cr.Spec.ForProvider.PortRanges = nil + } + if resp.Listener.Protocol != nil { + cr.Spec.ForProvider.Protocol = resp.Listener.Protocol + } else { + cr.Spec.ForProvider.Protocol = nil + } + + return cr +} + +// GenerateCreateListenerInput returns a create input. +func GenerateCreateListenerInput(cr *svcapitypes.Listener) *svcsdk.CreateListenerInput { + res := &svcsdk.CreateListenerInput{} + + if cr.Spec.ForProvider.ClientAffinity != nil { + res.SetClientAffinity(*cr.Spec.ForProvider.ClientAffinity) + } + if cr.Spec.ForProvider.PortRanges != nil { + f1 := []*svcsdk.PortRange{} + for _, f1iter := range cr.Spec.ForProvider.PortRanges { + f1elem := &svcsdk.PortRange{} + if f1iter.FromPort != nil { + f1elem.SetFromPort(*f1iter.FromPort) + } + if f1iter.ToPort != nil { + f1elem.SetToPort(*f1iter.ToPort) + } + f1 = append(f1, f1elem) + } + res.SetPortRanges(f1) + } + if cr.Spec.ForProvider.Protocol != nil { + res.SetProtocol(*cr.Spec.ForProvider.Protocol) + } + + return res +} + +// GenerateUpdateListenerInput returns an update input. +func GenerateUpdateListenerInput(cr *svcapitypes.Listener) *svcsdk.UpdateListenerInput { + res := &svcsdk.UpdateListenerInput{} + + if cr.Spec.ForProvider.ClientAffinity != nil { + res.SetClientAffinity(*cr.Spec.ForProvider.ClientAffinity) + } + if cr.Status.AtProvider.ListenerARN != nil { + res.SetListenerArn(*cr.Status.AtProvider.ListenerARN) + } + if cr.Spec.ForProvider.PortRanges != nil { + f2 := []*svcsdk.PortRange{} + for _, f2iter := range cr.Spec.ForProvider.PortRanges { + f2elem := &svcsdk.PortRange{} + if f2iter.FromPort != nil { + f2elem.SetFromPort(*f2iter.FromPort) + } + if f2iter.ToPort != nil { + f2elem.SetToPort(*f2iter.ToPort) + } + f2 = append(f2, f2elem) + } + res.SetPortRanges(f2) + } + if cr.Spec.ForProvider.Protocol != nil { + res.SetProtocol(*cr.Spec.ForProvider.Protocol) + } + + return res +} + +// GenerateDeleteListenerInput returns a deletion input. +func GenerateDeleteListenerInput(cr *svcapitypes.Listener) *svcsdk.DeleteListenerInput { + res := &svcsdk.DeleteListenerInput{} + + if cr.Status.AtProvider.ListenerARN != nil { + res.SetListenerArn(*cr.Status.AtProvider.ListenerARN) + } + + return res +} + +// IsNotFound returns whether the given error is of type NotFound or not. +func IsNotFound(err error) bool { + awsErr, ok := err.(awserr.Error) + return ok && awsErr.Code() == "ListenerNotFoundException" +} diff --git a/pkg/controller/globalaccelerator/setup.go b/pkg/controller/globalaccelerator/setup.go new file mode 100644 index 0000000000..3337d229a7 --- /dev/null +++ b/pkg/controller/globalaccelerator/setup.go @@ -0,0 +1,35 @@ +/* +Copyright 2023 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 globalaccelerator + +import ( + ctrl "sigs.k8s.io/controller-runtime" + + "github.com/crossplane/crossplane-runtime/pkg/controller" + + "github.com/crossplane-contrib/provider-aws/pkg/controller/globalaccelerator/accelerator" + "github.com/crossplane-contrib/provider-aws/pkg/controller/globalaccelerator/endpointgroup" + "github.com/crossplane-contrib/provider-aws/pkg/controller/globalaccelerator/listener" + "github.com/crossplane-contrib/provider-aws/pkg/utils/setup" +) + +// Setup athena controllers. +func Setup(mgr ctrl.Manager, o controller.Options) error { + return setup.SetupControllers( + mgr, o, + accelerator.SetupAccelerator, + listener.SetupListener, + endpointgroup.SetupEndpointGroup, + ) +}