From fda18b66e9958d918969639d79af2aba819a0037 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Thu, 9 Jan 2025 14:25:09 +1300 Subject: [PATCH 01/17] capacity_reservations_feature: Initial PR to add capacity reservations support --- apis/v1alpha1/ack-generate-metadata.yaml | 10 +- apis/v1alpha1/capacity_reservation.go | 203 ++++++ apis/v1alpha1/generator.yaml | 12 +- apis/v1alpha1/types.go | 47 +- apis/v1alpha1/zz_generated.deepcopy.go | 429 +++++++++--- cmd/controller/main.go | 1 + ...services.k8s.aws_capacityreservations.yaml | 309 +++++++++ config/crd/kustomization.yaml | 1 + config/rbac/cluster-role-controller.yaml | 2 + config/rbac/role-reader.yaml | 1 + config/rbac/role-writer.yaml | 2 + generator.yaml | 12 +- pkg/resource/capacity_reservation/delta.go | 156 +++++ .../capacity_reservation/descriptor.go | 155 +++++ pkg/resource/capacity_reservation/hooks.go | 27 + .../capacity_reservation/identifiers.go | 55 ++ pkg/resource/capacity_reservation/manager.go | 360 ++++++++++ .../capacity_reservation/manager_factory.go | 100 +++ .../capacity_reservation/references.go | 56 ++ pkg/resource/capacity_reservation/resource.go | 111 +++ pkg/resource/capacity_reservation/sdk.go | 645 ++++++++++++++++++ pkg/resource/capacity_reservation/tags.go | 63 ++ .../sdk_create_post_build_request.go.tpl | 1 + 23 files changed, 2654 insertions(+), 104 deletions(-) create mode 100644 apis/v1alpha1/capacity_reservation.go create mode 100644 config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml create mode 100644 pkg/resource/capacity_reservation/delta.go create mode 100644 pkg/resource/capacity_reservation/descriptor.go create mode 100644 pkg/resource/capacity_reservation/hooks.go create mode 100644 pkg/resource/capacity_reservation/identifiers.go create mode 100644 pkg/resource/capacity_reservation/manager.go create mode 100644 pkg/resource/capacity_reservation/manager_factory.go create mode 100644 pkg/resource/capacity_reservation/references.go create mode 100644 pkg/resource/capacity_reservation/resource.go create mode 100644 pkg/resource/capacity_reservation/sdk.go create mode 100644 pkg/resource/capacity_reservation/tags.go create mode 100644 templates/hooks/capacity_reservation/sdk_create_post_build_request.go.tpl diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 54a14169..7e264133 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,13 +1,13 @@ ack_generate_info: - build_date: "2024-12-09T17:32:07Z" + build_date: "2025-01-09T01:04:52Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 - go_version: go1.23.3 - version: v0.40.0 -api_directory_checksum: 585098fc7c99c27ca523f83e860107d22aaa5a10 + go_version: go1.23.4 + version: 631aeb1-dirty +api_directory_checksum: 941d1827a80332faefb389464dc0f14274772ef8 api_version: v1alpha1 aws_sdk_go_version: v1.44.93 generator_config_info: - file_checksum: 4a977c2334f44fd0ea8d09dd6afe759cd7459eb1 + file_checksum: 77d1b8c928fa077f4b824329cf3190e8d8728fdf original_file_name: generator.yaml last_modification: reason: API generation diff --git a/apis/v1alpha1/capacity_reservation.go b/apis/v1alpha1/capacity_reservation.go new file mode 100644 index 00000000..3737c2a7 --- /dev/null +++ b/apis/v1alpha1/capacity_reservation.go @@ -0,0 +1,203 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file 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 ( + ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// CapacityReservationSpec defines the desired state of CapacityReservation. +// +// Describes a Capacity Reservation. +type CapacityReservationSpec struct { + + // The Availability Zone in which to create the Capacity Reservation. + AvailabilityZone *string `json:"availabilityZone,omitempty"` + // The ID of the Availability Zone in which to create the Capacity Reservation. + AvailabilityZoneID *string `json:"availabilityZoneID,omitempty"` + // Unique, case-sensitive identifier that you provide to ensure the idempotency + // of the request. For more information, see Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). + ClientToken *string `json:"clientToken,omitempty"` + // Checks whether you have the required permissions for the action, without + // actually making the request, and provides an error response. If you have + // the required permissions, the error response is DryRunOperation. Otherwise, + // it is UnauthorizedOperation. + DryRun *bool `json:"dryRun,omitempty"` + // Indicates whether the Capacity Reservation supports EBS-optimized instances. + // This optimization provides dedicated throughput to Amazon EBS and an optimized + // configuration stack to provide optimal I/O performance. This optimization + // isn't available with all instance types. Additional usage charges apply when + // using an EBS- optimized instance. + EBSOptimized *bool `json:"ebsOptimized,omitempty"` + // The date and time at which the Capacity Reservation expires. When a Capacity + // Reservation expires, the reserved capacity is released and you can no longer + // launch instances into it. The Capacity Reservation's state changes to expired + // when it reaches its end date and time. + // + // You must provide an EndDate value if EndDateType is limited. Omit EndDate + // if EndDateType is unlimited. + // + // If the EndDateType is limited, the Capacity Reservation is cancelled within + // an hour from the specified time. For example, if you specify 5/31/2019, 13:30:55, + // the Capacity Reservation is guaranteed to end between 13:30:55 and 14:30:55 + // on 5/31/2019. + EndDate *metav1.Time `json:"endDate,omitempty"` + // Indicates the way in which the Capacity Reservation ends. A Capacity Reservation + // can have one of the following end types: + // + // - unlimited - The Capacity Reservation remains active until you explicitly + // cancel it. Do not provide an EndDate if the EndDateType is unlimited. + // + // - limited - The Capacity Reservation expires automatically at a specified + // date and time. You must provide an EndDate value if the EndDateType value + // is limited. + EndDateType *string `json:"endDateType,omitempty"` + // Deprecated. + EphemeralStorage *bool `json:"ephemeralStorage,omitempty"` + // The number of instances for which to reserve capacity. + // + // Valid range: 1 - 1000 + // +kubebuilder:validation:Required + InstanceCount *int64 `json:"instanceCount"` + // Indicates the type of instance launches that the Capacity Reservation accepts. + // The options include: + // + // - open - The Capacity Reservation automatically matches all instances + // that have matching attributes (instance type, platform, and Availability + // Zone). Instances that have matching attributes run in the Capacity Reservation + // automatically without specifying any additional parameters. + // + // - targeted - The Capacity Reservation only accepts instances that have + // matching attributes (instance type, platform, and Availability Zone), + // and explicitly target the Capacity Reservation. This ensures that only + // permitted instances can use the reserved capacity. + // + // Default: open + InstanceMatchCriteria *string `json:"instanceMatchCriteria,omitempty"` + // The type of operating system for which to reserve capacity. + // +kubebuilder:validation:Required + InstancePlatform *string `json:"instancePlatform"` + // The instance type for which to reserve capacity. For more information, see + // Instance types (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html) + // in the Amazon EC2 User Guide. + // +kubebuilder:validation:Required + InstanceType *string `json:"instanceType"` + // The Amazon Resource Name (ARN) of the Outpost on which to create the Capacity + // Reservation. + OutpostARN *string `json:"outpostARN,omitempty"` + // The Amazon Resource Name (ARN) of the cluster placement group in which to + // create the Capacity Reservation. For more information, see Capacity Reservations + // for cluster placement groups (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/cr-cpg.html) + // in the Amazon EC2 User Guide. + PlacementGroupARN *string `json:"placementGroupARN,omitempty"` + // The tags. The value parameter is required, but if you don't want the tag + // to have a value, specify the parameter with no value, and we set the value + // to an empty string. + Tags []*Tag `json:"tags,omitempty"` + // Indicates the tenancy of the Capacity Reservation. A Capacity Reservation + // can have one of the following tenancy settings: + // + // - default - The Capacity Reservation is created on hardware that is shared + // with other Amazon Web Services accounts. + // + // - dedicated - The Capacity Reservation is created on single-tenant hardware + // that is dedicated to a single Amazon Web Services account. + Tenancy *string `json:"tenancy,omitempty"` +} + +// CapacityReservationStatus defines the observed state of CapacityReservation +type CapacityReservationStatus struct { + // All CRs managed by ACK have a common `Status.ACKResourceMetadata` member + // that is used to contain resource sync state, account ownership, + // constructed ARN for the resource + // +kubebuilder:validation:Optional + ACKResourceMetadata *ackv1alpha1.ResourceMetadata `json:"ackResourceMetadata"` + // All CRS managed by ACK have a common `Status.Conditions` member that + // contains a collection of `ackv1alpha1.Condition` objects that describe + // the various terminal states of the CR and its backend AWS service API + // resource + // +kubebuilder:validation:Optional + Conditions []*ackv1alpha1.Condition `json:"conditions"` + // The remaining capacity. Indicates the number of instances that can be launched + // in the Capacity Reservation. + // +kubebuilder:validation:Optional + AvailableInstanceCount *int64 `json:"availableInstanceCount,omitempty"` + // The ID of the Capacity Reservation Fleet to which the Capacity Reservation + // belongs. Only valid for Capacity Reservations that were created by a Capacity + // Reservation Fleet. + // +kubebuilder:validation:Optional + CapacityReservationFleetID *string `json:"capacityReservationFleetID,omitempty"` + // The ID of the Capacity Reservation. + // +kubebuilder:validation:Optional + CapacityReservationID *string `json:"capacityReservationID,omitempty"` + // The date and time at which the Capacity Reservation was created. + // +kubebuilder:validation:Optional + CreateDate *metav1.Time `json:"createDate,omitempty"` + // The ID of the Amazon Web Services account that owns the Capacity Reservation. + // +kubebuilder:validation:Optional + OwnerID *string `json:"ownerID,omitempty"` + // The date and time at which the Capacity Reservation was started. + // +kubebuilder:validation:Optional + StartDate *metav1.Time `json:"startDate,omitempty"` + // The current state of the Capacity Reservation. A Capacity Reservation can + // be in one of the following states: + // + // * active - The Capacity Reservation is active and the capacity is available + // for your use. + // + // * expired - The Capacity Reservation expired automatically at the date + // and time specified in your request. The reserved capacity is no longer + // available for your use. + // + // * cancelled - The Capacity Reservation was cancelled. The reserved capacity + // is no longer available for your use. + // + // * pending - The Capacity Reservation request was successful but the capacity + // provisioning is still pending. + // + // * failed - The Capacity Reservation request has failed. A request might + // fail due to invalid request parameters, capacity constraints, or instance + // limit constraints. Failed requests are retained for 60 minutes. + // +kubebuilder:validation:Optional + State *string `json:"state,omitempty"` + // The total number of instances for which the Capacity Reservation reserves + // capacity. + // +kubebuilder:validation:Optional + TotalInstanceCount *int64 `json:"totalInstanceCount,omitempty"` +} + +// CapacityReservation is the Schema for the CapacityReservations API +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +type CapacityReservation struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec CapacityReservationSpec `json:"spec,omitempty"` + Status CapacityReservationStatus `json:"status,omitempty"` +} + +// CapacityReservationList contains a list of CapacityReservation +// +kubebuilder:object:root=true +type CapacityReservationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []CapacityReservation `json:"items"` +} + +func init() { + SchemeBuilder.Register(&CapacityReservation{}, &CapacityReservationList{}) +} diff --git a/apis/v1alpha1/generator.yaml b/apis/v1alpha1/generator.yaml index cf46d169..8922e4be 100644 --- a/apis/v1alpha1/generator.yaml +++ b/apis/v1alpha1/generator.yaml @@ -5,6 +5,7 @@ ignore: field_paths: - AllocateAddressInput.DryRun - AllocateAddressInput.TagSpecifications + - CreateCapacityReservationInput.TagSpecifications - CreateDhcpOptionsInput.DryRun - CreateDhcpOptionsInput.TagSpecifications - CreateFlowLogsInput.DryRun @@ -60,7 +61,7 @@ ignore: - TerminateInstancesInput.DryRun resource_names: - AccountAttribute - - CapacityReservation + # - CapacityReservation - CapacityReservationFleet - CarrierGateway - ClientVpnEndpoint @@ -216,6 +217,15 @@ operations: - Update resource_name: VpcPeeringConnection resources: + CapacityReservation: + fields: + Tags: + from: + operation: CreateTags + path: Tags + hooks: + sdk_create_post_build_request: + template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl DhcpOptions: exceptions: terminal_codes: diff --git a/apis/v1alpha1/types.go b/apis/v1alpha1/types.go index 41aefb85..caed6904 100644 --- a/apis/v1alpha1/types.go +++ b/apis/v1alpha1/types.go @@ -359,25 +359,6 @@ type CancelledSpotInstanceRequest struct { SpotInstanceRequestID *string `json:"spotInstanceRequestID,omitempty"` } -// Describes a Capacity Reservation. -type CapacityReservation struct { - AvailabilityZone *string `json:"availabilityZone,omitempty"` - AvailabilityZoneID *string `json:"availabilityZoneID,omitempty"` - AvailableInstanceCount *int64 `json:"availableInstanceCount,omitempty"` - CapacityReservationARN *string `json:"capacityReservationARN,omitempty"` - CapacityReservationFleetID *string `json:"capacityReservationFleetID,omitempty"` - CapacityReservationID *string `json:"capacityReservationID,omitempty"` - CreateDate *metav1.Time `json:"createDate,omitempty"` - EBSOptimized *bool `json:"ebsOptimized,omitempty"` - EndDate *metav1.Time `json:"endDate,omitempty"` - EphemeralStorage *bool `json:"ephemeralStorage,omitempty"` - InstanceType *string `json:"instanceType,omitempty"` - OwnerID *string `json:"ownerID,omitempty"` - StartDate *metav1.Time `json:"startDate,omitempty"` - Tags []*Tag `json:"tags,omitempty"` - TotalInstanceCount *int64 `json:"totalInstanceCount,omitempty"` -} - // Information about a Capacity Reservation Fleet. type CapacityReservationFleet struct { AllocationStrategy *string `json:"allocationStrategy,omitempty"` @@ -434,6 +415,32 @@ type CapacityReservationTargetResponse struct { CapacityReservationResourceGroupARN *string `json:"capacityReservationResourceGroupARN,omitempty"` } +// Describes a Capacity Reservation. +type CapacityReservation_SDK struct { + AvailabilityZone *string `json:"availabilityZone,omitempty"` + AvailabilityZoneID *string `json:"availabilityZoneID,omitempty"` + AvailableInstanceCount *int64 `json:"availableInstanceCount,omitempty"` + CapacityReservationARN *string `json:"capacityReservationARN,omitempty"` + CapacityReservationFleetID *string `json:"capacityReservationFleetID,omitempty"` + CapacityReservationID *string `json:"capacityReservationID,omitempty"` + CreateDate *metav1.Time `json:"createDate,omitempty"` + EBSOptimized *bool `json:"ebsOptimized,omitempty"` + EndDate *metav1.Time `json:"endDate,omitempty"` + EndDateType *string `json:"endDateType,omitempty"` + EphemeralStorage *bool `json:"ephemeralStorage,omitempty"` + InstanceMatchCriteria *string `json:"instanceMatchCriteria,omitempty"` + InstancePlatform *string `json:"instancePlatform,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + OutpostARN *string `json:"outpostARN,omitempty"` + OwnerID *string `json:"ownerID,omitempty"` + PlacementGroupARN *string `json:"placementGroupARN,omitempty"` + StartDate *metav1.Time `json:"startDate,omitempty"` + State *string `json:"state,omitempty"` + Tags []*Tag `json:"tags,omitempty"` + Tenancy *string `json:"tenancy,omitempty"` + TotalInstanceCount *int64 `json:"totalInstanceCount,omitempty"` +} + // Describes a carrier gateway. type CarrierGateway struct { CarrierGatewayID *string `json:"carrierGatewayID,omitempty"` @@ -1179,6 +1186,7 @@ type FleetCapacityReservation struct { CapacityReservationID *string `json:"capacityReservationID,omitempty"` CreateDate *metav1.Time `json:"createDate,omitempty"` EBSOptimized *bool `json:"ebsOptimized,omitempty"` + InstancePlatform *string `json:"instancePlatform,omitempty"` InstanceType *string `json:"instanceType,omitempty"` TotalInstanceCount *int64 `json:"totalInstanceCount,omitempty"` } @@ -3271,6 +3279,7 @@ type ReservationFleetInstanceSpecification struct { AvailabilityZone *string `json:"availabilityZone,omitempty"` AvailabilityZoneID *string `json:"availabilityZoneID,omitempty"` EBSOptimized *bool `json:"ebsOptimized,omitempty"` + InstancePlatform *string `json:"instancePlatform,omitempty"` InstanceType *string `json:"instanceType,omitempty"` } diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index fe5c152e..f9f1bfc3 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -1319,84 +1319,10 @@ func (in *CancelledSpotInstanceRequest) DeepCopy() *CancelledSpotInstanceRequest // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CapacityReservation) DeepCopyInto(out *CapacityReservation) { *out = *in - if in.AvailabilityZone != nil { - in, out := &in.AvailabilityZone, &out.AvailabilityZone - *out = new(string) - **out = **in - } - if in.AvailabilityZoneID != nil { - in, out := &in.AvailabilityZoneID, &out.AvailabilityZoneID - *out = new(string) - **out = **in - } - if in.AvailableInstanceCount != nil { - in, out := &in.AvailableInstanceCount, &out.AvailableInstanceCount - *out = new(int64) - **out = **in - } - if in.CapacityReservationARN != nil { - in, out := &in.CapacityReservationARN, &out.CapacityReservationARN - *out = new(string) - **out = **in - } - if in.CapacityReservationFleetID != nil { - in, out := &in.CapacityReservationFleetID, &out.CapacityReservationFleetID - *out = new(string) - **out = **in - } - if in.CapacityReservationID != nil { - in, out := &in.CapacityReservationID, &out.CapacityReservationID - *out = new(string) - **out = **in - } - if in.CreateDate != nil { - in, out := &in.CreateDate, &out.CreateDate - *out = (*in).DeepCopy() - } - if in.EBSOptimized != nil { - in, out := &in.EBSOptimized, &out.EBSOptimized - *out = new(bool) - **out = **in - } - if in.EndDate != nil { - in, out := &in.EndDate, &out.EndDate - *out = (*in).DeepCopy() - } - if in.EphemeralStorage != nil { - in, out := &in.EphemeralStorage, &out.EphemeralStorage - *out = new(bool) - **out = **in - } - if in.InstanceType != nil { - in, out := &in.InstanceType, &out.InstanceType - *out = new(string) - **out = **in - } - if in.OwnerID != nil { - in, out := &in.OwnerID, &out.OwnerID - *out = new(string) - **out = **in - } - if in.StartDate != nil { - in, out := &in.StartDate, &out.StartDate - *out = (*in).DeepCopy() - } - 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) - } - } - } - if in.TotalInstanceCount != nil { - in, out := &in.TotalInstanceCount, &out.TotalInstanceCount - *out = new(int64) - **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 CapacityReservation. @@ -1409,6 +1335,14 @@ func (in *CapacityReservation) DeepCopy() *CapacityReservation { return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CapacityReservation) 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 *CapacityReservationFleet) DeepCopyInto(out *CapacityReservationFleet) { *out = *in @@ -1483,6 +1417,138 @@ func (in *CapacityReservationGroup) DeepCopy() *CapacityReservationGroup { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CapacityReservationList) DeepCopyInto(out *CapacityReservationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CapacityReservation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapacityReservationList. +func (in *CapacityReservationList) DeepCopy() *CapacityReservationList { + if in == nil { + return nil + } + out := new(CapacityReservationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CapacityReservationList) 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 *CapacityReservationSpec) DeepCopyInto(out *CapacityReservationSpec) { + *out = *in + if in.AvailabilityZone != nil { + in, out := &in.AvailabilityZone, &out.AvailabilityZone + *out = new(string) + **out = **in + } + if in.AvailabilityZoneID != nil { + in, out := &in.AvailabilityZoneID, &out.AvailabilityZoneID + *out = new(string) + **out = **in + } + if in.ClientToken != nil { + in, out := &in.ClientToken, &out.ClientToken + *out = new(string) + **out = **in + } + if in.DryRun != nil { + in, out := &in.DryRun, &out.DryRun + *out = new(bool) + **out = **in + } + if in.EBSOptimized != nil { + in, out := &in.EBSOptimized, &out.EBSOptimized + *out = new(bool) + **out = **in + } + if in.EndDate != nil { + in, out := &in.EndDate, &out.EndDate + *out = (*in).DeepCopy() + } + if in.EndDateType != nil { + in, out := &in.EndDateType, &out.EndDateType + *out = new(string) + **out = **in + } + if in.EphemeralStorage != nil { + in, out := &in.EphemeralStorage, &out.EphemeralStorage + *out = new(bool) + **out = **in + } + if in.InstanceCount != nil { + in, out := &in.InstanceCount, &out.InstanceCount + *out = new(int64) + **out = **in + } + if in.InstanceMatchCriteria != nil { + in, out := &in.InstanceMatchCriteria, &out.InstanceMatchCriteria + *out = new(string) + **out = **in + } + if in.InstancePlatform != nil { + in, out := &in.InstancePlatform, &out.InstancePlatform + *out = new(string) + **out = **in + } + if in.InstanceType != nil { + in, out := &in.InstanceType, &out.InstanceType + *out = new(string) + **out = **in + } + if in.OutpostARN != nil { + in, out := &in.OutpostARN, &out.OutpostARN + *out = new(string) + **out = **in + } + if in.PlacementGroupARN != nil { + in, out := &in.PlacementGroupARN, &out.PlacementGroupARN + *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) + } + } + } + if in.Tenancy != nil { + in, out := &in.Tenancy, &out.Tenancy + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapacityReservationSpec. +func (in *CapacityReservationSpec) DeepCopy() *CapacityReservationSpec { + if in == nil { + return nil + } + out := new(CapacityReservationSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CapacityReservationSpecification) DeepCopyInto(out *CapacityReservationSpecification) { *out = *in @@ -1533,6 +1599,75 @@ func (in *CapacityReservationSpecificationResponse) DeepCopy() *CapacityReservat return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CapacityReservationStatus) DeepCopyInto(out *CapacityReservationStatus) { + *out = *in + if in.ACKResourceMetadata != nil { + in, out := &in.ACKResourceMetadata, &out.ACKResourceMetadata + *out = new(corev1alpha1.ResourceMetadata) + (*in).DeepCopyInto(*out) + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]*corev1alpha1.Condition, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(corev1alpha1.Condition) + (*in).DeepCopyInto(*out) + } + } + } + if in.AvailableInstanceCount != nil { + in, out := &in.AvailableInstanceCount, &out.AvailableInstanceCount + *out = new(int64) + **out = **in + } + if in.CapacityReservationFleetID != nil { + in, out := &in.CapacityReservationFleetID, &out.CapacityReservationFleetID + *out = new(string) + **out = **in + } + if in.CapacityReservationID != nil { + in, out := &in.CapacityReservationID, &out.CapacityReservationID + *out = new(string) + **out = **in + } + if in.CreateDate != nil { + in, out := &in.CreateDate, &out.CreateDate + *out = (*in).DeepCopy() + } + if in.OwnerID != nil { + in, out := &in.OwnerID, &out.OwnerID + *out = new(string) + **out = **in + } + if in.StartDate != nil { + in, out := &in.StartDate, &out.StartDate + *out = (*in).DeepCopy() + } + if in.State != nil { + in, out := &in.State, &out.State + *out = new(string) + **out = **in + } + if in.TotalInstanceCount != nil { + in, out := &in.TotalInstanceCount, &out.TotalInstanceCount + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapacityReservationStatus. +func (in *CapacityReservationStatus) DeepCopy() *CapacityReservationStatus { + if in == nil { + return nil + } + out := new(CapacityReservationStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CapacityReservationTarget) DeepCopyInto(out *CapacityReservationTarget) { *out = *in @@ -1583,6 +1718,134 @@ func (in *CapacityReservationTargetResponse) DeepCopy() *CapacityReservationTarg return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CapacityReservation_SDK) DeepCopyInto(out *CapacityReservation_SDK) { + *out = *in + if in.AvailabilityZone != nil { + in, out := &in.AvailabilityZone, &out.AvailabilityZone + *out = new(string) + **out = **in + } + if in.AvailabilityZoneID != nil { + in, out := &in.AvailabilityZoneID, &out.AvailabilityZoneID + *out = new(string) + **out = **in + } + if in.AvailableInstanceCount != nil { + in, out := &in.AvailableInstanceCount, &out.AvailableInstanceCount + *out = new(int64) + **out = **in + } + if in.CapacityReservationARN != nil { + in, out := &in.CapacityReservationARN, &out.CapacityReservationARN + *out = new(string) + **out = **in + } + if in.CapacityReservationFleetID != nil { + in, out := &in.CapacityReservationFleetID, &out.CapacityReservationFleetID + *out = new(string) + **out = **in + } + if in.CapacityReservationID != nil { + in, out := &in.CapacityReservationID, &out.CapacityReservationID + *out = new(string) + **out = **in + } + if in.CreateDate != nil { + in, out := &in.CreateDate, &out.CreateDate + *out = (*in).DeepCopy() + } + if in.EBSOptimized != nil { + in, out := &in.EBSOptimized, &out.EBSOptimized + *out = new(bool) + **out = **in + } + if in.EndDate != nil { + in, out := &in.EndDate, &out.EndDate + *out = (*in).DeepCopy() + } + if in.EndDateType != nil { + in, out := &in.EndDateType, &out.EndDateType + *out = new(string) + **out = **in + } + if in.EphemeralStorage != nil { + in, out := &in.EphemeralStorage, &out.EphemeralStorage + *out = new(bool) + **out = **in + } + if in.InstanceMatchCriteria != nil { + in, out := &in.InstanceMatchCriteria, &out.InstanceMatchCriteria + *out = new(string) + **out = **in + } + if in.InstancePlatform != nil { + in, out := &in.InstancePlatform, &out.InstancePlatform + *out = new(string) + **out = **in + } + if in.InstanceType != nil { + in, out := &in.InstanceType, &out.InstanceType + *out = new(string) + **out = **in + } + if in.OutpostARN != nil { + in, out := &in.OutpostARN, &out.OutpostARN + *out = new(string) + **out = **in + } + if in.OwnerID != nil { + in, out := &in.OwnerID, &out.OwnerID + *out = new(string) + **out = **in + } + if in.PlacementGroupARN != nil { + in, out := &in.PlacementGroupARN, &out.PlacementGroupARN + *out = new(string) + **out = **in + } + if in.StartDate != nil { + in, out := &in.StartDate, &out.StartDate + *out = (*in).DeepCopy() + } + if in.State != nil { + in, out := &in.State, &out.State + *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) + } + } + } + if in.Tenancy != nil { + in, out := &in.Tenancy, &out.Tenancy + *out = new(string) + **out = **in + } + if in.TotalInstanceCount != nil { + in, out := &in.TotalInstanceCount, &out.TotalInstanceCount + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapacityReservation_SDK. +func (in *CapacityReservation_SDK) DeepCopy() *CapacityReservation_SDK { + if in == nil { + return nil + } + out := new(CapacityReservation_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 *CarrierGateway) DeepCopyInto(out *CarrierGateway) { *out = *in @@ -5070,6 +5333,11 @@ func (in *FleetCapacityReservation) DeepCopyInto(out *FleetCapacityReservation) *out = new(bool) **out = **in } + if in.InstancePlatform != nil { + in, out := &in.InstancePlatform, &out.InstancePlatform + *out = new(string) + **out = **in + } if in.InstanceType != nil { in, out := &in.InstanceType, &out.InstanceType *out = new(string) @@ -15132,6 +15400,11 @@ func (in *ReservationFleetInstanceSpecification) DeepCopyInto(out *ReservationFl *out = new(bool) **out = **in } + if in.InstancePlatform != nil { + in, out := &in.InstancePlatform, &out.InstancePlatform + *out = new(string) + **out = **in + } if in.InstanceType != nil { in, out := &in.InstanceType, &out.InstanceType *out = new(string) diff --git a/cmd/controller/main.go b/cmd/controller/main.go index b3e26d28..a1a53e3f 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -39,6 +39,7 @@ import ( svcresource "github.com/aws-controllers-k8s/ec2-controller/pkg/resource" svcsdk "github.com/aws/aws-sdk-go/service/ec2" + _ "github.com/aws-controllers-k8s/ec2-controller/pkg/resource/capacity_reservation" _ "github.com/aws-controllers-k8s/ec2-controller/pkg/resource/dhcp_options" _ "github.com/aws-controllers-k8s/ec2-controller/pkg/resource/elastic_ip_address" _ "github.com/aws-controllers-k8s/ec2-controller/pkg/resource/flow_log" diff --git a/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml b/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml new file mode 100644 index 00000000..dd930db6 --- /dev/null +++ b/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml @@ -0,0 +1,309 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.2 + name: capacityreservations.ec2.services.k8s.aws +spec: + group: ec2.services.k8s.aws + names: + kind: CapacityReservation + listKind: CapacityReservationList + plural: capacityreservations + singular: capacityreservation + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: CapacityReservation is the Schema for the CapacityReservations + 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: |- + CapacityReservationSpec defines the desired state of CapacityReservation. + + Describes a Capacity Reservation. + properties: + availabilityZone: + description: The Availability Zone in which to create the Capacity + Reservation. + type: string + availabilityZoneID: + description: The ID of the Availability Zone in which to create the + Capacity Reservation. + type: string + clientToken: + description: |- + Unique, case-sensitive identifier that you provide to ensure the idempotency + of the request. For more information, see Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). + type: string + dryRun: + description: |- + Checks whether you have the required permissions for the action, without + actually making the request, and provides an error response. If you have + the required permissions, the error response is DryRunOperation. Otherwise, + it is UnauthorizedOperation. + type: boolean + ebsOptimized: + description: |- + Indicates whether the Capacity Reservation supports EBS-optimized instances. + This optimization provides dedicated throughput to Amazon EBS and an optimized + configuration stack to provide optimal I/O performance. This optimization + isn't available with all instance types. Additional usage charges apply when + using an EBS- optimized instance. + type: boolean + endDate: + description: |- + The date and time at which the Capacity Reservation expires. When a Capacity + Reservation expires, the reserved capacity is released and you can no longer + launch instances into it. The Capacity Reservation's state changes to expired + when it reaches its end date and time. + + You must provide an EndDate value if EndDateType is limited. Omit EndDate + if EndDateType is unlimited. + + If the EndDateType is limited, the Capacity Reservation is cancelled within + an hour from the specified time. For example, if you specify 5/31/2019, 13:30:55, + the Capacity Reservation is guaranteed to end between 13:30:55 and 14:30:55 + on 5/31/2019. + format: date-time + type: string + endDateType: + description: |- + Indicates the way in which the Capacity Reservation ends. A Capacity Reservation + can have one of the following end types: + + * unlimited - The Capacity Reservation remains active until you explicitly + cancel it. Do not provide an EndDate if the EndDateType is unlimited. + + * limited - The Capacity Reservation expires automatically at a specified + date and time. You must provide an EndDate value if the EndDateType value + is limited. + type: string + ephemeralStorage: + description: Deprecated. + type: boolean + instanceCount: + description: |- + The number of instances for which to reserve capacity. + + Valid range: 1 - 1000 + format: int64 + type: integer + instanceMatchCriteria: + description: |- + Indicates the type of instance launches that the Capacity Reservation accepts. + The options include: + + * open - The Capacity Reservation automatically matches all instances + that have matching attributes (instance type, platform, and Availability + Zone). Instances that have matching attributes run in the Capacity Reservation + automatically without specifying any additional parameters. + + * targeted - The Capacity Reservation only accepts instances that have + matching attributes (instance type, platform, and Availability Zone), + and explicitly target the Capacity Reservation. This ensures that only + permitted instances can use the reserved capacity. + + Default: open + type: string + instancePlatform: + description: The type of operating system for which to reserve capacity. + type: string + instanceType: + description: |- + The instance type for which to reserve capacity. For more information, see + Instance types (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html) + in the Amazon EC2 User Guide. + type: string + outpostARN: + description: |- + The Amazon Resource Name (ARN) of the Outpost on which to create the Capacity + Reservation. + type: string + placementGroupARN: + description: |- + The Amazon Resource Name (ARN) of the cluster placement group in which to + create the Capacity Reservation. For more information, see Capacity Reservations + for cluster placement groups (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/cr-cpg.html) + in the Amazon EC2 User Guide. + type: string + tags: + description: |- + The tags. The value parameter is required, but if you don't want the tag + to have a value, specify the parameter with no value, and we set the value + to an empty string. + items: + description: Describes a tag. + properties: + key: + type: string + value: + type: string + type: object + type: array + tenancy: + description: |- + Indicates the tenancy of the Capacity Reservation. A Capacity Reservation + can have one of the following tenancy settings: + + * default - The Capacity Reservation is created on hardware that is shared + with other Amazon Web Services accounts. + + * dedicated - The Capacity Reservation is created on single-tenant hardware + that is dedicated to a single Amazon Web Services account. + type: string + required: + - instanceCount + - instancePlatform + - instanceType + type: object + status: + description: CapacityReservationStatus defines the observed state of CapacityReservation + properties: + ackResourceMetadata: + description: |- + All CRs managed by ACK have a common `Status.ACKResourceMetadata` member + that is used to contain resource sync state, account ownership, + constructed ARN for the resource + properties: + arn: + description: |- + ARN is the Amazon Resource Name for the resource. This is a + globally-unique identifier and is set only by the ACK service controller + once the controller has orchestrated the creation of the resource OR + when it has verified that an "adopted" resource (a resource where the + ARN annotation was set by the Kubernetes user on the CR) exists and + matches the supplied CR's Spec field values. + https://github.com/aws/aws-controllers-k8s/issues/270 + type: string + ownerAccountID: + description: |- + OwnerAccountID is the AWS Account ID of the account that owns the + backend AWS service API resource. + type: string + region: + description: Region is the AWS region in which the resource exists + or will exist. + type: string + required: + - ownerAccountID + - region + type: object + availableInstanceCount: + description: |- + The remaining capacity. Indicates the number of instances that can be launched + in the Capacity Reservation. + format: int64 + type: integer + capacityReservationFleetID: + description: |- + The ID of the Capacity Reservation Fleet to which the Capacity Reservation + belongs. Only valid for Capacity Reservations that were created by a Capacity + Reservation Fleet. + type: string + capacityReservationID: + description: The ID of the Capacity Reservation. + type: string + conditions: + description: |- + All CRS managed by ACK have a common `Status.Conditions` member that + contains a collection of `ackv1alpha1.Condition` objects that describe + the various terminal states of the CR and its backend AWS service API + resource + items: + description: |- + Condition is the common struct used by all CRDs managed by ACK service + controllers to indicate terminal states of the CR and its backend AWS + service API resource + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. + format: date-time + type: string + message: + description: A human readable message indicating details about + the transition. + type: string + reason: + description: The reason for the condition's last transition. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type is the type of the Condition + type: string + required: + - status + - type + type: object + type: array + createDate: + description: The date and time at which the Capacity Reservation was + created. + format: date-time + type: string + ownerID: + description: The ID of the Amazon Web Services account that owns the + Capacity Reservation. + type: string + startDate: + description: The date and time at which the Capacity Reservation was + started. + format: date-time + type: string + state: + description: |- + The current state of the Capacity Reservation. A Capacity Reservation can + be in one of the following states: + + * active - The Capacity Reservation is active and the capacity is available + for your use. + + * expired - The Capacity Reservation expired automatically at the date + and time specified in your request. The reserved capacity is no longer + available for your use. + + * cancelled - The Capacity Reservation was cancelled. The reserved capacity + is no longer available for your use. + + * pending - The Capacity Reservation request was successful but the capacity + provisioning is still pending. + + * failed - The Capacity Reservation request has failed. A request might + fail due to invalid request parameters, capacity constraints, or instance + limit constraints. Failed requests are retained for 60 minutes. + type: string + totalInstanceCount: + description: |- + The total number of instances for which the Capacity Reservation reserves + capacity. + format: int64 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index eb1a5d49..d671a172 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - common + - bases/ec2.services.k8s.aws_capacityreservations.yaml - bases/ec2.services.k8s.aws_dhcpoptions.yaml - bases/ec2.services.k8s.aws_elasticipaddresses.yaml - bases/ec2.services.k8s.aws_flowlogs.yaml diff --git a/config/rbac/cluster-role-controller.yaml b/config/rbac/cluster-role-controller.yaml index 10c5dcfa..fe7ee008 100644 --- a/config/rbac/cluster-role-controller.yaml +++ b/config/rbac/cluster-role-controller.yaml @@ -25,6 +25,7 @@ rules: - apiGroups: - ec2.services.k8s.aws resources: + - capacityreservations - dhcpoptions - elasticipaddresses - flowlogs @@ -51,6 +52,7 @@ rules: - apiGroups: - ec2.services.k8s.aws resources: + - capacityreservations/status - dhcpoptions/status - elasticipaddresses/status - flowlogs/status diff --git a/config/rbac/role-reader.yaml b/config/rbac/role-reader.yaml index b129de3d..c98f612b 100644 --- a/config/rbac/role-reader.yaml +++ b/config/rbac/role-reader.yaml @@ -9,6 +9,7 @@ rules: - apiGroups: - ec2.services.k8s.aws resources: + - capacityreservations - dhcpoptions - elasticipaddresses - flowlogs diff --git a/config/rbac/role-writer.yaml b/config/rbac/role-writer.yaml index 03001e6a..edc3394c 100644 --- a/config/rbac/role-writer.yaml +++ b/config/rbac/role-writer.yaml @@ -9,6 +9,7 @@ rules: - apiGroups: - ec2.services.k8s.aws resources: + - capacityreservations - dhcpoptions - elasticipaddresses - flowlogs @@ -35,6 +36,7 @@ rules: - apiGroups: - ec2.services.k8s.aws resources: + - capacityreservations - dhcpoptions - elasticipaddresses - flowlogs diff --git a/generator.yaml b/generator.yaml index cf46d169..8922e4be 100644 --- a/generator.yaml +++ b/generator.yaml @@ -5,6 +5,7 @@ ignore: field_paths: - AllocateAddressInput.DryRun - AllocateAddressInput.TagSpecifications + - CreateCapacityReservationInput.TagSpecifications - CreateDhcpOptionsInput.DryRun - CreateDhcpOptionsInput.TagSpecifications - CreateFlowLogsInput.DryRun @@ -60,7 +61,7 @@ ignore: - TerminateInstancesInput.DryRun resource_names: - AccountAttribute - - CapacityReservation + # - CapacityReservation - CapacityReservationFleet - CarrierGateway - ClientVpnEndpoint @@ -216,6 +217,15 @@ operations: - Update resource_name: VpcPeeringConnection resources: + CapacityReservation: + fields: + Tags: + from: + operation: CreateTags + path: Tags + hooks: + sdk_create_post_build_request: + template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl DhcpOptions: exceptions: terminal_codes: diff --git a/pkg/resource/capacity_reservation/delta.go b/pkg/resource/capacity_reservation/delta.go new file mode 100644 index 00000000..8bce5628 --- /dev/null +++ b/pkg/resource/capacity_reservation/delta.go @@ -0,0 +1,156 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file 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 capacity_reservation + +import ( + "bytes" + "reflect" + + ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare" + acktags "github.com/aws-controllers-k8s/runtime/pkg/tags" +) + +// Hack to avoid import errors during build... +var ( + _ = &bytes.Buffer{} + _ = &reflect.Method{} + _ = &acktags.Tags{} +) + +// newResourceDelta returns a new `ackcompare.Delta` used to compare two +// resources +func newResourceDelta( + a *resource, + b *resource, +) *ackcompare.Delta { + delta := ackcompare.NewDelta() + if (a == nil && b != nil) || + (a != nil && b == nil) { + delta.Add("", a, b) + return delta + } + + if ackcompare.HasNilDifference(a.ko.Spec.AvailabilityZone, b.ko.Spec.AvailabilityZone) { + delta.Add("Spec.AvailabilityZone", a.ko.Spec.AvailabilityZone, b.ko.Spec.AvailabilityZone) + } else if a.ko.Spec.AvailabilityZone != nil && b.ko.Spec.AvailabilityZone != nil { + if *a.ko.Spec.AvailabilityZone != *b.ko.Spec.AvailabilityZone { + delta.Add("Spec.AvailabilityZone", a.ko.Spec.AvailabilityZone, b.ko.Spec.AvailabilityZone) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.AvailabilityZoneID, b.ko.Spec.AvailabilityZoneID) { + delta.Add("Spec.AvailabilityZoneID", a.ko.Spec.AvailabilityZoneID, b.ko.Spec.AvailabilityZoneID) + } else if a.ko.Spec.AvailabilityZoneID != nil && b.ko.Spec.AvailabilityZoneID != nil { + if *a.ko.Spec.AvailabilityZoneID != *b.ko.Spec.AvailabilityZoneID { + delta.Add("Spec.AvailabilityZoneID", a.ko.Spec.AvailabilityZoneID, b.ko.Spec.AvailabilityZoneID) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.ClientToken, b.ko.Spec.ClientToken) { + delta.Add("Spec.ClientToken", a.ko.Spec.ClientToken, b.ko.Spec.ClientToken) + } else if a.ko.Spec.ClientToken != nil && b.ko.Spec.ClientToken != nil { + if *a.ko.Spec.ClientToken != *b.ko.Spec.ClientToken { + delta.Add("Spec.ClientToken", a.ko.Spec.ClientToken, b.ko.Spec.ClientToken) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.DryRun, b.ko.Spec.DryRun) { + delta.Add("Spec.DryRun", a.ko.Spec.DryRun, b.ko.Spec.DryRun) + } else if a.ko.Spec.DryRun != nil && b.ko.Spec.DryRun != nil { + if *a.ko.Spec.DryRun != *b.ko.Spec.DryRun { + delta.Add("Spec.DryRun", a.ko.Spec.DryRun, b.ko.Spec.DryRun) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.EBSOptimized, b.ko.Spec.EBSOptimized) { + delta.Add("Spec.EBSOptimized", a.ko.Spec.EBSOptimized, b.ko.Spec.EBSOptimized) + } else if a.ko.Spec.EBSOptimized != nil && b.ko.Spec.EBSOptimized != nil { + if *a.ko.Spec.EBSOptimized != *b.ko.Spec.EBSOptimized { + delta.Add("Spec.EBSOptimized", a.ko.Spec.EBSOptimized, b.ko.Spec.EBSOptimized) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.EndDate, b.ko.Spec.EndDate) { + delta.Add("Spec.EndDate", a.ko.Spec.EndDate, b.ko.Spec.EndDate) + } else if a.ko.Spec.EndDate != nil && b.ko.Spec.EndDate != nil { + if !a.ko.Spec.EndDate.Equal(b.ko.Spec.EndDate) { + delta.Add("Spec.EndDate", a.ko.Spec.EndDate, b.ko.Spec.EndDate) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.EndDateType, b.ko.Spec.EndDateType) { + delta.Add("Spec.EndDateType", a.ko.Spec.EndDateType, b.ko.Spec.EndDateType) + } else if a.ko.Spec.EndDateType != nil && b.ko.Spec.EndDateType != nil { + if *a.ko.Spec.EndDateType != *b.ko.Spec.EndDateType { + delta.Add("Spec.EndDateType", a.ko.Spec.EndDateType, b.ko.Spec.EndDateType) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.EphemeralStorage, b.ko.Spec.EphemeralStorage) { + delta.Add("Spec.EphemeralStorage", a.ko.Spec.EphemeralStorage, b.ko.Spec.EphemeralStorage) + } else if a.ko.Spec.EphemeralStorage != nil && b.ko.Spec.EphemeralStorage != nil { + if *a.ko.Spec.EphemeralStorage != *b.ko.Spec.EphemeralStorage { + delta.Add("Spec.EphemeralStorage", a.ko.Spec.EphemeralStorage, b.ko.Spec.EphemeralStorage) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.InstanceCount, b.ko.Spec.InstanceCount) { + delta.Add("Spec.InstanceCount", a.ko.Spec.InstanceCount, b.ko.Spec.InstanceCount) + } else if a.ko.Spec.InstanceCount != nil && b.ko.Spec.InstanceCount != nil { + if *a.ko.Spec.InstanceCount != *b.ko.Spec.InstanceCount { + delta.Add("Spec.InstanceCount", a.ko.Spec.InstanceCount, b.ko.Spec.InstanceCount) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.InstanceMatchCriteria, b.ko.Spec.InstanceMatchCriteria) { + delta.Add("Spec.InstanceMatchCriteria", a.ko.Spec.InstanceMatchCriteria, b.ko.Spec.InstanceMatchCriteria) + } else if a.ko.Spec.InstanceMatchCriteria != nil && b.ko.Spec.InstanceMatchCriteria != nil { + if *a.ko.Spec.InstanceMatchCriteria != *b.ko.Spec.InstanceMatchCriteria { + delta.Add("Spec.InstanceMatchCriteria", a.ko.Spec.InstanceMatchCriteria, b.ko.Spec.InstanceMatchCriteria) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.InstancePlatform, b.ko.Spec.InstancePlatform) { + delta.Add("Spec.InstancePlatform", a.ko.Spec.InstancePlatform, b.ko.Spec.InstancePlatform) + } else if a.ko.Spec.InstancePlatform != nil && b.ko.Spec.InstancePlatform != nil { + if *a.ko.Spec.InstancePlatform != *b.ko.Spec.InstancePlatform { + delta.Add("Spec.InstancePlatform", a.ko.Spec.InstancePlatform, b.ko.Spec.InstancePlatform) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.InstanceType, b.ko.Spec.InstanceType) { + delta.Add("Spec.InstanceType", a.ko.Spec.InstanceType, b.ko.Spec.InstanceType) + } else if a.ko.Spec.InstanceType != nil && b.ko.Spec.InstanceType != nil { + if *a.ko.Spec.InstanceType != *b.ko.Spec.InstanceType { + delta.Add("Spec.InstanceType", a.ko.Spec.InstanceType, b.ko.Spec.InstanceType) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.OutpostARN, b.ko.Spec.OutpostARN) { + delta.Add("Spec.OutpostARN", a.ko.Spec.OutpostARN, b.ko.Spec.OutpostARN) + } else if a.ko.Spec.OutpostARN != nil && b.ko.Spec.OutpostARN != nil { + if *a.ko.Spec.OutpostARN != *b.ko.Spec.OutpostARN { + delta.Add("Spec.OutpostARN", a.ko.Spec.OutpostARN, b.ko.Spec.OutpostARN) + } + } + if ackcompare.HasNilDifference(a.ko.Spec.PlacementGroupARN, b.ko.Spec.PlacementGroupARN) { + delta.Add("Spec.PlacementGroupARN", a.ko.Spec.PlacementGroupARN, b.ko.Spec.PlacementGroupARN) + } else if a.ko.Spec.PlacementGroupARN != nil && b.ko.Spec.PlacementGroupARN != nil { + if *a.ko.Spec.PlacementGroupARN != *b.ko.Spec.PlacementGroupARN { + delta.Add("Spec.PlacementGroupARN", a.ko.Spec.PlacementGroupARN, b.ko.Spec.PlacementGroupARN) + } + } + if !ackcompare.MapStringStringEqual(ToACKTags(a.ko.Spec.Tags), ToACKTags(b.ko.Spec.Tags)) { + delta.Add("Spec.Tags", a.ko.Spec.Tags, b.ko.Spec.Tags) + } + if ackcompare.HasNilDifference(a.ko.Spec.Tenancy, b.ko.Spec.Tenancy) { + delta.Add("Spec.Tenancy", a.ko.Spec.Tenancy, b.ko.Spec.Tenancy) + } else if a.ko.Spec.Tenancy != nil && b.ko.Spec.Tenancy != nil { + if *a.ko.Spec.Tenancy != *b.ko.Spec.Tenancy { + delta.Add("Spec.Tenancy", a.ko.Spec.Tenancy, b.ko.Spec.Tenancy) + } + } + + return delta +} diff --git a/pkg/resource/capacity_reservation/descriptor.go b/pkg/resource/capacity_reservation/descriptor.go new file mode 100644 index 00000000..c14b3524 --- /dev/null +++ b/pkg/resource/capacity_reservation/descriptor.go @@ -0,0 +1,155 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file 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 capacity_reservation + +import ( + ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1" + ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare" + acktypes "github.com/aws-controllers-k8s/runtime/pkg/types" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + rtclient "sigs.k8s.io/controller-runtime/pkg/client" + k8sctrlutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + svcapitypes "github.com/aws-controllers-k8s/ec2-controller/apis/v1alpha1" +) + +const ( + FinalizerString = "finalizers.ec2.services.k8s.aws/CapacityReservation" +) + +var ( + GroupVersionResource = svcapitypes.GroupVersion.WithResource("capacityreservations") + GroupKind = metav1.GroupKind{ + Group: "ec2.services.k8s.aws", + Kind: "CapacityReservation", + } +) + +// resourceDescriptor implements the +// `aws-service-operator-k8s/pkg/types.AWSResourceDescriptor` interface +type resourceDescriptor struct { +} + +// GroupVersionKind returns a Kubernetes schema.GroupVersionKind struct that +// describes the API Group, Version and Kind of CRs described by the descriptor +func (d *resourceDescriptor) GroupVersionKind() schema.GroupVersionKind { + return svcapitypes.GroupVersion.WithKind(GroupKind.Kind) +} + +// EmptyRuntimeObject returns an empty object prototype that may be used in +// apimachinery and k8s client operations +func (d *resourceDescriptor) EmptyRuntimeObject() rtclient.Object { + return &svcapitypes.CapacityReservation{} +} + +// ResourceFromRuntimeObject returns an AWSResource that has been initialized +// with the supplied runtime.Object +func (d *resourceDescriptor) ResourceFromRuntimeObject( + obj rtclient.Object, +) acktypes.AWSResource { + return &resource{ + ko: obj.(*svcapitypes.CapacityReservation), + } +} + +// Delta returns an `ackcompare.Delta` object containing the difference between +// one `AWSResource` and another. +func (d *resourceDescriptor) Delta(a, b acktypes.AWSResource) *ackcompare.Delta { + return newResourceDelta(a.(*resource), b.(*resource)) +} + +// IsManaged returns true if the supplied AWSResource is under the management +// of an ACK service controller. What this means in practice is that the +// underlying custom resource (CR) in the AWSResource has had a +// resource-specific finalizer associated with it. +func (d *resourceDescriptor) IsManaged( + res acktypes.AWSResource, +) bool { + obj := res.RuntimeObject() + if obj == nil { + // Should not happen. If it does, there is a bug in the code + panic("nil RuntimeMetaObject in AWSResource") + } + // Remove use of custom code once + // https://github.com/kubernetes-sigs/controller-runtime/issues/994 is + // fixed. This should be able to be: + // + // return k8sctrlutil.ContainsFinalizer(obj, FinalizerString) + return containsFinalizer(obj, FinalizerString) +} + +// Remove once https://github.com/kubernetes-sigs/controller-runtime/issues/994 +// is fixed. +func containsFinalizer(obj rtclient.Object, finalizer string) bool { + f := obj.GetFinalizers() + for _, e := range f { + if e == finalizer { + return true + } + } + return false +} + +// MarkManaged places the supplied resource under the management of ACK. What +// this typically means is that the resource manager will decorate the +// underlying custom resource (CR) with a finalizer that indicates ACK is +// managing the resource and the underlying CR may not be deleted until ACK is +// finished cleaning up any backend AWS service resources associated with the +// CR. +func (d *resourceDescriptor) MarkManaged( + res acktypes.AWSResource, +) { + obj := res.RuntimeObject() + if obj == nil { + // Should not happen. If it does, there is a bug in the code + panic("nil RuntimeMetaObject in AWSResource") + } + k8sctrlutil.AddFinalizer(obj, FinalizerString) +} + +// MarkUnmanaged removes the supplied resource from management by ACK. What +// this typically means is that the resource manager will remove a finalizer +// underlying custom resource (CR) that indicates ACK is managing the resource. +// This will allow the Kubernetes API server to delete the underlying CR. +func (d *resourceDescriptor) MarkUnmanaged( + res acktypes.AWSResource, +) { + obj := res.RuntimeObject() + if obj == nil { + // Should not happen. If it does, there is a bug in the code + panic("nil RuntimeMetaObject in AWSResource") + } + k8sctrlutil.RemoveFinalizer(obj, FinalizerString) +} + +// MarkAdopted places descriptors on the custom resource that indicate the +// resource was not created from within ACK. +func (d *resourceDescriptor) MarkAdopted( + res acktypes.AWSResource, +) { + obj := res.RuntimeObject() + if obj == nil { + // Should not happen. If it does, there is a bug in the code + panic("nil RuntimeObject in AWSResource") + } + curr := obj.GetAnnotations() + if curr == nil { + curr = make(map[string]string) + } + curr[ackv1alpha1.AnnotationAdopted] = "true" + obj.SetAnnotations(curr) +} diff --git a/pkg/resource/capacity_reservation/hooks.go b/pkg/resource/capacity_reservation/hooks.go new file mode 100644 index 00000000..13594e46 --- /dev/null +++ b/pkg/resource/capacity_reservation/hooks.go @@ -0,0 +1,27 @@ +package capacity_reservation + +import svcsdk "github.com/aws/aws-sdk-go/service/ec2" + +// updateTagSpecificationsInCreateRequest adds +// Tags defined in the Spec to CreateCapacityReservationInput.TagSpecifications +// and ensures the ResourceType is always set to 'capacity-reservation' +func updateTagSpecificationsInCreateRequest(r *resource, + input *svcsdk.CreateCapacityReservationInput) { + input.TagSpecifications = nil + desiredTagSpecs := svcsdk.TagSpecification{} + if r.ko.Spec.Tags != nil { + requestedTags := []*svcsdk.Tag{} + for _, desiredTag := range r.ko.Spec.Tags { + // Add in tags defined in the Spec + tag := &svcsdk.Tag{} + if desiredTag.Key != nil && desiredTag.Value != nil { + tag.SetKey(*desiredTag.Key) + tag.SetValue(*desiredTag.Value) + } + requestedTags = append(requestedTags, tag) + } + desiredTagSpecs.SetResourceType("capacity-reservation") + desiredTagSpecs.SetTags(requestedTags) + input.TagSpecifications = []*svcsdk.TagSpecification{&desiredTagSpecs} + } +} diff --git a/pkg/resource/capacity_reservation/identifiers.go b/pkg/resource/capacity_reservation/identifiers.go new file mode 100644 index 00000000..6703d001 --- /dev/null +++ b/pkg/resource/capacity_reservation/identifiers.go @@ -0,0 +1,55 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file 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 capacity_reservation + +import ( + ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1" +) + +// resourceIdentifiers implements the +// `aws-service-operator-k8s/pkg/types.AWSResourceIdentifiers` interface +type resourceIdentifiers struct { + meta *ackv1alpha1.ResourceMetadata +} + +// ARN returns the AWS Resource Name for the backend AWS resource. If nil, +// this means the resource has not yet been created in the backend AWS +// service. +func (ri *resourceIdentifiers) ARN() *ackv1alpha1.AWSResourceName { + if ri.meta != nil { + return ri.meta.ARN + } + return nil +} + +// OwnerAccountID returns the AWS account identifier in which the +// backend AWS resource resides, or nil if this information is not known +// for the resource +func (ri *resourceIdentifiers) OwnerAccountID() *ackv1alpha1.AWSAccountID { + if ri.meta != nil { + return ri.meta.OwnerAccountID + } + return nil +} + +// Region returns the AWS region in which the resource exists, or +// nil if this information is not known. +func (ri *resourceIdentifiers) Region() *ackv1alpha1.AWSRegion { + if ri.meta != nil { + return ri.meta.Region + } + return nil +} diff --git a/pkg/resource/capacity_reservation/manager.go b/pkg/resource/capacity_reservation/manager.go new file mode 100644 index 00000000..18716af4 --- /dev/null +++ b/pkg/resource/capacity_reservation/manager.go @@ -0,0 +1,360 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file 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 capacity_reservation + +import ( + "context" + "fmt" + "time" + + ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1" + ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare" + ackcondition "github.com/aws-controllers-k8s/runtime/pkg/condition" + ackcfg "github.com/aws-controllers-k8s/runtime/pkg/config" + ackerr "github.com/aws-controllers-k8s/runtime/pkg/errors" + ackmetrics "github.com/aws-controllers-k8s/runtime/pkg/metrics" + ackrequeue "github.com/aws-controllers-k8s/runtime/pkg/requeue" + ackrt "github.com/aws-controllers-k8s/runtime/pkg/runtime" + ackrtlog "github.com/aws-controllers-k8s/runtime/pkg/runtime/log" + acktags "github.com/aws-controllers-k8s/runtime/pkg/tags" + acktypes "github.com/aws-controllers-k8s/runtime/pkg/types" + ackutil "github.com/aws-controllers-k8s/runtime/pkg/util" + "github.com/aws/aws-sdk-go/aws/session" + svcsdk "github.com/aws/aws-sdk-go/service/ec2" + svcsdkapi "github.com/aws/aws-sdk-go/service/ec2/ec2iface" + "github.com/go-logr/logr" + corev1 "k8s.io/api/core/v1" + + svcapitypes "github.com/aws-controllers-k8s/ec2-controller/apis/v1alpha1" +) + +var ( + _ = ackutil.InStrings + _ = acktags.NewTags() + _ = ackrt.MissingImageTagValue + _ = svcapitypes.CapacityReservation{} +) + +// +kubebuilder:rbac:groups=ec2.services.k8s.aws,resources=capacityreservations,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=ec2.services.k8s.aws,resources=capacityreservations/status,verbs=get;update;patch + +var lateInitializeFieldNames = []string{} + +// resourceManager is responsible for providing a consistent way to perform +// CRUD operations in a backend AWS service API for Book custom resources. +type resourceManager struct { + // cfg is a copy of the ackcfg.Config object passed on start of the service + // controller + cfg ackcfg.Config + // log refers to the logr.Logger object handling logging for the service + // controller + log logr.Logger + // metrics contains a collection of Prometheus metric objects that the + // service controller and its reconcilers track + metrics *ackmetrics.Metrics + // rr is the Reconciler which can be used for various utility + // functions such as querying for Secret values given a SecretReference + rr acktypes.Reconciler + // awsAccountID is the AWS account identifier that contains the resources + // managed by this resource manager + awsAccountID ackv1alpha1.AWSAccountID + // The AWS Region that this resource manager targets + awsRegion ackv1alpha1.AWSRegion + // sess is the AWS SDK Session object used to communicate with the backend + // AWS service API + sess *session.Session + // sdk is a pointer to the AWS service API interface exposed by the + // aws-sdk-go/services/{alias}/{alias}iface package. + sdkapi svcsdkapi.EC2API +} + +// concreteResource returns a pointer to a resource from the supplied +// generic AWSResource interface +func (rm *resourceManager) concreteResource( + res acktypes.AWSResource, +) *resource { + // cast the generic interface into a pointer type specific to the concrete + // implementing resource type managed by this resource manager + return res.(*resource) +} + +// ReadOne returns the currently-observed state of the supplied AWSResource in +// the backend AWS service API. +func (rm *resourceManager) ReadOne( + ctx context.Context, + res acktypes.AWSResource, +) (acktypes.AWSResource, error) { + r := rm.concreteResource(res) + if r.ko == nil { + // Should never happen... if it does, it's buggy code. + panic("resource manager's ReadOne() method received resource with nil CR object") + } + observed, err := rm.sdkFind(ctx, r) + if err != nil { + if observed != nil { + return rm.onError(observed, err) + } + return rm.onError(r, err) + } + return rm.onSuccess(observed) +} + +// Create attempts to create the supplied AWSResource in the backend AWS +// service API, returning an AWSResource representing the newly-created +// resource +func (rm *resourceManager) Create( + ctx context.Context, + res acktypes.AWSResource, +) (acktypes.AWSResource, error) { + r := rm.concreteResource(res) + if r.ko == nil { + // Should never happen... if it does, it's buggy code. + panic("resource manager's Create() method received resource with nil CR object") + } + created, err := rm.sdkCreate(ctx, r) + if err != nil { + if created != nil { + return rm.onError(created, err) + } + return rm.onError(r, err) + } + return rm.onSuccess(created) +} + +// Update attempts to mutate the supplied desired AWSResource in the backend AWS +// service API, returning an AWSResource representing the newly-mutated +// resource. +// Note for specialized logic implementers can check to see how the latest +// observed resource differs from the supplied desired state. The +// higher-level reonciler determines whether or not the desired differs +// from the latest observed and decides whether to call the resource +// manager's Update method +func (rm *resourceManager) Update( + ctx context.Context, + resDesired acktypes.AWSResource, + resLatest acktypes.AWSResource, + delta *ackcompare.Delta, +) (acktypes.AWSResource, error) { + desired := rm.concreteResource(resDesired) + latest := rm.concreteResource(resLatest) + if desired.ko == nil || latest.ko == nil { + // Should never happen... if it does, it's buggy code. + panic("resource manager's Update() method received resource with nil CR object") + } + updated, err := rm.sdkUpdate(ctx, desired, latest, delta) + if err != nil { + if updated != nil { + return rm.onError(updated, err) + } + return rm.onError(latest, err) + } + return rm.onSuccess(updated) +} + +// Delete attempts to destroy the supplied AWSResource in the backend AWS +// service API, returning an AWSResource representing the +// resource being deleted (if delete is asynchronous and takes time) +func (rm *resourceManager) Delete( + ctx context.Context, + res acktypes.AWSResource, +) (acktypes.AWSResource, error) { + r := rm.concreteResource(res) + if r.ko == nil { + // Should never happen... if it does, it's buggy code. + panic("resource manager's Update() method received resource with nil CR object") + } + observed, err := rm.sdkDelete(ctx, r) + if err != nil { + if observed != nil { + return rm.onError(observed, err) + } + return rm.onError(r, err) + } + + return rm.onSuccess(observed) +} + +// ARNFromName returns an AWS Resource Name from a given string name. This +// is useful for constructing ARNs for APIs that require ARNs in their +// GetAttributes operations but all we have (for new CRs at least) is a +// name for the resource +func (rm *resourceManager) ARNFromName(name string) string { + return fmt.Sprintf( + "arn:aws:ec2:%s:%s:%s", + rm.awsRegion, + rm.awsAccountID, + name, + ) +} + +// LateInitialize returns an acktypes.AWSResource after setting the late initialized +// fields from the readOne call. This method will initialize the optional fields +// which were not provided by the k8s user but were defaulted by the AWS service. +// If there are no such fields to be initialized, the returned object is similar to +// object passed in the parameter. +func (rm *resourceManager) LateInitialize( + ctx context.Context, + latest acktypes.AWSResource, +) (acktypes.AWSResource, error) { + rlog := ackrtlog.FromContext(ctx) + // If there are no fields to late initialize, do nothing + if len(lateInitializeFieldNames) == 0 { + rlog.Debug("no late initialization required.") + return latest, nil + } + latestCopy := latest.DeepCopy() + lateInitConditionReason := "" + lateInitConditionMessage := "" + observed, err := rm.ReadOne(ctx, latestCopy) + if err != nil { + lateInitConditionMessage = "Unable to complete Read operation required for late initialization" + lateInitConditionReason = "Late Initialization Failure" + ackcondition.SetLateInitialized(latestCopy, corev1.ConditionFalse, &lateInitConditionMessage, &lateInitConditionReason) + ackcondition.SetSynced(latestCopy, corev1.ConditionFalse, nil, nil) + return latestCopy, err + } + lateInitializedRes := rm.lateInitializeFromReadOneOutput(observed, latestCopy) + incompleteInitialization := rm.incompleteLateInitialization(lateInitializedRes) + if incompleteInitialization { + // Add the condition with LateInitialized=False + lateInitConditionMessage = "Late initialization did not complete, requeuing with delay of 5 seconds" + lateInitConditionReason = "Delayed Late Initialization" + ackcondition.SetLateInitialized(lateInitializedRes, corev1.ConditionFalse, &lateInitConditionMessage, &lateInitConditionReason) + ackcondition.SetSynced(lateInitializedRes, corev1.ConditionFalse, nil, nil) + return lateInitializedRes, ackrequeue.NeededAfter(nil, time.Duration(5)*time.Second) + } + // Set LateInitialized condition to True + lateInitConditionMessage = "Late initialization successful" + lateInitConditionReason = "Late initialization successful" + ackcondition.SetLateInitialized(lateInitializedRes, corev1.ConditionTrue, &lateInitConditionMessage, &lateInitConditionReason) + return lateInitializedRes, nil +} + +// incompleteLateInitialization return true if there are fields which were supposed to be +// late initialized but are not. If all the fields are late initialized, false is returned +func (rm *resourceManager) incompleteLateInitialization( + res acktypes.AWSResource, +) bool { + return false +} + +// lateInitializeFromReadOneOutput late initializes the 'latest' resource from the 'observed' +// resource and returns 'latest' resource +func (rm *resourceManager) lateInitializeFromReadOneOutput( + observed acktypes.AWSResource, + latest acktypes.AWSResource, +) acktypes.AWSResource { + return latest +} + +// IsSynced returns true if the resource is synced. +func (rm *resourceManager) IsSynced(ctx context.Context, res acktypes.AWSResource) (bool, error) { + r := rm.concreteResource(res) + if r.ko == nil { + // Should never happen... if it does, it's buggy code. + panic("resource manager's IsSynced() method received resource with nil CR object") + } + + return true, nil +} + +// EnsureTags ensures that tags are present inside the AWSResource. +// If the AWSResource does not have any existing resource tags, the 'tags' +// field is initialized and the controller tags are added. +// If the AWSResource has existing resource tags, then controller tags are +// added to the existing resource tags without overriding them. +// If the AWSResource does not support tags, only then the controller tags +// will not be added to the AWSResource. +func (rm *resourceManager) EnsureTags( + ctx context.Context, + res acktypes.AWSResource, + md acktypes.ServiceControllerMetadata, +) error { + r := rm.concreteResource(res) + if r.ko == nil { + // Should never happen... if it does, it's buggy code. + panic("resource manager's EnsureTags method received resource with nil CR object") + } + defaultTags := ackrt.GetDefaultTags(&rm.cfg, r.ko, md) + var existingTags []*svcapitypes.Tag + existingTags = r.ko.Spec.Tags + resourceTags := ToACKTags(existingTags) + tags := acktags.Merge(resourceTags, defaultTags) + r.ko.Spec.Tags = FromACKTags(tags) + return nil +} + +// newResourceManager returns a new struct implementing +// acktypes.AWSResourceManager +func newResourceManager( + cfg ackcfg.Config, + log logr.Logger, + metrics *ackmetrics.Metrics, + rr acktypes.Reconciler, + sess *session.Session, + id ackv1alpha1.AWSAccountID, + region ackv1alpha1.AWSRegion, +) (*resourceManager, error) { + return &resourceManager{ + cfg: cfg, + log: log, + metrics: metrics, + rr: rr, + awsAccountID: id, + awsRegion: region, + sess: sess, + sdkapi: svcsdk.New(sess), + }, nil +} + +// onError updates resource conditions and returns updated resource +// it returns nil if no condition is updated. +func (rm *resourceManager) onError( + r *resource, + err error, +) (acktypes.AWSResource, error) { + if r == nil { + return nil, err + } + r1, updated := rm.updateConditions(r, false, err) + if !updated { + return r, err + } + for _, condition := range r1.Conditions() { + if condition.Type == ackv1alpha1.ConditionTypeTerminal && + condition.Status == corev1.ConditionTrue { + // resource is in Terminal condition + // return Terminal error + return r1, ackerr.Terminal + } + } + return r1, err +} + +// onSuccess updates resource conditions and returns updated resource +// it returns the supplied resource if no condition is updated. +func (rm *resourceManager) onSuccess( + r *resource, +) (acktypes.AWSResource, error) { + if r == nil { + return nil, nil + } + r1, updated := rm.updateConditions(r, true, nil) + if !updated { + return r, nil + } + return r1, nil +} diff --git a/pkg/resource/capacity_reservation/manager_factory.go b/pkg/resource/capacity_reservation/manager_factory.go new file mode 100644 index 00000000..f2020c53 --- /dev/null +++ b/pkg/resource/capacity_reservation/manager_factory.go @@ -0,0 +1,100 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file 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 capacity_reservation + +import ( + "fmt" + "sync" + + ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1" + ackcfg "github.com/aws-controllers-k8s/runtime/pkg/config" + ackmetrics "github.com/aws-controllers-k8s/runtime/pkg/metrics" + acktypes "github.com/aws-controllers-k8s/runtime/pkg/types" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/go-logr/logr" + + svcresource "github.com/aws-controllers-k8s/ec2-controller/pkg/resource" +) + +// resourceManagerFactory produces resourceManager objects. It implements the +// `types.AWSResourceManagerFactory` interface. +type resourceManagerFactory struct { + sync.RWMutex + // rmCache contains resource managers for a particular AWS account ID + rmCache map[string]*resourceManager +} + +// ResourcePrototype returns an AWSResource that resource managers produced by +// this factory will handle +func (f *resourceManagerFactory) ResourceDescriptor() acktypes.AWSResourceDescriptor { + return &resourceDescriptor{} +} + +// ManagerFor returns a resource manager object that can manage resources for a +// supplied AWS account +func (f *resourceManagerFactory) ManagerFor( + cfg ackcfg.Config, + log logr.Logger, + metrics *ackmetrics.Metrics, + rr acktypes.Reconciler, + sess *session.Session, + id ackv1alpha1.AWSAccountID, + region ackv1alpha1.AWSRegion, + roleARN ackv1alpha1.AWSResourceName, +) (acktypes.AWSResourceManager, error) { + // We use the account ID, region, and role ARN to uniquely identify a + // resource manager. This helps us to avoid creating multiple resource + // managers for the same account/region/roleARN combination. + rmId := fmt.Sprintf("%s/%s/%s", id, region, roleARN) + f.RLock() + rm, found := f.rmCache[rmId] + f.RUnlock() + + if found { + return rm, nil + } + + f.Lock() + defer f.Unlock() + + rm, err := newResourceManager(cfg, log, metrics, rr, sess, id, region) + if err != nil { + return nil, err + } + f.rmCache[rmId] = rm + return rm, nil +} + +// IsAdoptable returns true if the resource is able to be adopted +func (f *resourceManagerFactory) IsAdoptable() bool { + return true +} + +// RequeueOnSuccessSeconds returns true if the resource should be requeued after specified seconds +// Default is false which means resource will not be requeued after success. +func (f *resourceManagerFactory) RequeueOnSuccessSeconds() int { + return 0 +} + +func newResourceManagerFactory() *resourceManagerFactory { + return &resourceManagerFactory{ + rmCache: map[string]*resourceManager{}, + } +} + +func init() { + svcresource.RegisterManagerFactory(newResourceManagerFactory()) +} diff --git a/pkg/resource/capacity_reservation/references.go b/pkg/resource/capacity_reservation/references.go new file mode 100644 index 00000000..0b380ae9 --- /dev/null +++ b/pkg/resource/capacity_reservation/references.go @@ -0,0 +1,56 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file 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 capacity_reservation + +import ( + "context" + "sigs.k8s.io/controller-runtime/pkg/client" + + acktypes "github.com/aws-controllers-k8s/runtime/pkg/types" + + svcapitypes "github.com/aws-controllers-k8s/ec2-controller/apis/v1alpha1" +) + +// ClearResolvedReferences removes any reference values that were made +// concrete in the spec. It returns a copy of the input AWSResource which +// contains the original *Ref values, but none of their respective concrete +// values. +func (rm *resourceManager) ClearResolvedReferences(res acktypes.AWSResource) acktypes.AWSResource { + ko := rm.concreteResource(res).ko.DeepCopy() + + return &resource{ko} +} + +// ResolveReferences finds if there are any Reference field(s) present +// inside AWSResource passed in the parameter and attempts to resolve those +// reference field(s) into their respective target field(s). It returns a +// copy of the input AWSResource with resolved reference(s), a boolean which +// is set to true if the resource contains any references (regardless of if +// they are resolved successfully) and an error if the passed AWSResource's +// reference field(s) could not be resolved. +func (rm *resourceManager) ResolveReferences( + ctx context.Context, + apiReader client.Reader, + res acktypes.AWSResource, +) (acktypes.AWSResource, bool, error) { + return res, false, nil +} + +// validateReferenceFields validates the reference field and corresponding +// identifier field. +func validateReferenceFields(ko *svcapitypes.CapacityReservation) error { + return nil +} diff --git a/pkg/resource/capacity_reservation/resource.go b/pkg/resource/capacity_reservation/resource.go new file mode 100644 index 00000000..03683c5b --- /dev/null +++ b/pkg/resource/capacity_reservation/resource.go @@ -0,0 +1,111 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file 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 capacity_reservation + +import ( + ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1" + ackerrors "github.com/aws-controllers-k8s/runtime/pkg/errors" + acktypes "github.com/aws-controllers-k8s/runtime/pkg/types" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + rtclient "sigs.k8s.io/controller-runtime/pkg/client" + + svcapitypes "github.com/aws-controllers-k8s/ec2-controller/apis/v1alpha1" +) + +// Hack to avoid import errors during build... +var ( + _ = &ackerrors.MissingNameIdentifier +) + +// resource implements the `aws-controller-k8s/runtime/pkg/types.AWSResource` +// interface +type resource struct { + // The Kubernetes-native CR representing the resource + ko *svcapitypes.CapacityReservation +} + +// Identifiers returns an AWSResourceIdentifiers object containing various +// identifying information, including the AWS account ID that owns the +// resource, the resource's AWS Resource Name (ARN) +func (r *resource) Identifiers() acktypes.AWSResourceIdentifiers { + return &resourceIdentifiers{r.ko.Status.ACKResourceMetadata} +} + +// IsBeingDeleted returns true if the Kubernetes resource has a non-zero +// deletion timestamp +func (r *resource) IsBeingDeleted() bool { + return !r.ko.DeletionTimestamp.IsZero() +} + +// RuntimeObject returns the Kubernetes apimachinery/runtime representation of +// the AWSResource +func (r *resource) RuntimeObject() rtclient.Object { + return r.ko +} + +// MetaObject returns the Kubernetes apimachinery/apis/meta/v1.Object +// representation of the AWSResource +func (r *resource) MetaObject() metav1.Object { + return r.ko.GetObjectMeta() +} + +// Conditions returns the ACK Conditions collection for the AWSResource +func (r *resource) Conditions() []*ackv1alpha1.Condition { + return r.ko.Status.Conditions +} + +// ReplaceConditions sets the Conditions status field for the resource +func (r *resource) ReplaceConditions(conditions []*ackv1alpha1.Condition) { + r.ko.Status.Conditions = conditions +} + +// SetObjectMeta sets the ObjectMeta field for the resource +func (r *resource) SetObjectMeta(meta metav1.ObjectMeta) { + r.ko.ObjectMeta = meta +} + +// SetStatus will set the Status field for the resource +func (r *resource) SetStatus(desired acktypes.AWSResource) { + r.ko.Status = desired.(*resource).ko.Status +} + +// SetIdentifiers sets the Spec or Status field that is referenced as the unique +// resource identifier +func (r *resource) SetIdentifiers(identifier *ackv1alpha1.AWSIdentifiers) error { + if identifier.NameOrID == "" { + return ackerrors.MissingNameIdentifier + } + r.ko.Status.CapacityReservationID = &identifier.NameOrID + + return nil +} + +// PopulateResourceFromAnnotation populates the fields passed from adoption annotation +func (r *resource) PopulateResourceFromAnnotation(fields map[string]string) error { + tmp, ok := fields["capacityReservationID"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Status.CapacityReservationID = &tmp + + return nil +} + +// DeepCopy will return a copy of the resource +func (r *resource) DeepCopy() acktypes.AWSResource { + koCopy := r.ko.DeepCopy() + return &resource{koCopy} +} diff --git a/pkg/resource/capacity_reservation/sdk.go b/pkg/resource/capacity_reservation/sdk.go new file mode 100644 index 00000000..c73f4661 --- /dev/null +++ b/pkg/resource/capacity_reservation/sdk.go @@ -0,0 +1,645 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file 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 capacity_reservation + +import ( + "context" + "errors" + "fmt" + "reflect" + "strings" + + ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1" + ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare" + ackcondition "github.com/aws-controllers-k8s/runtime/pkg/condition" + ackerr "github.com/aws-controllers-k8s/runtime/pkg/errors" + ackrequeue "github.com/aws-controllers-k8s/runtime/pkg/requeue" + ackrtlog "github.com/aws-controllers-k8s/runtime/pkg/runtime/log" + "github.com/aws/aws-sdk-go/aws" + svcsdk "github.com/aws/aws-sdk-go/service/ec2" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + svcapitypes "github.com/aws-controllers-k8s/ec2-controller/apis/v1alpha1" +) + +// Hack to avoid import errors during build... +var ( + _ = &metav1.Time{} + _ = strings.ToLower("") + _ = &aws.JSONValue{} + _ = &svcsdk.EC2{} + _ = &svcapitypes.CapacityReservation{} + _ = ackv1alpha1.AWSAccountID("") + _ = &ackerr.NotFound + _ = &ackcondition.NotManagedMessage + _ = &reflect.Value{} + _ = fmt.Sprintf("") + _ = &ackrequeue.NoRequeue{} +) + +// sdkFind returns SDK-specific information about a supplied resource +func (rm *resourceManager) sdkFind( + ctx context.Context, + r *resource, +) (latest *resource, err error) { + rlog := ackrtlog.FromContext(ctx) + exit := rlog.Trace("rm.sdkFind") + defer func() { + exit(err) + }() + // If any required fields in the input shape are missing, AWS resource is + // not created yet. Return NotFound here to indicate to callers that the + // resource isn't yet created. + if rm.requiredFieldsMissingFromReadManyInput(r) { + return nil, ackerr.NotFound + } + + input, err := rm.newListRequestPayload(r) + if err != nil { + return nil, err + } + var resp *svcsdk.DescribeCapacityReservationsOutput + resp, err = rm.sdkapi.DescribeCapacityReservationsWithContext(ctx, input) + rm.metrics.RecordAPICall("READ_MANY", "DescribeCapacityReservations", err) + if err != nil { + if awsErr, ok := ackerr.AWSError(err); ok && awsErr.Code() == "UNKNOWN" { + return nil, ackerr.NotFound + } + return nil, err + } + + // Merge in the information we read from the API call above to the copy of + // the original Kubernetes object we passed to the function + ko := r.ko.DeepCopy() + + found := false + for _, elem := range resp.CapacityReservations { + if elem.AvailabilityZone != nil { + ko.Spec.AvailabilityZone = elem.AvailabilityZone + } else { + ko.Spec.AvailabilityZone = nil + } + if elem.AvailabilityZoneId != nil { + ko.Spec.AvailabilityZoneID = elem.AvailabilityZoneId + } else { + ko.Spec.AvailabilityZoneID = nil + } + if elem.AvailableInstanceCount != nil { + ko.Status.AvailableInstanceCount = elem.AvailableInstanceCount + } else { + ko.Status.AvailableInstanceCount = nil + } + if elem.CapacityReservationArn != nil { + if ko.Status.ACKResourceMetadata == nil { + ko.Status.ACKResourceMetadata = &ackv1alpha1.ResourceMetadata{} + } + tmpARN := ackv1alpha1.AWSResourceName(*elem.CapacityReservationArn) + ko.Status.ACKResourceMetadata.ARN = &tmpARN + } + if elem.CapacityReservationFleetId != nil { + ko.Status.CapacityReservationFleetID = elem.CapacityReservationFleetId + } else { + ko.Status.CapacityReservationFleetID = nil + } + if elem.CapacityReservationId != nil { + ko.Status.CapacityReservationID = elem.CapacityReservationId + } else { + ko.Status.CapacityReservationID = nil + } + if elem.CreateDate != nil { + ko.Status.CreateDate = &metav1.Time{*elem.CreateDate} + } else { + ko.Status.CreateDate = nil + } + if elem.EbsOptimized != nil { + ko.Spec.EBSOptimized = elem.EbsOptimized + } else { + ko.Spec.EBSOptimized = nil + } + if elem.EndDate != nil { + ko.Spec.EndDate = &metav1.Time{*elem.EndDate} + } else { + ko.Spec.EndDate = nil + } + if elem.EndDateType != nil { + ko.Spec.EndDateType = elem.EndDateType + } else { + ko.Spec.EndDateType = nil + } + if elem.EphemeralStorage != nil { + ko.Spec.EphemeralStorage = elem.EphemeralStorage + } else { + ko.Spec.EphemeralStorage = nil + } + if elem.InstanceMatchCriteria != nil { + ko.Spec.InstanceMatchCriteria = elem.InstanceMatchCriteria + } else { + ko.Spec.InstanceMatchCriteria = nil + } + if elem.InstancePlatform != nil { + ko.Spec.InstancePlatform = elem.InstancePlatform + } else { + ko.Spec.InstancePlatform = nil + } + if elem.InstanceType != nil { + ko.Spec.InstanceType = elem.InstanceType + } else { + ko.Spec.InstanceType = nil + } + if elem.OutpostArn != nil { + ko.Spec.OutpostARN = elem.OutpostArn + } else { + ko.Spec.OutpostARN = nil + } + if elem.OwnerId != nil { + ko.Status.OwnerID = elem.OwnerId + } else { + ko.Status.OwnerID = nil + } + if elem.PlacementGroupArn != nil { + ko.Spec.PlacementGroupARN = elem.PlacementGroupArn + } else { + ko.Spec.PlacementGroupARN = nil + } + if elem.StartDate != nil { + ko.Status.StartDate = &metav1.Time{*elem.StartDate} + } else { + ko.Status.StartDate = nil + } + if elem.State != nil { + ko.Status.State = elem.State + } else { + ko.Status.State = nil + } + if elem.Tags != nil { + f19 := []*svcapitypes.Tag{} + for _, f19iter := range elem.Tags { + f19elem := &svcapitypes.Tag{} + if f19iter.Key != nil { + f19elem.Key = f19iter.Key + } + if f19iter.Value != nil { + f19elem.Value = f19iter.Value + } + f19 = append(f19, f19elem) + } + ko.Spec.Tags = f19 + } else { + ko.Spec.Tags = nil + } + if elem.Tenancy != nil { + ko.Spec.Tenancy = elem.Tenancy + } else { + ko.Spec.Tenancy = nil + } + if elem.TotalInstanceCount != nil { + ko.Status.TotalInstanceCount = elem.TotalInstanceCount + } else { + ko.Status.TotalInstanceCount = nil + } + found = true + break + } + if !found { + return nil, ackerr.NotFound + } + + rm.setStatusDefaults(ko) + return &resource{ko}, nil +} + +// requiredFieldsMissingFromReadManyInput returns true if there are any fields +// for the ReadMany Input shape that are required but not present in the +// resource's Spec or Status +func (rm *resourceManager) requiredFieldsMissingFromReadManyInput( + r *resource, +) bool { + return r.ko.Status.CapacityReservationID == nil + +} + +// newListRequestPayload returns SDK-specific struct for the HTTP request +// payload of the List API call for the resource +func (rm *resourceManager) newListRequestPayload( + r *resource, +) (*svcsdk.DescribeCapacityReservationsInput, error) { + res := &svcsdk.DescribeCapacityReservationsInput{} + + if r.ko.Status.CapacityReservationID != nil { + f0 := []*string{} + f0 = append(f0, r.ko.Status.CapacityReservationID) + res.SetCapacityReservationIds(f0) + } + if r.ko.Spec.DryRun != nil { + res.SetDryRun(*r.ko.Spec.DryRun) + } + + return res, nil +} + +// sdkCreate creates the supplied resource in the backend AWS service API and +// returns a copy of the resource with resource fields (in both Spec and +// Status) filled in with values from the CREATE API operation's Output shape. +func (rm *resourceManager) sdkCreate( + ctx context.Context, + desired *resource, +) (created *resource, err error) { + rlog := ackrtlog.FromContext(ctx) + exit := rlog.Trace("rm.sdkCreate") + defer func() { + exit(err) + }() + input, err := rm.newCreateRequestPayload(ctx, desired) + if err != nil { + return nil, err + } + updateTagSpecificationsInCreateRequest(desired, input) + + var resp *svcsdk.CreateCapacityReservationOutput + _ = resp + resp, err = rm.sdkapi.CreateCapacityReservationWithContext(ctx, input) + rm.metrics.RecordAPICall("CREATE", "CreateCapacityReservation", err) + if err != nil { + return nil, err + } + // Merge in the information we read from the API call above to the copy of + // the original Kubernetes object we passed to the function + ko := desired.ko.DeepCopy() + + if resp.CapacityReservation.AvailabilityZone != nil { + ko.Spec.AvailabilityZone = resp.CapacityReservation.AvailabilityZone + } else { + ko.Spec.AvailabilityZone = nil + } + if resp.CapacityReservation.AvailabilityZoneId != nil { + ko.Spec.AvailabilityZoneID = resp.CapacityReservation.AvailabilityZoneId + } else { + ko.Spec.AvailabilityZoneID = nil + } + if resp.CapacityReservation.AvailableInstanceCount != nil { + ko.Status.AvailableInstanceCount = resp.CapacityReservation.AvailableInstanceCount + } else { + ko.Status.AvailableInstanceCount = nil + } + if ko.Status.ACKResourceMetadata == nil { + ko.Status.ACKResourceMetadata = &ackv1alpha1.ResourceMetadata{} + } + if resp.CapacityReservation.CapacityReservationArn != nil { + arn := ackv1alpha1.AWSResourceName(*resp.CapacityReservation.CapacityReservationArn) + ko.Status.ACKResourceMetadata.ARN = &arn + } + if resp.CapacityReservation.CapacityReservationFleetId != nil { + ko.Status.CapacityReservationFleetID = resp.CapacityReservation.CapacityReservationFleetId + } else { + ko.Status.CapacityReservationFleetID = nil + } + if resp.CapacityReservation.CapacityReservationId != nil { + ko.Status.CapacityReservationID = resp.CapacityReservation.CapacityReservationId + } else { + ko.Status.CapacityReservationID = nil + } + if resp.CapacityReservation.CreateDate != nil { + ko.Status.CreateDate = &metav1.Time{*resp.CapacityReservation.CreateDate} + } else { + ko.Status.CreateDate = nil + } + if resp.CapacityReservation.EbsOptimized != nil { + ko.Spec.EBSOptimized = resp.CapacityReservation.EbsOptimized + } else { + ko.Spec.EBSOptimized = nil + } + if resp.CapacityReservation.EndDate != nil { + ko.Spec.EndDate = &metav1.Time{*resp.CapacityReservation.EndDate} + } else { + ko.Spec.EndDate = nil + } + if resp.CapacityReservation.EndDateType != nil { + ko.Spec.EndDateType = resp.CapacityReservation.EndDateType + } else { + ko.Spec.EndDateType = nil + } + if resp.CapacityReservation.EphemeralStorage != nil { + ko.Spec.EphemeralStorage = resp.CapacityReservation.EphemeralStorage + } else { + ko.Spec.EphemeralStorage = nil + } + if resp.CapacityReservation.InstanceMatchCriteria != nil { + ko.Spec.InstanceMatchCriteria = resp.CapacityReservation.InstanceMatchCriteria + } else { + ko.Spec.InstanceMatchCriteria = nil + } + if resp.CapacityReservation.InstancePlatform != nil { + ko.Spec.InstancePlatform = resp.CapacityReservation.InstancePlatform + } else { + ko.Spec.InstancePlatform = nil + } + if resp.CapacityReservation.InstanceType != nil { + ko.Spec.InstanceType = resp.CapacityReservation.InstanceType + } else { + ko.Spec.InstanceType = nil + } + if resp.CapacityReservation.OutpostArn != nil { + ko.Spec.OutpostARN = resp.CapacityReservation.OutpostArn + } else { + ko.Spec.OutpostARN = nil + } + if resp.CapacityReservation.OwnerId != nil { + ko.Status.OwnerID = resp.CapacityReservation.OwnerId + } else { + ko.Status.OwnerID = nil + } + if resp.CapacityReservation.PlacementGroupArn != nil { + ko.Spec.PlacementGroupARN = resp.CapacityReservation.PlacementGroupArn + } else { + ko.Spec.PlacementGroupARN = nil + } + if resp.CapacityReservation.StartDate != nil { + ko.Status.StartDate = &metav1.Time{*resp.CapacityReservation.StartDate} + } else { + ko.Status.StartDate = nil + } + if resp.CapacityReservation.State != nil { + ko.Status.State = resp.CapacityReservation.State + } else { + ko.Status.State = nil + } + if resp.CapacityReservation.Tags != nil { + f19 := []*svcapitypes.Tag{} + for _, f19iter := range resp.CapacityReservation.Tags { + f19elem := &svcapitypes.Tag{} + if f19iter.Key != nil { + f19elem.Key = f19iter.Key + } + if f19iter.Value != nil { + f19elem.Value = f19iter.Value + } + f19 = append(f19, f19elem) + } + ko.Spec.Tags = f19 + } else { + ko.Spec.Tags = nil + } + if resp.CapacityReservation.Tenancy != nil { + ko.Spec.Tenancy = resp.CapacityReservation.Tenancy + } else { + ko.Spec.Tenancy = nil + } + if resp.CapacityReservation.TotalInstanceCount != nil { + ko.Status.TotalInstanceCount = resp.CapacityReservation.TotalInstanceCount + } else { + ko.Status.TotalInstanceCount = nil + } + + rm.setStatusDefaults(ko) + return &resource{ko}, nil +} + +// newCreateRequestPayload returns an SDK-specific struct for the HTTP request +// payload of the Create API call for the resource +func (rm *resourceManager) newCreateRequestPayload( + ctx context.Context, + r *resource, +) (*svcsdk.CreateCapacityReservationInput, error) { + res := &svcsdk.CreateCapacityReservationInput{} + + if r.ko.Spec.AvailabilityZone != nil { + res.SetAvailabilityZone(*r.ko.Spec.AvailabilityZone) + } + if r.ko.Spec.AvailabilityZoneID != nil { + res.SetAvailabilityZoneId(*r.ko.Spec.AvailabilityZoneID) + } + if r.ko.Spec.ClientToken != nil { + res.SetClientToken(*r.ko.Spec.ClientToken) + } + if r.ko.Spec.DryRun != nil { + res.SetDryRun(*r.ko.Spec.DryRun) + } + if r.ko.Spec.EBSOptimized != nil { + res.SetEbsOptimized(*r.ko.Spec.EBSOptimized) + } + if r.ko.Spec.EndDate != nil { + res.SetEndDate(r.ko.Spec.EndDate.Time) + } + if r.ko.Spec.EndDateType != nil { + res.SetEndDateType(*r.ko.Spec.EndDateType) + } + if r.ko.Spec.EphemeralStorage != nil { + res.SetEphemeralStorage(*r.ko.Spec.EphemeralStorage) + } + if r.ko.Spec.InstanceCount != nil { + res.SetInstanceCount(*r.ko.Spec.InstanceCount) + } + if r.ko.Spec.InstanceMatchCriteria != nil { + res.SetInstanceMatchCriteria(*r.ko.Spec.InstanceMatchCriteria) + } + if r.ko.Spec.InstancePlatform != nil { + res.SetInstancePlatform(*r.ko.Spec.InstancePlatform) + } + if r.ko.Spec.InstanceType != nil { + res.SetInstanceType(*r.ko.Spec.InstanceType) + } + if r.ko.Spec.OutpostARN != nil { + res.SetOutpostArn(*r.ko.Spec.OutpostARN) + } + if r.ko.Spec.PlacementGroupARN != nil { + res.SetPlacementGroupArn(*r.ko.Spec.PlacementGroupARN) + } + if r.ko.Spec.Tenancy != nil { + res.SetTenancy(*r.ko.Spec.Tenancy) + } + + return res, nil +} + +// sdkUpdate patches the supplied resource in the backend AWS service API and +// returns a new resource with updated fields. +func (rm *resourceManager) sdkUpdate( + ctx context.Context, + desired *resource, + latest *resource, + delta *ackcompare.Delta, +) (updated *resource, err error) { + rlog := ackrtlog.FromContext(ctx) + exit := rlog.Trace("rm.sdkUpdate") + defer func() { + exit(err) + }() + input, err := rm.newUpdateRequestPayload(ctx, desired, delta) + if err != nil { + return nil, err + } + + var resp *svcsdk.ModifyCapacityReservationOutput + _ = resp + resp, err = rm.sdkapi.ModifyCapacityReservationWithContext(ctx, input) + rm.metrics.RecordAPICall("UPDATE", "ModifyCapacityReservation", err) + if err != nil { + return nil, err + } + // Merge in the information we read from the API call above to the copy of + // the original Kubernetes object we passed to the function + ko := desired.ko.DeepCopy() + + rm.setStatusDefaults(ko) + return &resource{ko}, nil +} + +// newUpdateRequestPayload returns an SDK-specific struct for the HTTP request +// payload of the Update API call for the resource +func (rm *resourceManager) newUpdateRequestPayload( + ctx context.Context, + r *resource, + delta *ackcompare.Delta, +) (*svcsdk.ModifyCapacityReservationInput, error) { + res := &svcsdk.ModifyCapacityReservationInput{} + + if r.ko.Status.CapacityReservationID != nil { + res.SetCapacityReservationId(*r.ko.Status.CapacityReservationID) + } + if r.ko.Spec.DryRun != nil { + res.SetDryRun(*r.ko.Spec.DryRun) + } + if r.ko.Spec.EndDate != nil { + res.SetEndDate(r.ko.Spec.EndDate.Time) + } + if r.ko.Spec.EndDateType != nil { + res.SetEndDateType(*r.ko.Spec.EndDateType) + } + if r.ko.Spec.InstanceCount != nil { + res.SetInstanceCount(*r.ko.Spec.InstanceCount) + } + + return res, nil +} + +// sdkDelete deletes the supplied resource in the backend AWS service API +func (rm *resourceManager) sdkDelete( + ctx context.Context, + r *resource, +) (latest *resource, err error) { + rlog := ackrtlog.FromContext(ctx) + exit := rlog.Trace("rm.sdkDelete") + defer func() { + exit(err) + }() + // TODO(jaypipes): Figure this out... + return nil, nil + +} + +// setStatusDefaults sets default properties into supplied custom resource +func (rm *resourceManager) setStatusDefaults( + ko *svcapitypes.CapacityReservation, +) { + if ko.Status.ACKResourceMetadata == nil { + ko.Status.ACKResourceMetadata = &ackv1alpha1.ResourceMetadata{} + } + if ko.Status.ACKResourceMetadata.Region == nil { + ko.Status.ACKResourceMetadata.Region = &rm.awsRegion + } + if ko.Status.ACKResourceMetadata.OwnerAccountID == nil { + ko.Status.ACKResourceMetadata.OwnerAccountID = &rm.awsAccountID + } + if ko.Status.Conditions == nil { + ko.Status.Conditions = []*ackv1alpha1.Condition{} + } +} + +// updateConditions returns updated resource, true; if conditions were updated +// else it returns nil, false +func (rm *resourceManager) updateConditions( + r *resource, + onSuccess bool, + err error, +) (*resource, bool) { + ko := r.ko.DeepCopy() + rm.setStatusDefaults(ko) + + // Terminal condition + var terminalCondition *ackv1alpha1.Condition = nil + var recoverableCondition *ackv1alpha1.Condition = nil + var syncCondition *ackv1alpha1.Condition = nil + for _, condition := range ko.Status.Conditions { + if condition.Type == ackv1alpha1.ConditionTypeTerminal { + terminalCondition = condition + } + if condition.Type == ackv1alpha1.ConditionTypeRecoverable { + recoverableCondition = condition + } + if condition.Type == ackv1alpha1.ConditionTypeResourceSynced { + syncCondition = condition + } + } + var termError *ackerr.TerminalError + if rm.terminalAWSError(err) || err == ackerr.SecretTypeNotSupported || err == ackerr.SecretNotFound || errors.As(err, &termError) { + if terminalCondition == nil { + terminalCondition = &ackv1alpha1.Condition{ + Type: ackv1alpha1.ConditionTypeTerminal, + } + ko.Status.Conditions = append(ko.Status.Conditions, terminalCondition) + } + var errorMessage = "" + if err == ackerr.SecretTypeNotSupported || err == ackerr.SecretNotFound || errors.As(err, &termError) { + errorMessage = err.Error() + } else { + awsErr, _ := ackerr.AWSError(err) + errorMessage = awsErr.Error() + } + terminalCondition.Status = corev1.ConditionTrue + terminalCondition.Message = &errorMessage + } else { + // Clear the terminal condition if no longer present + if terminalCondition != nil { + terminalCondition.Status = corev1.ConditionFalse + terminalCondition.Message = nil + } + // Handling Recoverable Conditions + if err != nil { + if recoverableCondition == nil { + // Add a new Condition containing a non-terminal error + recoverableCondition = &ackv1alpha1.Condition{ + Type: ackv1alpha1.ConditionTypeRecoverable, + } + ko.Status.Conditions = append(ko.Status.Conditions, recoverableCondition) + } + recoverableCondition.Status = corev1.ConditionTrue + awsErr, _ := ackerr.AWSError(err) + errorMessage := err.Error() + if awsErr != nil { + errorMessage = awsErr.Error() + } + recoverableCondition.Message = &errorMessage + } else if recoverableCondition != nil { + recoverableCondition.Status = corev1.ConditionFalse + recoverableCondition.Message = nil + } + } + // Required to avoid the "declared but not used" error in the default case + _ = syncCondition + if terminalCondition != nil || recoverableCondition != nil || syncCondition != nil { + return &resource{ko}, true // updated + } + return nil, false // not updated +} + +// terminalAWSError returns awserr, true; if the supplied error is an aws Error type +// and if the exception indicates that it is a Terminal exception +// 'Terminal' exception are specified in generator configuration +func (rm *resourceManager) terminalAWSError(err error) bool { + // No terminal_errors specified for this resource in generator config + return false +} diff --git a/pkg/resource/capacity_reservation/tags.go b/pkg/resource/capacity_reservation/tags.go new file mode 100644 index 00000000..bf088e50 --- /dev/null +++ b/pkg/resource/capacity_reservation/tags.go @@ -0,0 +1,63 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file 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 capacity_reservation + +import ( + acktags "github.com/aws-controllers-k8s/runtime/pkg/tags" + + svcapitypes "github.com/aws-controllers-k8s/ec2-controller/apis/v1alpha1" +) + +var ( + _ = svcapitypes.CapacityReservation{} + _ = acktags.NewTags() +) + +// ToACKTags converts the tags parameter into 'acktags.Tags' shape. +// This method helps in creating the hub(acktags.Tags) for merging +// default controller tags with existing resource tags. +func ToACKTags(tags []*svcapitypes.Tag) acktags.Tags { + result := acktags.NewTags() + if tags == nil || len(tags) == 0 { + return result + } + + for _, t := range tags { + if t.Key != nil { + if t.Value == nil { + result[*t.Key] = "" + } else { + result[*t.Key] = *t.Value + } + } + } + + return result +} + +// FromACKTags converts the tags parameter into []*svcapitypes.Tag shape. +// This method helps in setting the tags back inside AWSResource after merging +// default controller tags with existing resource tags. +func FromACKTags(tags acktags.Tags) []*svcapitypes.Tag { + result := []*svcapitypes.Tag{} + for k, v := range tags { + kCopy := k + vCopy := v + tag := svcapitypes.Tag{Key: &kCopy, Value: &vCopy} + result = append(result, &tag) + } + return result +} diff --git a/templates/hooks/capacity_reservation/sdk_create_post_build_request.go.tpl b/templates/hooks/capacity_reservation/sdk_create_post_build_request.go.tpl new file mode 100644 index 00000000..31eec6c0 --- /dev/null +++ b/templates/hooks/capacity_reservation/sdk_create_post_build_request.go.tpl @@ -0,0 +1 @@ + updateTagSpecificationsInCreateRequest(desired, input) \ No newline at end of file From fa6880798473aa4f5a74bf9a409f739585eb0ca0 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Thu, 9 Jan 2025 14:26:38 +1300 Subject: [PATCH 02/17] capacity_reservations_feature: Initial PR to add capacity reservations support --- .../capacity_reservation/sdk_create_post_build_request.go.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/hooks/capacity_reservation/sdk_create_post_build_request.go.tpl b/templates/hooks/capacity_reservation/sdk_create_post_build_request.go.tpl index 31eec6c0..58058089 100644 --- a/templates/hooks/capacity_reservation/sdk_create_post_build_request.go.tpl +++ b/templates/hooks/capacity_reservation/sdk_create_post_build_request.go.tpl @@ -1 +1 @@ - updateTagSpecificationsInCreateRequest(desired, input) \ No newline at end of file + updateTagSpecificationsInCreateRequest(desired, input) From 2e07fa55e9ff54133e6be66eb5822c9be9f2180e Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Tue, 21 Jan 2025 20:13:28 +1300 Subject: [PATCH 03/17] capacity_reservations_feature: Changes after running release --- apis/v1alpha1/ack-generate-metadata.yaml | 2 +- config/controller/kustomization.yaml | 2 +- helm/Chart.yaml | 4 +- ...services.k8s.aws_capacityreservations.yaml | 309 ++++++++++++++++++ helm/templates/NOTES.txt | 2 +- helm/templates/_helpers.tpl | 2 + helm/templates/role-reader.yaml | 1 + helm/templates/role-writer.yaml | 2 + helm/values.yaml | 2 +- 9 files changed, 320 insertions(+), 6 deletions(-) create mode 100644 helm/crds/ec2.services.k8s.aws_capacityreservations.yaml diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 7e264133..2091bf83 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,5 +1,5 @@ ack_generate_info: - build_date: "2025-01-09T01:04:52Z" + build_date: "2025-01-21T07:10:38Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 go_version: go1.23.4 version: 631aeb1-dirty diff --git a/config/controller/kustomization.yaml b/config/controller/kustomization.yaml index 6af598e3..39fcc564 100644 --- a/config/controller/kustomization.yaml +++ b/config/controller/kustomization.yaml @@ -6,4 +6,4 @@ kind: Kustomization images: - name: controller newName: public.ecr.aws/aws-controllers-k8s/ec2-controller - newTag: 1.3.1 + newTag: 1.3.2 diff --git a/helm/Chart.yaml b/helm/Chart.yaml index bbe98524..29f2c2d6 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 name: ec2-chart description: A Helm chart for the ACK service controller for Amazon Elastic Cloud Compute (EC2) -version: 1.3.1 -appVersion: 1.3.1 +version: 1.3.2 +appVersion: 1.3.2 home: https://github.com/aws-controllers-k8s/ec2-controller icon: https://raw.githubusercontent.com/aws/eks-charts/master/docs/logo/aws.png sources: diff --git a/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml b/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml new file mode 100644 index 00000000..b39a1f3c --- /dev/null +++ b/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml @@ -0,0 +1,309 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.2 + name: capacityreservations.ec2.services.k8s.aws +spec: + group: ec2.services.k8s.aws + names: + kind: CapacityReservation + listKind: CapacityReservationList + plural: capacityreservations + singular: capacityreservation + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: CapacityReservation is the Schema for the CapacityReservations + 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: |- + CapacityReservationSpec defines the desired state of CapacityReservation. + + Describes a Capacity Reservation. + properties: + availabilityZone: + description: The Availability Zone in which to create the Capacity + Reservation. + type: string + availabilityZoneID: + description: The ID of the Availability Zone in which to create the + Capacity Reservation. + type: string + clientToken: + description: |- + Unique, case-sensitive identifier that you provide to ensure the idempotency + of the request. For more information, see Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). + type: string + dryRun: + description: |- + Checks whether you have the required permissions for the action, without + actually making the request, and provides an error response. If you have + the required permissions, the error response is DryRunOperation. Otherwise, + it is UnauthorizedOperation. + type: boolean + ebsOptimized: + description: |- + Indicates whether the Capacity Reservation supports EBS-optimized instances. + This optimization provides dedicated throughput to Amazon EBS and an optimized + configuration stack to provide optimal I/O performance. This optimization + isn't available with all instance types. Additional usage charges apply when + using an EBS- optimized instance. + type: boolean + endDate: + description: |- + The date and time at which the Capacity Reservation expires. When a Capacity + Reservation expires, the reserved capacity is released and you can no longer + launch instances into it. The Capacity Reservation's state changes to expired + when it reaches its end date and time. + + You must provide an EndDate value if EndDateType is limited. Omit EndDate + if EndDateType is unlimited. + + If the EndDateType is limited, the Capacity Reservation is cancelled within + an hour from the specified time. For example, if you specify 5/31/2019, 13:30:55, + the Capacity Reservation is guaranteed to end between 13:30:55 and 14:30:55 + on 5/31/2019. + format: date-time + type: string + endDateType: + description: |- + Indicates the way in which the Capacity Reservation ends. A Capacity Reservation + can have one of the following end types: + + - unlimited - The Capacity Reservation remains active until you explicitly + cancel it. Do not provide an EndDate if the EndDateType is unlimited. + + - limited - The Capacity Reservation expires automatically at a specified + date and time. You must provide an EndDate value if the EndDateType value + is limited. + type: string + ephemeralStorage: + description: Deprecated. + type: boolean + instanceCount: + description: |- + The number of instances for which to reserve capacity. + + Valid range: 1 - 1000 + format: int64 + type: integer + instanceMatchCriteria: + description: |- + Indicates the type of instance launches that the Capacity Reservation accepts. + The options include: + + - open - The Capacity Reservation automatically matches all instances + that have matching attributes (instance type, platform, and Availability + Zone). Instances that have matching attributes run in the Capacity Reservation + automatically without specifying any additional parameters. + + - targeted - The Capacity Reservation only accepts instances that have + matching attributes (instance type, platform, and Availability Zone), + and explicitly target the Capacity Reservation. This ensures that only + permitted instances can use the reserved capacity. + + Default: open + type: string + instancePlatform: + description: The type of operating system for which to reserve capacity. + type: string + instanceType: + description: |- + The instance type for which to reserve capacity. For more information, see + Instance types (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html) + in the Amazon EC2 User Guide. + type: string + outpostARN: + description: |- + The Amazon Resource Name (ARN) of the Outpost on which to create the Capacity + Reservation. + type: string + placementGroupARN: + description: |- + The Amazon Resource Name (ARN) of the cluster placement group in which to + create the Capacity Reservation. For more information, see Capacity Reservations + for cluster placement groups (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/cr-cpg.html) + in the Amazon EC2 User Guide. + type: string + tags: + description: |- + The tags. The value parameter is required, but if you don't want the tag + to have a value, specify the parameter with no value, and we set the value + to an empty string. + items: + description: Describes a tag. + properties: + key: + type: string + value: + type: string + type: object + type: array + tenancy: + description: |- + Indicates the tenancy of the Capacity Reservation. A Capacity Reservation + can have one of the following tenancy settings: + + - default - The Capacity Reservation is created on hardware that is shared + with other Amazon Web Services accounts. + + - dedicated - The Capacity Reservation is created on single-tenant hardware + that is dedicated to a single Amazon Web Services account. + type: string + required: + - instanceCount + - instancePlatform + - instanceType + type: object + status: + description: CapacityReservationStatus defines the observed state of CapacityReservation + properties: + ackResourceMetadata: + description: |- + All CRs managed by ACK have a common `Status.ACKResourceMetadata` member + that is used to contain resource sync state, account ownership, + constructed ARN for the resource + properties: + arn: + description: |- + ARN is the Amazon Resource Name for the resource. This is a + globally-unique identifier and is set only by the ACK service controller + once the controller has orchestrated the creation of the resource OR + when it has verified that an "adopted" resource (a resource where the + ARN annotation was set by the Kubernetes user on the CR) exists and + matches the supplied CR's Spec field values. + https://github.com/aws/aws-controllers-k8s/issues/270 + type: string + ownerAccountID: + description: |- + OwnerAccountID is the AWS Account ID of the account that owns the + backend AWS service API resource. + type: string + region: + description: Region is the AWS region in which the resource exists + or will exist. + type: string + required: + - ownerAccountID + - region + type: object + availableInstanceCount: + description: |- + The remaining capacity. Indicates the number of instances that can be launched + in the Capacity Reservation. + format: int64 + type: integer + capacityReservationFleetID: + description: |- + The ID of the Capacity Reservation Fleet to which the Capacity Reservation + belongs. Only valid for Capacity Reservations that were created by a Capacity + Reservation Fleet. + type: string + capacityReservationID: + description: The ID of the Capacity Reservation. + type: string + conditions: + description: |- + All CRS managed by ACK have a common `Status.Conditions` member that + contains a collection of `ackv1alpha1.Condition` objects that describe + the various terminal states of the CR and its backend AWS service API + resource + items: + description: |- + Condition is the common struct used by all CRDs managed by ACK service + controllers to indicate terminal states of the CR and its backend AWS + service API resource + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. + format: date-time + type: string + message: + description: A human readable message indicating details about + the transition. + type: string + reason: + description: The reason for the condition's last transition. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type is the type of the Condition + type: string + required: + - status + - type + type: object + type: array + createDate: + description: The date and time at which the Capacity Reservation was + created. + format: date-time + type: string + ownerID: + description: The ID of the Amazon Web Services account that owns the + Capacity Reservation. + type: string + startDate: + description: The date and time at which the Capacity Reservation was + started. + format: date-time + type: string + state: + description: |- + The current state of the Capacity Reservation. A Capacity Reservation can + be in one of the following states: + + * active - The Capacity Reservation is active and the capacity is available + for your use. + + * expired - The Capacity Reservation expired automatically at the date + and time specified in your request. The reserved capacity is no longer + available for your use. + + * cancelled - The Capacity Reservation was cancelled. The reserved capacity + is no longer available for your use. + + * pending - The Capacity Reservation request was successful but the capacity + provisioning is still pending. + + * failed - The Capacity Reservation request has failed. A request might + fail due to invalid request parameters, capacity constraints, or instance + limit constraints. Failed requests are retained for 60 minutes. + type: string + totalInstanceCount: + description: |- + The total number of instances for which the Capacity Reservation reserves + capacity. + format: int64 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index 0efde9de..b8be053e 100644 --- a/helm/templates/NOTES.txt +++ b/helm/templates/NOTES.txt @@ -1,5 +1,5 @@ {{ .Chart.Name }} has been installed. -This chart deploys "public.ecr.aws/aws-controllers-k8s/ec2-controller:1.3.1". +This chart deploys "public.ecr.aws/aws-controllers-k8s/ec2-controller:1.3.2". Check its status by running: kubectl --namespace {{ .Release.Namespace }} get pods -l "app.kubernetes.io/instance={{ .Release.Name }}" diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index aa8afacd..f0e38abb 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -72,6 +72,7 @@ rules: - apiGroups: - ec2.services.k8s.aws resources: + - capacityreservations - dhcpoptions - elasticipaddresses - flowlogs @@ -98,6 +99,7 @@ rules: - apiGroups: - ec2.services.k8s.aws resources: + - capacityreservations/status - dhcpoptions/status - elasticipaddresses/status - flowlogs/status diff --git a/helm/templates/role-reader.yaml b/helm/templates/role-reader.yaml index e5d5b63e..c1f0e595 100644 --- a/helm/templates/role-reader.yaml +++ b/helm/templates/role-reader.yaml @@ -9,6 +9,7 @@ rules: - apiGroups: - ec2.services.k8s.aws resources: + - capacityreservations - dhcpoptions - elasticipaddresses - flowlogs diff --git a/helm/templates/role-writer.yaml b/helm/templates/role-writer.yaml index 56bac28f..7fa983db 100644 --- a/helm/templates/role-writer.yaml +++ b/helm/templates/role-writer.yaml @@ -9,6 +9,7 @@ rules: - apiGroups: - ec2.services.k8s.aws resources: + - capacityreservations - dhcpoptions - elasticipaddresses - flowlogs @@ -35,6 +36,7 @@ rules: - apiGroups: - ec2.services.k8s.aws resources: + - capacityreservations - dhcpoptions - elasticipaddresses - flowlogs diff --git a/helm/values.yaml b/helm/values.yaml index 0acbb523..195466ae 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -4,7 +4,7 @@ image: repository: public.ecr.aws/aws-controllers-k8s/ec2-controller - tag: 1.3.1 + tag: 1.3.2 pullPolicy: IfNotPresent pullSecrets: [] From a2c1d7f3277210d5ba4c6f3d4e5cd12b02a06437 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Thu, 23 Jan 2025 20:52:43 +1300 Subject: [PATCH 04/17] capacity_reservations_feature: Add hook to update tags --- apis/v1alpha1/ack-generate-metadata.yaml | 4 +- apis/v1alpha1/generator.yaml | 2 + generator.yaml | 2 + pkg/resource/capacity_reservation/hooks.go | 38 ++++++++++++++- pkg/resource/capacity_reservation/sdk.go | 54 +--------------------- 5 files changed, 45 insertions(+), 55 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 2091bf83..a15cdbbf 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,5 +1,5 @@ ack_generate_info: - build_date: "2025-01-21T07:10:38Z" + build_date: "2025-01-23T07:47:53Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 go_version: go1.23.4 version: 631aeb1-dirty @@ -7,7 +7,7 @@ api_directory_checksum: 941d1827a80332faefb389464dc0f14274772ef8 api_version: v1alpha1 aws_sdk_go_version: v1.44.93 generator_config_info: - file_checksum: 77d1b8c928fa077f4b824329cf3190e8d8728fdf + file_checksum: 54483f09380cf1a8296d7565b252781274537cd4 original_file_name: generator.yaml last_modification: reason: API generation diff --git a/apis/v1alpha1/generator.yaml b/apis/v1alpha1/generator.yaml index 8922e4be..df2d6033 100644 --- a/apis/v1alpha1/generator.yaml +++ b/apis/v1alpha1/generator.yaml @@ -226,6 +226,8 @@ resources: hooks: sdk_create_post_build_request: template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl + update_operation: + custom_method_name: customUpdateCapacityReservation DhcpOptions: exceptions: terminal_codes: diff --git a/generator.yaml b/generator.yaml index 8922e4be..df2d6033 100644 --- a/generator.yaml +++ b/generator.yaml @@ -226,6 +226,8 @@ resources: hooks: sdk_create_post_build_request: template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl + update_operation: + custom_method_name: customUpdateCapacityReservation DhcpOptions: exceptions: terminal_codes: diff --git a/pkg/resource/capacity_reservation/hooks.go b/pkg/resource/capacity_reservation/hooks.go index 13594e46..37353cb3 100644 --- a/pkg/resource/capacity_reservation/hooks.go +++ b/pkg/resource/capacity_reservation/hooks.go @@ -1,6 +1,42 @@ package capacity_reservation -import svcsdk "github.com/aws/aws-sdk-go/service/ec2" +import ( + "context" + + "github.com/aws-controllers-k8s/ec2-controller/pkg/tags" + ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare" + ackrtlog "github.com/aws-controllers-k8s/runtime/pkg/runtime/log" + svcsdk "github.com/aws/aws-sdk-go/service/ec2" +) + +func (rm *resourceManager) customUpdateCapacityReservation( + ctx context.Context, + desired *resource, + latest *resource, + delta *ackcompare.Delta, +) (updated *resource, err error) { + rlog := ackrtlog.FromContext(ctx) + exit := rlog.Trace("rm.customUpdateCapacityReservation") + defer exit(err) + + // Default `updated` to `desired` because it is likely + // EC2 `modify` APIs do NOT return output, only errors. + // If the `modify` calls (i.e. `sync`) do NOT return + // an error, then the update was successful and desired.Spec + // (now updated.Spec) reflects the latest resource state. + updated = rm.concreteResource(desired.DeepCopy()) + + if delta.DifferentAt("Spec.Tags") { + if err := tags.Sync( + ctx, rm.sdkapi, rm.metrics, *latest.ko.Status.CapacityReservationID, + desired.ko.Spec.Tags, latest.ko.Spec.Tags, + ); err != nil { + return nil, err + } + } + + return updated, nil +} // updateTagSpecificationsInCreateRequest adds // Tags defined in the Spec to CreateCapacityReservationInput.TagSpecifications diff --git a/pkg/resource/capacity_reservation/sdk.go b/pkg/resource/capacity_reservation/sdk.go index c73f4661..a1e66fb8 100644 --- a/pkg/resource/capacity_reservation/sdk.go +++ b/pkg/resource/capacity_reservation/sdk.go @@ -472,58 +472,8 @@ func (rm *resourceManager) sdkUpdate( desired *resource, latest *resource, delta *ackcompare.Delta, -) (updated *resource, err error) { - rlog := ackrtlog.FromContext(ctx) - exit := rlog.Trace("rm.sdkUpdate") - defer func() { - exit(err) - }() - input, err := rm.newUpdateRequestPayload(ctx, desired, delta) - if err != nil { - return nil, err - } - - var resp *svcsdk.ModifyCapacityReservationOutput - _ = resp - resp, err = rm.sdkapi.ModifyCapacityReservationWithContext(ctx, input) - rm.metrics.RecordAPICall("UPDATE", "ModifyCapacityReservation", err) - if err != nil { - return nil, err - } - // Merge in the information we read from the API call above to the copy of - // the original Kubernetes object we passed to the function - ko := desired.ko.DeepCopy() - - rm.setStatusDefaults(ko) - return &resource{ko}, nil -} - -// newUpdateRequestPayload returns an SDK-specific struct for the HTTP request -// payload of the Update API call for the resource -func (rm *resourceManager) newUpdateRequestPayload( - ctx context.Context, - r *resource, - delta *ackcompare.Delta, -) (*svcsdk.ModifyCapacityReservationInput, error) { - res := &svcsdk.ModifyCapacityReservationInput{} - - if r.ko.Status.CapacityReservationID != nil { - res.SetCapacityReservationId(*r.ko.Status.CapacityReservationID) - } - if r.ko.Spec.DryRun != nil { - res.SetDryRun(*r.ko.Spec.DryRun) - } - if r.ko.Spec.EndDate != nil { - res.SetEndDate(r.ko.Spec.EndDate.Time) - } - if r.ko.Spec.EndDateType != nil { - res.SetEndDateType(*r.ko.Spec.EndDateType) - } - if r.ko.Spec.InstanceCount != nil { - res.SetInstanceCount(*r.ko.Spec.InstanceCount) - } - - return res, nil +) (*resource, error) { + return rm.customUpdateCapacityReservation(ctx, desired, latest, delta) } // sdkDelete deletes the supplied resource in the backend AWS service API From 3192dbd0e5979fe79b32332bb17fba84522913e4 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Thu, 23 Jan 2025 21:21:47 +1300 Subject: [PATCH 05/17] capacity_reservations_feature: Update generator.yaml to add delete function --- apis/v1alpha1/ack-generate-metadata.yaml | 4 ++-- apis/v1alpha1/generator.yaml | 4 ++++ generator.yaml | 4 ++++ pkg/resource/capacity_reservation/sdk.go | 27 ++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index a15cdbbf..c6ada76e 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,5 +1,5 @@ ack_generate_info: - build_date: "2025-01-23T07:47:53Z" + build_date: "2025-01-23T08:17:25Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 go_version: go1.23.4 version: 631aeb1-dirty @@ -7,7 +7,7 @@ api_directory_checksum: 941d1827a80332faefb389464dc0f14274772ef8 api_version: v1alpha1 aws_sdk_go_version: v1.44.93 generator_config_info: - file_checksum: 54483f09380cf1a8296d7565b252781274537cd4 + file_checksum: 3bb016df683d1aaea775c558cf38c4047359467f original_file_name: generator.yaml last_modification: reason: API generation diff --git a/apis/v1alpha1/generator.yaml b/apis/v1alpha1/generator.yaml index df2d6033..2cd3a351 100644 --- a/apis/v1alpha1/generator.yaml +++ b/apis/v1alpha1/generator.yaml @@ -148,6 +148,10 @@ operations: operation_type: - Create resource_name: ElasticIPAddress + CancelCapacityReservation: + operation_type: + - Delete + resource_name: CapacityReservation DescribeAddresses: operation_type: - List diff --git a/generator.yaml b/generator.yaml index df2d6033..2cd3a351 100644 --- a/generator.yaml +++ b/generator.yaml @@ -148,6 +148,10 @@ operations: operation_type: - Create resource_name: ElasticIPAddress + CancelCapacityReservation: + operation_type: + - Delete + resource_name: CapacityReservation DescribeAddresses: operation_type: - List diff --git a/pkg/resource/capacity_reservation/sdk.go b/pkg/resource/capacity_reservation/sdk.go index a1e66fb8..8b0c6357 100644 --- a/pkg/resource/capacity_reservation/sdk.go +++ b/pkg/resource/capacity_reservation/sdk.go @@ -486,9 +486,32 @@ func (rm *resourceManager) sdkDelete( defer func() { exit(err) }() - // TODO(jaypipes): Figure this out... - return nil, nil + input, err := rm.newDeleteRequestPayload(r) + if err != nil { + return nil, err + } + var resp *svcsdk.CancelCapacityReservationOutput + _ = resp + resp, err = rm.sdkapi.CancelCapacityReservationWithContext(ctx, input) + rm.metrics.RecordAPICall("DELETE", "CancelCapacityReservation", err) + return nil, err +} + +// newDeleteRequestPayload returns an SDK-specific struct for the HTTP request +// payload of the Delete API call for the resource +func (rm *resourceManager) newDeleteRequestPayload( + r *resource, +) (*svcsdk.CancelCapacityReservationInput, error) { + res := &svcsdk.CancelCapacityReservationInput{} + if r.ko.Status.CapacityReservationID != nil { + res.SetCapacityReservationId(*r.ko.Status.CapacityReservationID) + } + if r.ko.Spec.DryRun != nil { + res.SetDryRun(*r.ko.Spec.DryRun) + } + + return res, nil } // setStatusDefaults sets default properties into supplied custom resource From 3bca0cfcd16d16b59cbb62d870b74dd9827dd8f2 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Fri, 24 Jan 2025 12:41:50 +1300 Subject: [PATCH 06/17] capacity_reservations_feature: Update metadata --- apis/v1alpha1/ack-generate-metadata.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index c6ada76e..18845772 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,5 +1,5 @@ ack_generate_info: - build_date: "2025-01-23T08:17:25Z" + build_date: "2025-01-23T23:37:25Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 go_version: go1.23.4 version: 631aeb1-dirty From 79401e2476f7e268447f178ff61b09fd4ce84e03 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Fri, 24 Jan 2025 16:07:11 +1300 Subject: [PATCH 07/17] capacity_reservations_feature: Add additional printer columns --- apis/v1alpha1/ack-generate-metadata.yaml | 6 +++--- apis/v1alpha1/capacity_reservation.go | 3 +++ apis/v1alpha1/generator.yaml | 9 +++++++++ .../ec2.services.k8s.aws_capacityreservations.yaml | 12 +++++++++++- generator.yaml | 9 +++++++++ .../ec2.services.k8s.aws_capacityreservations.yaml | 12 +++++++++++- 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 18845772..bece443a 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,13 +1,13 @@ ack_generate_info: - build_date: "2025-01-23T23:37:25Z" + build_date: "2025-01-24T03:02:40Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 go_version: go1.23.4 version: 631aeb1-dirty -api_directory_checksum: 941d1827a80332faefb389464dc0f14274772ef8 +api_directory_checksum: f1edcbbbc96a40924bad556dbeeeaedd78affb6e api_version: v1alpha1 aws_sdk_go_version: v1.44.93 generator_config_info: - file_checksum: 3bb016df683d1aaea775c558cf38c4047359467f + file_checksum: da955f4a6028f6368718889a269b70beb11338b4 original_file_name: generator.yaml last_modification: reason: API generation diff --git a/apis/v1alpha1/capacity_reservation.go b/apis/v1alpha1/capacity_reservation.go index 3737c2a7..9b235e08 100644 --- a/apis/v1alpha1/capacity_reservation.go +++ b/apis/v1alpha1/capacity_reservation.go @@ -183,6 +183,9 @@ type CapacityReservationStatus struct { // CapacityReservation is the Schema for the CapacityReservations API // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="ID",type=string,priority=0,JSONPath=`.status.capacityReservationID` +// +kubebuilder:printcolumn:name="START_DATE",type=date,priority=0,JSONPath=`.status.startDate` +// +kubebuilder:printcolumn:name="STATE",type=string,priority=0,JSONPath=`.status.state` type CapacityReservation struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/apis/v1alpha1/generator.yaml b/apis/v1alpha1/generator.yaml index 2cd3a351..67fb2df0 100644 --- a/apis/v1alpha1/generator.yaml +++ b/apis/v1alpha1/generator.yaml @@ -227,6 +227,15 @@ resources: from: operation: CreateTags path: Tags + CapacityReservationID: + print: + name: ID + State: + print: + name: STATE + StartDate: + print: + name: START_DATE hooks: sdk_create_post_build_request: template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl diff --git a/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml b/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml index dd930db6..720ef3dc 100644 --- a/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml +++ b/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml @@ -14,7 +14,17 @@ spec: singular: capacityreservation scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - jsonPath: .status.capacityReservationID + name: ID + type: string + - jsonPath: .status.startDate + name: START_DATE + type: date + - jsonPath: .status.state + name: STATE + type: string + name: v1alpha1 schema: openAPIV3Schema: description: CapacityReservation is the Schema for the CapacityReservations diff --git a/generator.yaml b/generator.yaml index 2cd3a351..67fb2df0 100644 --- a/generator.yaml +++ b/generator.yaml @@ -227,6 +227,15 @@ resources: from: operation: CreateTags path: Tags + CapacityReservationID: + print: + name: ID + State: + print: + name: STATE + StartDate: + print: + name: START_DATE hooks: sdk_create_post_build_request: template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl diff --git a/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml b/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml index b39a1f3c..d20b6e02 100644 --- a/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml +++ b/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml @@ -14,7 +14,17 @@ spec: singular: capacityreservation scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - jsonPath: .status.capacityReservationID + name: ID + type: string + - jsonPath: .status.startDate + name: START_DATE + type: date + - jsonPath: .status.state + name: STATE + type: string + name: v1alpha1 schema: openAPIV3Schema: description: CapacityReservation is the Schema for the CapacityReservations From 0a650bbad55a1371be641c2a4bb8b38675be6a94 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Sun, 26 Jan 2025 13:52:56 +1300 Subject: [PATCH 08/17] capacity_reservations_feature: Fix update logic to update tags and other fields --- apis/v1alpha1/ack-generate-metadata.yaml | 4 +- apis/v1alpha1/generator.yaml | 4 +- generator.yaml | 4 +- pkg/resource/capacity_reservation/hooks.go | 33 +-------- pkg/resource/capacity_reservation/sdk.go | 69 ++++++++++++++++++- .../sdk_update_pre_build_request.go.tpl | 14 ++++ 6 files changed, 88 insertions(+), 40 deletions(-) create mode 100644 templates/hooks/capacity_reservation/sdk_update_pre_build_request.go.tpl diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index bece443a..ab63e33d 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,5 +1,5 @@ ack_generate_info: - build_date: "2025-01-24T03:02:40Z" + build_date: "2025-01-26T00:41:01Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 go_version: go1.23.4 version: 631aeb1-dirty @@ -7,7 +7,7 @@ api_directory_checksum: f1edcbbbc96a40924bad556dbeeeaedd78affb6e api_version: v1alpha1 aws_sdk_go_version: v1.44.93 generator_config_info: - file_checksum: da955f4a6028f6368718889a269b70beb11338b4 + file_checksum: c8bc70104ea03c09dbaced37967eb1e9fa66dcba original_file_name: generator.yaml last_modification: reason: API generation diff --git a/apis/v1alpha1/generator.yaml b/apis/v1alpha1/generator.yaml index 67fb2df0..826a82f8 100644 --- a/apis/v1alpha1/generator.yaml +++ b/apis/v1alpha1/generator.yaml @@ -239,8 +239,8 @@ resources: hooks: sdk_create_post_build_request: template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl - update_operation: - custom_method_name: customUpdateCapacityReservation + sdk_update_pre_build_request: + template_path: hooks/capacity_reservation/sdk_update_pre_build_request.go.tpl DhcpOptions: exceptions: terminal_codes: diff --git a/generator.yaml b/generator.yaml index 67fb2df0..826a82f8 100644 --- a/generator.yaml +++ b/generator.yaml @@ -239,8 +239,8 @@ resources: hooks: sdk_create_post_build_request: template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl - update_operation: - custom_method_name: customUpdateCapacityReservation + sdk_update_pre_build_request: + template_path: hooks/capacity_reservation/sdk_update_pre_build_request.go.tpl DhcpOptions: exceptions: terminal_codes: diff --git a/pkg/resource/capacity_reservation/hooks.go b/pkg/resource/capacity_reservation/hooks.go index 37353cb3..aacf76f6 100644 --- a/pkg/resource/capacity_reservation/hooks.go +++ b/pkg/resource/capacity_reservation/hooks.go @@ -1,42 +1,11 @@ package capacity_reservation import ( - "context" - "github.com/aws-controllers-k8s/ec2-controller/pkg/tags" - ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare" - ackrtlog "github.com/aws-controllers-k8s/runtime/pkg/runtime/log" svcsdk "github.com/aws/aws-sdk-go/service/ec2" ) -func (rm *resourceManager) customUpdateCapacityReservation( - ctx context.Context, - desired *resource, - latest *resource, - delta *ackcompare.Delta, -) (updated *resource, err error) { - rlog := ackrtlog.FromContext(ctx) - exit := rlog.Trace("rm.customUpdateCapacityReservation") - defer exit(err) - - // Default `updated` to `desired` because it is likely - // EC2 `modify` APIs do NOT return output, only errors. - // If the `modify` calls (i.e. `sync`) do NOT return - // an error, then the update was successful and desired.Spec - // (now updated.Spec) reflects the latest resource state. - updated = rm.concreteResource(desired.DeepCopy()) - - if delta.DifferentAt("Spec.Tags") { - if err := tags.Sync( - ctx, rm.sdkapi, rm.metrics, *latest.ko.Status.CapacityReservationID, - desired.ko.Spec.Tags, latest.ko.Spec.Tags, - ); err != nil { - return nil, err - } - } - - return updated, nil -} +var syncTags = tags.Sync // updateTagSpecificationsInCreateRequest adds // Tags defined in the Spec to CreateCapacityReservationInput.TagSpecifications diff --git a/pkg/resource/capacity_reservation/sdk.go b/pkg/resource/capacity_reservation/sdk.go index 8b0c6357..c0dcf453 100644 --- a/pkg/resource/capacity_reservation/sdk.go +++ b/pkg/resource/capacity_reservation/sdk.go @@ -472,8 +472,73 @@ func (rm *resourceManager) sdkUpdate( desired *resource, latest *resource, delta *ackcompare.Delta, -) (*resource, error) { - return rm.customUpdateCapacityReservation(ctx, desired, latest, delta) +) (updated *resource, err error) { + rlog := ackrtlog.FromContext(ctx) + exit := rlog.Trace("rm.sdkUpdate") + defer func() { + exit(err) + }() + + if delta.DifferentAt("Spec.Tags") { + if err := syncTags( + ctx, rm.sdkapi, rm.metrics, *latest.ko.Status.CapacityReservationID, + desired.ko.Spec.Tags, latest.ko.Spec.Tags, + ); err != nil { + return nil, err + } + } + + // Only continue if something other than Tags has changed in the Spec + if !delta.DifferentExcept("Spec.Tags") { + return desired, nil + } + + input, err := rm.newUpdateRequestPayload(ctx, desired, delta) + if err != nil { + return nil, err + } + + var resp *svcsdk.ModifyCapacityReservationOutput + _ = resp + resp, err = rm.sdkapi.ModifyCapacityReservationWithContext(ctx, input) + rm.metrics.RecordAPICall("UPDATE", "ModifyCapacityReservation", err) + if err != nil { + return nil, err + } + // Merge in the information we read from the API call above to the copy of + // the original Kubernetes object we passed to the function + ko := desired.ko.DeepCopy() + + rm.setStatusDefaults(ko) + return &resource{ko}, nil +} + +// newUpdateRequestPayload returns an SDK-specific struct for the HTTP request +// payload of the Update API call for the resource +func (rm *resourceManager) newUpdateRequestPayload( + ctx context.Context, + r *resource, + delta *ackcompare.Delta, +) (*svcsdk.ModifyCapacityReservationInput, error) { + res := &svcsdk.ModifyCapacityReservationInput{} + + if r.ko.Status.CapacityReservationID != nil { + res.SetCapacityReservationId(*r.ko.Status.CapacityReservationID) + } + if r.ko.Spec.DryRun != nil { + res.SetDryRun(*r.ko.Spec.DryRun) + } + if r.ko.Spec.EndDate != nil { + res.SetEndDate(r.ko.Spec.EndDate.Time) + } + if r.ko.Spec.EndDateType != nil { + res.SetEndDateType(*r.ko.Spec.EndDateType) + } + if r.ko.Spec.InstanceCount != nil { + res.SetInstanceCount(*r.ko.Spec.InstanceCount) + } + + return res, nil } // sdkDelete deletes the supplied resource in the backend AWS service API diff --git a/templates/hooks/capacity_reservation/sdk_update_pre_build_request.go.tpl b/templates/hooks/capacity_reservation/sdk_update_pre_build_request.go.tpl new file mode 100644 index 00000000..c70e62ab --- /dev/null +++ b/templates/hooks/capacity_reservation/sdk_update_pre_build_request.go.tpl @@ -0,0 +1,14 @@ + + if delta.DifferentAt("Spec.Tags") { + if err := syncTags( + ctx, rm.sdkapi, rm.metrics, *latest.ko.Status.CapacityReservationID, + desired.ko.Spec.Tags, latest.ko.Spec.Tags, + ); err != nil { + return nil, err + } + } + + // Only continue if something other than Tags has changed in the Spec + if !delta.DifferentExcept("Spec.Tags") { + return desired, nil + } From f31792899b4acacb95e8ead99f3d051b1dff3d2f Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Wed, 29 Jan 2025 12:37:59 +1300 Subject: [PATCH 09/17] capacity_reservations_feature: Modify update logic to immediately fetch resource --- apis/v1alpha1/ack-generate-metadata.yaml | 4 ++-- apis/v1alpha1/generator.yaml | 2 ++ generator.yaml | 2 ++ pkg/resource/capacity_reservation/sdk.go | 11 +++++++++++ .../sdk_update_post_set_output.go.tpl | 10 ++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 templates/hooks/capacity_reservation/sdk_update_post_set_output.go.tpl diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index ab63e33d..0b7be1fa 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,5 +1,5 @@ ack_generate_info: - build_date: "2025-01-26T00:41:01Z" + build_date: "2025-01-28T23:32:32Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 go_version: go1.23.4 version: 631aeb1-dirty @@ -7,7 +7,7 @@ api_directory_checksum: f1edcbbbc96a40924bad556dbeeeaedd78affb6e api_version: v1alpha1 aws_sdk_go_version: v1.44.93 generator_config_info: - file_checksum: c8bc70104ea03c09dbaced37967eb1e9fa66dcba + file_checksum: 763200d3677a57874be1b3630e229e25d94dd7b5 original_file_name: generator.yaml last_modification: reason: API generation diff --git a/apis/v1alpha1/generator.yaml b/apis/v1alpha1/generator.yaml index 826a82f8..e6d5f312 100644 --- a/apis/v1alpha1/generator.yaml +++ b/apis/v1alpha1/generator.yaml @@ -241,6 +241,8 @@ resources: template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl sdk_update_pre_build_request: template_path: hooks/capacity_reservation/sdk_update_pre_build_request.go.tpl + sdk_update_post_set_output: + template_path: hooks/capacity_reservation/sdk_update_post_set_output.go.tpl DhcpOptions: exceptions: terminal_codes: diff --git a/generator.yaml b/generator.yaml index 826a82f8..e6d5f312 100644 --- a/generator.yaml +++ b/generator.yaml @@ -241,6 +241,8 @@ resources: template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl sdk_update_pre_build_request: template_path: hooks/capacity_reservation/sdk_update_pre_build_request.go.tpl + sdk_update_post_set_output: + template_path: hooks/capacity_reservation/sdk_update_post_set_output.go.tpl DhcpOptions: exceptions: terminal_codes: diff --git a/pkg/resource/capacity_reservation/sdk.go b/pkg/resource/capacity_reservation/sdk.go index c0dcf453..78aaa538 100644 --- a/pkg/resource/capacity_reservation/sdk.go +++ b/pkg/resource/capacity_reservation/sdk.go @@ -510,6 +510,17 @@ func (rm *resourceManager) sdkUpdate( ko := desired.ko.DeepCopy() rm.setStatusDefaults(ko) + + // Explicitly call sdkFind to fetch the latest resource state + latestCopy, err := rm.sdkFind(ctx, desired) + if err != nil { + return nil, err + } + + ko.Status.AvailableInstanceCount = latestCopy.ko.Status.AvailableInstanceCount + ko.Status.TotalInstanceCount = latestCopy.ko.Status.TotalInstanceCount + ko.Status.State = latestCopy.ko.Status.State + return &resource{ko}, nil } diff --git a/templates/hooks/capacity_reservation/sdk_update_post_set_output.go.tpl b/templates/hooks/capacity_reservation/sdk_update_post_set_output.go.tpl new file mode 100644 index 00000000..c66db5db --- /dev/null +++ b/templates/hooks/capacity_reservation/sdk_update_post_set_output.go.tpl @@ -0,0 +1,10 @@ + + // Explicitly call sdkFind to fetch the latest resource state + latestCopy, err := rm.sdkFind(ctx, desired) + if err != nil { + return nil, err + } + + ko.Status.AvailableInstanceCount = latestCopy.ko.Status.AvailableInstanceCount + ko.Status.TotalInstanceCount = latestCopy.ko.Status.TotalInstanceCount + ko.Status.State = latestCopy.ko.Status.State From 604229abce79e586992085165d1087c74a02a3cd Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Wed, 29 Jan 2025 13:47:02 +1300 Subject: [PATCH 10/17] capacity_reservations_feature: Add tests for capacity reservation CRUD operations --- test/e2e/resources/capacity_reservation.yaml | 12 ++ test/e2e/tests/helper.py | 24 +++- test/e2e/tests/test_capacity_reservation.py | 115 +++++++++++++++++++ 3 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 test/e2e/resources/capacity_reservation.yaml create mode 100644 test/e2e/tests/test_capacity_reservation.py diff --git a/test/e2e/resources/capacity_reservation.yaml b/test/e2e/resources/capacity_reservation.yaml new file mode 100644 index 00000000..3279661d --- /dev/null +++ b/test/e2e/resources/capacity_reservation.yaml @@ -0,0 +1,12 @@ +apiVersion: ec2.services.k8s.aws/v1alpha1 +kind: CapacityReservation +metadata: + name: $RESERVATION_NAME +spec: + instanceType: $INSTANCE_TYPE + instancePlatform: $INSTANCE_PLATFORM + instanceCount: $INSTANCE_COUNT + availabilityZone: "$AVAILABILITY_ZONE" + tags: + - key: $TAG_KEY + value: $TAG_VALUE \ No newline at end of file diff --git a/test/e2e/tests/helper.py b/test/e2e/tests/helper.py index fb08655f..10bf2f25 100644 --- a/test/e2e/tests/helper.py +++ b/test/e2e/tests/helper.py @@ -297,4 +297,26 @@ def assert_vpc_peering_connection(self, vpc_peering_connection_id: str, exists=T pass assert (res_found is exists or - aws_res["VpcPeeringConnections"][0]["Status"]["Code"] == "deleted") \ No newline at end of file + aws_res["VpcPeeringConnections"][0]["Status"]["Code"] == "deleted") + + def get_capacity_reservation(self, capacity_reservation_id: str) -> Union[None, Dict]: + try: + aws_res = self.ec2_client.describe_capacity_reservations( + CapacityReservationIds=[capacity_reservation_id] + ) + if len(aws_res["CapacityReservations"]) > 0: + return aws_res["CapacityReservations"][0] + return None + except self.ec2_client.exceptions.ClientError: + return None + + def assert_capacity_reservation(self, capacity_reservation_id: str, exists=True): + res_found = False + try: + aws_res = self.ec2_client.describe_capacity_reservations(CapacityReservationIds=[capacity_reservation_id]) + res_found = len(aws_res["CapacityReservations"]) > 0 + except self.ec2_client.exceptions.ClientError: + pass + assert (res_found is exists + or + aws_res["CapacityReservations"][0]["State"] == "cancelled") \ No newline at end of file diff --git a/test/e2e/tests/test_capacity_reservation.py b/test/e2e/tests/test_capacity_reservation.py new file mode 100644 index 00000000..0d689c3f --- /dev/null +++ b/test/e2e/tests/test_capacity_reservation.py @@ -0,0 +1,115 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You may +# not use this file except in compliance with the License. A copy of the +# License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file 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. + +"""Integration tests for Capacity Reservations API. +""" + +import pytest +import time +import logging + +from acktest import tags +from acktest.resources import random_suffix_name +from acktest.k8s import resource as k8s +from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_ec2_resource +from e2e.replacement_values import REPLACEMENT_VALUES +from e2e.tests.helper import EC2Validator + +RESOURCE_PLURAL = "capacityreservations" + +CREATE_WAIT_AFTER_SECONDS = 10 +DELETE_WAIT_AFTER_SECONDS = 10 +MODIFY_WAIT_AFTER_SECONDS = 5 + +@pytest.fixture +def simple_capacity_reservation(request): + resource_name = random_suffix_name("cr-ack-test", 24) + + replacements = REPLACEMENT_VALUES.copy() + replacements["RESERVATION_NAME"] = resource_name + replacements["INSTANCE_TYPE"] = "t2.nano" + replacements["INSTANCE_PLATFORM"] = "Linux/UNIX" + replacements["INSTANCE_COUNT"] = "1" + replacements["AVAILABILITY_ZONE"] = "us-west-2a" + + marker = request.node.get_closest_marker("resource_data") + if marker is not None: + data = marker.args[0] + if 'tag_key' in data: + replacements["TAG_KEY"] = data['tag_key'] + if 'tag_value' in data: + replacements["TAG_VALUE"] = data['tag_value'] + + # Load CapacityReservation CR + resource_data = load_ec2_resource( + "capacity_reservation", + additional_replacements=replacements, + ) + logging.debug(resource_data) + + # Create k8s resource + ref = k8s.CustomResourceReference( + CRD_GROUP, CRD_VERSION, RESOURCE_PLURAL, + resource_name, namespace="default", + ) + k8s.create_custom_resource(ref, resource_data) + time.sleep(CREATE_WAIT_AFTER_SECONDS) + + cr = k8s.wait_resource_consumed_by_controller(ref) + assert cr is not None + assert k8s.get_resource_exists(ref) + + yield (ref, cr) + + # Try to delete, if doesn't already exist + try: + _, deleted = k8s.delete_custom_resource(ref, 3, 10) + assert deleted + except: + pass + +@service_marker +@pytest.mark.canary +class TestCapacityReservation: + def test_crud(self, ec2_client, simple_capacity_reservation): + (ref, cr) = simple_capacity_reservation + resource_id = cr["status"]["capacityReservationID"] + + # Check CapacityReservation exists in AWS + ec2_validator = EC2Validator(ec2_client) + ec2_validator.assert_capacity_reservation(resource_id) + + # Patch the capacity reservation + updates = { + "spec": {"instanceCount": 2}, + } + k8s.patch_custom_resource(ref, updates) + time.sleep(MODIFY_WAIT_AFTER_SECONDS) + + # Check resource synced successfully + assert k8s.wait_on_condition(ref, "ACK.ResourceSynced", "True", wait_periods=5) + capacity_reservation = ec2_validator.get_capacity_reservation(resource_id) + assert capacity_reservation['TotalInstanceCount'] == 2 + + resource = k8s.get_resource(ref) + assert resource["spec"]["instanceCount"] == resource["status"]["totalInstanceCount"] + + # Delete k8s resource + _, deleted = k8s.delete_custom_resource(ref, 2, 5) + assert deleted is True + + time.sleep(DELETE_WAIT_AFTER_SECONDS) + + # Check CapacityReservation no longer exists in AWS + ec2_validator.assert_capacity_reservation(resource_id, exists=False) + From c3f284f0caa3f2f4b19aaa7abb50ef1492b686f9 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Wed, 29 Jan 2025 14:03:28 +1300 Subject: [PATCH 11/17] capacity_reservations_feature: Add tests for capacity reservation CRUD operations for Tags --- test/e2e/tests/test_capacity_reservation.py | 102 ++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/test/e2e/tests/test_capacity_reservation.py b/test/e2e/tests/test_capacity_reservation.py index 0d689c3f..a7e36489 100644 --- a/test/e2e/tests/test_capacity_reservation.py +++ b/test/e2e/tests/test_capacity_reservation.py @@ -113,3 +113,105 @@ def test_crud(self, ec2_client, simple_capacity_reservation): # Check CapacityReservation no longer exists in AWS ec2_validator.assert_capacity_reservation(resource_id, exists=False) + @pytest.mark.resource_data({'tag_key': 'initialtagkey', 'tag_value': 'initialtagvalue'}) + def test_crud_tags(self, ec2_client, simple_capacity_reservation): + (ref, cr) = simple_capacity_reservation + + resource = k8s.get_resource(ref) + resource_id = cr["status"]["capacityReservationID"] + + time.sleep(CREATE_WAIT_AFTER_SECONDS) + + # Check CapacityReservation exists in AWS + ec2_validator = EC2Validator(ec2_client) + ec2_validator.assert_capacity_reservation(resource_id) + + # Check system and user tags exist for capacity reservation resource + capacity_reservation = ec2_validator.get_capacity_reservation(resource_id) + user_tags = { + "initialtagkey": "initialtagvalue" + } + tags.assert_ack_system_tags( + tags=capacity_reservation["Tags"], + ) + tags.assert_equal_without_ack_tags( + expected=user_tags, + actual=capacity_reservation["Tags"], + ) + + # Only user tags should be present in Spec + assert len(resource["spec"]["tags"]) == 1 + assert resource["spec"]["tags"][0]["key"] == "initialtagkey" + assert resource["spec"]["tags"][0]["value"] == "initialtagvalue" + + # Update tags + update_tags = [ + { + "key": "updatedtagkey", + "value": "updatedtagvalue", + } + ] + + # Patch the capacity reservation, updating the tags with new pair + updates = { + "spec": {"tags": update_tags}, + } + + k8s.patch_custom_resource(ref, updates) + time.sleep(MODIFY_WAIT_AFTER_SECONDS) + + # Check resource synced successfully + assert k8s.wait_on_condition(ref, "ACK.ResourceSynced", "True", wait_periods=5) + + # Check for updated user tags; system tags should persist + capacity_reservation = ec2_validator.get_capacity_reservation(resource_id) + updated_tags = { + "updatedtagkey": "updatedtagvalue" + } + tags.assert_ack_system_tags( + tags=capacity_reservation["Tags"], + ) + tags.assert_equal_without_ack_tags( + expected=updated_tags, + actual=capacity_reservation["Tags"], + ) + + # Only user tags should be present in Spec + resource = k8s.get_resource(ref) + assert len(resource["spec"]["tags"]) == 1 + assert resource["spec"]["tags"][0]["key"] == "updatedtagkey" + assert resource["spec"]["tags"][0]["value"] == "updatedtagvalue" + + # Patch the capacity reservation resource, deleting the tags + updates = { + "spec": {"tags": []}, + } + + k8s.patch_custom_resource(ref, updates) + time.sleep(MODIFY_WAIT_AFTER_SECONDS) + + # Check resource synced successfully + assert k8s.wait_on_condition(ref, "ACK.ResourceSynced", "True", wait_periods=5) + + # Check for removed user tags; system tags should persist + capacity_reservation = ec2_validator.get_capacity_reservation(resource_id) + tags.assert_ack_system_tags( + tags=capacity_reservation["Tags"], + ) + tags.assert_equal_without_ack_tags( + expected=[], + actual=capacity_reservation["Tags"], + ) + + # Check user tags are removed from Spec + resource = k8s.get_resource(ref) + assert len(resource["spec"]["tags"]) == 0 + + # Delete k8s resource + _, deleted = k8s.delete_custom_resource(ref) + assert deleted is True + + time.sleep(DELETE_WAIT_AFTER_SECONDS) + + # Check capacity reservation no longer exists in AWS + ec2_validator.assert_capacity_reservation(resource_id, exists=False) From 1215ef0ac418aead9e4fdcbf3430aec730a41b50 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Wed, 29 Jan 2025 14:24:53 +1300 Subject: [PATCH 12/17] capacity_reservations_feature: latest build date --- apis/v1alpha1/ack-generate-metadata.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 0b7be1fa..25a16090 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,5 +1,5 @@ ack_generate_info: - build_date: "2025-01-28T23:32:32Z" + build_date: "2025-01-29T01:23:39Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 go_version: go1.23.4 version: 631aeb1-dirty From 5f6920067398b8a9132a073d437a16ea6f455791 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Wed, 29 Jan 2025 14:37:00 +1300 Subject: [PATCH 13/17] capacity_reservations_feature: add newlines --- apis/v1alpha1/ack-generate-metadata.yaml | 2 +- test/e2e/resources/capacity_reservation.yaml | 2 +- test/e2e/tests/helper.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 25a16090..938a4829 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,5 +1,5 @@ ack_generate_info: - build_date: "2025-01-29T01:23:39Z" + build_date: "2025-01-29T01:33:01Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 go_version: go1.23.4 version: 631aeb1-dirty diff --git a/test/e2e/resources/capacity_reservation.yaml b/test/e2e/resources/capacity_reservation.yaml index 3279661d..285cc145 100644 --- a/test/e2e/resources/capacity_reservation.yaml +++ b/test/e2e/resources/capacity_reservation.yaml @@ -9,4 +9,4 @@ spec: availabilityZone: "$AVAILABILITY_ZONE" tags: - key: $TAG_KEY - value: $TAG_VALUE \ No newline at end of file + value: $TAG_VALUE diff --git a/test/e2e/tests/helper.py b/test/e2e/tests/helper.py index 10bf2f25..14d001c1 100644 --- a/test/e2e/tests/helper.py +++ b/test/e2e/tests/helper.py @@ -319,4 +319,4 @@ def assert_capacity_reservation(self, capacity_reservation_id: str, exists=True) pass assert (res_found is exists or - aws_res["CapacityReservations"][0]["State"] == "cancelled") \ No newline at end of file + aws_res["CapacityReservations"][0]["State"] == "cancelled") From b82039070e54b789c5a1f5c14b61f02c64d2745a Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Fri, 31 Jan 2025 17:34:17 +1300 Subject: [PATCH 14/17] capacity_reservations_feature: Add additional info to the spec --- apis/v1alpha1/ack-generate-metadata.yaml | 6 +++--- apis/v1alpha1/capacity_reservation.go | 2 ++ apis/v1alpha1/generator.yaml | 4 ++++ apis/v1alpha1/zz_generated.deepcopy.go | 5 +++++ .../bases/ec2.services.k8s.aws_capacityreservations.yaml | 3 +++ generator.yaml | 4 ++++ helm/crds/ec2.services.k8s.aws_capacityreservations.yaml | 3 +++ pkg/resource/capacity_reservation/delta.go | 7 +++++++ pkg/resource/capacity_reservation/sdk.go | 3 +++ 9 files changed, 34 insertions(+), 3 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 938a4829..3a98b43c 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,13 +1,13 @@ ack_generate_info: - build_date: "2025-01-29T01:33:01Z" + build_date: "2025-01-31T02:54:54Z" build_hash: 631aeb190e332addb8379672df6367a0875dce88 go_version: go1.23.4 version: 631aeb1-dirty -api_directory_checksum: f1edcbbbc96a40924bad556dbeeeaedd78affb6e +api_directory_checksum: 1ca5d8175acde30e318f4fa0ff4f0d0ad83a1f86 api_version: v1alpha1 aws_sdk_go_version: v1.44.93 generator_config_info: - file_checksum: 763200d3677a57874be1b3630e229e25d94dd7b5 + file_checksum: 081abb18d8ab455768e0daafc6fb8c503fc6e49e original_file_name: generator.yaml last_modification: reason: API generation diff --git a/apis/v1alpha1/capacity_reservation.go b/apis/v1alpha1/capacity_reservation.go index 9b235e08..6608c9bd 100644 --- a/apis/v1alpha1/capacity_reservation.go +++ b/apis/v1alpha1/capacity_reservation.go @@ -25,6 +25,8 @@ import ( // Describes a Capacity Reservation. type CapacityReservationSpec struct { + // Reserved for future use. + AdditionalInfo *string `json:"additionalInfo,omitempty"` // The Availability Zone in which to create the Capacity Reservation. AvailabilityZone *string `json:"availabilityZone,omitempty"` // The ID of the Availability Zone in which to create the Capacity Reservation. diff --git a/apis/v1alpha1/generator.yaml b/apis/v1alpha1/generator.yaml index e6d5f312..50ff3211 100644 --- a/apis/v1alpha1/generator.yaml +++ b/apis/v1alpha1/generator.yaml @@ -227,6 +227,10 @@ resources: from: operation: CreateTags path: Tags + AdditionalInfo: + from: + operation: ModifyCapacityReservation + path: AdditionalInfo CapacityReservationID: print: name: ID diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index f9f1bfc3..7f3dd109 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -1452,6 +1452,11 @@ func (in *CapacityReservationList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CapacityReservationSpec) DeepCopyInto(out *CapacityReservationSpec) { *out = *in + if in.AdditionalInfo != nil { + in, out := &in.AdditionalInfo, &out.AdditionalInfo + *out = new(string) + **out = **in + } if in.AvailabilityZone != nil { in, out := &in.AvailabilityZone, &out.AvailabilityZone *out = new(string) diff --git a/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml b/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml index 720ef3dc..321be862 100644 --- a/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml +++ b/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml @@ -53,6 +53,9 @@ spec: Describes a Capacity Reservation. properties: + additionalInfo: + description: Reserved for future use. + type: string availabilityZone: description: The Availability Zone in which to create the Capacity Reservation. diff --git a/generator.yaml b/generator.yaml index e6d5f312..50ff3211 100644 --- a/generator.yaml +++ b/generator.yaml @@ -227,6 +227,10 @@ resources: from: operation: CreateTags path: Tags + AdditionalInfo: + from: + operation: ModifyCapacityReservation + path: AdditionalInfo CapacityReservationID: print: name: ID diff --git a/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml b/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml index d20b6e02..24cb075b 100644 --- a/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml +++ b/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml @@ -53,6 +53,9 @@ spec: Describes a Capacity Reservation. properties: + additionalInfo: + description: Reserved for future use. + type: string availabilityZone: description: The Availability Zone in which to create the Capacity Reservation. diff --git a/pkg/resource/capacity_reservation/delta.go b/pkg/resource/capacity_reservation/delta.go index 8bce5628..b587b738 100644 --- a/pkg/resource/capacity_reservation/delta.go +++ b/pkg/resource/capacity_reservation/delta.go @@ -43,6 +43,13 @@ func newResourceDelta( return delta } + if ackcompare.HasNilDifference(a.ko.Spec.AdditionalInfo, b.ko.Spec.AdditionalInfo) { + delta.Add("Spec.AdditionalInfo", a.ko.Spec.AdditionalInfo, b.ko.Spec.AdditionalInfo) + } else if a.ko.Spec.AdditionalInfo != nil && b.ko.Spec.AdditionalInfo != nil { + if *a.ko.Spec.AdditionalInfo != *b.ko.Spec.AdditionalInfo { + delta.Add("Spec.AdditionalInfo", a.ko.Spec.AdditionalInfo, b.ko.Spec.AdditionalInfo) + } + } if ackcompare.HasNilDifference(a.ko.Spec.AvailabilityZone, b.ko.Spec.AvailabilityZone) { delta.Add("Spec.AvailabilityZone", a.ko.Spec.AvailabilityZone, b.ko.Spec.AvailabilityZone) } else if a.ko.Spec.AvailabilityZone != nil && b.ko.Spec.AvailabilityZone != nil { diff --git a/pkg/resource/capacity_reservation/sdk.go b/pkg/resource/capacity_reservation/sdk.go index 78aaa538..03ad9ea4 100644 --- a/pkg/resource/capacity_reservation/sdk.go +++ b/pkg/resource/capacity_reservation/sdk.go @@ -533,6 +533,9 @@ func (rm *resourceManager) newUpdateRequestPayload( ) (*svcsdk.ModifyCapacityReservationInput, error) { res := &svcsdk.ModifyCapacityReservationInput{} + if r.ko.Spec.AdditionalInfo != nil { + res.SetAdditionalInfo(*r.ko.Spec.AdditionalInfo) + } if r.ko.Status.CapacityReservationID != nil { res.SetCapacityReservationId(*r.ko.Status.CapacityReservationID) } From 5e183b5edc133041cfb07dd2ef09926c41453a0c Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Wed, 5 Feb 2025 12:53:11 +1300 Subject: [PATCH 15/17] capacity_reservations_feature: Update ATTRIBUTION.MD --- ATTRIBUTION.md | 1714 ++++++++++++++++++++++++++---------------------- 1 file changed, 940 insertions(+), 774 deletions(-) diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index db4d9a72..a9c6d813 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -1,16 +1,17 @@ # Open Source Software Attribution -The AWS Controllers for Kubernetes (ACK) source code is licensed under the +[//]: # (File generated by attribution-gen. DO NOT EDIT.) + +The github.com/aws-controllers-k8s/ec2-controller source code is licensed under the Apache License, version 2.0. A copy of this license is available in the [LICENSE](LICENSE) file in the root source code directory and is included, -along with this document, in any images containing AWS service controller +along with this document, in any images containing github.com/aws-controllers-k8s/ec2-controller binaries. ## Package dependencies -ACK depends on a number of Open Source Go packages. Direct dependencies are -listed in the -[`go.mod`](https://github.com/aws/aws-controllers-k8s/tree/main/go.mod) file. +The module github.com/aws-controllers-k8s/ec2-controller depends on a number of Open Source Go packages. Direct +dependencies are listed in the ./go.mod file. Those direct package dependencies have some dependencies of their own (known as "transitive dependencies") @@ -19,135 +20,126 @@ include an indication of the Open Source License under which that package is distributed. For any package *NOT* distributed under the terms of the Apache License version 2.0, we include the full text of the package's License below. +* `github.com/aws-controllers-k8s/runtime` +* `github.com/aws/aws-sdk-go` +* `github.com/go-logr/logr` +* `github.com/samber/lo` +* `github.com/spf13/pflag` +* `k8s.io/api` +* `k8s.io/apimachinery` +* `k8s.io/client-go` +* `sigs.k8s.io/controller-runtime` + +### github.com/aws-controllers-k8s/runtime + +Apache License version 2.0 + +Subdependencies: * `github.com/aws/aws-sdk-go` -* `github.com/dlclark/regexp2` -* `github.com/gertd/go-pluralize` -* `github.com/ghodss/yaml` +* `github.com/cenkalti/backoff/v4` * `github.com/go-logr/logr` * `github.com/google/go-cmp` -* `github.com/iancoleman/strcase` -* `github.com/mitchellh/go-homedir` +* `github.com/itchyny/gojq` +* `github.com/jaypipes/envutil` * `github.com/pkg/errors` -* `github.com/spf13/cobra` +* `github.com/prometheus/client_golang` +* `github.com/samber/lo` * `github.com/spf13/pflag` * `github.com/stretchr/testify` -* `golang.org/x/mod` +* `go.uber.org/zap` * `k8s.io/api` * `k8s.io/apimachinery` * `k8s.io/client-go` +* `k8s.io/klog/v2` * `sigs.k8s.io/controller-runtime` -* `sigs.k8s.io/controller-tools` +* `github.com/beorn7/perks` +* `github.com/cespare/xxhash/v2` +* `github.com/davecgh/go-spew` +* `github.com/emicklei/go-restful/v3` +* `github.com/evanphx/json-patch` +* `github.com/evanphx/json-patch/v5` +* `github.com/fsnotify/fsnotify` +* `github.com/fxamacker/cbor/v2` +* `github.com/go-logr/zapr` +* `github.com/go-openapi/jsonpointer` +* `github.com/go-openapi/jsonreference` +* `github.com/go-openapi/swag` +* `github.com/gogo/protobuf` +* `github.com/golang/groupcache` +* `github.com/golang/protobuf` +* `github.com/google/gnostic-models` +* `github.com/google/gofuzz` +* `github.com/google/uuid` +* `github.com/imdario/mergo` +* `github.com/itchyny/timefmt-go` +* `github.com/jmespath/go-jmespath` +* `github.com/josharian/intern` +* `github.com/json-iterator/go` +* `github.com/mailru/easyjson` +* `github.com/modern-go/concurrent` +* `github.com/modern-go/reflect2` +* `github.com/munnerz/goautoneg` +* `github.com/pmezard/go-difflib` +* `github.com/prometheus/client_model` +* `github.com/prometheus/common` +* `github.com/prometheus/procfs` +* `github.com/stretchr/objx` +* `github.com/x448/float16` +* `go.uber.org/multierr` +* `golang.org/x/exp` +* `golang.org/x/net` +* `golang.org/x/oauth2` +* `golang.org/x/sys` +* `golang.org/x/term` +* `golang.org/x/text` +* `golang.org/x/time` +* `gomodules.xyz/jsonpatch/v2` +* `google.golang.org/protobuf` +* `gopkg.in/evanphx/json-patch.v4` +* `gopkg.in/inf.v0` +* `gopkg.in/yaml.v2` +* `gopkg.in/yaml.v3` +* `k8s.io/apiextensions-apiserver` +* `k8s.io/kube-openapi` +* `k8s.io/utils` +* `sigs.k8s.io/json` +* `sigs.k8s.io/structured-merge-diff/v4` +* `sigs.k8s.io/yaml` -### github.com/aws/aws-sdk-go +#### github.com/aws/aws-sdk-go Apache License version 2.0 -### github.com/dlclark/regexp2 +#### github.com/cenkalti/backoff/v4 The MIT License (MIT) -Copyright (c) Doug Clark +Copyright (c) 2014 Cenk Altı -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -#### github.com/dlclark/regexp2 Attribution - -============ -These pieces of code were ported from dotnet/corefx: - -syntax/charclass.go (from RegexCharClass.cs): ported to use the built-in Go unicode classes. Canonicalize is - a direct port, but most of the other code required large changes because the C# implementation - used a string to represent the CharSet data structure and I cleaned that up in my implementation. - -syntax/code.go (from RegexCode.cs): ported literally with various cleanups and layout to make it more Go-ish. - -syntax/escape.go (from RegexParser.cs): ported Escape method and added some optimizations. Unescape is inspired by - the C# implementation but couldn't be directly ported because of the lack of do-while syntax in Go. - -syntax/parser.go (from RegexpParser.cs and RegexOptions.cs): ported parser struct and associated methods as - literally as possible. Several language differences required changes. E.g. lack pre/post-fix increments as - expressions, lack of do-while loops, lack of overloads, etc. - -syntax/prefix.go (from RegexFCD.cs and RegexBoyerMoore.cs): ported as literally as possible and added support - for unicode chars that are longer than the 16-bit char in C# for the 32-bit rune in Go. - -syntax/replacerdata.go (from RegexReplacement.cs): conceptually ported and re-organized to handle differences - in charclass implementation, and fix odd code layout between RegexParser.cs, Regex.cs, and RegexReplacement.cs. - -syntax/tree.go (from RegexTree.cs and RegexNode.cs): ported literally as possible. - -syntax/writer.go (from RegexWriter.cs): ported literally with minor changes to make it more Go-ish. - -match.go (from RegexMatch.cs): ported, simplified, and changed to handle Go's lack of inheritence. - -regexp.go (from Regex.cs and RegexOptions.cs): conceptually serves the same "starting point", but is simplified - and changed to handle differences in C# strings and Go strings/runes. - -replace.go (from RegexReplacement.cs): ported closely and then cleaned up to combine the MatchEvaluator and - simple string replace implementations. - -runner.go (from RegexRunner.cs): ported literally as possible. - -regexp_test.go (from CaptureTests.cs and GroupNamesAndNumbers.cs): conceptually ported, but the code was - manually structured like Go tests. - -replace_test.go (from RegexReplaceStringTest0.cs): conceptually ported - -rtl_test.go (from RightToLeft.cs): conceptually ported ---- -dotnet/corefx was released under this license: - -The MIT License (MIT) - -Copyright (c) Microsoft Corporation - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +#### github.com/go-logr/logr -============ -These pieces of code are copied from the Go framework: +Apache License version 2.0 -- The overall directory structure of regexp2 was inspired by the Go runtime regexp package. -- The optimization in the escape method of syntax/escape.go is from the Go runtime QuoteMeta() func in regexp/regexp.go -- The method signatures in regexp.go are designed to match the Go framework regexp methods closely -- func regexp2.MustCompile and func quote are almost identifical to the regexp package versions -- BenchmarkMatch* and TestProgramTooLong* funcs in regexp_performance_test.go were copied from the framework - regexp/exec_test.go ---- -The Go framework was released under this license: +#### github.com/google/go-cmp -Copyright (c) 2012 The Go Authors. All rights reserved. +Copyright (c) 2017 The Go Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -175,39 +167,11 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -============ -Some test data were gathered from the Mono project. - -regexp_mono_test.go: ported from https://github.com/mono/mono/blob/master/mcs/class/System/Test/System.Text.RegularExpressions/PerlTrials.cs ---- -Mono tests released under this license: - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -### github.com/gertd/go-pluralize - -MIT License +#### github.com/itchyny/gojq -Copyright (c) 2019 Gert Drapers +The MIT License (MIT) -Copyright (c) 2013 Blake Embrey (hello@blakeembrey.com) +Copyright (c) 2019-2021 itchyny Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -227,11 +191,45 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -### github.com/ghodss/yaml +#### github.com/jaypipes/envutil -The MIT License (MIT) +Apache License version 2.0 + +#### github.com/pkg/errors + +Copyright (c) 2015, Dave Cheney +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#### github.com/prometheus/client_golang + +Apache License version 2.0 -Copyright (c) 2014 Sam Ghods +#### github.com/samber/lo + +MIT License + +Copyright (c) 2022 Samuel Berthe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -251,7 +249,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#### github.com/spf13/pflag +Copyright (c) 2012 Alex Ogier. All rights reserved. Copyright (c) 2012 The Go Authors. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -280,56 +280,21 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -### github.com/go-logr/logr - -Apache License version 2.0 - -### github.com/google/go-cmp - -Copyright (c) 2017 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -### github.com/iancoleman/strcase +#### github.com/stretchr/testify -The MIT License (MIT) +MIT License -Copyright (c) 2015 Ian Coleman -Copyright (c) 2018 Ma_124, +Copyright (c) 2012-2020 Mat Ryer, Tyler Bunnell and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, Subject to the following conditions: +furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all -copies or Substantial portions of the Software. +copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -339,11 +304,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -### github.com/mitchellh/go-homedir - -The MIT License (MIT) +#### go.uber.org/zap -Copyright (c) 2013 Mitchell Hashimoto +Copyright (c) 2016-2017 Uber Technologies, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -363,116 +326,73 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -### github.com/pkg/errors +#### k8s.io/api -Copyright (c) 2015, Dave Cheney -All rights reserved. +Apache License version 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +#### k8s.io/apimachinery -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +Apache License version 2.0 -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. +#### k8s.io/client-go -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Apache License version 2.0 -### github.com/spf13/cobra +#### k8s.io/klog/v2 Apache License version 2.0 -Subdependencies: - -* `github.com/cpuguy83/go-md2man/v2` -* `github.com/inconshreveable/mousetrap` -* `github.com/spf13/pflag` -* `gopkg.in/yaml.v2` +#### sigs.k8s.io/controller-runtime -#### github.com/cpuguy83/go-md2man +Apache License version 2.0 -The MIT License (MIT) +#### github.com/beorn7/perks -Copyright (c) 2014 Brian Goff +Copyright (C) 2013 Blake Mizerany -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -#### github.com/inconshreveable/mousetrap - -Apache License version 2.0 - -#### goplg.in/yaml.v2 - -Apache License version 2.0 - -Subdependencies: - -* `gopkg.in/check.v1` - -#### gopkg.in/check.v1 - -Apache License version 2.0 - -### github.com/spf13/pflag` +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Apache License version 2.0 +#### github.com/cespare/xxhash/v2 -### github.com/stretchr/testify +Copyright (c) 2016 Caleb Spare MIT License -Copyright (c) 2012-2020 Mat Ryer, Tyler Bunnell and contributors. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. -Subdependencies: -* `github.com/davecgh/go-spew` -* `github.com/pmezard/go-difflib` -* `github.com/stretchr/objx` -* `gopkg.in/yaml.v3` +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #### github.com/davecgh/go-spew @@ -492,42 +412,120 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -#### github.com/pmezard/go-difflib +#### github.com/emicklei/go-restful/v3 -Copyright (c) 2013, Patrick Mezard +Copyright (c) 2012,2013 Ernest Micklei + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#### github.com/evanphx/json-patch + +Copyright (c) 2014, Evan Phoenix All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - The names of its contributors may not be used to endorse or promote -products derived from this software without specific prior written -permission. +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of the Evan Phoenix nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#### github.com/evanphx/json-patch/v5 + +Copyright (c) 2014, Evan Phoenix +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of the Evan Phoenix nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#### github.com/fsnotify/fsnotify + +Copyright © 2012 The Go Authors. All rights reserved. +Copyright © fsnotify Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. +* Neither the name of Google Inc. nor the names of its contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#### github.com/stretchr/objx +#### github.com/fxamacker/cbor/v2 -The MIT License +MIT License -Copyright (c) 2014 Stretchr, Inc. -Copyright (c) 2017-2018 objx contributors +Copyright (c) 2019-present Faye Amacker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -547,25 +545,44 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#### gopkg.in/yaml.v3 +#### github.com/go-logr/zapr Apache License version 2.0 -### golang.org/x/mod +#### github.com/go-openapi/jsonpointer -Copyright (c) 2009 The Go Authors. All rights reserved. +Apache License version 2.0 + +#### github.com/go-openapi/jsonreference + +Apache License version 2.0 + +#### github.com/go-openapi/swag + +Apache License version 2.0 + +#### github.com/gogo/protobuf + +Copyright (c) 2013, The GoGo Authors. All rights reserved. + +Protocol Buffers for Go with Gadgets + +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -581,72 +598,25 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Subdependencies: -* `golang.org/x/crypto` -* `golang.org/x/tools` -* `golang.org/x/xerrors` - -### k8s.io/api - -Apache License version 2.0 - -### k8s.io/apimachinery - -Apache License version 2.0 - -Subdependencies: - -* `github.com/davecgh/go-spew` -* `github.com/docker/spdystream` -* `github.com/elazarl/goproxy` -* `github.com/evanphx/json-patch` -* `github.com/fsnotify/fsnotify` -* `github.com/gogo/protobuf` -* `github.com/golang/groupcache` -* `github.com/golang/protobuf` -* `github.com/google/go-cmp` -* `github.com/google/gofuzz` -* `github.com/google/uuid` -* `github.com/googleapis/gnostic` -* `github.com/hashicorp/golang-lru` -* `github.com/json-iterator/go` -* `github.com/modern-go/reflect2` -* `github.com/mxk/go-flowrate` -* `github.com/onsi/ginkgo` -* `github.com/onsi/gomega` -* `github.com/pkg/errors` -* `github.com/spf13/pflag` -* `github.com/stretchr/testify` -* `golang.org/x/net` -* `golang.org/x/sys` -* `golang.org/x/text` -* `google.golang.org/protobuf` -* `gopkg.in/inf.v0` -* `gopkg.in/yaml.v2` -* `k8s.io/klog/v2` -* `k8s.io/kube-openapi` -* `sigs.k8s.io/structured-merge-diff/v4` -* `sigs.k8s.io/yaml` - -#### github.com/docker/spdystream +#### github.com/golang/groupcache Apache License version 2.0 -#### github.com/elazarl/goproxy +#### github.com/golang/protobuf -Copyright (c) 2012 Elazar Leibovich. All rights reserved. +Copyright 2010 The Go Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Elazar Leibovich. nor the names of its + * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -662,38 +632,17 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#### github.com/evanphx/json-patch - -Copyright (c) 2014, Evan Phoenix -All rights reserved. +#### github.com/google/gnostic-models -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +Apache License version 2.0 -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. -* Neither the name of the Evan Phoenix nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. +#### github.com/google/gofuzz -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Apache License version 2.0 -#### github.com/fsnotify/fsnotify +#### github.com/google/uuid -Copyright (c) 2012 The Go Authors. All rights reserved. -Copyright (c) 2012-2019 fsnotify Authors. All rights reserved. +Copyright (c) 2009,2014 Google Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -721,28 +670,22 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#### github.com/gogo/protobuf +#### github.com/imdario/mergo -Copyright (c) 2013, The GoGo Authors. All rights reserved. +Copyright (c) 2013 Dario Castañé. All rights reserved. +Copyright (c) 2012 The Go Authors. All rights reserved. -Protocol Buffers for Go with Gadgets +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: -Go support for Protocol Buffers - Google's data interchange format - -Copyright 2010 The Go Authors. All rights reserved. -https://github.com/golang/protobuf - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -758,67 +701,127 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#### github.com/golang/groupcache +#### github.com/itchyny/timefmt-go + +The MIT License (MIT) + +Copyright (c) 2020,2021 itchyny + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +#### github.com/jmespath/go-jmespath Apache License version 2.0 -#### github.com/golang/protobuf +#### github.com/josharian/intern -Copyright 2010 The Go Authors. All rights reserved. +MIT License -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +Copyright (c) 2019 Josh Bleecher Snyder - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -#### github.com/google/gofuzz +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +#### github.com/json-iterator/go + +MIT License + +Copyright (c) 2016 json-iterator + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +#### github.com/mailru/easyjson + +Copyright (c) 2016 Mail.Ru Group + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#### github.com/modern-go/concurrent Apache License version 2.0 -#### github.com/google/uuid +#### github.com/modern-go/reflect2 -Copyright (c) 2009,2014 Google Inc. All rights reserved. +Apache License version 2.0 + +#### github.com/munnerz/goautoneg + +Copyright (c) 2011, Open Knowledge Foundation Ltd. +All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + Neither the name of the Open Knowledge Foundation Ltd. nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY @@ -826,48 +829,54 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#### github.com/googleapis/gnostic +#### github.com/pmezard/go-difflib -Apache License version 2.0 +Copyright (c) 2013, Patrick Mezard +All rights reserved. -Subdependencies: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: -* `github.com/docopt/docopt-go` -* `github.com/golang/protobuf` -* `github.com/stoewer/go-strcase` -* `google.golang.org/protobuf` -* `gopkg.in/check.v1` -* `gopkg.in/yaml.v3` + Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + The names of its contributors may not be used to endorse or promote +products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -##### github.com/docopt/docopt-go +#### github.com/prometheus/client_model -The MIT License (MIT) +Apache License version 2.0 -Copyright (c) 2013 Keith Batten -Copyright (c) 2016 David Irvine +#### github.com/prometheus/common -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: +Apache License version 2.0 -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +#### github.com/prometheus/procfs -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Apache License version 2.0 -##### github.com/stoewer/go-strcase +#### github.com/stretchr/objx -The MIT License (MIT) +The MIT License -Copyright (c) 2017, Adrian Stoewer +Copyright (c) 2014 Stretchr, Inc. +Copyright (c) 2017-2018 objx contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -887,15 +896,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#### github.com/hashicorp/golang-lru - -Mozilla Public License, version 2.0 - -#### github.com/json-iterator/go +#### github.com/x448/float16 MIT License -Copyright (c) 2016 json-iterator +Copyright (c) 2019 Montgomery Edwards⁴⁴⁸ and Faye Amacker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -915,33 +920,45 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Subdependencies: +#### go.uber.org/multierr -* `github.com/modern-go/reflect2` +Copyright (c) 2017-2021 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -##### github.com/modern-go/reflect2 +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -Apache License version 2.0 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. -#### github.com/mxk/go-flowrate +#### golang.org/x/exp -Copyright (c) 2014 The Go-FlowRate Authors. All rights reserved. +Copyright (c) 2009 The Go Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the - distribution. - - * Neither the name of the go-flowrate project nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -955,34 +972,9 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#### github.com/onsi/ginkgo -#### github.com/onsi/gomega - -Copyright (c) 2013-2014 Onsi Fakhouri - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#### gopkg.in/inf.v0 +#### golang.org/x/net -Copyright (c) 2012 Péter Surányi. Portions Copyright (c) 2009 The Go -Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -994,7 +986,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -1010,116 +1002,129 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#### github.com/kubernetes-sigs/structured-merge-diff +#### golang.org/x/oauth2 -Apache License version 2.0 - -### k8s.io/client-go - -Apache License version 2.0 +Copyright (c) 2009 The Go Authors. All rights reserved. -Subdependencies: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: -* `github.com/Azure/go-autorest/autorest` -* `github.com/Azure/go-autorest/autorest/adal` -* `github.com/davecgh/go-spew` -* `github.com/evanphx/json-patch` -* `github.com/gogo/protobuf` -* `github.com/golang/groupcache` -* `github.com/golang/protobuf` -* `github.com/google/go-cmp` -* `github.com/google/gofuzz` -* `github.com/google/uuid` -* `github.com/googleapis/gnostic` -* `github.com/gregjones/httpcache` -* `github.com/imdario/mergo` -* `github.com/peterbourgon/diskv` -* `github.com/spf13/pflag` -* `github.com/stretchr/testify` -* `golang.org/x/crypto` -* `golang.org/x/net` -* `golang.org/x/oauth2` -* `golang.org/x/time` -* `k8s.io/api` -* `k8s.io/apimachinery` -* `k8s.io/klog/v2` -* `k8s.io/utils` -* `sigs.k8s.io/yaml` - -#### github.com/Azure/go-autorest - -Apache License version 2.0 - -Subdependencies: - -* `contrib.go.opencensus.io/exporter/ocagent` -* `github.com/dgrijalva/jwt-go` -* `github.com/dimchansky/utfbom` -* `github.com/mitchellh/go-homedir` -* `github.com/stretchr/testify` -* `go.opencensus.io` -* `golang.org/x/crypto` + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. -##### contrib.go.opencensus.io/ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Apache License version 2.0 +#### golang.org/x/sys -##### github.com/dgrijalva/jwt-go +Copyright 2009 The Go Authors. -Copyright (c) 2012 Dave Grijalva +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google LLC nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +#### golang.org/x/term -##### github.com/dimchansky/utfbom +Copyright 2009 The Go Authors. -Apache License version 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: -##### go.opencensus.io + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google LLC nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. -Apache License version 2.0 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#### github.com/gregjones/httpcache +#### golang.org/x/text -Copyright © 2012 Greg Jones (greg.jones@gmail.com) +Copyright 2009 The Go Authors. -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the “Software”), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google LLC nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#### github.com/imdario/mergo +#### golang.org/x/time -Copyright (c) 2013 Dario Castañé. All rights reserved. -Copyright (c) 2012 The Go Authors. All rights reserved. +Copyright (c) 2009 The Go Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -1147,219 +1152,380 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#### github.com/peterbourgon/diskv +#### gomodules.xyz/jsonpatch/v2 -Copyright (c) 2011-2012 Peter Bourgon +Apache License version 2.0 -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +#### google.golang.org/protobuf -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +Copyright (c) 2018 The Go Authors. All rights reserved. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: -Subdependencies: + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* `github.com/google/btree` +#### gopkg.in/evanphx/json-patch.v4 -##### github.com/google/btree +Copyright (c) 2014, Evan Phoenix +All rights reserved. -Apache License version 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -### sigs.k8s.io/controller-runtime +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of the Evan Phoenix nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. -Apache License version 2.0 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Subdependencies: +#### gopkg.in/inf.v0 -* `github.com/evanphx/json-patch` -* `github.com/fsnotify/fsnotify` -* `github.com/go-logr/logr` -* `github.com/go-logr/zapr` -* `github.com/onsi/ginkgo` -* `github.com/onsi/gomega` -* `github.com/prometheus/client_golang` -* `github.com/prometheus/client_model` -* `go.uber.org/goleak` -* `go.uber.org/zap` -* `golang.org/x/time` -* `gomodules.xyz/jsonpatch/v2` -* `k8s.io/api` -* `k8s.io/apiextensions-apiserver` -* `k8s.io/apimachinery` -* `k8s.io/client-go` -* `k8s.io/utils` -* `sigs.k8s.io/yaml` +Copyright (c) 2012 Péter Surányi. Portions Copyright (c) 2009 The Go +Authors. All rights reserved. -#### github.com/prometheus/client_golang +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: -Apaches License version 2.0 + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. -Subdependencies: +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* `github.com/beorn7/perks` -* `github.com/cespare/xxhash/v2` -* `github.com/golang/protobuf` -* `github.com/json-iterator/go` -* `github.com/prometheus/client_model` -* `github.com/prometheus/common` -* `github.com/prometheus/procfs` -* `golang.org/x/sys` +#### gopkg.in/yaml.v2 -##### github.com/beorn7/perks +Apache License version 2.0 -Copyright (C) 2013 Blake Mizerany +#### gopkg.in/yaml.v3 -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Apache License version 2.0 -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. +#### k8s.io/apiextensions-apiserver -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Apache License version 2.0 -##### github.com/cespare/xxhash +#### k8s.io/kube-openapi -Copyright (c) 2016 Caleb Spare +Apache License version 2.0 -MIT License +#### k8s.io/utils -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Apache License version 2.0 -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. +#### sigs.k8s.io/json + +Files other than internal/golang/* licensed under: + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. + + +------------------ + +internal/golang/* files licensed under: -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#### go.uber.org/goleak -#### go.uber.org/zap +Copyright (c) 2009 The Go Authors. All rights reserved. -The MIT License (MIT) +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: -Copyright (c) 2018 Uber Technologies, Inc. + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +#### sigs.k8s.io/structured-merge-diff/v4 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +Apache License version 2.0 -### sigs.k8s.io/controller-tools +#### sigs.k8s.io/yaml Apache License version 2.0 -Subdependencies: -* `github.com/fatih/color` -* `github.com/gobuffalo/flect` -* `github.com/google/go-cmp` -* `github.com/onsi/ginkgo` -* `github.com/onsi/gomega` -* `github.com/spf13/cobra` -* `github.com/spf13/pflag` -* `golang.org/x/tools` -* `gopkg.in/yaml.v3` -* `k8s.io/api` -* `k8s.io/apiextensions-apiserver` -* `k8s.io/apimachinery` -* `sigs.k8s.io/yaml` -#### github.com/fatih/color -The MIT License (MIT) -Copyright (c) 2013 Fatih Arslan -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -Subdependencies: -* `github.com/mattn/go-colorable` -* `github.com/mattn/go-isatty` -# github.com/mattn/go-colorable -# github.com/mattn/go-isatty -The MIT License (MIT) -Copyright (c) 2016 Yasuhiro Matsumoto -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. From e3cf18fb485fd0ebe676134651a8d429561a68ac Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Fri, 7 Feb 2025 16:54:42 +1300 Subject: [PATCH 16/17] capacity_reservations_feature: Update release and attribution file --- ATTRIBUTION.md | 105 +++++++++++++- apis/v1alpha1/ack-generate-metadata.yaml | 4 +- go.mod | 1 - go.sum | 2 - ...services.k8s.aws_capacityreservations.yaml | 130 ++++++++++++++++-- 5 files changed, 215 insertions(+), 27 deletions(-) diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index a9c6d813..286b2abc 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -22,6 +22,9 @@ License version 2.0, we include the full text of the package's License below. * `github.com/aws-controllers-k8s/runtime` * `github.com/aws/aws-sdk-go` +* `github.com/aws/aws-sdk-go-v2` +* `github.com/aws/aws-sdk-go-v2/service/ec2` +* `github.com/aws/smithy-go` * `github.com/go-logr/logr` * `github.com/samber/lo` * `github.com/spf13/pflag` @@ -35,7 +38,11 @@ License version 2.0, we include the full text of the package's License below. Apache License version 2.0 Subdependencies: -* `github.com/aws/aws-sdk-go` +* `github.com/aws/aws-sdk-go-v2` +* `github.com/aws/aws-sdk-go-v2/config` +* `github.com/aws/aws-sdk-go-v2/credentials` +* `github.com/aws/aws-sdk-go-v2/service/sts` +* `github.com/aws/smithy-go` * `github.com/cenkalti/backoff/v4` * `github.com/go-logr/logr` * `github.com/google/go-cmp` @@ -52,6 +59,14 @@ Subdependencies: * `k8s.io/client-go` * `k8s.io/klog/v2` * `sigs.k8s.io/controller-runtime` +* `github.com/aws/aws-sdk-go-v2/feature/ec2/imds` +* `github.com/aws/aws-sdk-go-v2/internal/configsources` +* `github.com/aws/aws-sdk-go-v2/internal/endpoints/v2` +* `github.com/aws/aws-sdk-go-v2/internal/ini` +* `github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding` +* `github.com/aws/aws-sdk-go-v2/service/internal/presigned-url` +* `github.com/aws/aws-sdk-go-v2/service/sso` +* `github.com/aws/aws-sdk-go-v2/service/ssooidc` * `github.com/beorn7/perks` * `github.com/cespare/xxhash/v2` * `github.com/davecgh/go-spew` @@ -72,7 +87,6 @@ Subdependencies: * `github.com/google/uuid` * `github.com/imdario/mergo` * `github.com/itchyny/timefmt-go` -* `github.com/jmespath/go-jmespath` * `github.com/josharian/intern` * `github.com/json-iterator/go` * `github.com/mailru/easyjson` @@ -106,7 +120,23 @@ Subdependencies: * `sigs.k8s.io/structured-merge-diff/v4` * `sigs.k8s.io/yaml` -#### github.com/aws/aws-sdk-go +#### github.com/aws/aws-sdk-go-v2 + +Apache License version 2.0 + +#### github.com/aws/aws-sdk-go-v2/config + +Apache License version 2.0 + +#### github.com/aws/aws-sdk-go-v2/credentials + +Apache License version 2.0 + +#### github.com/aws/aws-sdk-go-v2/service/sts + +Apache License version 2.0 + +#### github.com/aws/smithy-go Apache License version 2.0 @@ -346,6 +376,38 @@ Apache License version 2.0 Apache License version 2.0 +#### github.com/aws/aws-sdk-go-v2/feature/ec2/imds + +Apache License version 2.0 + +#### github.com/aws/aws-sdk-go-v2/internal/configsources + +Apache License version 2.0 + +#### github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 + +Apache License version 2.0 + +#### github.com/aws/aws-sdk-go-v2/internal/ini + +Apache License version 2.0 + +#### github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding + +Apache License version 2.0 + +#### github.com/aws/aws-sdk-go-v2/service/internal/presigned-url + +Apache License version 2.0 + +#### github.com/aws/aws-sdk-go-v2/service/sso + +Apache License version 2.0 + +#### github.com/aws/aws-sdk-go-v2/service/ssooidc + +Apache License version 2.0 + #### github.com/beorn7/perks Copyright (C) 2013 Blake Mizerany @@ -725,10 +787,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#### github.com/jmespath/go-jmespath - -Apache License version 2.0 - #### github.com/josharian/intern MIT License @@ -1514,6 +1572,39 @@ Apache License version 2.0 Apache License version 2.0 +### github.com/aws/aws-sdk-go + +Apache License version 2.0 + +Subdependencies: +* `github.com/jmespath/go-jmespath` +* `golang.org/x/net` +* `golang.org/x/text` + +#### github.com/jmespath/go-jmespath + +Apache License version 2.0 + +### github.com/aws/aws-sdk-go-v2 + +Apache License version 2.0 + +Subdependencies: +* `github.com/aws/smithy-go` +* `github.com/jmespath/go-jmespath` + +### github.com/aws/aws-sdk-go-v2/service/ec2 + +Apache License version 2.0 + +Subdependencies: +* `github.com/aws/aws-sdk-go-v2` +* `github.com/aws/aws-sdk-go-v2/internal/configsources` +* `github.com/aws/aws-sdk-go-v2/internal/endpoints/v2` +* `github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding` +* `github.com/aws/aws-sdk-go-v2/service/internal/presigned-url` +* `github.com/aws/smithy-go` + diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 6f5e3c70..5fdc08ca 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,9 +1,9 @@ ack_generate_info: - build_date: "2025-02-07T00:30:42Z" + build_date: "2025-02-07T03:17:24Z" build_hash: 8762917215d9902b2011a2b0b1b0c776855a683e go_version: go1.23.4 version: v0.42.0-dirty -api_directory_checksum: 1c6d4b5f68a399d1d242e60da8a423a1c7768c96 +api_directory_checksum: bd956cbd49a39d2c7c0839446933204a27a99310 api_version: v1alpha1 aws_sdk_go_version: v1.32.6 generator_config_info: diff --git a/go.mod b/go.mod index e8356755..e5b337a2 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,6 @@ require ( github.com/itchyny/gojq v0.12.6 // indirect github.com/itchyny/timefmt-go v0.1.3 // indirect github.com/jaypipes/envutil v1.0.0 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect diff --git a/go.sum b/go.sum index 3632ecca..6e70d6c8 100644 --- a/go.sum +++ b/go.sum @@ -93,8 +93,6 @@ github.com/jaypipes/envutil v1.0.0 h1:u6Vwy9HwruFihoZrL0bxDLCa/YNadGVwKyPElNmZWo github.com/jaypipes/envutil v1.0.0/go.mod h1:vgIRDly+xgBq0eeZRcflOHMMobMwgC6MkMbxo/Nw65M= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= diff --git a/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml b/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml index 24cb075b..1c4ba6f6 100644 --- a/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml +++ b/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml @@ -18,7 +18,7 @@ spec: - jsonPath: .status.capacityReservationID name: ID type: string - - jsonPath: .status.startDate + - jsonPath: .spec.startDate name: START_DATE type: date - jsonPath: .status.state @@ -69,6 +69,32 @@ spec: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). type: string + commitmentDuration: + description: |- + Required for future-dated Capacity Reservations only. To create a Capacity + Reservation for immediate use, omit this parameter. + + Specify a commitment duration, in seconds, for the future-dated Capacity + Reservation. + + The commitment duration is a minimum duration for which you commit to having + the future-dated Capacity Reservation in the active state in your account + after it has been delivered. + + For more information, see Commitment duration (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/cr-concepts.html#cr-commitment-duration). + format: int64 + type: integer + deliveryPreference: + description: |- + Required for future-dated Capacity Reservations only. To create a Capacity + Reservation for immediate use, omit this parameter. + + Indicates that the requested capacity will be delivered in addition to any + running instances or reserved capacity that you have in your account at the + requested date and time. + + The only supported value is incremental. + type: string dryRun: description: |- Checks whether you have the required permissions for the action, without @@ -98,6 +124,9 @@ spec: an hour from the specified time. For example, if you specify 5/31/2019, 13:30:55, the Capacity Reservation is guaranteed to end between 13:30:55 and 14:30:55 on 5/31/2019. + + If you are requesting a future-dated Capacity Reservation, you can't specify + an end date and time that is within the commitment duration. format: date-time type: string endDateType: @@ -119,6 +148,11 @@ spec: description: |- The number of instances for which to reserve capacity. + You can request future-dated Capacity Reservations for an instance count + with a minimum of 100 VPUs. For example, if you request a future-dated Capacity + Reservation for m5.xlarge instances, you must request at least 25 instances + (25 * m5.xlarge = 100 vCPUs). + Valid range: 1 - 1000 format: int64 type: integer @@ -137,6 +171,9 @@ spec: and explicitly target the Capacity Reservation. This ensures that only permitted instances can use the reserved capacity. + If you are requesting a future-dated Capacity Reservation, you must specify + targeted. + Default: open type: string instancePlatform: @@ -144,22 +181,42 @@ spec: type: string instanceType: description: |- - The instance type for which to reserve capacity. For more information, see - Instance types (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html) + The instance type for which to reserve capacity. + + You can request future-dated Capacity Reservations for instance types in + the C, M, R, I, and T instance families only. + + For more information, see Instance types (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html) in the Amazon EC2 User Guide. type: string outpostARN: description: |- + Not supported for future-dated Capacity Reservations. + The Amazon Resource Name (ARN) of the Outpost on which to create the Capacity Reservation. type: string placementGroupARN: description: |- + Not supported for future-dated Capacity Reservations. + The Amazon Resource Name (ARN) of the cluster placement group in which to create the Capacity Reservation. For more information, see Capacity Reservations for cluster placement groups (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/cr-cpg.html) in the Amazon EC2 User Guide. type: string + startDate: + description: |- + Required for future-dated Capacity Reservations only. To create a Capacity + Reservation for immediate use, omit this parameter. + + The date and time at which the future-dated Capacity Reservation should become + available for use, in the ISO8601 format in the UTC time zone (YYYY-MM-DDThh:mm:ss.sssZ). + + You can request a future-dated Capacity Reservation between 5 and 120 days + in advance. + format: date-time + type: string tags: description: |- The tags. The value parameter is required, but if you don't want the tag @@ -228,6 +285,19 @@ spec: in the Capacity Reservation. format: int64 type: integer + capacityAllocations: + description: Information about instance capacity usage. + items: + description: Information about instance capacity usage for a Capacity + Reservation. + properties: + allocationType: + type: string + count: + format: int64 + type: integer + type: object + type: array capacityReservationFleetID: description: |- The ID of the Capacity Reservation Fleet to which the Capacity Reservation @@ -237,6 +307,17 @@ spec: capacityReservationID: description: The ID of the Capacity Reservation. type: string + commitmentInfo: + description: Information about your commitment for a future-dated + Capacity Reservation. + properties: + commitmentEndDate: + format: date-time + type: string + committedInstanceCount: + format: int64 + type: integer + type: object conditions: description: |- All CRS managed by ACK have a common `Status.Conditions` member that @@ -281,32 +362,46 @@ spec: description: The ID of the Amazon Web Services account that owns the Capacity Reservation. type: string - startDate: - description: The date and time at which the Capacity Reservation was - started. - format: date-time + reservationType: + description: The type of Capacity Reservation. type: string state: description: |- The current state of the Capacity Reservation. A Capacity Reservation can be in one of the following states: - * active - The Capacity Reservation is active and the capacity is available - for your use. + * active - The capacity is available for use. * expired - The Capacity Reservation expired automatically at the date - and time specified in your request. The reserved capacity is no longer - available for your use. + and time specified in your reservation request. The reserved capacity + is no longer available for your use. - * cancelled - The Capacity Reservation was cancelled. The reserved capacity + * cancelled - The Capacity Reservation was canceled. The reserved capacity is no longer available for your use. * pending - The Capacity Reservation request was successful but the capacity provisioning is still pending. - * failed - The Capacity Reservation request has failed. A request might - fail due to invalid request parameters, capacity constraints, or instance - limit constraints. Failed requests are retained for 60 minutes. + * failed - The Capacity Reservation request has failed. A request can + fail due to request parameters that are not valid, capacity constraints, + or instance limit constraints. You can view a failed request for 60 minutes. + + * scheduled - (Future-dated Capacity Reservations only) The future-dated + Capacity Reservation request was approved and the Capacity Reservation + is scheduled for delivery on the requested start date. + + * assessing - (Future-dated Capacity Reservations only) Amazon EC2 is + assessing your request for a future-dated Capacity Reservation. + + * delayed - (Future-dated Capacity Reservations only) Amazon EC2 encountered + a delay in provisioning the requested future-dated Capacity Reservation. + Amazon EC2 is unable to deliver the requested capacity by the requested + start date and time. + + * unsupported - (Future-dated Capacity Reservations only) Amazon EC2 can't + support the future-dated Capacity Reservation request due to capacity + constraints. You can view unsupported requests for 30 days. The Capacity + Reservation will not be delivered. type: string totalInstanceCount: description: |- @@ -314,6 +409,11 @@ spec: capacity. format: int64 type: integer + unusedReservationBillingOwnerID: + description: |- + The ID of the Amazon Web Services account to which billing of the unused + capacity of the Capacity Reservation is assigned. + type: string type: object type: object served: true From 18cdeae91c49e462a34dfd9e2aaf927a7455ba19 Mon Sep 17 00:00:00 2001 From: Fiza Shaikh Date: Mon, 10 Feb 2025 14:00:04 +1300 Subject: [PATCH 17/17] capacity_reservations_feature: Remove ClientToken and Dryrun fields --- apis/v1alpha1/ack-generate-metadata.yaml | 6 +++--- apis/v1alpha1/capacity_reservation.go | 8 -------- apis/v1alpha1/generator.yaml | 2 ++ apis/v1alpha1/zz_generated.deepcopy.go | 10 ---------- ...ec2.services.k8s.aws_capacityreservations.yaml | 12 ------------ generator.yaml | 2 ++ ...ec2.services.k8s.aws_capacityreservations.yaml | 12 ------------ pkg/resource/capacity_reservation/delta.go | 14 -------------- pkg/resource/capacity_reservation/sdk.go | 15 --------------- 9 files changed, 7 insertions(+), 74 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 5fdc08ca..4242b44f 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,13 +1,13 @@ ack_generate_info: - build_date: "2025-02-07T03:17:24Z" + build_date: "2025-02-09T23:26:36Z" build_hash: 8762917215d9902b2011a2b0b1b0c776855a683e go_version: go1.23.4 version: v0.42.0-dirty -api_directory_checksum: bd956cbd49a39d2c7c0839446933204a27a99310 +api_directory_checksum: 6da0928938d9fb2e79fb8f7ab09fa6da0c5f3049 api_version: v1alpha1 aws_sdk_go_version: v1.32.6 generator_config_info: - file_checksum: 1c3f96db4ae9d063cd54228acfdc74643221cfb5 + file_checksum: b3d6924c2a4a2252ea9a7fa775eb86bd1660eeef original_file_name: generator.yaml last_modification: reason: API generation diff --git a/apis/v1alpha1/capacity_reservation.go b/apis/v1alpha1/capacity_reservation.go index a2932ab0..9691c149 100644 --- a/apis/v1alpha1/capacity_reservation.go +++ b/apis/v1alpha1/capacity_reservation.go @@ -31,9 +31,6 @@ type CapacityReservationSpec struct { AvailabilityZone *string `json:"availabilityZone,omitempty"` // The ID of the Availability Zone in which to create the Capacity Reservation. AvailabilityZoneID *string `json:"availabilityZoneID,omitempty"` - // Unique, case-sensitive identifier that you provide to ensure the idempotency - // of the request. For more information, see Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). - ClientToken *string `json:"clientToken,omitempty"` // Required for future-dated Capacity Reservations only. To create a Capacity // Reservation for immediate use, omit this parameter. // @@ -55,11 +52,6 @@ type CapacityReservationSpec struct { // // The only supported value is incremental. DeliveryPreference *string `json:"deliveryPreference,omitempty"` - // Checks whether you have the required permissions for the action, without - // actually making the request, and provides an error response. If you have - // the required permissions, the error response is DryRunOperation. Otherwise, - // it is UnauthorizedOperation. - DryRun *bool `json:"dryRun,omitempty"` // Indicates whether the Capacity Reservation supports EBS-optimized instances. // This optimization provides dedicated throughput to Amazon EBS and an optimized // configuration stack to provide optimal I/O performance. This optimization diff --git a/apis/v1alpha1/generator.yaml b/apis/v1alpha1/generator.yaml index 70db5bc0..884024d6 100644 --- a/apis/v1alpha1/generator.yaml +++ b/apis/v1alpha1/generator.yaml @@ -10,6 +10,8 @@ ignore: - AllocateAddressInput.DryRun - AllocateAddressInput.TagSpecifications - CreateCapacityReservationInput.TagSpecifications + - CreateCapacityReservationInput.DryRun + - CreateCapacityReservationInput.ClientToken - CreateDhcpOptionsInput.DryRun - CreateDhcpOptionsInput.TagSpecifications - CreateFlowLogsInput.DryRun diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index bdf58cb0..a0949756 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -2076,11 +2076,6 @@ func (in *CapacityReservationSpec) DeepCopyInto(out *CapacityReservationSpec) { *out = new(string) **out = **in } - if in.ClientToken != nil { - in, out := &in.ClientToken, &out.ClientToken - *out = new(string) - **out = **in - } if in.CommitmentDuration != nil { in, out := &in.CommitmentDuration, &out.CommitmentDuration *out = new(int64) @@ -2091,11 +2086,6 @@ func (in *CapacityReservationSpec) DeepCopyInto(out *CapacityReservationSpec) { *out = new(string) **out = **in } - if in.DryRun != nil { - in, out := &in.DryRun, &out.DryRun - *out = new(bool) - **out = **in - } if in.EBSOptimized != nil { in, out := &in.EBSOptimized, &out.EBSOptimized *out = new(bool) diff --git a/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml b/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml index 6e0420ab..4ceb607e 100644 --- a/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml +++ b/config/crd/bases/ec2.services.k8s.aws_capacityreservations.yaml @@ -64,11 +64,6 @@ spec: description: The ID of the Availability Zone in which to create the Capacity Reservation. type: string - clientToken: - description: |- - Unique, case-sensitive identifier that you provide to ensure the idempotency - of the request. For more information, see Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). - type: string commitmentDuration: description: |- Required for future-dated Capacity Reservations only. To create a Capacity @@ -95,13 +90,6 @@ spec: The only supported value is incremental. type: string - dryRun: - description: |- - Checks whether you have the required permissions for the action, without - actually making the request, and provides an error response. If you have - the required permissions, the error response is DryRunOperation. Otherwise, - it is UnauthorizedOperation. - type: boolean ebsOptimized: description: |- Indicates whether the Capacity Reservation supports EBS-optimized instances. diff --git a/generator.yaml b/generator.yaml index 70db5bc0..884024d6 100644 --- a/generator.yaml +++ b/generator.yaml @@ -10,6 +10,8 @@ ignore: - AllocateAddressInput.DryRun - AllocateAddressInput.TagSpecifications - CreateCapacityReservationInput.TagSpecifications + - CreateCapacityReservationInput.DryRun + - CreateCapacityReservationInput.ClientToken - CreateDhcpOptionsInput.DryRun - CreateDhcpOptionsInput.TagSpecifications - CreateFlowLogsInput.DryRun diff --git a/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml b/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml index 1c4ba6f6..a98e57d0 100644 --- a/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml +++ b/helm/crds/ec2.services.k8s.aws_capacityreservations.yaml @@ -64,11 +64,6 @@ spec: description: The ID of the Availability Zone in which to create the Capacity Reservation. type: string - clientToken: - description: |- - Unique, case-sensitive identifier that you provide to ensure the idempotency - of the request. For more information, see Ensure Idempotency (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). - type: string commitmentDuration: description: |- Required for future-dated Capacity Reservations only. To create a Capacity @@ -95,13 +90,6 @@ spec: The only supported value is incremental. type: string - dryRun: - description: |- - Checks whether you have the required permissions for the action, without - actually making the request, and provides an error response. If you have - the required permissions, the error response is DryRunOperation. Otherwise, - it is UnauthorizedOperation. - type: boolean ebsOptimized: description: |- Indicates whether the Capacity Reservation supports EBS-optimized instances. diff --git a/pkg/resource/capacity_reservation/delta.go b/pkg/resource/capacity_reservation/delta.go index c210f816..92acf887 100644 --- a/pkg/resource/capacity_reservation/delta.go +++ b/pkg/resource/capacity_reservation/delta.go @@ -64,13 +64,6 @@ func newResourceDelta( delta.Add("Spec.AvailabilityZoneID", a.ko.Spec.AvailabilityZoneID, b.ko.Spec.AvailabilityZoneID) } } - if ackcompare.HasNilDifference(a.ko.Spec.ClientToken, b.ko.Spec.ClientToken) { - delta.Add("Spec.ClientToken", a.ko.Spec.ClientToken, b.ko.Spec.ClientToken) - } else if a.ko.Spec.ClientToken != nil && b.ko.Spec.ClientToken != nil { - if *a.ko.Spec.ClientToken != *b.ko.Spec.ClientToken { - delta.Add("Spec.ClientToken", a.ko.Spec.ClientToken, b.ko.Spec.ClientToken) - } - } if ackcompare.HasNilDifference(a.ko.Spec.CommitmentDuration, b.ko.Spec.CommitmentDuration) { delta.Add("Spec.CommitmentDuration", a.ko.Spec.CommitmentDuration, b.ko.Spec.CommitmentDuration) } else if a.ko.Spec.CommitmentDuration != nil && b.ko.Spec.CommitmentDuration != nil { @@ -85,13 +78,6 @@ func newResourceDelta( delta.Add("Spec.DeliveryPreference", a.ko.Spec.DeliveryPreference, b.ko.Spec.DeliveryPreference) } } - if ackcompare.HasNilDifference(a.ko.Spec.DryRun, b.ko.Spec.DryRun) { - delta.Add("Spec.DryRun", a.ko.Spec.DryRun, b.ko.Spec.DryRun) - } else if a.ko.Spec.DryRun != nil && b.ko.Spec.DryRun != nil { - if *a.ko.Spec.DryRun != *b.ko.Spec.DryRun { - delta.Add("Spec.DryRun", a.ko.Spec.DryRun, b.ko.Spec.DryRun) - } - } if ackcompare.HasNilDifference(a.ko.Spec.EBSOptimized, b.ko.Spec.EBSOptimized) { delta.Add("Spec.EBSOptimized", a.ko.Spec.EBSOptimized, b.ko.Spec.EBSOptimized) } else if a.ko.Spec.EBSOptimized != nil && b.ko.Spec.EBSOptimized != nil { diff --git a/pkg/resource/capacity_reservation/sdk.go b/pkg/resource/capacity_reservation/sdk.go index e61adaed..3c3e7131 100644 --- a/pkg/resource/capacity_reservation/sdk.go +++ b/pkg/resource/capacity_reservation/sdk.go @@ -295,9 +295,6 @@ func (rm *resourceManager) newListRequestPayload( f0 = append(f0, *r.ko.Status.CapacityReservationID) res.CapacityReservationIds = f0 } - if r.ko.Spec.DryRun != nil { - res.DryRun = r.ko.Spec.DryRun - } return res, nil } @@ -520,18 +517,12 @@ func (rm *resourceManager) newCreateRequestPayload( if r.ko.Spec.AvailabilityZoneID != nil { res.AvailabilityZoneId = r.ko.Spec.AvailabilityZoneID } - if r.ko.Spec.ClientToken != nil { - res.ClientToken = r.ko.Spec.ClientToken - } if r.ko.Spec.CommitmentDuration != nil { res.CommitmentDuration = r.ko.Spec.CommitmentDuration } if r.ko.Spec.DeliveryPreference != nil { res.DeliveryPreference = svcsdktypes.CapacityReservationDeliveryPreference(*r.ko.Spec.DeliveryPreference) } - if r.ko.Spec.DryRun != nil { - res.DryRun = r.ko.Spec.DryRun - } if r.ko.Spec.EBSOptimized != nil { res.EbsOptimized = r.ko.Spec.EBSOptimized } @@ -651,9 +642,6 @@ func (rm *resourceManager) newUpdateRequestPayload( if r.ko.Status.CapacityReservationID != nil { res.CapacityReservationId = r.ko.Status.CapacityReservationID } - if r.ko.Spec.DryRun != nil { - res.DryRun = r.ko.Spec.DryRun - } if r.ko.Spec.EndDate != nil { res.EndDate = &r.ko.Spec.EndDate.Time } @@ -706,9 +694,6 @@ func (rm *resourceManager) newDeleteRequestPayload( if r.ko.Status.CapacityReservationID != nil { res.CapacityReservationId = r.ko.Status.CapacityReservationID } - if r.ko.Spec.DryRun != nil { - res.DryRun = r.ko.Spec.DryRun - } return res, nil }