diff --git a/.golangci-kal.yml b/.golangci-kal.yml index ab8ed03edf..02dfc5a6da 100644 --- a/.golangci-kal.yml +++ b/.golangci-kal.yml @@ -24,7 +24,7 @@ linters: #- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items. #- "nobools" # Bools do not evolve over time, should use enums instead. #- "nofloats" # Ensure floats are not used. - #- "optionalorrequired" # Every field should be marked as `+optional` or `+required`. + - "optionalorrequired" # Every field should be marked as `+optional` or `+required`. # - "requiredfields" # Required fields should not be pointers, and should not have `omitempty`. - "statussubresource" # All root objects that have a `status` field should have a status subresource. diff --git a/api/v1beta1/awscluster_types.go b/api/v1beta1/awscluster_types.go index 0c258d7cf6..25d49fd4ed 100644 --- a/api/v1beta1/awscluster_types.go +++ b/api/v1beta1/awscluster_types.go @@ -20,6 +20,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) const ( @@ -34,9 +35,11 @@ const ( // AWSClusterSpec defines the desired state of an EC2-based Kubernetes cluster. type AWSClusterSpec struct { // NetworkSpec encapsulates all things related to AWS network. + // +optional NetworkSpec NetworkSpec `json:"network,omitempty"` // The AWS Region the cluster lives in. + // +optional Region string `json:"region,omitempty"` // SSHKeyName is the name of the ssh key to attach to the bastion host. Valid values are empty string (do not use SSH keys), a valid SSH key name, or omitted (use the default SSH key name) @@ -45,7 +48,7 @@ type AWSClusterSpec struct { // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. // +optional - ControlPlaneEndpoint clusterv1beta1.APIEndpoint `json:"controlPlaneEndpoint"` + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` // AdditionalTags is an optional set of tags to add to AWS resources managed by the AWS provider, in addition to the // ones added by default. @@ -81,6 +84,7 @@ type AWSClusterSpec struct { // up machine images when a machine does not specify an AMI. When set, this // will be used for all cluster machines unless a machine specifies a // different ImageLookupBaseOS. + // +optional ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"` // Bastion contains options to configure the bastion host. @@ -91,6 +95,7 @@ type AWSClusterSpec struct { // IdentityRef is a reference to an identity to be used when reconciling the managed control plane. // If no identity is specified, the default identity for this controller will be used. + // +optional IdentityRef *AWSIdentityReference `json:"identityRef,omitempty"` // S3Bucket contains options to configure a supporting S3 bucket for this @@ -119,10 +124,12 @@ var ( type AWSIdentityReference struct { // Name of the identity. // +kubebuilder:validation:MinLength=1 + // +required Name string `json:"name"` // Kind of the identity. // +kubebuilder:validation:Enum=AWSClusterControllerIdentity;AWSClusterRoleIdentity;AWSClusterStaticIdentity + // +required Kind AWSIdentityKind `json:"kind"` } @@ -146,6 +153,7 @@ type Bastion struct { // InstanceType will use the specified instance type for the bastion. If not specified, // Cluster API Provider AWS will use t3.micro for all regions except us-east-1, where t2.micro // will be the default. + // +optional InstanceType string `json:"instanceType,omitempty"` // AMI will use the specified AMI to boot the bastion. If not specified, @@ -200,27 +208,35 @@ type AWSLoadBalancerSpec struct { // AWSClusterStatus defines the observed state of AWSCluster. type AWSClusterStatus struct { // +kubebuilder:default=false - Ready bool `json:"ready"` - Network NetworkStatus `json:"networkStatus,omitempty"` + // +required + Ready bool `json:"ready"` + // +optional + Network NetworkStatus `json:"networkStatus,omitempty"` + // +optional FailureDomains clusterv1beta1.FailureDomains `json:"failureDomains,omitempty"` - Bastion *Instance `json:"bastion,omitempty"` - Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"` + // +optional + Bastion *Instance `json:"bastion,omitempty"` + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // S3Bucket defines a supporting S3 bucket for the cluster, currently can be optionally used for Ignition. type S3Bucket struct { // ControlPlaneIAMInstanceProfile is a name of the IAMInstanceProfile, which will be allowed // to read control-plane node bootstrap data from S3 Bucket. + // +required ControlPlaneIAMInstanceProfile string `json:"controlPlaneIAMInstanceProfile"` // NodesIAMInstanceProfiles is a list of IAM instance profiles, which will be allowed to read // worker nodes bootstrap data from S3 Bucket. + // +required NodesIAMInstanceProfiles []string `json:"nodesIAMInstanceProfiles"` // Name defines name of S3 Bucket to be created. // +kubebuilder:validation:MinLength:=3 // +kubebuilder:validation:MaxLength:=63 // +kubebuilder:validation:Pattern=`^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$` + // +required Name string `json:"name"` } @@ -236,10 +252,13 @@ type S3Bucket struct { // AWSCluster is the schema for Amazon EC2 based Kubernetes Cluster API. type AWSCluster struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec AWSClusterSpec `json:"spec,omitempty"` + // +optional + Spec AWSClusterSpec `json:"spec,omitempty"` + // +optional Status AWSClusterStatus `json:"status,omitempty"` } @@ -249,8 +268,10 @@ type AWSCluster struct { // AWSClusterList contains a list of AWSCluster. type AWSClusterList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []AWSCluster `json:"items"` + // +required + Items []AWSCluster `json:"items"` } // GetConditions returns the observations of the operational state of the AWSCluster resource. diff --git a/api/v1beta1/awsclustertemplate_types.go b/api/v1beta1/awsclustertemplate_types.go index 1b0d1f100f..e2d64bca1e 100644 --- a/api/v1beta1/awsclustertemplate_types.go +++ b/api/v1beta1/awsclustertemplate_types.go @@ -19,11 +19,12 @@ package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) // AWSClusterTemplateSpec defines the desired state of AWSClusterTemplate. type AWSClusterTemplateSpec struct { + // +required Template AWSClusterTemplateResource `json:"template"` } @@ -34,9 +35,11 @@ type AWSClusterTemplateSpec struct { // AWSClusterTemplate is the schema for Amazon EC2 based Kubernetes Cluster Templates. type AWSClusterTemplate struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSClusterTemplateSpec `json:"spec,omitempty"` } @@ -45,8 +48,10 @@ type AWSClusterTemplate struct { // AWSClusterTemplateList contains a list of AWSClusterTemplate. type AWSClusterTemplateList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []AWSClusterTemplate `json:"items"` + // +required + Items []AWSClusterTemplate `json:"items"` } func init() { @@ -58,6 +63,7 @@ type AWSClusterTemplateResource struct { // Standard object's metadata. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata // +optional - ObjectMeta clusterv1beta1.ObjectMeta `json:"metadata,omitempty"` - Spec AWSClusterSpec `json:"spec"` + ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"` + // +required + Spec AWSClusterSpec `json:"spec"` } diff --git a/api/v1beta1/awsidentity_types.go b/api/v1beta1/awsidentity_types.go index 63a1751f17..1a273d715f 100644 --- a/api/v1beta1/awsidentity_types.go +++ b/api/v1beta1/awsidentity_types.go @@ -53,19 +53,24 @@ type AllowedNamespaces struct { // AWSRoleSpec defines the specifications for all identities based around AWS roles. type AWSRoleSpec struct { // The Amazon Resource Name (ARN) of the role to assume. + // +required RoleArn string `json:"roleARN"` // An identifier for the assumed role session + // +optional SessionName string `json:"sessionName,omitempty"` // The duration, in seconds, of the role session before it is renewed. // +kubebuilder:validation:Minimum:=900 // +kubebuilder:validation:Maximum:=43200 + // +optional DurationSeconds int32 `json:"durationSeconds,omitempty"` // An IAM policy as a JSON-encoded string that you want to use as an inline session policy. + // +optional InlinePolicy string `json:"inlinePolicy,omitempty"` // The Amazon Resource Names (ARNs) of the IAM managed policies that you want // to use as managed session policies. // The policies must exist in the same account as the role. + // +optional PolicyARNs []string `json:"policyARNs,omitempty"` } @@ -77,9 +82,11 @@ type AWSRoleSpec struct { // It represents a reference to an AWS access key ID and secret access key, stored in a secret. type AWSClusterStaticIdentity struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` // Spec for this AWSClusterStaticIdentity + // +optional Spec AWSClusterStaticIdentitySpec `json:"spec,omitempty"` } @@ -89,7 +96,9 @@ type AWSClusterStaticIdentity struct { // AWSClusterStaticIdentityList contains a list of AWSClusterStaticIdentity. type AWSClusterStaticIdentityList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSClusterStaticIdentity `json:"items"` } @@ -101,6 +110,7 @@ type AWSClusterStaticIdentitySpec struct { // AccessKeyID: AKIAIOSFODNN7EXAMPLE // SecretAccessKey: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY // SessionToken: Optional + // +required SecretRef string `json:"secretRef"` } @@ -112,9 +122,11 @@ type AWSClusterStaticIdentitySpec struct { // It is used to assume a role using the provided sourceRef. type AWSClusterRoleIdentity struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` // Spec for this AWSClusterRoleIdentity. + // +optional Spec AWSClusterRoleIdentitySpec `json:"spec,omitempty"` } @@ -124,7 +136,9 @@ type AWSClusterRoleIdentity struct { // AWSClusterRoleIdentityList contains a list of AWSClusterRoleIdentity. type AWSClusterRoleIdentityList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSClusterRoleIdentity `json:"items"` } @@ -146,6 +160,7 @@ type AWSClusterRoleIdentitySpec struct { // SourceIdentityRef is a reference to another identity which will be chained to do // role assumption. All identity types are accepted. + // +optional SourceIdentityRef *AWSIdentityReference `json:"sourceIdentityRef,omitempty"` } @@ -157,9 +172,11 @@ type AWSClusterRoleIdentitySpec struct { // It is used to grant access to use Cluster API Provider AWS Controller credentials. type AWSClusterControllerIdentity struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` // Spec for this AWSClusterControllerIdentity. + // +optional Spec AWSClusterControllerIdentitySpec `json:"spec,omitempty"` } @@ -169,7 +186,9 @@ type AWSClusterControllerIdentity struct { // AWSClusterControllerIdentityList contains a list of AWSClusterControllerIdentity. type AWSClusterControllerIdentityList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSClusterControllerIdentity `json:"items"` } diff --git a/api/v1beta1/awsmachine_types.go b/api/v1beta1/awsmachine_types.go index d6bf89d1ea..69df253174 100644 --- a/api/v1beta1/awsmachine_types.go +++ b/api/v1beta1/awsmachine_types.go @@ -19,7 +19,7 @@ package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) const ( @@ -45,12 +45,15 @@ var ( // AWSMachineSpec defines the desired state of an Amazon EC2 instance. type AWSMachineSpec struct { // ProviderID is the unique identifier as specified by the cloud provider. + // +optional ProviderID *string `json:"providerID,omitempty"` // InstanceID is the EC2 instance ID for this machine. + // +optional InstanceID *string `json:"instanceID,omitempty"` // AMI is the reference to the AMI from which to create the machine instance. + // +optional AMI AMIReference `json:"ami,omitempty"` // ImageLookupFormat is the AMI naming format to look up the image for this @@ -68,14 +71,16 @@ type AWSMachineSpec struct { ImageLookupFormat string `json:"imageLookupFormat,omitempty"` // ImageLookupOrg is the AWS Organization ID to use for image lookup if AMI is not set. + // +optional ImageLookupOrg string `json:"imageLookupOrg,omitempty"` // ImageLookupBaseOS is the name of the base operating system to use for // image lookup the AMI is not set. + // +optional ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"` // InstanceType is the type of instance to create. Example: m4.xlarge - // +kubebuilder:validation:Required + // +required // +kubebuilder:validation:MinLength:=2 InstanceType string `json:"instanceType"` @@ -107,6 +112,7 @@ type AWSMachineSpec struct { // FailureDomain is the failure domain unique identifier this Machine should be attached to, as defined in Cluster API. // For this infrastructure provider, the ID is equivalent to an AWS Availability Zone. // If multiple subnets are matched for the availability zone, the first one returned is picked. + // +optional FailureDomain *string `json:"failureDomain,omitempty"` // Subnet is a reference to the subnet to use for this instance. If not specified, @@ -165,6 +171,7 @@ type CloudInit struct { // or AWS Systems Manager Parameter Store to ensure privacy of userdata. // By default, a cloud-init boothook shell script is prepended to download // the userdata from Secrets Manager and additionally delete the secret. + // +optional InsecureSkipSecretsManager bool `json:"insecureSkipSecretsManager,omitempty"` // SecretCount is the number of secrets used to form the complete secret @@ -207,7 +214,8 @@ type AWSMachineStatus struct { Interruptible bool `json:"interruptible,omitempty"` // Addresses contains the AWS instance associated addresses. - Addresses []clusterv1beta1.MachineAddress `json:"addresses,omitempty"` + // +optional + Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"` // InstanceState is the state of the AWS instance for this machine. // +optional @@ -253,7 +261,7 @@ type AWSMachineStatus struct { // Conditions defines current service state of the AWSMachine. // +optional - Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"` + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // +kubebuilder:object:root=true @@ -268,20 +276,23 @@ type AWSMachineStatus struct { // AWSMachine is the schema for Amazon EC2 machines. type AWSMachine struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec AWSMachineSpec `json:"spec,omitempty"` + // +optional + Spec AWSMachineSpec `json:"spec,omitempty"` + // +optional Status AWSMachineStatus `json:"status,omitempty"` } // GetConditions returns the observations of the operational state of the AWSMachine resource. -func (r *AWSMachine) GetConditions() clusterv1beta1.Conditions { +func (r *AWSMachine) GetConditions() clusterv1.Conditions { return r.Status.Conditions } -// SetConditions sets the underlying service state of the AWSMachine to the predescribed clusterv1beta1.Conditions. -func (r *AWSMachine) SetConditions(conditions clusterv1beta1.Conditions) { +// SetConditions sets the underlying service state of the AWSMachine to the predescribed clusterv1.Conditions. +func (r *AWSMachine) SetConditions(conditions clusterv1.Conditions) { r.Status.Conditions = conditions } @@ -291,8 +302,10 @@ func (r *AWSMachine) SetConditions(conditions clusterv1beta1.Conditions) { // AWSMachineList contains a list of Amazon EC2 machines. type AWSMachineList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []AWSMachine `json:"items"` + // +required + Items []AWSMachine `json:"items"` } func init() { diff --git a/api/v1beta1/awsmachinetemplate_types.go b/api/v1beta1/awsmachinetemplate_types.go index 6e1a98fdbc..57684eee60 100644 --- a/api/v1beta1/awsmachinetemplate_types.go +++ b/api/v1beta1/awsmachinetemplate_types.go @@ -34,6 +34,7 @@ type AWSMachineTemplateStatus struct { // AWSMachineTemplateSpec defines the desired state of AWSMachineTemplate. type AWSMachineTemplateSpec struct { + // +required Template AWSMachineTemplateResource `json:"template"` } @@ -44,9 +45,12 @@ type AWSMachineTemplateSpec struct { // AWSMachineTemplate is the schema for the Amazon EC2 Machine Templates API. type AWSMachineTemplate struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSMachineTemplateSpec `json:"spec,omitempty"` + // +optional Status AWSMachineTemplateStatus `json:"status,omitempty"` } @@ -56,7 +60,9 @@ type AWSMachineTemplate struct { // AWSMachineTemplateList contains a list of AWSMachineTemplate. type AWSMachineTemplateList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSMachineTemplate `json:"items"` } @@ -68,6 +74,7 @@ type AWSMachineTemplateResource struct { ObjectMeta clusterv1beta1.ObjectMeta `json:"metadata,omitempty"` // Spec is the specification of the desired behavior of the machine. + // +required Spec AWSMachineSpec `json:"spec"` } diff --git a/api/v1beta1/network_types.go b/api/v1beta1/network_types.go index f72940f45b..9438152c4d 100644 --- a/api/v1beta1/network_types.go +++ b/api/v1beta1/network_types.go @@ -25,9 +25,11 @@ import ( // NetworkStatus encapsulates AWS networking resources. type NetworkStatus struct { // SecurityGroups is a map from the role/kind of the security group to its unique name, if any. + // +optional SecurityGroups map[SecurityGroupRole]SecurityGroup `json:"securityGroups,omitempty"` // APIServerELB is the Kubernetes api server classic load balancer. + // +optional APIServerELB ClassicELB `json:"apiServerElb,omitempty"` } @@ -80,30 +82,39 @@ type ClassicELB struct { Name string `json:"name,omitempty"` // DNSName is the dns name of the load balancer. + // +optional DNSName string `json:"dnsName,omitempty"` // Scheme is the load balancer scheme, either internet-facing or private. + // +optional Scheme ClassicELBScheme `json:"scheme,omitempty"` // AvailabilityZones is an array of availability zones in the VPC attached to the load balancer. + // +optional AvailabilityZones []string `json:"availabilityZones,omitempty"` // SubnetIDs is an array of subnets in the VPC attached to the load balancer. + // +optional SubnetIDs []string `json:"subnetIds,omitempty"` // SecurityGroupIDs is an array of security groups assigned to the load balancer. + // +optional SecurityGroupIDs []string `json:"securityGroupIds,omitempty"` // Listeners is an array of classic elb listeners associated with the load balancer. There must be at least one. + // +optional Listeners []ClassicELBListener `json:"listeners,omitempty"` // HealthCheck is the classic elb health check associated with the load balancer. + // +optional HealthCheck *ClassicELBHealthCheck `json:"healthChecks,omitempty"` // Attributes defines extra attributes associated with the load balancer. + // +optional Attributes ClassicELBAttributes `json:"attributes,omitempty"` // Tags is a map of tags associated with the load balancer. + // +optional Tags map[string]string `json:"tags,omitempty"` } @@ -121,6 +132,7 @@ func (b *ClassicELB) IsManaged(clusterName string) bool { type ClassicELBAttributes struct { // IdleTimeout is time that the connection is allowed to be idle (no data // has been sent over the connection) before it is closed by the load balancer. + // +optional IdleTimeout time.Duration `json:"idleTimeout,omitempty"` // CrossZoneLoadBalancing enables the classic load balancer load balancing. @@ -130,18 +142,27 @@ type ClassicELBAttributes struct { // ClassicELBListener defines an AWS classic load balancer listener. type ClassicELBListener struct { + // +required Protocol ClassicELBProtocol `json:"protocol"` + // +required Port int64 `json:"port"` + // +required InstanceProtocol ClassicELBProtocol `json:"instanceProtocol"` + // +required InstancePort int64 `json:"instancePort"` } // ClassicELBHealthCheck defines an AWS classic load balancer health check. type ClassicELBHealthCheck struct { + // +required Target string `json:"target"` + // +required Interval time.Duration `json:"interval"` + // +required Timeout time.Duration `json:"timeout"` + // +required HealthyThreshold int64 `json:"healthyThreshold"` + // +required UnhealthyThreshold int64 `json:"unhealthyThreshold"` } @@ -183,10 +204,12 @@ type IPv6 struct { // VPCSpec configures an AWS VPC. type VPCSpec struct { // ID is the vpc-id of the VPC this provider should use to create resources. + // +optional ID string `json:"id,omitempty"` // CidrBlock is the CIDR block to be used when the provider creates a managed VPC. // Defaults to 10.0.0.0/16. + // +optional CidrBlock string `json:"cidrBlock,omitempty"` // IPv6 contains ipv6 specific settings for the network. Supported only in managed clusters. @@ -199,6 +222,7 @@ type VPCSpec struct { InternetGatewayID *string `json:"internetGatewayId,omitempty"` // Tags is a collection of tags describing the resource. + // +optional Tags Tags `json:"tags,omitempty"` // AvailabilityZoneUsageLimit specifies the maximum number of availability zones (AZ) that @@ -207,6 +231,7 @@ type VPCSpec struct { // default subnets. Defaults to 3 // +kubebuilder:default=3 // +kubebuilder:validation:Minimum=1 + // +optional AvailabilityZoneUsageLimit *int `json:"availabilityZoneUsageLimit,omitempty"` // AvailabilityZoneSelection specifies how AZs should be selected if there are more AZs @@ -216,6 +241,7 @@ type VPCSpec struct { // Defaults to Ordered // +kubebuilder:default=Ordered // +kubebuilder:validation:Enum=Ordered;Random + // +optional AvailabilityZoneSelection *AZSelectionScheme `json:"availabilityZoneSelection,omitempty"` } @@ -242,9 +268,11 @@ func (v *VPCSpec) IsIPv6Enabled() bool { // SubnetSpec configures an AWS Subnet. type SubnetSpec struct { // ID defines a unique identifier to reference this resource. + // +optional ID string `json:"id,omitempty"` // CidrBlock is the CIDR block to be used when the provider creates a managed VPC. + // +optional CidrBlock string `json:"cidrBlock,omitempty"` // IPv6CidrBlock is the IPv6 CIDR block to be used when the provider creates a managed VPC. @@ -254,6 +282,7 @@ type SubnetSpec struct { IPv6CidrBlock string `json:"ipv6CidrBlock,omitempty"` // AvailabilityZone defines the availability zone to use for this subnet in the cluster's region. + // +optional AvailabilityZone string `json:"availabilityZone,omitempty"` // IsPublic defines the subnet as a public subnet. A subnet is public when it is associated with a route table that has a route to an internet gateway. @@ -275,6 +304,7 @@ type SubnetSpec struct { NatGatewayID *string `json:"natGatewayId,omitempty"` // Tags is a collection of tags describing the resource. + // +optional Tags Tags `json:"tags,omitempty"` } @@ -375,6 +405,7 @@ func (s Subnets) GetUniqueZones() []string { type CNISpec struct { // CNIIngressRules specify rules to apply to control plane and worker node security groups. // The source for the rule will be set to control plane and worker security group IDs. + // +optional CNIIngressRules CNIIngressRules `json:"cniIngressRules,omitempty"` } @@ -383,14 +414,19 @@ type CNIIngressRules []CNIIngressRule // CNIIngressRule defines an AWS ingress rule for CNI requirements. type CNIIngressRule struct { + // +required Description string `json:"description"` + // +required Protocol SecurityGroupProtocol `json:"protocol"` + // +required FromPort int64 `json:"fromPort"` + // +required ToPort int64 `json:"toPort"` } // RouteTable defines an AWS routing table. type RouteTable struct { + // +required ID string `json:"id"` } @@ -420,9 +456,11 @@ var ( // SecurityGroup defines an AWS security group. type SecurityGroup struct { // ID is a unique identifier. + // +required ID string `json:"id"` // Name is the security group name. + // +required Name string `json:"name"` // IngressRules is the inbound rules associated with the security group. @@ -430,6 +468,7 @@ type SecurityGroup struct { IngressRules IngressRules `json:"ingressRule,omitempty"` // Tags is a map of tags associated with the security group. + // +optional Tags Tags `json:"tags,omitempty"` } @@ -463,9 +502,13 @@ var ( // IngressRule defines an AWS ingress rule for security groups. type IngressRule struct { + // +required Description string `json:"description"` + // +required Protocol SecurityGroupProtocol `json:"protocol"` + // +required FromPort int64 `json:"fromPort"` + // +required ToPort int64 `json:"toPort"` // List of CIDR blocks to allow access from. Cannot be specified with SourceSecurityGroupID. diff --git a/api/v1beta1/tags.go b/api/v1beta1/tags.go index 1d711937a0..959c1abb40 100644 --- a/api/v1beta1/tags.go +++ b/api/v1beta1/tags.go @@ -212,12 +212,15 @@ func ClusterAWSCloudProviderTagKey(name string) string { // BuildParams is used to build tags around an aws resource. type BuildParams struct { // Lifecycle determines the resource lifecycle. + // +optional Lifecycle ResourceLifecycle // ClusterName is the cluster associated with the resource. + // +optional ClusterName string // ResourceID is the unique identifier of the resource to be tagged. + // +optional ResourceID string // Name is the name of the resource, it's applied as the tag "Name" on AWS. diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index 55ec56b0c7..f8c0633bf9 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -19,7 +19,7 @@ package v1beta1 import ( "k8s.io/apimachinery/pkg/util/sets" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) // AWSResourceReference is a reference to a specific AWS resource by ID or filters. @@ -59,9 +59,11 @@ type AMIReference struct { // Filter is a filter used to identify an AWS resource. type Filter struct { // Name of the filter. Filter names are case-sensitive. + // +required Name string `json:"name"` // Values includes one or more filter values. Filter values are case-sensitive. + // +required Values []string `json:"values"` } @@ -137,46 +139,58 @@ var ( // Instance describes an AWS instance. type Instance struct { + // +required ID string `json:"id"` // The current state of the instance. + // +optional State InstanceState `json:"instanceState,omitempty"` // The instance type. + // +optional Type string `json:"type,omitempty"` // The ID of the subnet of the instance. + // +optional SubnetID string `json:"subnetId,omitempty"` // The ID of the AMI used to launch the instance. + // +optional ImageID string `json:"imageId,omitempty"` // The name of the SSH key pair. + // +optional SSHKeyName *string `json:"sshKeyName,omitempty"` // SecurityGroupIDs are one or more security group IDs this instance belongs to. + // +optional SecurityGroupIDs []string `json:"securityGroupIds,omitempty"` // UserData is the raw data script passed to the instance which is run upon bootstrap. // This field must not be base64 encoded and should only be used when running a new instance. + // +optional UserData *string `json:"userData,omitempty"` // The name of the IAM instance profile associated with the instance, if applicable. + // +optional IAMProfile string `json:"iamProfile,omitempty"` // Addresses contains the AWS instance associated addresses. - Addresses []clusterv1beta1.MachineAddress `json:"addresses,omitempty"` - - // The private IPv4 address assigned to the instance. + // +optional + Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"` // The private IPv4 address assigned to the instance. + // +optional PrivateIP *string `json:"privateIp,omitempty"` // The public IPv4 address assigned to the instance, if applicable. + // +optional PublicIP *string `json:"publicIp,omitempty"` // Specifies whether enhanced networking with ENA is enabled. + // +optional ENASupport *bool `json:"enaSupport,omitempty"` // Indicates whether the instance is optimized for Amazon EBS I/O. + // +optional EBSOptimized *bool `json:"ebsOptimized,omitempty"` // Configuration options for the root storage volume. @@ -188,15 +202,19 @@ type Instance struct { NonRootVolumes []Volume `json:"nonRootVolumes,omitempty"` // Specifies ENIs attached to instance + // +optional NetworkInterfaces []string `json:"networkInterfaces,omitempty"` // The tags associated with the instance. + // +optional Tags map[string]string `json:"tags,omitempty"` // Availability zone of instance + // +optional AvailabilityZone string `json:"availabilityZone,omitempty"` // SpotMarketOptions option for configuring instances to be run using AWS Spot instances. + // +optional SpotMarketOptions *SpotMarketOptions `json:"spotMarketOptions,omitempty"` // Tenancy indicates if instance should run on shared or single-tenant hardware. @@ -217,6 +235,7 @@ type Volume struct { // Size specifies size (in Gi) of the storage device. // Must be greater than the image snapshot size or 8 (whichever is greater). // +kubebuilder:validation:Minimum=8 + // +required Size int64 `json:"size"` // Type is the type of the volume (e.g. gp2, io1, etc...). diff --git a/api/v1beta2/awscluster_types.go b/api/v1beta2/awscluster_types.go index 184ef9de43..3040585a44 100644 --- a/api/v1beta2/awscluster_types.go +++ b/api/v1beta2/awscluster_types.go @@ -19,7 +19,7 @@ package v1beta2 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) const ( @@ -34,9 +34,11 @@ const ( // AWSClusterSpec defines the desired state of an EC2-based Kubernetes cluster. type AWSClusterSpec struct { // NetworkSpec encapsulates all things related to AWS network. + // +optional NetworkSpec NetworkSpec `json:"network,omitempty"` // The AWS Region the cluster lives in. + // +optional Region string `json:"region,omitempty"` // Partition is the AWS security partition being used. Defaults to "aws" @@ -49,7 +51,7 @@ type AWSClusterSpec struct { // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. // +optional - ControlPlaneEndpoint clusterv1beta1.APIEndpoint `json:"controlPlaneEndpoint"` + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` // AdditionalTags is an optional set of tags to add to AWS resources managed by the AWS provider, in addition to the // ones added by default. @@ -93,6 +95,7 @@ type AWSClusterSpec struct { // up machine images when a machine does not specify an AMI. When set, this // will be used for all cluster machines unless a machine specifies a // different ImageLookupBaseOS. + // +optional ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"` // Bastion contains options to configure the bastion host. @@ -103,6 +106,7 @@ type AWSClusterSpec struct { // IdentityRef is a reference to an identity to be used when reconciling the managed control plane. // If no identity is specified, the default identity for this controller will be used. + // +optional IdentityRef *AWSIdentityReference `json:"identityRef,omitempty"` // S3Bucket contains options to configure a supporting S3 bucket for this @@ -131,10 +135,12 @@ var ( type AWSIdentityReference struct { // Name of the identity. // +kubebuilder:validation:MinLength=1 + // +required Name string `json:"name"` // Kind of the identity. // +kubebuilder:validation:Enum=AWSClusterControllerIdentity;AWSClusterRoleIdentity;AWSClusterStaticIdentity + // +required Kind AWSIdentityKind `json:"kind"` } @@ -158,6 +164,7 @@ type Bastion struct { // InstanceType will use the specified instance type for the bastion. If not specified, // Cluster API Provider AWS will use t3.micro for all regions except us-east-1, where t2.micro // will be the default. + // +optional InstanceType string `json:"instanceType,omitempty"` // AMI will use the specified AMI to boot the bastion. If not specified, @@ -243,14 +250,17 @@ type AWSLoadBalancerSpec struct { // LoadBalancerType sets the type for a load balancer. The default type is classic. // +kubebuilder:default=classic // +kubebuilder:validation:Enum:=classic;elb;alb;nlb;disabled + // +optional LoadBalancerType LoadBalancerType `json:"loadBalancerType,omitempty"` // DisableHostsRewrite disabled the hair pinning issue solution that adds the NLB's address as 127.0.0.1 to the hosts // file of each instance. This is by default, false. + // +optional DisableHostsRewrite bool `json:"disableHostsRewrite,omitempty"` // PreserveClientIP lets the user control if preservation of client ips must be retained or not. // If this is enabled 6443 will be opened to 0.0.0.0/0. + // +optional PreserveClientIP bool `json:"preserveClientIP,omitempty"` } @@ -260,12 +270,14 @@ type AdditionalListenerSpec struct { // Port sets the port for the additional listener. // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 + // +required Port int64 `json:"port"` // Protocol sets the protocol for the additional listener. // Currently only TCP is supported. // +kubebuilder:validation:Enum=TCP // +kubebuilder:default=TCP + // +optional Protocol ELBProtocol `json:"protocol,omitempty"` // HealthCheck sets the optional custom health check configuration to the API target group. @@ -276,11 +288,16 @@ type AdditionalListenerSpec struct { // AWSClusterStatus defines the observed state of AWSCluster. type AWSClusterStatus struct { // +kubebuilder:default=false - Ready bool `json:"ready"` - Network NetworkStatus `json:"networkStatus,omitempty"` - FailureDomains clusterv1beta1.FailureDomains `json:"failureDomains,omitempty"` - Bastion *Instance `json:"bastion,omitempty"` - Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"` + // +required + Ready bool `json:"ready"` + // +optional + Network NetworkStatus `json:"networkStatus,omitempty"` + // +optional + FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"` + // +optional + Bastion *Instance `json:"bastion,omitempty"` + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // S3Bucket defines a supporting S3 bucket for the cluster, currently can be optionally used for Ignition. @@ -308,6 +325,7 @@ type S3Bucket struct { // +kubebuilder:validation:MinLength:=3 // +kubebuilder:validation:MaxLength:=63 // +kubebuilder:validation:Pattern=`^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$` + // +required Name string `json:"name"` // BestEffortDeleteObjects defines whether access/permission errors during object deletion should be ignored. @@ -328,10 +346,13 @@ type S3Bucket struct { // AWSCluster is the schema for Amazon EC2 based Kubernetes Cluster API. type AWSCluster struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec AWSClusterSpec `json:"spec,omitempty"` + // +optional + Spec AWSClusterSpec `json:"spec,omitempty"` + // +optional Status AWSClusterStatus `json:"status,omitempty"` } @@ -341,17 +362,19 @@ type AWSCluster struct { // +k8s:defaulter-gen=true type AWSClusterList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []AWSCluster `json:"items"` + // +required + Items []AWSCluster `json:"items"` } // GetConditions returns the observations of the operational state of the AWSCluster resource. -func (r *AWSCluster) GetConditions() clusterv1beta1.Conditions { +func (r *AWSCluster) GetConditions() clusterv1.Conditions { return r.Status.Conditions } -// SetConditions sets the underlying service state of the AWSCluster to the predescribed clusterv1beta1.Conditions. -func (r *AWSCluster) SetConditions(conditions clusterv1beta1.Conditions) { +// SetConditions sets the underlying service state of the AWSCluster to the predescribed clusterv1.Conditions. +func (r *AWSCluster) SetConditions(conditions clusterv1.Conditions) { r.Status.Conditions = conditions } diff --git a/api/v1beta2/awsclustertemplate_types.go b/api/v1beta2/awsclustertemplate_types.go index 2f81400eef..d28c18f498 100644 --- a/api/v1beta2/awsclustertemplate_types.go +++ b/api/v1beta2/awsclustertemplate_types.go @@ -19,11 +19,12 @@ package v1beta2 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) // AWSClusterTemplateSpec defines the desired state of AWSClusterTemplate. type AWSClusterTemplateSpec struct { + // +required Template AWSClusterTemplateResource `json:"template"` } @@ -35,9 +36,11 @@ type AWSClusterTemplateSpec struct { // AWSClusterTemplate is the schema for Amazon EC2 based Kubernetes Cluster Templates. type AWSClusterTemplate struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSClusterTemplateSpec `json:"spec,omitempty"` } @@ -46,8 +49,10 @@ type AWSClusterTemplate struct { // AWSClusterTemplateList contains a list of AWSClusterTemplate. type AWSClusterTemplateList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []AWSClusterTemplate `json:"items"` + // +required + Items []AWSClusterTemplate `json:"items"` } func init() { @@ -59,6 +64,7 @@ type AWSClusterTemplateResource struct { // Standard object's metadata. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata // +optional - ObjectMeta clusterv1beta1.ObjectMeta `json:"metadata,omitempty"` - Spec AWSClusterSpec `json:"spec"` + ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"` + // +required + Spec AWSClusterSpec `json:"spec"` } diff --git a/api/v1beta2/awsidentity_types.go b/api/v1beta2/awsidentity_types.go index 27b56d78d5..140356ca66 100644 --- a/api/v1beta2/awsidentity_types.go +++ b/api/v1beta2/awsidentity_types.go @@ -53,19 +53,24 @@ type AllowedNamespaces struct { // AWSRoleSpec defines the specifications for all identities based around AWS roles. type AWSRoleSpec struct { // The Amazon Resource Name (ARN) of the role to assume. + // +required RoleArn string `json:"roleARN"` // An identifier for the assumed role session + // +optional SessionName string `json:"sessionName,omitempty"` // The duration, in seconds, of the role session before it is renewed. // +kubebuilder:validation:Minimum:=900 // +kubebuilder:validation:Maximum:=43200 + // +optional DurationSeconds int32 `json:"durationSeconds,omitempty"` // An IAM policy as a JSON-encoded string that you want to use as an inline session policy. + // +optional InlinePolicy string `json:"inlinePolicy,omitempty"` // The Amazon Resource Names (ARNs) of the IAM managed policies that you want // to use as managed session policies. // The policies must exist in the same account as the role. + // +optional PolicyARNs []string `json:"policyARNs,omitempty"` } @@ -78,9 +83,11 @@ type AWSRoleSpec struct { // It represents a reference to an AWS access key ID and secret access key, stored in a secret. type AWSClusterStaticIdentity struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` // Spec for this AWSClusterStaticIdentity + // +optional Spec AWSClusterStaticIdentitySpec `json:"spec,omitempty"` } @@ -90,7 +97,9 @@ type AWSClusterStaticIdentity struct { // AWSClusterStaticIdentityList contains a list of AWSClusterStaticIdentity. type AWSClusterStaticIdentityList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSClusterStaticIdentity `json:"items"` } @@ -102,6 +111,7 @@ type AWSClusterStaticIdentitySpec struct { // AccessKeyID: AKIAIOSFODNN7EXAMPLE // SecretAccessKey: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY // SessionToken: Optional + // +required SecretRef string `json:"secretRef"` } @@ -114,9 +124,11 @@ type AWSClusterStaticIdentitySpec struct { // It is used to assume a role using the provided sourceRef. type AWSClusterRoleIdentity struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` // Spec for this AWSClusterRoleIdentity. + // +optional Spec AWSClusterRoleIdentitySpec `json:"spec,omitempty"` } @@ -126,7 +138,9 @@ type AWSClusterRoleIdentity struct { // AWSClusterRoleIdentityList contains a list of AWSClusterRoleIdentity. type AWSClusterRoleIdentityList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSClusterRoleIdentity `json:"items"` } @@ -148,6 +162,7 @@ type AWSClusterRoleIdentitySpec struct { // SourceIdentityRef is a reference to another identity which will be chained to do // role assumption. All identity types are accepted. + // +optional SourceIdentityRef *AWSIdentityReference `json:"sourceIdentityRef,omitempty"` } @@ -160,9 +175,11 @@ type AWSClusterRoleIdentitySpec struct { // It is used to grant access to use Cluster API Provider AWS Controller credentials. type AWSClusterControllerIdentity struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` // Spec for this AWSClusterControllerIdentity. + // +optional Spec AWSClusterControllerIdentitySpec `json:"spec,omitempty"` } @@ -172,7 +189,9 @@ type AWSClusterControllerIdentity struct { // AWSClusterControllerIdentityList contains a list of AWSClusterControllerIdentity. type AWSClusterControllerIdentityList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSClusterControllerIdentity `json:"items"` } diff --git a/api/v1beta2/awsmachine_types.go b/api/v1beta2/awsmachine_types.go index 2ff52d71e0..62e164d04f 100644 --- a/api/v1beta2/awsmachine_types.go +++ b/api/v1beta2/awsmachine_types.go @@ -19,7 +19,7 @@ package v1beta2 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) const ( @@ -78,9 +78,11 @@ const ( // +kubebuilder:validation:XValidation:rule="!has(self.capacityReservationId) || !has(self.spotMarketOptions)",message="capacityReservationId cannot be set when spotMarketOptions is specified" type AWSMachineSpec struct { // ProviderID is the unique identifier as specified by the cloud provider. + // +optional ProviderID *string `json:"providerID,omitempty"` // InstanceID is the EC2 instance ID for this machine. + // +optional InstanceID *string `json:"instanceID,omitempty"` // InstanceMetadataOptions is the metadata options for the EC2 instance. @@ -88,6 +90,7 @@ type AWSMachineSpec struct { InstanceMetadataOptions *InstanceMetadataOptions `json:"instanceMetadataOptions,omitempty"` // AMI is the reference to the AMI from which to create the machine instance. + // +optional AMI AMIReference `json:"ami,omitempty"` // ImageLookupFormat is the AMI naming format to look up the image for this @@ -105,14 +108,16 @@ type AWSMachineSpec struct { ImageLookupFormat string `json:"imageLookupFormat,omitempty"` // ImageLookupOrg is the AWS Organization ID to use for image lookup if AMI is not set. + // +optional ImageLookupOrg string `json:"imageLookupOrg,omitempty"` // ImageLookupBaseOS is the name of the base operating system to use for // image lookup the AMI is not set. + // +optional ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"` // InstanceType is the type of instance to create. Example: m4.xlarge - // +kubebuilder:validation:Required + // +required // +kubebuilder:validation:MinLength:=2 InstanceType string `json:"instanceType"` @@ -290,6 +295,7 @@ type CloudInit struct { // or AWS Systems Manager Parameter Store to ensure privacy of userdata. // By default, a cloud-init boothook shell script is prepended to download // the userdata from Secrets Manager and additionally delete the secret. + // +optional InsecureSkipSecretsManager bool `json:"insecureSkipSecretsManager,omitempty"` // SecretCount is the number of secrets used to form the complete secret @@ -414,7 +420,8 @@ type AWSMachineStatus struct { Interruptible bool `json:"interruptible,omitempty"` // Addresses contains the AWS instance associated addresses. - Addresses []clusterv1beta1.MachineAddress `json:"addresses,omitempty"` + // +optional + Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"` // InstanceState is the state of the AWS instance for this machine. // +optional @@ -460,7 +467,7 @@ type AWSMachineStatus struct { // Conditions defines current service state of the AWSMachine. // +optional - Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"` + Conditions clusterv1.Conditions `json:"conditions,omitempty"` // DedicatedHost tracks the dynamically allocated dedicated host. // This field is populated when DynamicHostAllocation is used. @@ -490,20 +497,23 @@ type DedicatedHostStatus struct { // AWSMachine is the schema for Amazon EC2 machines. type AWSMachine struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec AWSMachineSpec `json:"spec,omitempty"` + // +optional + Spec AWSMachineSpec `json:"spec,omitempty"` + // +optional Status AWSMachineStatus `json:"status,omitempty"` } // GetConditions returns the observations of the operational state of the AWSMachine resource. -func (r *AWSMachine) GetConditions() clusterv1beta1.Conditions { +func (r *AWSMachine) GetConditions() clusterv1.Conditions { return r.Status.Conditions } -// SetConditions sets the underlying service state of the AWSMachine to the predescribed clusterv1beta1.Conditions. -func (r *AWSMachine) SetConditions(conditions clusterv1beta1.Conditions) { +// SetConditions sets the underlying service state of the AWSMachine to the predescribed clusterv1.Conditions. +func (r *AWSMachine) SetConditions(conditions clusterv1.Conditions) { r.Status.Conditions = conditions } @@ -512,8 +522,10 @@ func (r *AWSMachine) SetConditions(conditions clusterv1beta1.Conditions) { // AWSMachineList contains a list of Amazon EC2 machines. type AWSMachineList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []AWSMachine `json:"items"` + // +required + Items []AWSMachine `json:"items"` } func init() { diff --git a/api/v1beta2/awsmachinetemplate_types.go b/api/v1beta2/awsmachinetemplate_types.go index 12829090f2..534e7dcb73 100644 --- a/api/v1beta2/awsmachinetemplate_types.go +++ b/api/v1beta2/awsmachinetemplate_types.go @@ -20,7 +20,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) // Architecture represents the CPU architecture of the node. @@ -75,11 +75,12 @@ type AWSMachineTemplateStatus struct { // Conditions defines current service state of the AWSMachineTemplate. // +optional - Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"` + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // AWSMachineTemplateSpec defines the desired state of AWSMachineTemplate. type AWSMachineTemplateSpec struct { + // +required Template AWSMachineTemplateResource `json:"template"` } @@ -91,10 +92,13 @@ type AWSMachineTemplateSpec struct { // AWSMachineTemplate is the schema for the Amazon EC2 Machine Templates API. type AWSMachineTemplate struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec AWSMachineTemplateSpec `json:"spec,omitempty"` + // +optional + Spec AWSMachineTemplateSpec `json:"spec,omitempty"` + // +optional Status AWSMachineTemplateStatus `json:"status,omitempty"` } @@ -103,8 +107,10 @@ type AWSMachineTemplate struct { // AWSMachineTemplateList contains a list of AWSMachineTemplate. type AWSMachineTemplateList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []AWSMachineTemplate `json:"items"` + // +required + Items []AWSMachineTemplate `json:"items"` } // AWSMachineTemplateResource describes the data needed to create am AWSMachine from a template. @@ -112,19 +118,20 @@ type AWSMachineTemplateResource struct { // Standard object's metadata. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata // +optional - ObjectMeta clusterv1beta1.ObjectMeta `json:"metadata,omitempty"` + ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"` // Spec is the specification of the desired behavior of the machine. + // +required Spec AWSMachineSpec `json:"spec"` } // GetConditions returns the observations of the operational state of the AWSMachineTemplate resource. -func (r *AWSMachineTemplate) GetConditions() clusterv1beta1.Conditions { +func (r *AWSMachineTemplate) GetConditions() clusterv1.Conditions { return r.Status.Conditions } -// SetConditions sets the underlying service state of the AWSMachineTemplate to the predescribed clusterv1beta1.Conditions. -func (r *AWSMachineTemplate) SetConditions(conditions clusterv1beta1.Conditions) { +// SetConditions sets the underlying service state of the AWSMachineTemplate to the predescribed clusterv1.Conditions. +func (r *AWSMachineTemplate) SetConditions(conditions clusterv1.Conditions) { r.Status.Conditions = conditions } diff --git a/api/v1beta2/awsmanagedcluster_types.go b/api/v1beta2/awsmanagedcluster_types.go index ce04e18669..29259d1a0b 100644 --- a/api/v1beta2/awsmanagedcluster_types.go +++ b/api/v1beta2/awsmanagedcluster_types.go @@ -55,9 +55,12 @@ type AWSManagedClusterStatus struct { // AWSManagedCluster is the Schema for the awsmanagedclusters API type AWSManagedCluster struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSManagedClusterSpec `json:"spec,omitempty"` + // +optional Status AWSManagedClusterStatus `json:"status,omitempty"` } @@ -66,7 +69,9 @@ type AWSManagedCluster struct { // AWSManagedClusterList contains a list of AWSManagedCluster. type AWSManagedClusterList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSManagedCluster `json:"items"` } diff --git a/api/v1beta2/awsmanagedclustertemplate_types.go b/api/v1beta2/awsmanagedclustertemplate_types.go index 28ab2bea9e..1c5e67f3be 100644 --- a/api/v1beta2/awsmanagedclustertemplate_types.go +++ b/api/v1beta2/awsmanagedclustertemplate_types.go @@ -22,6 +22,7 @@ import ( // AWSManagedClusterTemplateSpec defines the desired state of AWSManagedClusterTemplate. type AWSManagedClusterTemplateSpec struct { + // +required Template AWSManagedClusterTemplateResource `json:"template"` } @@ -32,8 +33,10 @@ type AWSManagedClusterTemplateSpec struct { // AWSManagedClusterTemplate is the Schema for the AWSManagedClusterTemplates API. type AWSManagedClusterTemplate struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSManagedClusterTemplateSpec `json:"spec,omitempty"` } @@ -42,7 +45,9 @@ type AWSManagedClusterTemplate struct { // AWSManagedClusterTemplateList contains a list of AWSManagedClusterTemplates. type AWSManagedClusterTemplateList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSManagedClusterTemplate `json:"items"` } @@ -52,5 +57,6 @@ func init() { // AWSManagedClusterTemplateResource describes the data needed to create an AWSManagedCluster from a template. type AWSManagedClusterTemplateResource struct { + // +required Spec AWSManagedClusterSpec `json:"spec"` } diff --git a/api/v1beta2/network_types.go b/api/v1beta2/network_types.go index 26e38bc934..70c14362eb 100644 --- a/api/v1beta2/network_types.go +++ b/api/v1beta2/network_types.go @@ -53,15 +53,19 @@ const ( // NetworkStatus encapsulates AWS networking resources. type NetworkStatus struct { // SecurityGroups is a map from the role/kind of the security group to its unique name, if any. + // +optional SecurityGroups map[SecurityGroupRole]SecurityGroup `json:"securityGroups,omitempty"` // APIServerELB is the Kubernetes api server load balancer. + // +optional APIServerELB LoadBalancer `json:"apiServerElb,omitempty"` // SecondaryAPIServerELB is the secondary Kubernetes api server load balancer. + // +optional SecondaryAPIServerELB LoadBalancer `json:"secondaryAPIServerELB,omitempty"` // NatGatewaysIPs contains the public IPs of the NAT Gateways + // +optional NatGatewaysIPs []string `json:"natGatewaysIPs,omitempty"` } @@ -115,12 +119,19 @@ var ( // TargetGroupHealthCheck defines health check settings for the target group. type TargetGroupHealthCheck struct { + // +optional Protocol *string `json:"protocol,omitempty"` + // +optional Path *string `json:"path,omitempty"` + // +optional Port *string `json:"port,omitempty"` + // +optional IntervalSeconds *int64 `json:"intervalSeconds,omitempty"` + // +optional TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"` + // +optional ThresholdCount *int64 `json:"thresholdCount,omitempty"` + // +optional UnhealthyThresholdCount *int64 `json:"unhealthyThresholdCount,omitempty"` } @@ -234,20 +245,28 @@ var ( type TargetGroupSpec struct { // Name of the TargetGroup. Must be unique over the same group of listeners. // +kubebuilder:validation:MaxLength=32 + // +required Name string `json:"name"` // Port is the exposed port + // +required Port int64 `json:"port"` // +kubebuilder:validation:Enum=tcp;tls;udp;TCP;TLS;UDP + // +required Protocol ELBProtocol `json:"protocol"` + // +required VpcID string `json:"vpcId"` // HealthCheck is the elb health check associated with the load balancer. + // +optional HealthCheck *TargetGroupHealthCheck `json:"targetGroupHealthCheck,omitempty"` } // Listener defines an AWS network load balancer listener. type Listener struct { + // +required Protocol ELBProtocol `json:"protocol"` + // +required Port int64 `json:"port"` + // +required TargetGroup TargetGroupSpec `json:"targetGroup"` } @@ -255,6 +274,7 @@ type Listener struct { type LoadBalancer struct { // ARN of the load balancer. Unlike the ClassicLB, ARN is used mostly // to define and get it. + // +optional ARN string `json:"arn,omitempty"` // The name of the load balancer. It must be unique within the set of load balancers // defined in the region. It also serves as identifier. @@ -262,40 +282,52 @@ type LoadBalancer struct { Name string `json:"name,omitempty"` // DNSName is the dns name of the load balancer. + // +optional DNSName string `json:"dnsName,omitempty"` // Scheme is the load balancer scheme, either internet-facing or private. + // +optional Scheme ELBScheme `json:"scheme,omitempty"` // AvailabilityZones is an array of availability zones in the VPC attached to the load balancer. + // +optional AvailabilityZones []string `json:"availabilityZones,omitempty"` // SubnetIDs is an array of subnets in the VPC attached to the load balancer. + // +optional SubnetIDs []string `json:"subnetIds,omitempty"` // SecurityGroupIDs is an array of security groups assigned to the load balancer. + // +optional SecurityGroupIDs []string `json:"securityGroupIds,omitempty"` // ClassicELBListeners is an array of classic elb listeners associated with the load balancer. There must be at least one. + // +optional ClassicELBListeners []ClassicELBListener `json:"listeners,omitempty"` // HealthCheck is the classic elb health check associated with the load balancer. + // +optional HealthCheck *ClassicELBHealthCheck `json:"healthChecks,omitempty"` // ClassicElbAttributes defines extra attributes associated with the load balancer. + // +optional ClassicElbAttributes ClassicELBAttributes `json:"attributes,omitempty"` // Tags is a map of tags associated with the load balancer. + // +optional Tags map[string]string `json:"tags,omitempty"` // ELBListeners is an array of listeners associated with the load balancer. There must be at least one. + // +optional ELBListeners []Listener `json:"elbListeners,omitempty"` // ELBAttributes defines extra attributes associated with v2 load balancers. + // +optional ELBAttributes map[string]*string `json:"elbAttributes,omitempty"` // LoadBalancerType sets the type for a load balancer. The default type is classic. // +kubebuilder:validation:Enum:=classic;elb;alb;nlb + // +optional LoadBalancerType LoadBalancerType `json:"loadBalancerType,omitempty"` } @@ -313,6 +345,7 @@ func (b *LoadBalancer) IsManaged(clusterName string) bool { type ClassicELBAttributes struct { // IdleTimeout is time that the connection is allowed to be idle (no data // has been sent over the connection) before it is closed by the load balancer. + // +optional IdleTimeout time.Duration `json:"idleTimeout,omitempty"` // CrossZoneLoadBalancing enables the classic load balancer load balancing. @@ -322,18 +355,27 @@ type ClassicELBAttributes struct { // ClassicELBListener defines an AWS classic load balancer listener. type ClassicELBListener struct { + // +required Protocol ELBProtocol `json:"protocol"` + // +required Port int64 `json:"port"` + // +required InstanceProtocol ELBProtocol `json:"instanceProtocol"` + // +required InstancePort int64 `json:"instancePort"` } // ClassicELBHealthCheck defines an AWS classic load balancer health check. type ClassicELBHealthCheck struct { + // +required Target string `json:"target"` + // +required Interval time.Duration `json:"interval"` + // +required Timeout time.Duration `json:"timeout"` + // +required HealthyThreshold int64 `json:"healthyThreshold"` + // +required UnhealthyThreshold int64 `json:"unhealthyThreshold"` } @@ -396,12 +438,15 @@ type IPv6 struct { // IPAMPool defines the IPAM pool to be used for VPC. type IPAMPool struct { // ID is the ID of the IPAM pool this provider should use to create VPC. + // +optional ID string `json:"id,omitempty"` // Name is the name of the IPAM pool this provider should use to create VPC. + // +optional Name string `json:"name,omitempty"` // The netmask length of the IPv4 CIDR you want to allocate to VPC from // an Amazon VPC IP Address Manager (IPAM) pool. // Defaults to /16 for IPv4 if not specified. + // +optional NetmaskLength int64 `json:"netmaskLength,omitempty"` } @@ -409,17 +454,20 @@ type IPAMPool struct { type VpcCidrBlock struct { // IPv4CidrBlock is the IPv4 CIDR block to associate with the managed VPC. // +kubebuilder:validation:MinLength=1 + // +required IPv4CidrBlock string `json:"ipv4CidrBlock"` } // VPCSpec configures an AWS VPC. type VPCSpec struct { // ID is the vpc-id of the VPC this provider should use to create resources. + // +optional ID string `json:"id,omitempty"` // CidrBlock is the CIDR block to be used when the provider creates a managed VPC. // Defaults to 10.0.0.0/16. // Mutually exclusive with IPAMPool. + // +optional CidrBlock string `json:"cidrBlock,omitempty"` // SecondaryCidrBlocks are additional CIDR blocks to be associated when the provider creates a managed VPC. @@ -430,6 +478,7 @@ type VPCSpec struct { // IPAMPool defines the IPAMv4 pool to be used for VPC. // Mutually exclusive with CidrBlock. + // +optional IPAMPool *IPAMPool `json:"ipamPool,omitempty"` // IPv6 contains ipv6 specific settings for the network. Supported only in managed clusters. @@ -448,6 +497,7 @@ type VPCSpec struct { CarrierGatewayID *string `json:"carrierGatewayId,omitempty"` // Tags is a collection of tags describing the resource. + // +optional Tags Tags `json:"tags,omitempty"` // AvailabilityZoneUsageLimit specifies the maximum number of availability zones (AZ) that @@ -456,6 +506,7 @@ type VPCSpec struct { // default subnets. Defaults to 3 // +kubebuilder:default=3 // +kubebuilder:validation:Minimum=1 + // +optional AvailabilityZoneUsageLimit *int `json:"availabilityZoneUsageLimit,omitempty"` // AvailabilityZoneSelection specifies how AZs should be selected if there are more AZs @@ -465,6 +516,7 @@ type VPCSpec struct { // Defaults to Ordered // +kubebuilder:default=Ordered // +kubebuilder:validation:Enum=Ordered;Random + // +optional AvailabilityZoneSelection *AZSelectionScheme `json:"availabilityZoneSelection,omitempty"` // EmptyRoutesDefaultVPCSecurityGroup specifies whether the default VPC security group ingress @@ -549,6 +601,7 @@ type SubnetSpec struct { // upon creation, the subnet AWS identifier will be populated in the `ResourceID` field and // the `id` field is going to be used as the subnet name. If you specify a tag // called `Name`, it takes precedence. + // +required ID string `json:"id"` // ResourceID is the subnet identifier from AWS, READ ONLY. @@ -557,6 +610,7 @@ type SubnetSpec struct { ResourceID string `json:"resourceID,omitempty"` // CidrBlock is the CIDR block to be used when the provider creates a managed VPC. + // +optional CidrBlock string `json:"cidrBlock,omitempty"` // IPv6CidrBlock is the IPv6 CIDR block to be used when the provider creates a managed VPC. @@ -566,6 +620,7 @@ type SubnetSpec struct { IPv6CidrBlock string `json:"ipv6CidrBlock,omitempty"` // AvailabilityZone defines the availability zone to use for this subnet in the cluster's region. + // +optional AvailabilityZone string `json:"availabilityZone,omitempty"` // IsPublic defines the subnet as a public subnet. A subnet is public when it is associated with a route table that has a route to an internet gateway. @@ -587,6 +642,7 @@ type SubnetSpec struct { NatGatewayID *string `json:"natGatewayId,omitempty"` // Tags is a collection of tags describing the resource. + // +optional Tags Tags `json:"tags,omitempty"` // ZoneType defines the type of the zone where the subnet is created. @@ -852,6 +908,7 @@ func (s Subnets) HasPublicSubnetWavelength() bool { type CNISpec struct { // CNIIngressRules specify rules to apply to control plane and worker node security groups. // The source for the rule will be set to control plane and worker security group IDs. + // +optional CNIIngressRules CNIIngressRules `json:"cniIngressRules,omitempty"` } @@ -860,14 +917,19 @@ type CNIIngressRules []CNIIngressRule // CNIIngressRule defines an AWS ingress rule for CNI requirements. type CNIIngressRule struct { + // +required Description string `json:"description"` + // +required Protocol SecurityGroupProtocol `json:"protocol"` + // +required FromPort int64 `json:"fromPort"` + // +required ToPort int64 `json:"toPort"` } // RouteTable defines an AWS routing table. type RouteTable struct { + // +required ID string `json:"id"` } @@ -898,9 +960,11 @@ var ( // SecurityGroup defines an AWS security group. type SecurityGroup struct { // ID is a unique identifier. + // +required ID string `json:"id"` // Name is the security group name. + // +required Name string `json:"name"` // IngressRules is the inbound rules associated with the security group. @@ -908,6 +972,7 @@ type SecurityGroup struct { IngressRules IngressRules `json:"ingressRule,omitempty"` // Tags is a map of tags associated with the security group. + // +optional Tags Tags `json:"tags,omitempty"` } @@ -945,13 +1010,17 @@ var ( // IngressRule defines an AWS ingress rule for security groups. type IngressRule struct { // Description provides extended information about the ingress rule. + // +required Description string `json:"description"` // Protocol is the protocol for the ingress rule. Accepted values are "-1" (all), "4" (IP in IP),"tcp", "udp", "icmp", and "58" (ICMPv6), "50" (ESP). // +kubebuilder:validation:Enum="-1";"4";tcp;udp;icmp;"58";"50" + // +required Protocol SecurityGroupProtocol `json:"protocol"` // FromPort is the start of port range. + // +required FromPort int64 `json:"fromPort"` // ToPort is the end of port range. + // +required ToPort int64 `json:"toPort"` // List of CIDR blocks to allow access from. Cannot be specified with SourceSecurityGroupID. diff --git a/api/v1beta2/tags.go b/api/v1beta2/tags.go index 764d06f73d..3cbbb68701 100644 --- a/api/v1beta2/tags.go +++ b/api/v1beta2/tags.go @@ -216,12 +216,15 @@ func ClusterAWSCloudProviderTagKey(name string) string { // BuildParams is used to build tags around an aws resource. type BuildParams struct { // Lifecycle determines the resource lifecycle. + // +optional Lifecycle ResourceLifecycle // ClusterName is the cluster associated with the resource. + // +optional ClusterName string // ResourceID is the unique identifier of the resource to be tagged. + // +optional ResourceID string // Name is the name of the resource, it's applied as the tag "Name" on AWS. diff --git a/api/v1beta2/types.go b/api/v1beta2/types.go index 81a3be6db3..a10f69ec44 100644 --- a/api/v1beta2/types.go +++ b/api/v1beta2/types.go @@ -21,7 +21,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) const ( @@ -62,9 +62,11 @@ type AMIReference struct { // Filter is a filter used to identify an AWS resource. type Filter struct { // Name of the filter. Filter names are case-sensitive. + // +required Name string `json:"name"` // Values includes one or more filter values. Filter values are case-sensitive. + // +required Values []string `json:"values"` } @@ -164,46 +166,60 @@ var ( // Instance describes an AWS instance. type Instance struct { + // +required ID string `json:"id"` // The current state of the instance. + // +optional State InstanceState `json:"instanceState,omitempty"` // The instance type. + // +optional Type string `json:"type,omitempty"` // The ID of the subnet of the instance. + // +optional SubnetID string `json:"subnetId,omitempty"` // The ID of the AMI used to launch the instance. + // +optional ImageID string `json:"imageId,omitempty"` // The name of the SSH key pair. + // +optional SSHKeyName *string `json:"sshKeyName,omitempty"` // SecurityGroupIDs are one or more security group IDs this instance belongs to. + // +optional SecurityGroupIDs []string `json:"securityGroupIds,omitempty"` // UserData is the raw data script passed to the instance which is run upon bootstrap. // This field must not be base64 encoded and should only be used when running a new instance. + // +optional UserData *string `json:"userData,omitempty"` // The name of the IAM instance profile associated with the instance, if applicable. + // +optional IAMProfile string `json:"iamProfile,omitempty"` // Addresses contains the AWS instance associated addresses. - Addresses []clusterv1beta1.MachineAddress `json:"addresses,omitempty"` + // +optional + Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"` // The private IPv4 address assigned to the instance. + // +optional PrivateIP *string `json:"privateIp,omitempty"` // The public IPv4 address assigned to the instance, if applicable. + // +optional PublicIP *string `json:"publicIp,omitempty"` // Specifies whether enhanced networking with ENA is enabled. + // +optional ENASupport *bool `json:"enaSupport,omitempty"` // Indicates whether the instance is optimized for Amazon EBS I/O. + // +optional EBSOptimized *bool `json:"ebsOptimized,omitempty"` // Configuration options for the root storage volume. @@ -215,18 +231,23 @@ type Instance struct { NonRootVolumes []Volume `json:"nonRootVolumes,omitempty"` // Specifies ENIs attached to instance + // +optional NetworkInterfaces []string `json:"networkInterfaces,omitempty"` // NetworkInterfaceType is the interface type of the primary network Interface. + // +optional NetworkInterfaceType NetworkInterfaceType `json:"networkInterfaceType,omitempty"` // The tags associated with the instance. + // +optional Tags map[string]string `json:"tags,omitempty"` // Availability zone of instance + // +optional AvailabilityZone string `json:"availabilityZone,omitempty"` // SpotMarketOptions option for configuring instances to be run using AWS Spot instances. + // +optional SpotMarketOptions *SpotMarketOptions `json:"spotMarketOptions,omitempty"` // PlacementGroupName specifies the name of the placement group in which to launch the instance. @@ -324,27 +345,35 @@ const ( // DedicatedHostInfo contains information about a dedicated host. type DedicatedHostInfo struct { // HostID is the ID of the dedicated host. + // +required HostID string `json:"hostID"` // InstanceFamily is the instance family supported by the host. + // +required InstanceFamily string `json:"instanceFamily"` // InstanceType is the instance type supported by the host. + // +required InstanceType string `json:"instanceType"` // AvailabilityZone is the AZ where the host is located. + // +required AvailabilityZone string `json:"availabilityZone"` // State is the current state of the dedicated host. + // +required State string `json:"state"` // TotalCapacity is the total number of instances that can be launched on the host. + // +required TotalCapacity int32 `json:"totalCapacity"` // AvailableCapacity is the number of instances that can still be launched on the host. + // +required AvailableCapacity int32 `json:"availableCapacity"` // Tags associated with the dedicated host. + // +optional Tags map[string]string `json:"tags,omitempty"` } @@ -395,6 +424,7 @@ type InstanceMetadataOptions struct { // // +kubebuilder:validation:Enum:=enabled;disabled // +kubebuilder:default=enabled + // +optional HTTPEndpoint InstanceMetadataState `json:"httpEndpoint,omitempty"` // The desired HTTP PUT response hop limit for instance metadata requests. The @@ -405,6 +435,7 @@ type InstanceMetadataOptions struct { // +kubebuilder:validation:Minimum:=1 // +kubebuilder:validation:Maximum:=64 // +kubebuilder:default=1 + // +optional HTTPPutResponseHopLimit int64 `json:"httpPutResponseHopLimit,omitempty"` // The state of token usage for your instance metadata requests. @@ -424,6 +455,7 @@ type InstanceMetadataOptions struct { // // +kubebuilder:validation:Enum:=optional;required // +kubebuilder:default=optional + // +optional HTTPTokens HTTPTokensState `json:"httpTokens,omitempty"` // Set to enabled to allow access to instance tags from the instance metadata. @@ -435,6 +467,7 @@ type InstanceMetadataOptions struct { // // +kubebuilder:validation:Enum:=enabled;disabled // +kubebuilder:default=disabled + // +optional InstanceMetadataTags InstanceMetadataState `json:"instanceMetadataTags,omitempty"` } @@ -463,6 +496,7 @@ type Volume struct { // Size specifies size (in Gi) of the storage device. // Must be greater than the image snapshot size or 8 (whichever is greater). // +kubebuilder:validation:Minimum=8 + // +required Size int64 `json:"size"` // Type is the type of the volume (e.g. gp2, io1, etc...). diff --git a/bootstrap/eks/api/v1beta1/eksconfig_types.go b/bootstrap/eks/api/v1beta1/eksconfig_types.go index 8380ce1d7a..68f115dfde 100644 --- a/bootstrap/eks/api/v1beta1/eksconfig_types.go +++ b/bootstrap/eks/api/v1beta1/eksconfig_types.go @@ -56,14 +56,17 @@ type EKSConfigSpec struct { // PauseContainer contains details of pause container. type PauseContainer struct { // AccountNumber is the AWS account number to pull the pause container from. + // +required AccountNumber string `json:"accountNumber"` // Version is the tag of the pause container to use. + // +required Version string `json:"version"` } // EKSConfigStatus defines the observed state of the Amazon EKS Bootstrap Configuration. type EKSConfigStatus struct { // Ready indicates the BootstrapData secret is ready to be consumed + // +optional Ready bool `json:"ready,omitempty"` // DataSecretName is the name of the secret that stores the bootstrap data script. @@ -97,9 +100,12 @@ type EKSConfigStatus struct { // EKSConfig is the schema for the Amazon EKS Machine Bootstrap Configuration API. type EKSConfig struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec EKSConfigSpec `json:"spec,omitempty"` + // +optional Status EKSConfigStatus `json:"status,omitempty"` } @@ -119,7 +125,9 @@ func (r *EKSConfig) SetConditions(conditions clusterv1beta1.Conditions) { // EKSConfigList contains a list of EKSConfig. type EKSConfigList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []EKSConfig `json:"items"` } diff --git a/bootstrap/eks/api/v1beta1/eksconfigtemplate_types.go b/bootstrap/eks/api/v1beta1/eksconfigtemplate_types.go index 3f4776514a..abbc28385e 100644 --- a/bootstrap/eks/api/v1beta1/eksconfigtemplate_types.go +++ b/bootstrap/eks/api/v1beta1/eksconfigtemplate_types.go @@ -22,11 +22,13 @@ import ( // EKSConfigTemplateSpec defines the desired state of templated EKSConfig Amazon EKS Bootstrap Configuration resources. type EKSConfigTemplateSpec struct { + // +required Template EKSConfigTemplateResource `json:"template"` } // EKSConfigTemplateResource defines the Template structure. type EKSConfigTemplateResource struct { + // +optional Spec EKSConfigSpec `json:"spec,omitempty"` } @@ -37,8 +39,10 @@ type EKSConfigTemplateResource struct { // EKSConfigTemplate is the Amazon EKS Bootstrap Configuration Template API. type EKSConfigTemplate struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec EKSConfigTemplateSpec `json:"spec,omitempty"` } @@ -48,7 +52,9 @@ type EKSConfigTemplate struct { // EKSConfigTemplateList contains a list of Amazon EKS Bootstrap Configuration Templates. type EKSConfigTemplateList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []EKSConfigTemplate `json:"items"` } diff --git a/bootstrap/eks/api/v1beta2/eksconfig_types.go b/bootstrap/eks/api/v1beta2/eksconfig_types.go index 1f7905fc1e..9723b7063a 100644 --- a/bootstrap/eks/api/v1beta2/eksconfig_types.go +++ b/bootstrap/eks/api/v1beta2/eksconfig_types.go @@ -79,14 +79,17 @@ type EKSConfigSpec struct { // PauseContainer contains details of pause container. type PauseContainer struct { // AccountNumber is the AWS account number to pull the pause container from. + // +required AccountNumber string `json:"accountNumber"` // Version is the tag of the pause container to use. + // +required Version string `json:"version"` } // EKSConfigStatus defines the observed state of the Amazon EKS Bootstrap Configuration. type EKSConfigStatus struct { // Ready indicates the BootstrapData secret is ready to be consumed + // +optional Ready bool `json:"ready,omitempty"` // DataSecretName is the name of the secret that stores the bootstrap data script. @@ -126,6 +129,7 @@ const ( // File defines the input for generating write_files in cloud-init. type File struct { // Path specifies the full path on disk where to store the file. + // +required Path string `json:"path"` // Owner specifies the ownership of the file, e.g. "root:root". @@ -158,6 +162,7 @@ type File struct { // sources of data for target systems should add them here. type FileSource struct { // Secret represents a secret that should populate this file. + // +required Secret SecretFileSource `json:"secret"` } @@ -167,9 +172,11 @@ type FileSource struct { // as files using the keys in the Data field as the file names. type SecretFileSource struct { // Name of the secret in the KubeadmBootstrapConfig's namespace to use. + // +required Name string `json:"name"` // Key is the key in the secret's data map for this value. + // +required Key string `json:"key"` } @@ -178,6 +185,7 @@ type SecretFileSource struct { // sources of data for target systems should add them here. type PasswdSource struct { // Secret represents a secret that should populate this password. + // +required Secret SecretPasswdSource `json:"secret"` } @@ -187,15 +195,18 @@ type PasswdSource struct { // as passwd using the keys in the Data field as the file names. type SecretPasswdSource struct { // Name of the secret in the KubeadmBootstrapConfig's namespace to use. + // +required Name string `json:"name"` // Key is the key in the secret's data map for this value. + // +required Key string `json:"key"` } // User defines the input for a generated user in cloud-init. type User struct { // Name specifies the username + // +required Name string `json:"name"` // Gecos specifies the gecos to use for the user @@ -268,10 +279,12 @@ type DiskSetup struct { // Partition defines how to create and layout a partition. type Partition struct { // Device is the name of the device. + // +required Device string `json:"device"` // Layout specifies the device layout. // If it is true, a single partition will be created for the entire device. // When layout is false, it means don't partition or ignore existing partitioning. + // +required Layout bool `json:"layout"` // Overwrite describes whether to skip checks and create the partition if a partition or filesystem is found on the device. // Use with caution. Default is 'false'. @@ -287,10 +300,13 @@ type Partition struct { // Filesystem defines the file systems to be created. type Filesystem struct { // Device specifies the device name + // +required Device string `json:"device"` // Filesystem specifies the file system type. + // +required Filesystem string `json:"filesystem"` // Label specifies the file system label to be used. If set to None, no label is used. + // +required Label string `json:"label"` // Partition specifies the partition to use. The valid options are: "auto|any", "auto", "any", "none", and , where NUM is the actual partition number. // +optional @@ -317,9 +333,12 @@ type MountPoints []string // EKSConfig is the schema for the Amazon EKS Machine Bootstrap Configuration API. type EKSConfig struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec EKSConfigSpec `json:"spec,omitempty"` + // +optional Status EKSConfigStatus `json:"status,omitempty"` } @@ -338,7 +357,9 @@ func (r *EKSConfig) SetConditions(conditions clusterv1beta1.Conditions) { // EKSConfigList contains a list of EKSConfig. type EKSConfigList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []EKSConfig `json:"items"` } diff --git a/bootstrap/eks/api/v1beta2/eksconfigtemplate_types.go b/bootstrap/eks/api/v1beta2/eksconfigtemplate_types.go index 262ed5fe81..759e9d00e3 100644 --- a/bootstrap/eks/api/v1beta2/eksconfigtemplate_types.go +++ b/bootstrap/eks/api/v1beta2/eksconfigtemplate_types.go @@ -22,11 +22,13 @@ import ( // EKSConfigTemplateSpec defines the desired state of templated EKSConfig Amazon EKS Bootstrap Configuration resources. type EKSConfigTemplateSpec struct { + // +required Template EKSConfigTemplateResource `json:"template"` } // EKSConfigTemplateResource defines the Template structure. type EKSConfigTemplateResource struct { + // +optional Spec EKSConfigSpec `json:"spec,omitempty"` } @@ -37,8 +39,10 @@ type EKSConfigTemplateResource struct { // EKSConfigTemplate is the Amazon EKS Bootstrap Configuration Template API. type EKSConfigTemplate struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec EKSConfigTemplateSpec `json:"spec,omitempty"` } @@ -47,7 +51,9 @@ type EKSConfigTemplate struct { // EKSConfigTemplateList contains a list of Amazon EKS Bootstrap Configuration Templates. type EKSConfigTemplateList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []EKSConfigTemplate `json:"items"` } diff --git a/bootstrap/eks/controllers/eksconfig_controller.go b/bootstrap/eks/controllers/eksconfig_controller.go index f59bbc1262..5a0711e047 100644 --- a/bootstrap/eks/controllers/eksconfig_controller.go +++ b/bootstrap/eks/controllers/eksconfig_controller.go @@ -55,8 +55,11 @@ const eksConfigKind = "EKSConfig" // EKSConfigReconciler reconciles a EKSConfig object. type EKSConfigReconciler struct { + // +optional client.Client + // +optional Scheme *runtime.Scheme + // +optional WatchFilterValue string } diff --git a/bootstrap/eks/internal/userdata/node.go b/bootstrap/eks/internal/userdata/node.go index 468f15478f..f66e169dff 100644 --- a/bootstrap/eks/internal/userdata/node.go +++ b/bootstrap/eks/internal/userdata/node.go @@ -45,26 +45,45 @@ runcmd: // NodeInput defines the context to generate a node user data. type NodeInput struct { + // +optional ClusterName string + // +optional KubeletExtraArgs map[string]string + // +optional ContainerRuntime *string + // +optional DNSClusterIP *string + // +optional DockerConfigJSON *string + // +optional APIRetryAttempts *int + // +optional PauseContainerAccount *string + // +optional PauseContainerVersion *string + // +optional UseMaxPods *bool // NOTE: currently the IPFamily/ServiceIPV6Cidr isn't exposed to the user. // TODO (richardcase): remove the above comment when IPV6 / dual stack is implemented. + // +optional IPFamily *string + // +optional ServiceIPV6Cidr *string + // +optional PreBootstrapCommands []string + // +optional PostBootstrapCommands []string + // +optional BootstrapCommandOverride *string + // +optional Files []eksbootstrapv1.File + // +optional DiskSetup *eksbootstrapv1.DiskSetup + // +optional Mounts []eksbootstrapv1.MountPoints + // +optional Users []eksbootstrapv1.User + // +optional NTP *eksbootstrapv1.NTP } diff --git a/cmd/clusterawsadm/ami/copy.go b/cmd/clusterawsadm/ami/copy.go index 142b50dffd..c6e388314e 100644 --- a/cmd/clusterawsadm/ami/copy.go +++ b/cmd/clusterawsadm/ami/copy.go @@ -37,14 +37,23 @@ import ( // CopyInput defines input that can be copied to create an AWSAMI. type CopyInput struct { + // +optional SourceRegion string + // +optional DestinationRegion string + // +optional OwnerID string + // +optional OperatingSystem string + // +optional KubernetesVersion string + // +optional KmsKeyID string + // +optional DryRun bool + // +optional Encrypted bool + // +optional Log logr.Logger } @@ -115,10 +124,15 @@ func Copy(input CopyInput) (*amiv1.AWSAMI, error) { } type copyWithoutSnapshotInput struct { + // +optional sourceRegion string + // +optional dryRun bool + // +optional log logr.Logger + // +optional cfg aws.Config + // +optional image *types.Image } @@ -144,13 +158,21 @@ func copyWithoutSnapshot(input copyWithoutSnapshotInput) (string, string, error) } type copyWithSnapshotInput struct { + // +optional sourceRegion string + // +optional destinationRegion string + // +optional kmsKeyID string + // +optional dryRun bool + // +optional encrypted bool + // +optional log logr.Logger + // +optional image *types.Image + // +optional cfg aws.Config } diff --git a/cmd/clusterawsadm/ami/list.go b/cmd/clusterawsadm/ami/list.go index d545079eb0..1abf9bc3e5 100644 --- a/cmd/clusterawsadm/ami/list.go +++ b/cmd/clusterawsadm/ami/list.go @@ -33,9 +33,13 @@ import ( // ListInput defines the specs required to construct an AWSAMIList. type ListInput struct { + // +optional Region string + // +optional KubernetesVersion string + // +optional OperatingSystem string + // +optional OwnerID string } diff --git a/cmd/clusterawsadm/api/ami/v1beta1/types.go b/cmd/clusterawsadm/api/ami/v1beta1/types.go index e404f3dbe9..bcbfa4ab6a 100644 --- a/cmd/clusterawsadm/api/ami/v1beta1/types.go +++ b/cmd/clusterawsadm/api/ami/v1beta1/types.go @@ -32,9 +32,13 @@ const ( // AWSAMISpec defines an AMI. type AWSAMISpec struct { + // +required OS string `json:"os"` + // +required Region string `json:"region"` + // +required ImageID string `json:"imageID"` + // +required KubernetesVersion string `json:"kubernetesVersion"` } @@ -44,7 +48,9 @@ type AWSAMISpec struct { // AWSAMI defines an AMI. type AWSAMI struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSAMISpec `json:"spec,omitempty"` } @@ -54,7 +60,9 @@ type AWSAMI struct { // AWSAMIList defines a list of AMIs. type AWSAMIList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSAMI `json:"items"` } diff --git a/cmd/clusterawsadm/api/bootstrap/v1alpha1/types.go b/cmd/clusterawsadm/api/bootstrap/v1alpha1/types.go index 8ae624f22c..41c7ca69c6 100644 --- a/cmd/clusterawsadm/api/bootstrap/v1alpha1/types.go +++ b/cmd/clusterawsadm/api/bootstrap/v1alpha1/types.go @@ -32,26 +32,33 @@ type BootstrapUser struct { // This can be used to scope down the initial credentials used to bootstrap the // cluster. // Defaults to false. + // +required Enable bool `json:"enable"` // UserName controls the username of the bootstrap user. Defaults to // "bootstrapper.cluster-api-provider-aws.sigs.k8s.io" + // +optional UserName string `json:"userName,omitempty"` // GroupName controls the group the user will belong to. Defaults to // "bootstrapper.cluster-api-provider-aws.sigs.k8s.io" + // +optional GroupName string `json:"groupName,omitempty"` // ExtraPolicyAttachments is a list of additional policies to be attached to the IAM user. + // +optional ExtraPolicyAttachments []string `json:"extraPolicyAttachments,omitempty"` // ExtraGroups is a list of groups to add this user to. + // +optional ExtraGroups []string `json:"extraGroups,omitempty"` // ExtraStatements are additional AWS IAM policy document statements to be included inline for the user. + // +optional ExtraStatements []iamv1.StatementEntry `json:"extraStatements,omitempty"` // Tags is a map of tags to be applied to the AWS IAM user. + // +optional Tags infrav1.Tags `json:"tags,omitempty"` } @@ -62,12 +69,15 @@ type ControlPlane struct { // DisableClusterAPIControllerPolicyAttachment, if set to true, will not attach the AWS IAM policy for Cluster // API Provider AWS to the control plane role. Defaults to false. + // +optional DisableClusterAPIControllerPolicyAttachment bool `json:"disableClusterAPIControllerPolicyAttachment,omitempty"` // DisableCloudProviderPolicy if set to true, will not generate and attach the AWS IAM policy for the AWS Cloud Provider. + // +required DisableCloudProviderPolicy bool `json:"disableCloudProviderPolicy"` // EnableCSIPolicy if set to true, will generate and attach the AWS IAM policy for the EBS CSI Driver. + // +required EnableCSIPolicy bool `json:"enableCSIPolicy"` } @@ -75,45 +85,57 @@ type ControlPlane struct { // Kubernetes Cluster API Provider AWS. type AWSIAMRoleSpec struct { // Disable if set to true will not create the AWS IAM role. Defaults to false. + // +required Disable bool `json:"disable"` // default: false // ExtraPolicyAttachments is a list of additional policies to be attached to the IAM role. + // +optional ExtraPolicyAttachments []string `json:"extraPolicyAttachments,omitempty"` // ExtraStatements are additional IAM statements to be included inline for the role. + // +optional ExtraStatements []iamv1.StatementEntry `json:"extraStatements,omitempty"` // TrustStatements is an IAM PolicyDocument defining what identities are allowed to assume this role. // See "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/api/iam/v1beta1" for more documentation. + // +optional TrustStatements []iamv1.StatementEntry `json:"trustStatements,omitempty"` // Tags is a map of tags to be applied to the AWS IAM role. + // +optional Tags infrav1.Tags `json:"tags,omitempty"` } // EKSConfig represents the EKS related configuration config. type EKSConfig struct { // Disable controls whether EKS-related permissions are granted + // +required Disable bool `json:"disable"` // AllowIAMRoleCreation controls whether the EKS controllers have permissions for creating IAM // roles per cluster + // +optional AllowIAMRoleCreation bool `json:"iamRoleCreation,omitempty"` // EnableUserEKSConsolePolicy controls the creation of the policy to view EKS nodes and workloads. + // +optional EnableUserEKSConsolePolicy bool `json:"enableUserEKSConsolePolicy,omitempty"` // DefaultControlPlaneRole controls the configuration of the AWS IAM role for // the EKS control plane. This is the default role that will be used if // no role is included in the spec and automatic creation of the role // isn't enabled + // +optional DefaultControlPlaneRole AWSIAMRoleSpec `json:"defaultControlPlaneRole,omitempty"` // ManagedMachinePool controls the configuration of the AWS IAM role for // used by EKS managed machine pools. + // +optional ManagedMachinePool *AWSIAMRoleSpec `json:"managedMachinePool,omitempty"` // Fargate controls the configuration of the AWS IAM role for // used by EKS managed machine pools. + // +optional Fargate *AWSIAMRoleSpec `json:"fargate,omitempty"` // KMSAliasPrefix is prefix to use to restrict permission to KMS keys to only those that have an alias // name that is prefixed by this. // Defaults to cluster-api-provider-aws-* + // +optional KMSAliasPrefix string `json:"kmsAliasPrefix,omitempty"` } @@ -121,6 +143,7 @@ type EKSConfig struct { // EventBridge EC2 events. type EventBridgeConfig struct { // Enable controls whether permissions are granted to consume EC2 events + // +optional Enable bool `json:"enable,omitempty"` } @@ -131,6 +154,7 @@ type ClusterAPIControllers struct { // AllowedEC2InstanceProfiles controls which EC2 roles are allowed to be // consumed by Cluster API when creating an ec2 instance. Defaults to // *., where suffix is defaulted to .cluster-api-provider-aws.sigs.k8s.io + // +optional AllowedEC2InstanceProfiles []string `json:"allowedEC2InstanceProfiles,omitempty"` } @@ -141,10 +165,12 @@ type Nodes struct { // DisableCloudProviderPolicy if set to true, will not generate and attach the policy for the AWS Cloud Provider. // Defaults to false. + // +required DisableCloudProviderPolicy bool `json:"disableCloudProviderPolicy"` // EC2ContainerRegistryReadOnly controls whether the node has read-only access to the // EC2 container registry + // +required EC2ContainerRegistryReadOnly bool `json:"ec2ContainerRegistryReadOnly"` } @@ -156,52 +182,65 @@ type Nodes struct { type AWSIAMConfiguration struct { metav1.TypeMeta `json:",inline"` + // +optional Spec AWSIAMConfigurationSpec `json:"spec,omitempty"` } // AWSIAMConfigurationSpec defines the specification of the AWSIAMConfiguration. type AWSIAMConfigurationSpec struct { // NamePrefix will be prepended to every AWS IAM role, user and policy created by clusterawsadm. Defaults to "". + // +optional NamePrefix string `json:"namePrefix,omitempty"` // NameSuffix will be appended to every AWS IAM role, user and policy created by clusterawsadm. Defaults to // ".cluster-api-provider-aws.sigs.k8s.io". + // +optional NameSuffix *string `json:"nameSuffix,omitempty"` // ControlPlane controls the configuration of the AWS IAM role for a Kubernetes cluster's control plane nodes. + // +optional ControlPlane ControlPlane `json:"controlPlane,omitempty"` // ClusterAPIControllers controls the configuration of an IAM role and policy specifically for Kubernetes Cluster API Provider AWS. + // +optional ClusterAPIControllers ClusterAPIControllers `json:"clusterAPIControllers,omitempty"` // Nodes controls the configuration of the AWS IAM role for all nodes in a Kubernetes cluster. + // +optional Nodes Nodes `json:"nodes,omitempty"` // BootstrapUser contains a list of elements that is specific // to the configuration and enablement of an IAM user. + // +optional BootstrapUser BootstrapUser `json:"bootstrapUser,omitempty"` // StackName defines the name of the AWS CloudFormation stack. + // +optional StackName string `json:"stackName,omitempty"` // Region controls which region the control-plane is created in if not specified on the command line or // via environment variables. + // +optional Region string `json:"region,omitempty"` // EKS controls the configuration related to EKS. Settings in here affect the control plane // and nodes roles + // +optional EKS *EKSConfig `json:"eks,omitempty"` // EventBridge controls configuration for consuming EventBridge events + // +optional EventBridge *EventBridgeConfig `json:"eventBridge,omitempty"` // Partition is the AWS security partition being used. Defaults to "aws" + // +optional Partition string `json:"partition,omitempty"` // SecureSecretsBackend, when set to parameter-store will create AWS Systems Manager // Parameter Storage policies. By default or with the value of secrets-manager, // will generate AWS Secrets Manager policies instead. // +kubebuilder:validation:Enum=secrets-manager;ssm-parameter-store + // +optional SecureSecretsBackends []infrav1.SecretBackend `json:"secureSecretBackends,omitempty"` } diff --git a/cmd/clusterawsadm/api/bootstrap/v1beta1/types.go b/cmd/clusterawsadm/api/bootstrap/v1beta1/types.go index f7a262f965..4fbcedf87b 100644 --- a/cmd/clusterawsadm/api/bootstrap/v1beta1/types.go +++ b/cmd/clusterawsadm/api/bootstrap/v1beta1/types.go @@ -32,26 +32,33 @@ type BootstrapUser struct { // This can be used to scope down the initial credentials used to bootstrap the // cluster. // Defaults to false. + // +required Enable bool `json:"enable"` // UserName controls the username of the bootstrap user. Defaults to // "bootstrapper.cluster-api-provider-aws.sigs.k8s.io" + // +optional UserName string `json:"userName,omitempty"` // GroupName controls the group the user will belong to. Defaults to // "bootstrapper.cluster-api-provider-aws.sigs.k8s.io" + // +optional GroupName string `json:"groupName,omitempty"` // ExtraPolicyAttachments is a list of additional policies to be attached to the IAM user. + // +optional ExtraPolicyAttachments []string `json:"extraPolicyAttachments,omitempty"` // ExtraGroups is a list of groups to add this user to. + // +optional ExtraGroups []string `json:"extraGroups,omitempty"` // ExtraStatements are additional AWS IAM policy document statements to be included inline for the user. + // +optional ExtraStatements []iamv1.StatementEntry `json:"extraStatements,omitempty"` // Tags is a map of tags to be applied to the AWS IAM user. + // +optional Tags infrav1.Tags `json:"tags,omitempty"` } @@ -62,12 +69,15 @@ type ControlPlane struct { // DisableClusterAPIControllerPolicyAttachment, if set to true, will not attach the AWS IAM policy for Cluster // API Provider AWS to the control plane role. Defaults to false. + // +optional DisableClusterAPIControllerPolicyAttachment bool `json:"disableClusterAPIControllerPolicyAttachment,omitempty"` // DisableCloudProviderPolicy if set to true, will not generate and attach the AWS IAM policy for the AWS Cloud Provider. + // +required DisableCloudProviderPolicy bool `json:"disableCloudProviderPolicy"` // EnableCSIPolicy if set to true, will generate and attach the AWS IAM policy for the EBS CSI Driver. + // +required EnableCSIPolicy bool `json:"enableCSIPolicy"` } @@ -75,12 +85,15 @@ type ControlPlane struct { // Kubernetes Cluster API Provider AWS. type AWSIAMRoleSpec struct { // Disable if set to true will not create the AWS IAM role. Defaults to false. + // +required Disable bool `json:"disable"` // default: false // ExtraPolicyAttachments is a list of additional policies to be attached to the IAM role. + // +optional ExtraPolicyAttachments []string `json:"extraPolicyAttachments,omitempty"` // ExtraStatements are additional IAM statements to be included inline for the role. + // +optional ExtraStatements []iamv1.StatementEntry `json:"extraStatements,omitempty"` // Path sets the path to the role. @@ -93,35 +106,44 @@ type AWSIAMRoleSpec struct { // TrustStatements is an IAM PolicyDocument defining what identities are allowed to assume this role. // See "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/api/iam/v1beta1" for more documentation. + // +optional TrustStatements []iamv1.StatementEntry `json:"trustStatements,omitempty"` // Tags is a map of tags to be applied to the AWS IAM role. + // +optional Tags infrav1.Tags `json:"tags,omitempty"` } // EKSConfig represents the EKS related configuration config. type EKSConfig struct { // Disable controls whether EKS-related permissions are granted + // +required Disable bool `json:"disable"` // AllowIAMRoleCreation controls whether the EKS controllers have permissions for creating IAM // roles per cluster + // +optional AllowIAMRoleCreation bool `json:"iamRoleCreation,omitempty"` // EnableUserEKSConsolePolicy controls the creation of the policy to view EKS nodes and workloads. + // +optional EnableUserEKSConsolePolicy bool `json:"enableUserEKSConsolePolicy,omitempty"` // DefaultControlPlaneRole controls the configuration of the AWS IAM role for // the EKS control plane. This is the default role that will be used if // no role is included in the spec and automatic creation of the role // isn't enabled + // +optional DefaultControlPlaneRole AWSIAMRoleSpec `json:"defaultControlPlaneRole,omitempty"` // ManagedMachinePool controls the configuration of the AWS IAM role for // used by EKS managed machine pools. + // +optional ManagedMachinePool *AWSIAMRoleSpec `json:"managedMachinePool,omitempty"` // Fargate controls the configuration of the AWS IAM role for // used by EKS managed machine pools. + // +optional Fargate *AWSIAMRoleSpec `json:"fargate,omitempty"` // KMSAliasPrefix is prefix to use to restrict permission to KMS keys to only those that have an alias // name that is prefixed by this. // Defaults to cluster-api-provider-aws-* + // +optional KMSAliasPrefix string `json:"kmsAliasPrefix,omitempty"` } @@ -129,6 +151,7 @@ type EKSConfig struct { // EventBridge EC2 events. type EventBridgeConfig struct { // Enable controls whether permissions are granted to consume EC2 events + // +optional Enable bool `json:"enable,omitempty"` } @@ -139,6 +162,7 @@ type ClusterAPIControllers struct { // AllowedEC2InstanceProfiles controls which EC2 roles are allowed to be // consumed by Cluster API when creating an ec2 instance. Defaults to // *., where suffix is defaulted to .cluster-api-provider-aws.sigs.k8s.io + // +optional AllowedEC2InstanceProfiles []string `json:"allowedEC2InstanceProfiles,omitempty"` } @@ -149,10 +173,12 @@ type Nodes struct { // DisableCloudProviderPolicy if set to true, will not generate and attach the policy for the AWS Cloud Provider. // Defaults to false. + // +required DisableCloudProviderPolicy bool `json:"disableCloudProviderPolicy"` // EC2ContainerRegistryReadOnly controls whether the node has read-only access to the // EC2 container registry + // +required EC2ContainerRegistryReadOnly bool `json:"ec2ContainerRegistryReadOnly"` } @@ -164,6 +190,7 @@ type Nodes struct { type AWSIAMConfiguration struct { metav1.TypeMeta `json:",inline"` + // +optional Spec AWSIAMConfigurationSpec `json:"spec,omitempty"` } @@ -171,36 +198,45 @@ type AWSIAMConfiguration struct { // which can be created for storing bootstrap data for nodes requiring it. type S3Buckets struct { // Enable controls whether permissions are granted to manage S3 buckets. + // +required Enable bool `json:"enable"` // NamePrefix will be prepended to every AWS IAM role bucket name. Defaults to "cluster-api-provider-aws-". // AWSCluster S3 Bucket name must be prefixed with the same prefix. + // +required NamePrefix string `json:"namePrefix"` } // AWSIAMConfigurationSpec defines the specification of the AWSIAMConfiguration. type AWSIAMConfigurationSpec struct { // NamePrefix will be prepended to every AWS IAM role, user and policy created by clusterawsadm. Defaults to "". + // +optional NamePrefix string `json:"namePrefix,omitempty"` // NameSuffix will be appended to every AWS IAM role, user and policy created by clusterawsadm. Defaults to // ".cluster-api-provider-aws.sigs.k8s.io". + // +optional NameSuffix *string `json:"nameSuffix,omitempty"` // ControlPlane controls the configuration of the AWS IAM role for a Kubernetes cluster's control plane nodes. + // +optional ControlPlane ControlPlane `json:"controlPlane,omitempty"` // ClusterAPIControllers controls the configuration of an IAM role and policy specifically for Kubernetes Cluster API Provider AWS. + // +optional ClusterAPIControllers ClusterAPIControllers `json:"clusterAPIControllers,omitempty"` // Nodes controls the configuration of the AWS IAM role for all nodes in a Kubernetes cluster. + // +optional Nodes Nodes `json:"nodes,omitempty"` // BootstrapUser contains a list of elements that is specific // to the configuration and enablement of an IAM user. + // +optional BootstrapUser BootstrapUser `json:"bootstrapUser,omitempty"` // StackName defines the name of the AWS CloudFormation stack. + // +optional StackName string `json:"stackName,omitempty"` // StackTags defines the tags of the AWS CloudFormation stack. @@ -209,22 +245,27 @@ type AWSIAMConfigurationSpec struct { // Region controls which region the control-plane is created in if not specified on the command line or // via environment variables. + // +optional Region string `json:"region,omitempty"` // EKS controls the configuration related to EKS. Settings in here affect the control plane // and nodes roles + // +optional EKS *EKSConfig `json:"eks,omitempty"` // EventBridge controls configuration for consuming EventBridge events + // +optional EventBridge *EventBridgeConfig `json:"eventBridge,omitempty"` // Partition is the AWS security partition being used. Defaults to "aws" + // +optional Partition string `json:"partition,omitempty"` // SecureSecretsBackend, when set to parameter-store will create AWS Systems Manager // Parameter Storage policies. By default or with the value of secrets-manager, // will generate AWS Secrets Manager policies instead. // +kubebuilder:validation:Enum=secrets-manager;ssm-parameter-store + // +optional SecureSecretsBackends []infrav1.SecretBackend `json:"secureSecretBackends,omitempty"` // S3Buckets, when enabled, will add controller nodes permissions to @@ -234,6 +275,7 @@ type AWSIAMConfigurationSpec struct { S3Buckets S3Buckets `json:"s3Buckets,omitempty"` // AllowAssumeRole enables the sts:AssumeRole permission within the CAPA policies + // +optional AllowAssumeRole bool `json:"allowAssumeRole,omitempty"` } diff --git a/cmd/clusterawsadm/cloudformation/bootstrap/template.go b/cmd/clusterawsadm/cloudformation/bootstrap/template.go index 4ebffc73ef..12b1c755d2 100644 --- a/cmd/clusterawsadm/cloudformation/bootstrap/template.go +++ b/cmd/clusterawsadm/cloudformation/bootstrap/template.go @@ -56,6 +56,7 @@ const ( // Template is an AWS CloudFormation template to bootstrap // IAM policies, users and roles for use by Cluster API Provider AWS. type Template struct { + // +optional Spec *bootstrapv1.AWSIAMConfigurationSpec } diff --git a/cmd/clusterawsadm/cloudformation/service/service.go b/cmd/clusterawsadm/cloudformation/service/service.go index c73eeb9dd0..6c19129e7b 100644 --- a/cmd/clusterawsadm/cloudformation/service/service.go +++ b/cmd/clusterawsadm/cloudformation/service/service.go @@ -56,6 +56,7 @@ type CFNAPI interface { // CFNClient is a wrapper over cfn.Client for implementing custom methods of CFNAPI. type CFNClient struct { + // +optional *cfn.Client } @@ -63,6 +64,7 @@ type CFNClient struct { // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the ec2 client. type Service struct { + // +optional CFN CFNAPI } diff --git a/cmd/clusterawsadm/cmd/eks/addons/types.go b/cmd/clusterawsadm/cmd/eks/addons/types.go index 30323b4ed3..4ca267cc30 100644 --- a/cmd/clusterawsadm/cmd/eks/addons/types.go +++ b/cmd/clusterawsadm/cmd/eks/addons/types.go @@ -25,16 +25,24 @@ import ( ) type availableAddon struct { + // +required Name string `json:"name"` + // +required Type string `json:"type"` + // +required Version string `json:"version"` + // +required Architecture []string `json:"architecture"` + // +required Compatibilities []compatibility `json:"compatibilities"` } type compatibility struct { + // +required ClusterVersion string `json:"clusterVersion"` + // +required DefaultVersion bool `json:"defaultVersion"` + // +required PlatformVersions []string `json:"platformVersions"` } @@ -43,7 +51,9 @@ func (c compatibility) String() string { } type availableAddonsList struct { + // +required Cluster string `json:"cluster"` + // +required Addons []availableAddon `json:"addons"` } @@ -88,29 +98,43 @@ func (a *availableAddonsList) ToTable() *metav1.Table { } type installedAddon struct { + // +optional Name string + // +optional Version string + // +optional AddonARN string + // +optional RoleARN *string + // +optional Status string + // +optional Tags map[string]string + // +optional HealthIssues []issue + // +optional CreatedAt time.Time + // +optional ModifiedAt time.Time } type issue struct { + // +optional Code string + // +optional Message string + // +optional ResourceIDs []string } type installedAddonsList struct { + // +required Cluster string `json:"cluster"` + // +required Addons []installedAddon `json:"addons"` } diff --git a/cmd/clusterawsadm/cmd/version/version.go b/cmd/clusterawsadm/cmd/version/version.go index d5e4cbc37b..bb59333d63 100644 --- a/cmd/clusterawsadm/cmd/version/version.go +++ b/cmd/clusterawsadm/cmd/version/version.go @@ -31,6 +31,7 @@ import ( // Version provides the version information of clusterawsadm. type Version struct { + // +required ClientVersion *version.Info `json:"awsProviderVersion"` } diff --git a/cmd/clusterawsadm/configreader/configreader.go b/cmd/clusterawsadm/configreader/configreader.go index e5b1d800cd..90fbaa672b 100644 --- a/cmd/clusterawsadm/configreader/configreader.go +++ b/cmd/clusterawsadm/configreader/configreader.go @@ -61,8 +61,10 @@ type loader interface { type fsLoader struct { // bootstrapCodecs is the scheme used to decode config files + // +optional bootstrapCodecs *serializer.CodecFactory // bootstrapFile is an absolute path to the file containing a serialized KubeletConfiguration + // +optional bootstrapFile string } diff --git a/cmd/clusterawsadm/controller/credentials/update_credentials.go b/cmd/clusterawsadm/controller/credentials/update_credentials.go index eba621cb3e..a75a126cd7 100644 --- a/cmd/clusterawsadm/controller/credentials/update_credentials.go +++ b/cmd/clusterawsadm/controller/credentials/update_credentials.go @@ -30,9 +30,13 @@ import ( // UpdateCredentialsInput defines the specs for update credentials input. type UpdateCredentialsInput struct { + // +optional KubeconfigPath string + // +optional KubeconfigContext string + // +optional Credentials string + // +optional Namespace string } diff --git a/cmd/clusterawsadm/controller/credentials/zero_credentials.go b/cmd/clusterawsadm/controller/credentials/zero_credentials.go index 1b474165d5..845985fae6 100644 --- a/cmd/clusterawsadm/controller/credentials/zero_credentials.go +++ b/cmd/clusterawsadm/controller/credentials/zero_credentials.go @@ -18,8 +18,11 @@ package credentials // ZeroCredentialsInput defines the specs for zero credentials input. type ZeroCredentialsInput struct { + // +optional KubeconfigPath string + // +optional KubeconfigContext string + // +optional Namespace string } diff --git a/cmd/clusterawsadm/controller/rollout/rollout.go b/cmd/clusterawsadm/controller/rollout/rollout.go index eb55e32947..560ca8b7a8 100644 --- a/cmd/clusterawsadm/controller/rollout/rollout.go +++ b/cmd/clusterawsadm/controller/rollout/rollout.go @@ -37,8 +37,11 @@ const ControllerDeploymentName = "capa-controller-manager" // RolloutControllersInput defines the specs for rollout controllers input. type RolloutControllersInput struct { + // +optional KubeconfigPath string + // +optional KubeconfigContext string + // +optional Namespace string } diff --git a/cmd/clusterawsadm/credentials/credentials.go b/cmd/clusterawsadm/credentials/credentials.go index 43dc9eb0ed..3e1caff8a4 100644 --- a/cmd/clusterawsadm/credentials/credentials.go +++ b/cmd/clusterawsadm/credentials/credentials.go @@ -50,9 +50,13 @@ var ErrNoAWSRegionConfigured = errors.New("no AWS region configured. Use --regio // AWSCredentials defines the specs for AWS credentials. type AWSCredentials struct { + // +optional AccessKeyID string + // +optional SecretAccessKey string + // +optional SessionToken string + // +optional Region string } diff --git a/cmd/clusterawsadm/gc/gc.go b/cmd/clusterawsadm/gc/gc.go index 24b8779390..8dd4ebc0a8 100644 --- a/cmd/clusterawsadm/gc/gc.go +++ b/cmd/clusterawsadm/gc/gc.go @@ -51,16 +51,22 @@ func init() { // CmdProcessor handles the garbage collection commands. type CmdProcessor struct { + // +optional client client.Client + // +optional clusterName string + // +optional namespace string } // GCInput holds the configuration for the command processor. type GCInput struct { + // +optional ClusterName string + // +optional Namespace string + // +optional KubeconfigPath string } diff --git a/cmd/clusterawsadm/printers/printers.go b/cmd/clusterawsadm/printers/printers.go index 0c106aca12..017ada4092 100644 --- a/cmd/clusterawsadm/printers/printers.go +++ b/cmd/clusterawsadm/printers/printers.go @@ -70,6 +70,7 @@ func New(printerType string, writer io.Writer) (Printer, error) { } type tablePrinter struct { + // +optional writer io.Writer } @@ -91,6 +92,7 @@ func (p *tablePrinter) Print(in interface{}) error { } type yamlPrinter struct { + // +optional writer io.Writer } @@ -104,6 +106,7 @@ func (p *yamlPrinter) Print(in interface{}) error { } type jsonPrinter struct { + // +optional writer io.Writer } diff --git a/cmd/clusterawsadm/resource/type.go b/cmd/clusterawsadm/resource/type.go index 0dda210426..070726c752 100644 --- a/cmd/clusterawsadm/resource/type.go +++ b/cmd/clusterawsadm/resource/type.go @@ -21,17 +21,25 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" // AWSResource defines an AWS resource. type AWSResource struct { + // +required Partition string `json:"partition"` + // +required Service string `json:"service"` + // +required Region string `json:"region"` + // +required AccountID string `json:"account_id"` + // +required Resource string `json:"resource"` + // +required ARN string `json:"arn"` } // AWSResourceList defines list of AWSResources. type AWSResourceList struct { + // +required ClusterName string `json:"cluster_name"` + // +required AWSResources []AWSResource `json:"aws_resources"` } diff --git a/controllers/awscluster_controller.go b/controllers/awscluster_controller.go index 4462fefd41..7eb30c0c1b 100644 --- a/controllers/awscluster_controller.go +++ b/controllers/awscluster_controller.go @@ -71,16 +71,27 @@ var defaultAWSSecurityGroupRoles = []infrav1.SecurityGroupRole{ // AWSClusterReconciler reconciles a AwsCluster object. type AWSClusterReconciler struct { + // +optional client.Client + // +optional Recorder record.EventRecorder + // +optional ec2ServiceFactory func(scope.EC2Scope) services.EC2Interface + // +optional networkServiceFactory func(scope.ClusterScope) services.NetworkInterface + // +optional elbServiceFactory func(scope.ELBScope) services.ELBInterface + // +optional securityGroupFactory func(scope.ClusterScope) services.SecurityGroupInterface + // +optional WatchFilterValue string + // +optional ExternalResourceGC bool + // +optional AlternativeGCStrategy bool + // +optional TagUnmanagedNetworkResources bool + // +optional MaxWaitActiveUpdateDelete time.Duration } diff --git a/controllers/awsmachine_controller.go b/controllers/awsmachine_controller.go index ab76af1cf9..ed17e6c607 100644 --- a/controllers/awsmachine_controller.go +++ b/controllers/awsmachine_controller.go @@ -77,16 +77,27 @@ const ( // AWSMachineReconciler reconciles a AwsMachine object. type AWSMachineReconciler struct { + // +optional client.Client + // +optional Log logr.Logger + // +optional Recorder record.EventRecorder + // +optional ec2ServiceFactory func(scope.EC2Scope) services.EC2Interface + // +optional elbServiceFactory func(scope.ELBScope) services.ELBInterface + // +optional secretsManagerServiceFactory func(cloud.ClusterScoper) services.SecretInterface + // +optional SSMServiceFactory func(cloud.ClusterScoper) services.SecretInterface + // +optional objectStoreServiceFactory func(cloud.ClusterScoper) services.ObjectStoreInterface + // +optional WatchFilterValue string + // +optional TagUnmanagedNetworkResources bool + // +optional MaxWaitActiveUpdateDelete time.Duration } diff --git a/controllers/awsmachine_controller_test.go b/controllers/awsmachine_controller_test.go index ad65f4a5cb..0a19bfd41e 100644 --- a/controllers/awsmachine_controller_test.go +++ b/controllers/awsmachine_controller_test.go @@ -36,7 +36,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2" - expinfrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/exp/api/v1beta2" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/scope" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services" @@ -44,10 +43,9 @@ import ( elbService "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/elb" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/mock_services" "sigs.k8s.io/cluster-api-provider-aws/v2/test/mocks" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util" - v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions" + "sigs.k8s.io/cluster-api/util/conditions" ) func TestAWSMachineReconcilerIntegrationTests(t *testing.T) { @@ -142,7 +140,7 @@ func TestAWSMachineReconcilerIntegrationTests(t *testing.T) { g.Expect(err).To(BeNil()) ms.Machine.Spec.Bootstrap.DataSecretName = aws.String("bootstrap-data") - ms.Machine.Spec.Version = "test" + ms.Machine.Spec.Version = aws.String("test") ms.AWSMachine.Spec.Subnet = &infrav1.AWSResourceReference{ID: aws.String("subnet-1")} ms.AWSMachine.Status.InstanceState = &infrav1.InstanceStateRunning ms.Machine.Labels = map[string]string{clusterv1.MachineControlPlaneLabel: ""} @@ -243,8 +241,8 @@ func TestAWSMachineReconcilerIntegrationTests(t *testing.T) { _, err = reconciler.reconcileDelete(context.TODO(), ms, cs, cs, cs, cs) g.Expect(err).To(BeNil()) expectConditions(g, ms.AWSMachine, []conditionAssertion{ - {infrav1.InstanceReadyCondition, corev1.ConditionFalse, clusterv1beta1.ConditionSeverityInfo, clusterv1beta1.DeletedReason}, - {infrav1.ELBAttachedCondition, corev1.ConditionFalse, clusterv1beta1.ConditionSeverityInfo, clusterv1beta1.DeletedReason}, + {infrav1.InstanceReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, clusterv1.DeletedReason}, + {infrav1.ELBAttachedCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, clusterv1.DeletedReason}, }) g.Expect(ms.AWSMachine.Finalizers).ShouldNot(ContainElement(infrav1.MachineFinalizer)) }) @@ -322,7 +320,7 @@ func TestAWSMachineReconcilerIntegrationTests(t *testing.T) { g.Expect(err).To(BeNil()) ms.Machine.Spec.Bootstrap.DataSecretName = aws.String("bootstrap-data") - ms.Machine.Spec.Version = "test" + ms.Machine.Spec.Version = aws.String("test") ms.AWSMachine.Spec.Subnet = &infrav1.AWSResourceReference{ID: aws.String("subnet-1")} ms.AWSMachine.Status.InstanceState = &infrav1.InstanceStateRunning ms.Machine.Labels = map[string]string{clusterv1.MachineControlPlaneLabel: ""} @@ -424,110 +422,11 @@ func TestAWSMachineReconcilerIntegrationTests(t *testing.T) { _, err = reconciler.reconcileDelete(context.TODO(), ms, cs, cs, cs, cs) g.Expect(err).Should(HaveOccurred()) expectConditions(g, ms.AWSMachine, []conditionAssertion{ - {infrav1.InstanceReadyCondition, corev1.ConditionFalse, clusterv1beta1.ConditionSeverityWarning, "DeletingFailed"}, - {infrav1.ELBAttachedCondition, corev1.ConditionFalse, clusterv1beta1.ConditionSeverityInfo, clusterv1beta1.DeletedReason}, + {infrav1.InstanceReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityWarning, "DeletingFailed"}, + {infrav1.ELBAttachedCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, clusterv1.DeletedReason}, }) g.Expect(ms.AWSMachine.Finalizers).ShouldNot(ContainElement(infrav1.MachineFinalizer)) }) - t.Run("Should successfully continue AWSMachinePool machine deletion if spec.cloudInit=={}", func(t *testing.T) { - g := NewWithT(t) - mockCtrl = gomock.NewController(t) - ec2Mock := mocks.NewMockEC2API(mockCtrl) - - // Simulate terminated instance - ec2Mock.EXPECT().DescribeInstances(context.TODO(), gomock.Eq(&ec2.DescribeInstancesInput{ - InstanceIds: []string{"myMachine"}, - })).Return(&ec2.DescribeInstancesOutput{ - Reservations: []ec2types.Reservation{{Instances: []ec2types.Instance{{Placement: &ec2types.Placement{AvailabilityZone: aws.String("us-east-1a")}, InstanceId: aws.String("i-mymachine"), State: &ec2types.InstanceState{Name: ec2types.InstanceStateNameTerminated, Code: aws.Int32(48)}}}}}, - }, nil) - - ns, err := testEnv.CreateNamespace(ctx, fmt.Sprintf("integ-test-%s", util.RandomString(5))) - g.Expect(err).To(BeNil()) - - setup(t, g) - awsMachine := &infrav1.AWSMachine{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - GenerateName: "mypool-", - Labels: map[string]string{ - clusterv1.MachinePoolNameLabel: "mypool", - clusterv1.ClusterNameLabel: "test-cluster", - }, - OwnerReferences: []metav1.OwnerReference{ - { - APIVersion: expinfrav1.GroupVersion.String(), - Kind: "AWSMachinePool", - Name: "mypool", - BlockOwnerDeletion: ptr.To(true), - UID: "6d1e6238-045d-4297-8c7e-73df7a5cc998", - }, - }, - }, - Spec: infrav1.AWSMachineSpec{ - ProviderID: aws.String(providerID), - InstanceID: aws.String("i-mymachine"), - AMI: infrav1.AMIReference{ - ID: aws.String("ami-alsodoesntmatter"), - }, - InstanceType: "foo", - PublicIP: aws.Bool(false), - SSHKeyName: aws.String("foo"), - InstanceMetadataOptions: &infrav1.InstanceMetadataOptions{ - // ... - }, - IAMInstanceProfile: "foo", - AdditionalSecurityGroups: nil, - Subnet: &infrav1.AWSResourceReference{ID: aws.String("sub-doesntmatter")}, - RootVolume: &infrav1.Volume{ - Size: 8, - // ... - }, - NonRootVolumes: nil, - NetworkInterfaces: []string{"eni-foobar"}, - CloudInit: infrav1.CloudInit{}, - SpotMarketOptions: nil, - Tenancy: "host", - }, - } - createAWSMachine(g, awsMachine) - - defer teardown(g) - defer t.Cleanup(func() { - g.Expect(testEnv.Cleanup(ctx, awsMachine, ns)).To(Succeed()) - }) - - cs, err := getClusterScope(infrav1.AWSCluster{ObjectMeta: metav1.ObjectMeta{Name: "test"}}) - g.Expect(err).To(BeNil()) - cs.Cluster = &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "test-cluster"}} - ms, err := getMachineScope(cs, awsMachine) - g.Expect(err).To(BeNil()) - - // This case happened in a live object. It didn't get defaulted and actually was - // a machine pool AWSMachine managed via Ignition. The AWSMachine controller must - // not try to use this field or delete bootstrap data, as the object is managed - // by the AWSMachinePool controller. - ms.AWSMachine.Spec.CloudInit.SecureSecretsBackend = "" - now := metav1.Now() - ms.AWSMachine.DeletionTimestamp = &now - ms.AWSMachine.Status.InstanceState = &infrav1.InstanceStateTerminated - - // Machine pool controlled Machine/AWSMachine - if ms.Machine.Labels == nil { - ms.Machine.Labels = map[string]string{} - } - ms.Machine.Labels[clusterv1.MachinePoolNameLabel] = ms.AWSMachine.Labels[clusterv1.MachinePoolNameLabel] - ms.Machine.Labels[clusterv1.ClusterNameLabel] = ms.AWSMachine.Labels[clusterv1.ClusterNameLabel] - - ec2Svc := ec2Service.NewService(cs) - ec2Svc.EC2Client = ec2Mock - reconciler.ec2ServiceFactory = func(scope scope.EC2Scope) services.EC2Interface { - return ec2Svc - } - - _, err = reconciler.reconcileDelete(context.TODO(), ms, cs, cs, cs, cs) - g.Expect(err).To(BeNil()) - g.Expect(ms.AWSMachine.Finalizers).ShouldNot(ContainElement(infrav1.MachineFinalizer)) - }) } func getMachineScope(cs *scope.ClusterScope, awsMachine *infrav1.AWSMachine) (*scope.MachineScope, error) { @@ -539,9 +438,7 @@ func getMachineScope(cs *scope.ClusterScope, awsMachine *infrav1.AWSMachine) (*s Name: "test", }, Status: clusterv1.ClusterStatus{ - Initialization: clusterv1.ClusterInitializationStatus{ - InfrastructureProvisioned: ptr.To(true), - }, + InfrastructureReady: true, }, }, Machine: &clusterv1.Machine{ @@ -610,6 +507,7 @@ func PointsTo(s string) gomock.Matcher { } type pointsTo struct { + // +optional val string } @@ -631,16 +529,20 @@ func (p *pointsTo) String() string { } type conditionAssertion struct { - conditionType clusterv1beta1.ConditionType + // +optional + conditionType clusterv1.ConditionType + // +optional status corev1.ConditionStatus - severity clusterv1beta1.ConditionSeverity + // +optional + severity clusterv1.ConditionSeverity + // +optional reason string } func expectConditions(g *WithT, m *infrav1.AWSMachine, expected []conditionAssertion) { g.Expect(len(m.Status.Conditions)).To(BeNumerically(">=", len(expected)), "number of conditions") for _, c := range expected { - actual := v1beta1conditions.Get(m, c.conditionType) + actual := conditions.Get(m, c.conditionType) g.Expect(actual).To(Not(BeNil())) g.Expect(actual.Type).To(Equal(c.conditionType)) g.Expect(actual.Status).To(Equal(c.status)) diff --git a/controllers/awsmanagedcluster_controller.go b/controllers/awsmanagedcluster_controller.go index b5f0beee88..610ef2909c 100644 --- a/controllers/awsmanagedcluster_controller.go +++ b/controllers/awsmanagedcluster_controller.go @@ -44,8 +44,11 @@ import ( // AWSManagedClusterReconciler reconciles AWSManagedCluster. type AWSManagedClusterReconciler struct { + // +optional client.Client + // +optional Recorder record.EventRecorder + // +optional WatchFilterValue string } diff --git a/controllers/rosacluster_controller.go b/controllers/rosacluster_controller.go index 219e0d9202..0fc17b75b9 100644 --- a/controllers/rosacluster_controller.go +++ b/controllers/rosacluster_controller.go @@ -55,10 +55,15 @@ import ( // ROSAClusterReconciler reconciles ROSACluster. type ROSAClusterReconciler struct { + // +optional client.Client + // +optional Recorder record.EventRecorder + // +optional WatchFilterValue string + // +optional NewStsClient func(cloud.ScopeUsage, cloud.Session, logger.Wrapper, runtime.Object) stsservice.STSClient + // +optional NewOCMClient func(ctx context.Context, rosaScope *scope.ROSAControlPlaneScope) (rosa.OCMClient, error) } diff --git a/controlplane/eks/api/v1beta1/awsmanagedcontrolplane_types.go b/controlplane/eks/api/v1beta1/awsmanagedcontrolplane_types.go index 607ad2f4de..ffbadd18aa 100644 --- a/controlplane/eks/api/v1beta1/awsmanagedcontrolplane_types.go +++ b/controlplane/eks/api/v1beta1/awsmanagedcontrolplane_types.go @@ -21,7 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) const ( @@ -44,9 +44,11 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned // IdentityRef is a reference to an identity to be used when reconciling the managed control plane. // If no identity is specified, the default identity for this controller will be used. + // +optional IdentityRef *infrav1.AWSIdentityReference `json:"identityRef,omitempty"` // NetworkSpec encapsulates all things related to AWS network. + // +optional NetworkSpec infrav1.NetworkSpec `json:"network,omitempty"` // SecondaryCidrBlock is the additional CIDR range to use for pod IPs. @@ -55,6 +57,7 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned SecondaryCidrBlock *string `json:"secondaryCidrBlock,omitempty"` // The AWS Region the cluster lives in. + // +optional Region string `json:"region,omitempty"` // SSHKeyName is the name of the ssh key to attach to the bastion host. Valid values are empty string (do not use SSH keys), a valid SSH key name, or omitted (use the default SSH key name) @@ -137,6 +140,7 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned // up machine images when a machine does not specify an AMI. When set, this // will be used for all cluster machines unless a machine specifies a // different ImageLookupBaseOS. + // +optional ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"` // Bastion contains options to configure the bastion host. @@ -149,11 +153,13 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned // Defaults to iam-authenticator // +kubebuilder:default=iam-authenticator // +kubebuilder:validation:Enum=iam-authenticator;aws-cli + // +optional TokenMethod *EKSTokenMethod `json:"tokenMethod,omitempty"` // AssociateOIDCProvider can be enabled to automatically create an identity // provider for the controller for use with IAM roles for service accounts // +kubebuilder:default=false + // +optional AssociateOIDCProvider bool `json:"associateOIDCProvider,omitempty"` // Addons defines the EKS addons to enable with the EKS cluster. @@ -171,6 +177,7 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned // should be deleted. You cannot set this to true if you are using the // Amazon VPC CNI addon. // +kubebuilder:default=false + // +optional DisableVPCCNI bool `json:"disableVPCCNI,omitempty"` // VpcCni is used to set configuration options for the VPC CNI plugin @@ -178,6 +185,7 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned VpcCni VpcCni `json:"vpcCni,omitempty"` // KubeProxy defines managed attributes of the kube-proxy daemonset + // +optional KubeProxy KubeProxy `json:"kubeProxy,omitempty"` } @@ -189,6 +197,7 @@ type KubeProxy struct { // provides a way to specify that the kube-proxy daemonset should be deleted. You cannot // set this to true if you are using the Amazon kube-proxy addon. // +kubebuilder:default=false + // +optional Disable bool `json:"disable,omitempty"` } @@ -215,25 +224,31 @@ type EndpointAccess struct { // EncryptionConfig specifies the encryption configuration for the EKS clsuter. type EncryptionConfig struct { // Provider specifies the ARN or alias of the CMK (in AWS KMS) + // +optional Provider *string `json:"provider,omitempty"` // Resources specifies the resources to be encrypted + // +optional Resources []*string `json:"resources,omitempty"` } // OIDCProviderStatus holds the status of the AWS OIDC identity provider. type OIDCProviderStatus struct { // ARN holds the ARN of the provider + // +optional ARN string `json:"arn,omitempty"` // TrustPolicy contains the boilerplate IAM trust policy to use for IRSA + // +optional TrustPolicy string `json:"trustPolicy,omitempty"` } // IdentityProviderStatus holds the status for associated identity provider type IdentityProviderStatus struct { // ARN holds the ARN of associated identity provider + // +optional ARN string `json:"arn,omitempty"` // Status holds current status of associated identity provider + // +optional Status string `json:"status,omitempty"` } @@ -254,6 +269,7 @@ type AWSManagedControlPlaneStatus struct { // ExternalManagedControlPlane indicates to cluster-api that the control plane // is managed by an external service such as AKS, EKS, GKE, etc. // +kubebuilder:default=true + // +optional ExternalManagedControlPlane *bool `json:"externalManagedControlPlane,omitempty"` // Initialized denotes whether or not the control plane has the // uploaded kubernetes config-map. @@ -262,13 +278,15 @@ type AWSManagedControlPlaneStatus struct { // Ready denotes that the AWSManagedControlPlane API Server is ready to // receive requests and that the VPC infra is ready. // +kubebuilder:default=false + // +required Ready bool `json:"ready"` // ErrorMessage indicates that there is a terminal problem reconciling the // state, and will be set to a descriptive error message. // +optional FailureMessage *string `json:"failureMessage,omitempty"` // Conditions specifies the cpnditions for the managed control plane - Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"` + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` // Addons holds the current status of the EKS addons // +optional Addons []AddonState `json:"addons,omitempty"` @@ -290,10 +308,13 @@ type AWSManagedControlPlaneStatus struct { // AWSManagedControlPlane is the schema for the Amazon EKS Managed Control Plane API. type AWSManagedControlPlane struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec AWSManagedControlPlaneSpec `json:"spec,omitempty"` + // +optional + Spec AWSManagedControlPlaneSpec `json:"spec,omitempty"` + // +optional Status AWSManagedControlPlaneStatus `json:"status,omitempty"` } @@ -303,8 +324,10 @@ type AWSManagedControlPlane struct { // AWSManagedControlPlaneList contains a list of Amazon EKS Managed Control Planes. type AWSManagedControlPlaneList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []AWSManagedControlPlane `json:"items"` + // +required + Items []AWSManagedControlPlane `json:"items"` } // GetConditions returns the control planes conditions. diff --git a/controlplane/eks/api/v1beta1/types.go b/controlplane/eks/api/v1beta1/types.go index 4fa88aa0a5..84d243eddb 100644 --- a/controlplane/eks/api/v1beta1/types.go +++ b/controlplane/eks/api/v1beta1/types.go @@ -30,18 +30,23 @@ import ( type ControlPlaneLoggingSpec struct { // APIServer indicates if the Kubernetes API Server log (kube-apiserver) shoulkd be enabled // +kubebuilder:default=false + // +required APIServer bool `json:"apiServer"` // Audit indicates if the Kubernetes API audit log should be enabled // +kubebuilder:default=false + // +required Audit bool `json:"audit"` // Authenticator indicates if the iam authenticator log should be enabled // +kubebuilder:default=false + // +required Authenticator bool `json:"authenticator"` // ControllerManager indicates if the controller manager (kube-controller-manager) log should be enabled // +kubebuilder:default=false + // +required ControllerManager bool `json:"controllerManager"` // Scheduler indicates if the Kubernetes scheduler (kube-scheduler) log should be enabled // +kubebuilder:default=false + // +required Scheduler bool `json:"scheduler"` } @@ -99,8 +104,10 @@ type IAMAuthenticatorConfig struct { // KubernetesMapping represents the kubernetes RBAC mapping. type KubernetesMapping struct { // UserName is a kubernetes RBAC user subject + // +required UserName string `json:"username"` // Groups is a list of kubernetes RBAC groups + // +required Groups []string `json:"groups"` } @@ -108,6 +115,7 @@ type KubernetesMapping struct { type RoleMapping struct { // RoleARN is the AWS ARN for the role to map // +kubebuilder:validation:MinLength:=31 + // +required RoleARN string `json:"rolearn"` // KubernetesMapping holds the RBAC details for the mapping KubernetesMapping `json:",inline"` @@ -117,6 +125,7 @@ type RoleMapping struct { type UserMapping struct { // UserARN is the AWS ARN for the user to map // +kubebuilder:validation:MinLength:=31 + // +required UserARN string `json:"userarn"` // KubernetesMapping holds the RBAC details for the mapping KubernetesMapping `json:",inline"` @@ -126,9 +135,10 @@ type UserMapping struct { type Addon struct { // Name is the name of the addon // +kubebuilder:validation:MinLength:=2 - // +kubebuilder:validation:Required + // +required Name string `json:"name"` // Version is the version of the addon to use + // +required Version string `json:"version"` // Configuration of the EKS addon // +optional @@ -137,6 +147,7 @@ type Addon struct { // are parameter conflicts. Defaults to none // +kubebuilder:default=none // +kubebuilder:validation:Enum=overwrite;none + // +optional ConflictResolution *AddonResolution `json:"conflictResolution,omitempty"` // ServiceAccountRoleArn is the ARN of an IAM role to bind to the addons service account // +optional @@ -189,30 +200,41 @@ var ( // AddonState represents the state of an addon. type AddonState struct { // Name is the name of the addon + // +required Name string `json:"name"` // Version is the version of the addon to use + // +required Version string `json:"version"` // ARN is the AWS ARN of the addon + // +required ARN string `json:"arn"` // ServiceAccountRoleArn is the ARN of the IAM role used for the service account + // +optional ServiceAccountRoleArn *string `json:"serviceAccountRoleARN,omitempty"` // CreatedAt is the date and time the addon was created at + // +optional CreatedAt metav1.Time `json:"createdAt,omitempty"` // ModifiedAt is the date and time the addon was last modified + // +optional ModifiedAt metav1.Time `json:"modifiedAt,omitempty"` // Status is the status of the addon + // +optional Status *string `json:"status,omitempty"` // Issues is a list of issue associated with the addon + // +optional Issues []AddonIssue `json:"issues,omitempty"` } // AddonIssue represents an issue with an addon. type AddonIssue struct { // Code is the issue code + // +optional Code *string `json:"code,omitempty"` // Message is the textual description of the issue + // +optional Message *string `json:"message,omitempty"` // ResourceIDs is a list of resource ids for the issue + // +optional ResourceIDs []string `json:"resourceIds,omitempty"` } @@ -226,7 +248,7 @@ const ( type OIDCIdentityProviderConfig struct { // This is also known as audience. The ID for the client application that makes // authentication requests to the OpenID identity provider. - // +kubebuilder:validation:Required + // +required ClientID string `json:"clientId,omitempty"` // The JWT claim that the provider uses to return your groups. @@ -242,7 +264,7 @@ type OIDCIdentityProviderConfig struct { // The name of the OIDC provider configuration. // // IdentityProviderConfigName is a required field - // +kubebuilder:validation:Required + // +required IdentityProviderConfigName string `json:"identityProviderConfigName,omitempty"` // The URL of the OpenID identity provider that allows the API server to discover @@ -253,7 +275,7 @@ type OIDCIdentityProviderConfig struct { // or https://example.com. This URL should point to the level below .well-known/openid-configuration // and must be publicly accessible over the internet. // - // +kubebuilder:validation:Required + // +required IssuerURL string `json:"issuerUrl,omitempty"` // The key value pairs that describe required claims in the identity token. diff --git a/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_types.go b/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_types.go index a904069de9..50b177ed64 100644 --- a/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_types.go +++ b/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_types.go @@ -21,6 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) @@ -46,6 +47,7 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned IdentityRef *infrav1.AWSIdentityReference `json:"identityRef,omitempty"` // NetworkSpec encapsulates all things related to AWS network. + // +optional NetworkSpec infrav1.NetworkSpec `json:"network,omitempty"` // SecondaryCidrBlock is the additional CIDR range to use for pod IPs. @@ -54,6 +56,7 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned SecondaryCidrBlock *string `json:"secondaryCidrBlock,omitempty"` // The AWS Region the cluster lives in. + // +optional Region string `json:"region,omitempty"` // Partition is the AWS security partition being used. Defaults to "aws" @@ -137,7 +140,7 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. // +optional - ControlPlaneEndpoint clusterv1beta1.APIEndpoint `json:"controlPlaneEndpoint"` + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` // ImageLookupFormat is the AMI naming format to look up machine images when // a machine does not specify an AMI. When set, this will be used for all @@ -164,6 +167,7 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned // up machine images when a machine does not specify an AMI. When set, this // will be used for all cluster machines unless a machine specifies a // different ImageLookupBaseOS. + // +optional ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"` // Bastion contains options to configure the bastion host. @@ -176,11 +180,13 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned // Defaults to iam-authenticator // +kubebuilder:default=iam-authenticator // +kubebuilder:validation:Enum=iam-authenticator;aws-cli + // +optional TokenMethod *EKSTokenMethod `json:"tokenMethod,omitempty"` // AssociateOIDCProvider can be enabled to automatically create an identity // provider for the controller for use with IAM roles for service accounts // +kubebuilder:default=false + // +optional AssociateOIDCProvider bool `json:"associateOIDCProvider,omitempty"` // Addons defines the EKS addons to enable with the EKS cluster. @@ -204,13 +210,16 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned // bare EKS cluster without EKS default networking addons // If you set this value to false when creating a cluster, the default networking add-ons will not be installed // +kubebuilder:default=true + // +optional BootstrapSelfManagedAddons bool `json:"bootstrapSelfManagedAddons,omitempty"` // RestrictPrivateSubnets indicates that the EKS control plane should only use private subnets. // +kubebuilder:default=false + // +optional RestrictPrivateSubnets bool `json:"restrictPrivateSubnets,omitempty"` // KubeProxy defines managed attributes of the kube-proxy daemonset + // +optional KubeProxy KubeProxy `json:"kubeProxy,omitempty"` // The cluster upgrade policy to use for the cluster. @@ -231,6 +240,7 @@ type KubeProxy struct { // provides a way to specify that the kube-proxy daemonset should be deleted. You cannot // set this to true if you are using the Amazon kube-proxy addon. // +kubebuilder:default=false + // +optional Disable bool `json:"disable,omitempty"` } @@ -242,6 +252,7 @@ type VpcCni struct { // should be deleted. You cannot set this to true if you are using the // Amazon VPC CNI addon. // +kubebuilder:default=false + // +optional Disable bool `json:"disable,omitempty"` // Env defines a list of environment variables to apply to the `aws-node` DaemonSet // +optional @@ -267,37 +278,45 @@ type AccessConfig struct { // Defaults to config_map // +kubebuilder:default=config_map // +kubebuilder:validation:Enum=config_map;api;api_and_config_map + // +optional AuthenticationMode EKSAuthenticationMode `json:"authenticationMode,omitempty"` // BootstrapClusterCreatorAdminPermissions grants cluster admin permissions // to the IAM identity creating the cluster. Only applied during creation, // ignored when updating existing clusters. Defaults to true. // +kubebuilder:default=true + // +optional BootstrapClusterCreatorAdminPermissions *bool `json:"bootstrapClusterCreatorAdminPermissions,omitempty"` } // EncryptionConfig specifies the encryption configuration for the EKS clsuter. type EncryptionConfig struct { // Provider specifies the ARN or alias of the CMK (in AWS KMS) + // +optional Provider *string `json:"provider,omitempty"` // Resources specifies the resources to be encrypted + // +optional Resources []*string `json:"resources,omitempty"` } // OIDCProviderStatus holds the status of the AWS OIDC identity provider. type OIDCProviderStatus struct { // ARN holds the ARN of the provider + // +optional ARN string `json:"arn,omitempty"` // TrustPolicy contains the boilerplate IAM trust policy to use for IRSA + // +optional TrustPolicy string `json:"trustPolicy,omitempty"` } // IdentityProviderStatus holds the status for associated identity provider. type IdentityProviderStatus struct { // ARN holds the ARN of associated identity provider + // +optional ARN string `json:"arn,omitempty"` // Status holds current status of associated identity provider + // +optional Status string `json:"status,omitempty"` } @@ -308,7 +327,7 @@ type AWSManagedControlPlaneStatus struct { Network infrav1.NetworkStatus `json:"networkStatus,omitempty"` // FailureDomains specifies a list fo available availability zones that can be used // +optional - FailureDomains clusterv1beta1.FailureDomains `json:"failureDomains,omitempty"` + FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"` // Bastion holds details of the instance that is used as a bastion jump box // +optional Bastion *infrav1.Instance `json:"bastion,omitempty"` @@ -318,6 +337,7 @@ type AWSManagedControlPlaneStatus struct { // ExternalManagedControlPlane indicates to cluster-api that the control plane // is managed by an external service such as AKS, EKS, GKE, etc. // +kubebuilder:default=true + // +optional ExternalManagedControlPlane *bool `json:"externalManagedControlPlane,omitempty"` // Initialized denotes whether or not the control plane has the // uploaded kubernetes config-map. @@ -326,13 +346,15 @@ type AWSManagedControlPlaneStatus struct { // Ready denotes that the AWSManagedControlPlane API Server is ready to // receive requests and that the VPC infra is ready. // +kubebuilder:default=false + // +required Ready bool `json:"ready"` // ErrorMessage indicates that there is a terminal problem reconciling the // state, and will be set to a descriptive error message. // +optional FailureMessage *string `json:"failureMessage,omitempty"` // Conditions specifies the cpnditions for the managed control plane - Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"` + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` // Addons holds the current status of the EKS addons // +optional Addons []AddonState `json:"addons,omitempty"` @@ -358,10 +380,13 @@ type AWSManagedControlPlaneStatus struct { // AWSManagedControlPlane is the schema for the Amazon EKS Managed Control Plane API. type AWSManagedControlPlane struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec AWSManagedControlPlaneSpec `json:"spec,omitempty"` + // +optional + Spec AWSManagedControlPlaneSpec `json:"spec,omitempty"` + // +optional Status AWSManagedControlPlaneStatus `json:"status,omitempty"` } @@ -370,8 +395,10 @@ type AWSManagedControlPlane struct { // AWSManagedControlPlaneList contains a list of Amazon EKS Managed Control Planes. type AWSManagedControlPlaneList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []AWSManagedControlPlane `json:"items"` + // +required + Items []AWSManagedControlPlane `json:"items"` } // GetConditions returns the control planes conditions. diff --git a/controlplane/eks/api/v1beta2/awsmanagedcontrolplanetemplate_types.go b/controlplane/eks/api/v1beta2/awsmanagedcontrolplanetemplate_types.go index 3c1b4109b8..b5aafe12f1 100644 --- a/controlplane/eks/api/v1beta2/awsmanagedcontrolplanetemplate_types.go +++ b/controlplane/eks/api/v1beta2/awsmanagedcontrolplanetemplate_types.go @@ -22,6 +22,7 @@ import ( // AWSManagedControlPlaneTemplateSpec defines the desired state of AWSManagedControlPlaneTemplate. type AWSManagedControlPlaneTemplateSpec struct { + // +required Template AWSManagedControlPlaneTemplateResource `json:"template"` } @@ -32,8 +33,10 @@ type AWSManagedControlPlaneTemplateSpec struct { // AWSManagedControlPlaneTemplate is the Schema for the AWSManagedControlPlaneTemplates API. type AWSManagedControlPlaneTemplate struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSManagedControlPlaneTemplateSpec `json:"spec,omitempty"` } @@ -42,7 +45,9 @@ type AWSManagedControlPlaneTemplate struct { // AWSManagedControlPlaneTemplateList contains a list of AWSManagedControlPlaneTemplates. type AWSManagedControlPlaneTemplateList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSManagedControlPlaneTemplate `json:"items"` } @@ -52,5 +57,6 @@ func init() { // AWSManagedControlPlaneTemplateResource describes the data needed to create an AWSManagedCluster from a template. type AWSManagedControlPlaneTemplateResource struct { + // +required Spec AWSManagedControlPlaneSpec `json:"spec"` } diff --git a/controlplane/eks/api/v1beta2/types.go b/controlplane/eks/api/v1beta2/types.go index 60cd4b454d..1c3b088529 100644 --- a/controlplane/eks/api/v1beta2/types.go +++ b/controlplane/eks/api/v1beta2/types.go @@ -31,18 +31,23 @@ import ( type ControlPlaneLoggingSpec struct { // APIServer indicates if the Kubernetes API Server log (kube-apiserver) shoulkd be enabled // +kubebuilder:default=false + // +required APIServer bool `json:"apiServer"` // Audit indicates if the Kubernetes API audit log should be enabled // +kubebuilder:default=false + // +required Audit bool `json:"audit"` // Authenticator indicates if the iam authenticator log should be enabled // +kubebuilder:default=false + // +required Authenticator bool `json:"authenticator"` // ControllerManager indicates if the controller manager (kube-controller-manager) log should be enabled // +kubebuilder:default=false + // +required ControllerManager bool `json:"controllerManager"` // Scheduler indicates if the Kubernetes scheduler (kube-scheduler) log should be enabled // +kubebuilder:default=false + // +required Scheduler bool `json:"scheduler"` } @@ -120,8 +125,10 @@ type IAMAuthenticatorConfig struct { // KubernetesMapping represents the kubernetes RBAC mapping. type KubernetesMapping struct { // UserName is a kubernetes RBAC user subject + // +required UserName string `json:"username"` // Groups is a list of kubernetes RBAC groups + // +required Groups []string `json:"groups"` } @@ -129,6 +136,7 @@ type KubernetesMapping struct { type RoleMapping struct { // RoleARN is the AWS ARN for the role to map // +kubebuilder:validation:MinLength:=31 + // +required RoleARN string `json:"rolearn"` // KubernetesMapping holds the RBAC details for the mapping KubernetesMapping `json:",inline"` @@ -138,6 +146,7 @@ type RoleMapping struct { type UserMapping struct { // UserARN is the AWS ARN for the user to map // +kubebuilder:validation:MinLength:=31 + // +required UserARN string `json:"userarn"` // KubernetesMapping holds the RBAC details for the mapping KubernetesMapping `json:",inline"` @@ -147,9 +156,10 @@ type UserMapping struct { type Addon struct { // Name is the name of the addon // +kubebuilder:validation:MinLength:=2 - // +kubebuilder:validation:Required + // +required Name string `json:"name"` // Version is the version of the addon to use + // +required Version string `json:"version"` // Configuration of the EKS addon // +optional @@ -158,6 +168,7 @@ type Addon struct { // are parameter conflicts. Defaults to overwrite // +kubebuilder:default=overwrite // +kubebuilder:validation:Enum=overwrite;none;preserve + // +optional ConflictResolution *AddonResolution `json:"conflictResolution,omitempty"` // ServiceAccountRoleArn is the ARN of an IAM role to bind to the addons service account // +optional @@ -214,30 +225,41 @@ var ( // AddonState represents the state of an addon. type AddonState struct { // Name is the name of the addon + // +required Name string `json:"name"` // Version is the version of the addon to use + // +required Version string `json:"version"` // ARN is the AWS ARN of the addon + // +required ARN string `json:"arn"` // ServiceAccountRoleArn is the ARN of the IAM role used for the service account + // +optional ServiceAccountRoleArn *string `json:"serviceAccountRoleARN,omitempty"` // CreatedAt is the date and time the addon was created at + // +optional CreatedAt metav1.Time `json:"createdAt,omitempty"` // ModifiedAt is the date and time the addon was last modified + // +optional ModifiedAt metav1.Time `json:"modifiedAt,omitempty"` // Status is the status of the addon + // +optional Status *string `json:"status,omitempty"` // Issues is a list of issue associated with the addon + // +optional Issues []AddonIssue `json:"issues,omitempty"` } // AddonIssue represents an issue with an addon. type AddonIssue struct { // Code is the issue code + // +optional Code *string `json:"code,omitempty"` // Message is the textual description of the issue + // +optional Message *string `json:"message,omitempty"` // ResourceIDs is a list of resource ids for the issue + // +optional ResourceIDs []string `json:"resourceIds,omitempty"` } @@ -269,7 +291,7 @@ const ( type OIDCIdentityProviderConfig struct { // This is also known as audience. The ID for the client application that makes // authentication requests to the OpenID identity provider. - // +kubebuilder:validation:Required + // +required ClientID string `json:"clientId,omitempty"` // The JWT claim that the provider uses to return your groups. @@ -285,7 +307,7 @@ type OIDCIdentityProviderConfig struct { // The name of the OIDC provider configuration. // // IdentityProviderConfigName is a required field - // +kubebuilder:validation:Required + // +required IdentityProviderConfigName string `json:"identityProviderConfigName,omitempty"` // The URL of the OpenID identity provider that allows the API server to discover @@ -296,7 +318,7 @@ type OIDCIdentityProviderConfig struct { // or https://example.com. This URL should point to the level below .well-known/openid-configuration // and must be publicly accessible over the internet. // - // +kubebuilder:validation:Required + // +required IssuerURL string `json:"issuerUrl,omitempty"` // The key value pairs that describe required claims in the identity token. diff --git a/controlplane/eks/controllers/awsmanagedcontrolplane_controller.go b/controlplane/eks/controllers/awsmanagedcontrolplane_controller.go index 53f2c1f73b..9904481a27 100644 --- a/controlplane/eks/controllers/awsmanagedcontrolplane_controller.go +++ b/controlplane/eks/controllers/awsmanagedcontrolplane_controller.go @@ -86,24 +86,41 @@ func securityGroupRolesForControlPlane(scope *scope.ManagedControlPlaneScope) [] // AWSManagedControlPlaneReconciler reconciles a AWSManagedControlPlane object. type AWSManagedControlPlaneReconciler struct { + // +optional client.Client + // +optional Recorder record.EventRecorder + // +optional awsNodeServiceFactory func(scope.AWSNodeScope) services.AWSNodeInterface + // +optional ec2ServiceFactory func(scope.EC2Scope) services.EC2Interface + // +optional eksServiceFactory func(*scope.ManagedControlPlaneScope) *eks.Service + // +optional iamAuthenticatorServiceFactory func(scope.IAMAuthScope, iamauth.BackendType, client.Client) services.IAMAuthenticatorInterface + // +optional kubeProxyServiceFactory func(scope.KubeProxyScope) services.KubeProxyInterface + // +optional networkServiceFactory func(scope.NetworkScope) services.NetworkInterface + // +optional securityGroupServiceFactory func(*scope.ManagedControlPlaneScope) services.SecurityGroupInterface + // +optional EnableIAM bool + // +optional AllowAdditionalRoles bool + // +optional WatchFilterValue string + // +optional ExternalResourceGC bool + // +optional AlternativeGCStrategy bool + // +optional WaitInfraPeriod time.Duration + // +optional MaxWaitActiveUpdateDelete time.Duration + // +optional TagUnmanagedNetworkResources bool } diff --git a/controlplane/rosa/api/v1beta2/external_auth_types.go b/controlplane/rosa/api/v1beta2/external_auth_types.go index 7bd16d4585..f70d0b329a 100644 --- a/controlplane/rosa/api/v1beta2/external_auth_types.go +++ b/controlplane/rosa/api/v1beta2/external_auth_types.go @@ -5,12 +5,10 @@ type ExternalAuthProvider struct { // Name of the OIDC provider // // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:Required // +required Name string `json:"name"` // Issuer describes attributes of the OIDC token issuer // - // +kubebuilder:validation:Required // +required Issuer TokenIssuer `json:"issuer"` @@ -32,6 +30,7 @@ type ExternalAuthProvider struct { // ClaimValidationRules are rules that are applied to validate token claims to authenticate users. // // +listType=atomic + // +optional ClaimValidationRules []TokenClaimValidationRule `json:"claimValidationRules,omitempty"` } @@ -46,7 +45,6 @@ type TokenIssuer struct { // Must use the https:// scheme. // // +kubebuilder:validation:Pattern=`^https:\/\/[^\s]` - // +kubebuilder:validation:Required // +required URL string `json:"issuerURL"` @@ -56,7 +54,6 @@ type TokenIssuer struct { // Must be set to exactly one value. // // +listType=set - // +kubebuilder:validation:Required // +kubebuilder:validation:MinItems=1 // +kubebuilder:validation:MaxItems=10 // +required @@ -66,6 +63,7 @@ type TokenIssuer struct { // configuration namespace. The .data of the configMap must contain // the "ca-bundle.crt" key. // If unset, system trust is used instead. + // +optional CertificateAuthority *LocalObjectReference `json:"issuerCertificateAuthority,omitempty"` } @@ -77,7 +75,6 @@ type OIDCClientConfig struct { // // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=256 - // +kubebuilder:validation:Required // +required ComponentName string `json:"componentName"` @@ -86,19 +83,18 @@ type OIDCClientConfig struct { // // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=63 - // +kubebuilder:validation:Required // +required ComponentNamespace string `json:"componentNamespace"` // ClientID is the identifier of the OIDC client from the OIDC provider // // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:Required // +required ClientID string `json:"clientID"` // ClientSecret refers to a secret that // contains the client secret in the `clientSecret` key of the `.data` field + // +required ClientSecret LocalObjectReference `json:"clientSecret"` // ExtraScopes is an optional set of scopes to request tokens with. @@ -129,7 +125,6 @@ type TokenClaimMappings struct { type PrefixedClaimMapping struct { // Claim is a JWT token claim to be used in the mapping // - // +kubebuilder:validation:Required // +required Claim string `json:"claim"` @@ -141,6 +136,7 @@ type PrefixedClaimMapping struct { // Example: if `prefix` is set to "myoidc:"" and the `claim` in JWT contains // an array of strings "a", "b" and "c", the mapping will result in an // array of string "myoidc:a", "myoidc:b" and "myoidc:c". + // +optional Prefix string `json:"prefix,omitempty"` } @@ -150,7 +146,6 @@ type PrefixedClaimMapping struct { type UsernameClaimMapping struct { // Claim is a JWT token claim to be used in the mapping // - // +kubebuilder:validation:Required // +required Claim string `json:"claim"` @@ -214,10 +209,11 @@ type TokenClaimValidationRule struct { // // +kubebuilder:validation:Enum={"RequiredClaim"} // +kubebuilder:default="RequiredClaim" + // +required Type TokenValidationRuleType `json:"type"` // RequiredClaim allows configuring a required claim name and its expected value - // +kubebuilder:validation:Required + // +required RequiredClaim TokenRequiredClaim `json:"requiredClaim"` } @@ -227,14 +223,12 @@ type TokenRequiredClaim struct { // supported. // // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:Required // +required Claim string `json:"claim"` // RequiredValue is the required value for the claim. // // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:Required // +required RequiredValue string `json:"requiredValue"` } @@ -243,7 +237,6 @@ type TokenRequiredClaim struct { type LocalObjectReference struct { // Name is the metadata.name of the referenced object. // - // +kubebuilder:validation:Required // +required Name string `json:"name"` } diff --git a/controlplane/rosa/api/v1beta2/rosacontrolplane_types.go b/controlplane/rosa/api/v1beta2/rosacontrolplane_types.go index 4be22a8dec..89a1fdd4b0 100644 --- a/controlplane/rosa/api/v1beta2/rosacontrolplane_types.go +++ b/controlplane/rosa/api/v1beta2/rosacontrolplane_types.go @@ -21,6 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1" clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" ) @@ -92,6 +93,7 @@ type RosaControlPlaneSpec struct { //nolint: maligned // +kubebuilder:validation:XValidation:rule="self == oldSelf", message="rosaClusterName is immutable" // +kubebuilder:validation:MaxLength:=54 // +kubebuilder:validation:Pattern:=`^[a-z]([-a-z0-9]*[a-z0-9])?$` + // +required RosaClusterName string `json:"rosaClusterName"` // DomainPrefix is an optional prefix added to the cluster's domain name. It will be used @@ -118,15 +120,18 @@ type RosaControlPlaneSpec struct { //nolint: maligned AvailabilityZones []string `json:"availabilityZones,omitempty"` // The AWS Region the cluster lives in. + // +required Region string `json:"region"` // OpenShift semantic version, for example "4.14.5". + // +required Version string `json:"version"` // OpenShift version channel group, default is stable. // // +kubebuilder:validation:Enum=stable;eus;fast;candidate;nightly // +kubebuilder:default=stable + // +required ChannelGroup ChannelGroupType `json:"channelGroup"` // VersionGate requires acknowledgment when upgrading ROSA-HCP y-stream versions (e.g., from 4.15 to 4.16). @@ -137,6 +142,7 @@ type RosaControlPlaneSpec struct { //nolint: maligned // // +kubebuilder:validation:Enum=Acknowledge;WaitForAcknowledge;AlwaysAcknowledge // +kubebuilder:default=WaitForAcknowledge + // +required VersionGate VersionGateAckType `json:"versionGate"` // RosaRoleConfigRef is a reference to a RosaRoleConfig resource that contains account roles, operator roles and OIDC configuration. @@ -172,6 +178,7 @@ type RosaControlPlaneSpec struct { //nolint: maligned // +listType=map // +listMapKey=name // +kubebuilder:validation:MaxItems=1 + // +optional ExternalAuthProviders []ExternalAuthProvider `json:"externalAuthProviders,omitempty"` // InstallerRoleARN is an AWS IAM role that OpenShift Cluster Manager will assume to create the cluster. @@ -192,7 +199,6 @@ type RosaControlPlaneSpec struct { //nolint: maligned // The cost of running each ROSA HCP cluster will be billed to the infrastructure account in which the cluster // is running. // - // +kubebuilder:validation:Optional // +kubebuilder:validation:XValidation:rule="self == oldSelf", message="billingAccount is immutable" // +kubebuilder:validation:XValidation:rule="self.matches('^[0-9]{12}$')", message="billingAccount must be a valid AWS account ID" // +immutable @@ -257,7 +263,7 @@ type RosaControlPlaneSpec struct { //nolint: maligned // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. // +optional - ControlPlaneEndpoint clusterv1beta1.APIEndpoint `json:"controlPlaneEndpoint"` + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` // ClusterRegistryConfig represents registry config used with the cluster. // +optional @@ -398,8 +404,10 @@ type DefaultMachinePoolSpec struct { // AutoScaling specifies scaling options. type AutoScaling struct { // +kubebuilder:validation:Minimum=1 + // +optional MinReplicas int `json:"minReplicas,omitempty"` // +kubebuilder:validation:Minimum=1 + // +optional MaxReplicas int `json:"maxReplicas,omitempty"` } @@ -454,6 +462,7 @@ type AWSRolesRef struct { // } // ] // } + // +required IngressARN string `json:"ingressARN"` // ImageRegistryARN is an ARN value referencing a role appropriate for the Image Registry Operator. @@ -489,6 +498,7 @@ type AWSRolesRef struct { // } // ] // } + // +required ImageRegistryARN string `json:"imageRegistryARN"` // StorageARN is an ARN value referencing a role appropriate for the Storage Operator. @@ -520,6 +530,7 @@ type AWSRolesRef struct { // } // ] // } + // +required StorageARN string `json:"storageARN"` // NetworkARN is an ARN value referencing a role appropriate for the Network Operator. @@ -546,6 +557,7 @@ type AWSRolesRef struct { // } // ] // } + // +required NetworkARN string `json:"networkARN"` // KubeCloudControllerARN is an ARN value referencing a role appropriate for the KCM/KCC. @@ -624,6 +636,7 @@ type AWSRolesRef struct { // ] // } // +immutable + // +required KubeCloudControllerARN string `json:"kubeCloudControllerARN"` // NodePoolManagementARN is an ARN value referencing a role appropriate for the CAPI Controller. @@ -737,6 +750,7 @@ type AWSRolesRef struct { // } // // +immutable + // +required NodePoolManagementARN string `json:"nodePoolManagementARN"` // ControlPlaneOperatorARN is an ARN value referencing a role appropriate for the Control Plane Operator. @@ -777,8 +791,10 @@ type AWSRolesRef struct { // ] // } // +immutable + // +required ControlPlaneOperatorARN string `json:"controlPlaneOperatorARN"` - KMSProviderARN string `json:"kmsProviderARN"` + // +required + KMSProviderARN string `json:"kmsProviderARN"` } // RosaControlPlaneStatus defines the observed state of ROSAControlPlane. @@ -786,6 +802,7 @@ type RosaControlPlaneStatus struct { // ExternalManagedControlPlane indicates to cluster-api that the control plane // is managed by an external service such as AKS, EKS, GKE, etc. // +kubebuilder:default=true + // +optional ExternalManagedControlPlane *bool `json:"externalManagedControlPlane,omitempty"` // Initialized denotes whether or not the control plane has the // uploaded kubernetes config-map. @@ -793,6 +810,7 @@ type RosaControlPlaneStatus struct { Initialized bool `json:"initialized"` // Ready denotes that the ROSAControlPlane API Server is ready to receive requests. // +kubebuilder:default=false + // +required Ready bool `json:"ready"` // FailureMessage will be set in the event that there is a terminal problem // reconciling the state and will be set to a descriptive error message. @@ -806,13 +824,17 @@ type RosaControlPlaneStatus struct { // +optional FailureMessage *string `json:"failureMessage,omitempty"` // Conditions specifies the conditions for the managed control plane - Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"` + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` // ID is the cluster ID given by ROSA. + // +optional ID string `json:"id,omitempty"` // ConsoleURL is the url for the openshift console. + // +optional ConsoleURL string `json:"consoleURL,omitempty"` // OIDCEndpointURL is the endpoint url for the managed OIDC provider. + // +optional OIDCEndpointURL string `json:"oidcEndpointURL,omitempty"` // OpenShift semantic version, for example "4.14.5". @@ -820,6 +842,7 @@ type RosaControlPlaneStatus struct { Version string `json:"version"` // Available upgrades for the ROSA hosted control plane. + // +optional AvailableUpgrades []string `json:"availableUpgrades,omitempty"` } @@ -833,10 +856,13 @@ type RosaControlPlaneStatus struct { // ROSAControlPlane is the Schema for the ROSAControlPlanes API. type ROSAControlPlane struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec RosaControlPlaneSpec `json:"spec,omitempty"` + // +optional + Spec RosaControlPlaneSpec `json:"spec,omitempty"` + // +optional Status RosaControlPlaneStatus `json:"status,omitempty"` } @@ -845,8 +871,10 @@ type ROSAControlPlane struct { // ROSAControlPlaneList contains a list of ROSAControlPlane. type ROSAControlPlaneList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []ROSAControlPlane `json:"items"` + // +required + Items []ROSAControlPlane `json:"items"` } // GetConditions returns the control planes conditions. diff --git a/controlplane/rosa/controllers/rosacontrolplane_controller.go b/controlplane/rosa/controllers/rosacontrolplane_controller.go index a87b7a9a1d..481c7c0179 100644 --- a/controlplane/rosa/controllers/rosacontrolplane_controller.go +++ b/controlplane/rosa/controllers/rosacontrolplane_controller.go @@ -88,12 +88,18 @@ const ( // ROSAControlPlaneReconciler reconciles a ROSAControlPlane object. type ROSAControlPlaneReconciler struct { + // +optional client.Client + // +optional WatchFilterValue string + // +optional WaitInfraPeriod time.Duration + // +optional NewStsClient func(cloud.ScopeUsage, cloud.Session, logger.Wrapper, runtime.Object) stsiface.STSClient + // +optional NewOCMClient func(ctx context.Context, rosaScope *scope.ROSAControlPlaneScope) (rosa.OCMClient, error) // Exposing the restClientConfig for integration test. No need to initialize. + // +optional restClientConfig *restclient.Config } diff --git a/docs/book/cmd/clusterawsadmdocs/main.go b/docs/book/cmd/clusterawsadmdocs/main.go index 69c7c1d42d..8d8c1530d9 100644 --- a/docs/book/cmd/clusterawsadmdocs/main.go +++ b/docs/book/cmd/clusterawsadmdocs/main.go @@ -36,8 +36,11 @@ func (s byName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s byName) Less(i, j int) bool { return s[i].Name() < s[j].Name() } type commandLeaf struct { + // +optional name string + // +optional link string + // +optional subcommands map[string]commandLeaf } diff --git a/exp/api/v1beta1/awsfargateprofile_types.go b/exp/api/v1beta1/awsfargateprofile_types.go index 3bdcc0f5eb..4d19024b48 100644 --- a/exp/api/v1beta1/awsfargateprofile_types.go +++ b/exp/api/v1beta1/awsfargateprofile_types.go @@ -35,9 +35,11 @@ var DefaultEKSFargateRole = fmt.Sprintf("eks-fargate%s", iamv1.DefaultNameSuffix type FargateProfileSpec struct { // ClusterName is the name of the Cluster this object belongs to. // +kubebuilder:validation:MinLength=1 + // +required ClusterName string `json:"clusterName"` // ProfileName specifies the profile name. + // +optional ProfileName string `json:"profileName,omitempty"` // SubnetIDs specifies which subnets are used for the @@ -58,15 +60,18 @@ type FargateProfileSpec struct { RoleName string `json:"roleName,omitempty"` // Selectors specify fargate pod selectors. + // +optional Selectors []FargateSelector `json:"selectors,omitempty"` } // FargateSelector specifies a selector for pods that should run on this fargate pool. type FargateSelector struct { // Labels specifies which pod labels this selector should match. + // +optional Labels map[string]string `json:"labels,omitempty"` // Namespace specifies which namespace this selector should match. + // +optional Namespace string `json:"namespace,omitempty"` } @@ -74,6 +79,7 @@ type FargateSelector struct { type FargateProfileStatus struct { // Ready denotes that the FargateProfile is available. // +kubebuilder:default=false + // +required Ready bool `json:"ready"` // FailureReason will be set in the event that there is a terminal problem @@ -130,9 +136,12 @@ type FargateProfileStatus struct { // AWSFargateProfile is the Schema for the awsfargateprofiles API. type AWSFargateProfile struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec FargateProfileSpec `json:"spec,omitempty"` + // +optional Status FargateProfileStatus `json:"status,omitempty"` } @@ -152,7 +161,9 @@ func (r *AWSFargateProfile) SetConditions(conditions clusterv1beta1.Conditions) // AWSFargateProfileList contains a list of FargateProfiles. type AWSFargateProfileList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSFargateProfile `json:"items"` } diff --git a/exp/api/v1beta1/awsmachinepool_types.go b/exp/api/v1beta1/awsmachinepool_types.go index c4061baf12..ed8cc38bf2 100644 --- a/exp/api/v1beta1/awsmachinepool_types.go +++ b/exp/api/v1beta1/awsmachinepool_types.go @@ -39,14 +39,17 @@ type AWSMachinePoolSpec struct { // MinSize defines the minimum size of the group. // +kubebuilder:default=1 // +kubebuilder:validation:Minimum=0 + // +required MinSize int32 `json:"minSize"` // MaxSize defines the maximum size of the group. // +kubebuilder:default=1 // +kubebuilder:validation:Minimum=1 + // +required MaxSize int32 `json:"maxSize"` // AvailabilityZones is an array of availability zones instances can run in + // +optional AvailabilityZones []string `json:"availabilityZones,omitempty"` // Subnets is an array of subnet configurations @@ -59,10 +62,11 @@ type AWSMachinePoolSpec struct { AdditionalTags infrav1.Tags `json:"additionalTags,omitempty"` // AWSLaunchTemplate specifies the launch template and version to use when an instance is launched. - // +kubebuilder:validation:Required + // +required AWSLaunchTemplate AWSLaunchTemplate `json:"awsLaunchTemplate"` // MixedInstancesPolicy describes how multiple instance types will be used by the ASG. + // +optional MixedInstancesPolicy *MixedInstancesPolicy `json:"mixedInstancesPolicy,omitempty"` // ProviderIDList are the identification IDs of machine instances provided by the provider. @@ -123,6 +127,7 @@ type AWSMachinePoolStatus struct { Instances []AWSMachinePoolInstanceStatus `json:"instances,omitempty"` // The ID of the launch template + // +optional LaunchTemplateID string `json:"launchTemplateID,omitempty"` // The version of the launch template @@ -167,6 +172,7 @@ type AWSMachinePoolStatus struct { // +optional FailureMessage *string `json:"failureMessage,omitempty"` + // +optional ASGStatus *ASGStatus `json:"asgStatus,omitempty"` } @@ -194,9 +200,12 @@ type AWSMachinePoolInstanceStatus struct { // AWSMachinePool is the Schema for the awsmachinepools API. type AWSMachinePool struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSMachinePoolSpec `json:"spec,omitempty"` + // +optional Status AWSMachinePoolStatus `json:"status,omitempty"` } @@ -206,7 +215,9 @@ type AWSMachinePool struct { // AWSMachinePoolList contains a list of AWSMachinePool. type AWSMachinePoolList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSMachinePool `json:"items"` } diff --git a/exp/api/v1beta1/awsmanagedmachinepool_types.go b/exp/api/v1beta1/awsmanagedmachinepool_types.go index 08fdd1d0c9..1d3199a19c 100644 --- a/exp/api/v1beta1/awsmanagedmachinepool_types.go +++ b/exp/api/v1beta1/awsmanagedmachinepool_types.go @@ -67,6 +67,7 @@ type AWSManagedMachinePoolSpec struct { EKSNodegroupName string `json:"eksNodegroupName,omitempty"` // AvailabilityZones is an array of availability zones instances can run in + // +optional AvailabilityZones []string `json:"availabilityZones,omitempty"` // SubnetIDs specifies which subnets are used for the @@ -155,7 +156,9 @@ type AWSManagedMachinePoolSpec struct { // ManagedMachinePoolScaling specifies scaling options. type ManagedMachinePoolScaling struct { + // +optional MinSize *int32 `json:"minSize,omitempty"` + // +optional MaxSize *int32 `json:"maxSize,omitempty"` } @@ -163,12 +166,15 @@ type ManagedMachinePoolScaling struct { type ManagedRemoteAccess struct { // SSHKeyName specifies which EC2 SSH key can be used to access machines. // If left empty, the key from the control plane is used. + // +optional SSHKeyName *string `json:"sshKeyName,omitempty"` // SourceSecurityGroups specifies which security groups are allowed access + // +optional SourceSecurityGroups []string `json:"sourceSecurityGroups,omitempty"` // Public specifies whether to open port 22 to the public internet + // +optional Public bool `json:"public,omitempty"` } @@ -177,6 +183,7 @@ type AWSManagedMachinePoolStatus struct { // Ready denotes that the AWSManagedMachinePool nodegroup has joined // the cluster // +kubebuilder:default=false + // +required Ready bool `json:"ready"` // Replicas is the most recently observed number of replicas. @@ -244,9 +251,12 @@ type AWSManagedMachinePoolStatus struct { // AWSManagedMachinePool is the Schema for the awsmanagedmachinepools API. type AWSManagedMachinePool struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSManagedMachinePoolSpec `json:"spec,omitempty"` + // +optional Status AWSManagedMachinePoolStatus `json:"status,omitempty"` } @@ -266,7 +276,9 @@ func (r *AWSManagedMachinePool) SetConditions(conditions clusterv1beta1.Conditio // AWSManagedMachinePoolList contains a list of AWSManagedMachinePools. type AWSManagedMachinePoolList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSManagedMachinePool `json:"items"` } diff --git a/exp/api/v1beta1/types.go b/exp/api/v1beta1/types.go index f0886db879..867018ebe0 100644 --- a/exp/api/v1beta1/types.go +++ b/exp/api/v1beta1/types.go @@ -52,7 +52,7 @@ type EBS struct { // You can specify virtual devices and EBS volumes. type BlockDeviceMapping struct { // The device name exposed to the EC2 instance (for example, /dev/sdh or xvdh). - // +kubebuilder:validation:Required + // +required DeviceName string `json:"deviceName,omitempty"` // You can specify either VirtualName or Ebs, but not both. @@ -63,11 +63,13 @@ type BlockDeviceMapping struct { // AWSLaunchTemplate defines the desired state of AWSLaunchTemplate. type AWSLaunchTemplate struct { // The name of the launch template. + // +optional Name string `json:"name,omitempty"` // The name or the Amazon Resource Name (ARN) of the instance profile associated // with the IAM role for the instance. The instance profile contains the IAM // role. + // +optional IamInstanceProfile string `json:"iamInstanceProfile,omitempty"` // AMI is the reference to the AMI from which to create the machine instance. @@ -89,13 +91,16 @@ type AWSLaunchTemplate struct { ImageLookupFormat string `json:"imageLookupFormat,omitempty"` // ImageLookupOrg is the AWS Organization ID to use for image lookup if AMI is not set. + // +optional ImageLookupOrg string `json:"imageLookupOrg,omitempty"` // ImageLookupBaseOS is the name of the base operating system to use for // image lookup the AMI is not set. + // +optional ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"` // InstanceType is the type of instance to create. Example: m4.xlarge + // +optional InstanceType string `json:"instanceType,omitempty"` // RootVolume encapsulates the configuration options for the root volume @@ -112,6 +117,7 @@ type AWSLaunchTemplate struct { // 1) A new launch template spec is applied. // 2) One or more parameters in an existing template is changed. // 3) A new AMI is discovered. + // +optional VersionNumber *int64 `json:"versionNumber,omitempty"` // AdditionalSecurityGroups is an array of references to security groups that should be applied to the @@ -121,12 +127,14 @@ type AWSLaunchTemplate struct { AdditionalSecurityGroups []infrav1.AWSResourceReference `json:"additionalSecurityGroups,omitempty"` // SpotMarketOptions are options for configuring AWSMachinePool instances to be run using AWS Spot instances. + // +optional SpotMarketOptions *infrav1.SpotMarketOptions `json:"spotMarketOptions,omitempty"` } // Overrides are used to override the instance type specified by the launch template with multiple // instance types that can be used to launch On-Demand Instances and Spot Instances. type Overrides struct { + // +required InstanceType string `json:"instanceType"` } @@ -157,22 +165,28 @@ var ( type InstancesDistribution struct { // +kubebuilder:validation:Enum=prioritized // +kubebuilder:default=prioritized + // +optional OnDemandAllocationStrategy OnDemandAllocationStrategy `json:"onDemandAllocationStrategy,omitempty"` // +kubebuilder:validation:Enum=lowest-price;capacity-optimized // +kubebuilder:default=lowest-price + // +optional SpotAllocationStrategy SpotAllocationStrategy `json:"spotAllocationStrategy,omitempty"` // +kubebuilder:default=0 + // +optional OnDemandBaseCapacity *int64 `json:"onDemandBaseCapacity,omitempty"` // +kubebuilder:default=100 + // +optional OnDemandPercentageAboveBaseCapacity *int64 `json:"onDemandPercentageAboveBaseCapacity,omitempty"` } // MixedInstancesPolicy for an Auto Scaling group. type MixedInstancesPolicy struct { + // +optional InstancesDistribution *InstancesDistribution `json:"instancesDistribution,omitempty"` + // +optional Overrides []Overrides `json:"overrides,omitempty"` } @@ -182,19 +196,32 @@ type Tags map[string]string // AutoScalingGroup describes an AWS autoscaling group. type AutoScalingGroup struct { // The tags associated with the instance. + // +optional ID string `json:"id,omitempty"` + // +optional Tags infrav1.Tags `json:"tags,omitempty"` + // +optional Name string `json:"name,omitempty"` + // +optional DesiredCapacity *int32 `json:"desiredCapacity,omitempty"` + // +optional MaxSize int32 `json:"maxSize,omitempty"` + // +optional MinSize int32 `json:"minSize,omitempty"` + // +optional PlacementGroup string `json:"placementGroup,omitempty"` + // +optional Subnets []string `json:"subnets,omitempty"` + // +optional DefaultCoolDown metav1.Duration `json:"defaultCoolDown,omitempty"` + // +optional CapacityRebalance bool `json:"capacityRebalance,omitempty"` + // +optional MixedInstancesPolicy *MixedInstancesPolicy `json:"mixedInstancesPolicy,omitempty"` + // +optional Status ASGStatus + // +optional Instances []infrav1.Instance `json:"instances,omitempty"` } @@ -225,14 +252,14 @@ var ( // Taint defines the specs for a Kubernetes taint. type Taint struct { // Effect specifies the effect for the taint - // +kubebuilder:validation:Required + // +required // +kubebuilder:validation:Enum=no-schedule;no-execute;prefer-no-schedule Effect TaintEffect `json:"effect"` // Key is the key of the taint - // +kubebuilder:validation:Required + // +required Key string `json:"key"` // Value is the value of the taint - // +kubebuilder:validation:Required + // +required Value string `json:"value"` } diff --git a/exp/api/v1beta2/awsfargateprofile_types.go b/exp/api/v1beta2/awsfargateprofile_types.go index 453fd4b724..e71c57ac36 100644 --- a/exp/api/v1beta2/awsfargateprofile_types.go +++ b/exp/api/v1beta2/awsfargateprofile_types.go @@ -37,9 +37,11 @@ var ( type FargateProfileSpec struct { // ClusterName is the name of the Cluster this object belongs to. // +kubebuilder:validation:MinLength=1 + // +required ClusterName string `json:"clusterName"` // ProfileName specifies the profile name. + // +optional ProfileName string `json:"profileName,omitempty"` // SubnetIDs specifies which subnets are used for the @@ -84,15 +86,18 @@ type FargateProfileSpec struct { RolePermissionsBoundary string `json:"rolePermissionsBoundary,omitempty"` // Selectors specify fargate pod selectors. + // +optional Selectors []FargateSelector `json:"selectors,omitempty"` } // FargateSelector specifies a selector for pods that should run on this fargate pool. type FargateSelector struct { // Labels specifies which pod labels this selector should match. + // +optional Labels map[string]string `json:"labels,omitempty"` // Namespace specifies which namespace this selector should match. + // +optional Namespace string `json:"namespace,omitempty"` } @@ -100,6 +105,7 @@ type FargateSelector struct { type FargateProfileStatus struct { // Ready denotes that the FargateProfile is available. // +kubebuilder:default=false + // +required Ready bool `json:"ready"` // FailureReason will be set in the event that there is a terminal problem @@ -156,9 +162,12 @@ type FargateProfileStatus struct { // AWSFargateProfile is the Schema for the awsfargateprofiles API. type AWSFargateProfile struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec FargateProfileSpec `json:"spec,omitempty"` + // +optional Status FargateProfileStatus `json:"status,omitempty"` } @@ -177,7 +186,9 @@ func (r *AWSFargateProfile) SetConditions(conditions clusterv1beta1.Conditions) // AWSFargateProfileList contains a list of FargateProfiles. type AWSFargateProfileList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSFargateProfile `json:"items"` } diff --git a/exp/api/v1beta2/awsmachinepool_types.go b/exp/api/v1beta2/awsmachinepool_types.go index a5eb28ee20..6ef55d3819 100644 --- a/exp/api/v1beta2/awsmachinepool_types.go +++ b/exp/api/v1beta2/awsmachinepool_types.go @@ -41,14 +41,17 @@ type AWSMachinePoolSpec struct { // MinSize defines the minimum size of the group. // +kubebuilder:default=1 // +kubebuilder:validation:Minimum=0 + // +required MinSize int32 `json:"minSize"` // MaxSize defines the maximum size of the group. // +kubebuilder:default=1 // +kubebuilder:validation:Minimum=1 + // +required MaxSize int32 `json:"maxSize"` // AvailabilityZones is an array of availability zones instances can run in + // +optional AvailabilityZones []string `json:"availabilityZones,omitempty"` // AvailabilityZoneSubnetType specifies which type of subnets to use when an availability zone is specified. @@ -66,10 +69,11 @@ type AWSMachinePoolSpec struct { AdditionalTags infrav1.Tags `json:"additionalTags,omitempty"` // AWSLaunchTemplate specifies the launch template and version to use when an instance is launched. - // +kubebuilder:validation:Required + // +required AWSLaunchTemplate AWSLaunchTemplate `json:"awsLaunchTemplate"` // MixedInstancesPolicy describes how multiple instance types will be used by the ASG. + // +optional MixedInstancesPolicy *MixedInstancesPolicy `json:"mixedInstancesPolicy,omitempty"` // ProviderIDList are the identification IDs of machine instances provided by the provider. @@ -99,6 +103,7 @@ type AWSMachinePoolSpec struct { // SuspendProcesses defines a list of processes to suspend for the given ASG. This is constantly reconciled. // If a process is removed from this list it will automatically be resumed. + // +optional SuspendProcesses *SuspendProcessesTypes `json:"suspendProcesses,omitempty"` // Ignition defined options related to the bootstrapping systems where Ignition is used. @@ -112,20 +117,31 @@ type AWSMachinePoolSpec struct { // SuspendProcessesTypes contains user friendly auto-completable values for suspended process names. type SuspendProcessesTypes struct { + // +optional All bool `json:"all,omitempty"` + // +optional Processes *Processes `json:"processes,omitempty"` } // Processes defines the processes which can be enabled or disabled individually. type Processes struct { + // +optional Launch *bool `json:"launch,omitempty"` + // +optional Terminate *bool `json:"terminate,omitempty"` + // +optional AddToLoadBalancer *bool `json:"addToLoadBalancer,omitempty"` + // +optional AlarmNotification *bool `json:"alarmNotification,omitempty"` + // +optional AZRebalance *bool `json:"azRebalance,omitempty"` + // +optional HealthCheck *bool `json:"healthCheck,omitempty"` + // +optional InstanceRefresh *bool `json:"instanceRefresh,omitempty"` + // +optional ReplaceUnhealthy *bool `json:"replaceUnhealthy,omitempty"` + // +optional ScheduledActions *bool `json:"scheduledActions,omitempty"` } @@ -211,6 +227,7 @@ type AWSMachinePoolStatus struct { Instances []AWSMachinePoolInstanceStatus `json:"instances,omitempty"` // The ID of the launch template + // +optional LaunchTemplateID string `json:"launchTemplateID,omitempty"` // The version of the launch template @@ -259,6 +276,7 @@ type AWSMachinePoolStatus struct { // +optional FailureMessage *string `json:"failureMessage,omitempty"` + // +optional ASGStatus *ASGStatus `json:"asgStatus,omitempty"` } @@ -286,9 +304,12 @@ type AWSMachinePoolInstanceStatus struct { // AWSMachinePool is the Schema for the awsmachinepools API. type AWSMachinePool struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSMachinePoolSpec `json:"spec,omitempty"` + // +optional Status AWSMachinePoolStatus `json:"status,omitempty"` } @@ -297,7 +318,9 @@ type AWSMachinePool struct { // AWSMachinePoolList contains a list of AWSMachinePool. type AWSMachinePoolList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSMachinePool `json:"items"` } diff --git a/exp/api/v1beta2/awsmanagedmachinepool_types.go b/exp/api/v1beta2/awsmanagedmachinepool_types.go index 8e761a506f..a8c4263f99 100644 --- a/exp/api/v1beta2/awsmanagedmachinepool_types.go +++ b/exp/api/v1beta2/awsmanagedmachinepool_types.go @@ -99,6 +99,7 @@ type AWSManagedMachinePoolSpec struct { EKSNodegroupName string `json:"eksNodegroupName,omitempty"` // AvailabilityZones is an array of availability zones instances can run in + // +optional AvailabilityZones []string `json:"availabilityZones,omitempty"` // AvailabilityZoneSubnetType specifies which type of subnets to use when an availability zone is specified. @@ -135,6 +136,7 @@ type AWSManagedMachinePoolSpec struct { // // This parameter is optional. If it is not included, it defaults to a slash // (/). + // +optional RolePath string `json:"rolePath,omitempty"` // RolePermissionsBoundary sets the ARN of the managed policy that is used @@ -149,6 +151,7 @@ type AWSManagedMachinePoolSpec struct { // // For more information about policy types, see Policy types (https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#access_policy-types) // in the IAM User Guide. + // +optional RolePermissionsBoundary string `json:"rolePermissionsBoundary,omitempty"` // AMIVersion defines the desired AMI release version. If no version number @@ -222,7 +225,9 @@ type AWSManagedMachinePoolSpec struct { // ManagedMachinePoolScaling specifies scaling options. type ManagedMachinePoolScaling struct { + // +optional MinSize *int32 `json:"minSize,omitempty"` + // +optional MaxSize *int32 `json:"maxSize,omitempty"` } @@ -230,12 +235,15 @@ type ManagedMachinePoolScaling struct { type ManagedRemoteAccess struct { // SSHKeyName specifies which EC2 SSH key can be used to access machines. // If left empty, the key from the control plane is used. + // +optional SSHKeyName *string `json:"sshKeyName,omitempty"` // SourceSecurityGroups specifies which security groups are allowed access + // +optional SourceSecurityGroups []string `json:"sourceSecurityGroups,omitempty"` // Public specifies whether to open port 22 to the public internet + // +optional Public bool `json:"public,omitempty"` } @@ -244,6 +252,7 @@ type AWSManagedMachinePoolStatus struct { // Ready denotes that the AWSManagedMachinePool nodegroup has joined // the cluster // +kubebuilder:default=false + // +required Ready bool `json:"ready"` // Replicas is the most recently observed number of replicas. @@ -320,9 +329,12 @@ type NodeRepairConfig struct { // AWSManagedMachinePool is the Schema for the awsmanagedmachinepools API. type AWSManagedMachinePool struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec AWSManagedMachinePoolSpec `json:"spec,omitempty"` + // +optional Status AWSManagedMachinePoolStatus `json:"status,omitempty"` } @@ -341,7 +353,9 @@ func (r *AWSManagedMachinePool) SetConditions(conditions clusterv1beta1.Conditio // AWSManagedMachinePoolList contains a list of AWSManagedMachinePools. type AWSManagedMachinePoolList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []AWSManagedMachinePool `json:"items"` } diff --git a/exp/api/v1beta2/rosacluster_types.go b/exp/api/v1beta2/rosacluster_types.go index 2b24e5f0e2..4e6243c09a 100644 --- a/exp/api/v1beta2/rosacluster_types.go +++ b/exp/api/v1beta2/rosacluster_types.go @@ -55,9 +55,12 @@ type ROSAClusterStatus struct { // ROSACluster is the Schema for the ROSAClusters API. type ROSACluster struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec ROSAClusterSpec `json:"spec,omitempty"` + // +optional Status ROSAClusterStatus `json:"status,omitempty"` } @@ -66,7 +69,9 @@ type ROSACluster struct { // ROSAClusterList contains a list of ROSACluster. type ROSAClusterList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []ROSACluster `json:"items"` } diff --git a/exp/api/v1beta2/rosamachinepool_types.go b/exp/api/v1beta2/rosamachinepool_types.go index 9c379586c6..f58503b70f 100644 --- a/exp/api/v1beta2/rosamachinepool_types.go +++ b/exp/api/v1beta2/rosamachinepool_types.go @@ -35,6 +35,7 @@ type RosaMachinePoolSpec struct { // +kubebuilder:validation:XValidation:rule="self == oldSelf", message="nodepoolName is immutable" // +kubebuilder:validation:MaxLength:=15 // +kubebuilder:validation:Pattern:=`^[a-z]([-a-z0-9]*[a-z0-9])?$` + // +required NodePoolName string `json:"nodePoolName"` // Version specifies the OpenShift version of the nodes associated with this machinepool. @@ -74,7 +75,7 @@ type RosaMachinePoolSpec struct { // InstanceType specifies the AWS instance type // - // +kubebuilder:validation:Required + // +required InstanceType string `json:"instanceType"` // Autoscaling specifies auto scaling behaviour for this MachinePool. @@ -131,7 +132,7 @@ type RosaMachinePoolSpec struct { type RosaTaint struct { // The taint key to be applied to a node. // - // +kubebuilder:validation:Required + // +required Key string `json:"key"` // The taint value corresponding to the taint key. // @@ -141,7 +142,7 @@ type RosaTaint struct { // The effect of the taint on pods that do not tolerate the taint. // Valid effects are NoSchedule, PreferNoSchedule and NoExecute. // - // +kubebuilder:validation:Required + // +required // +kubebuilder:validation:Enum=NoSchedule;PreferNoSchedule;NoExecute Effect corev1.TaintEffect `json:"effect"` } @@ -200,6 +201,7 @@ type RosaMachinePoolStatus struct { // Ready denotes that the RosaMachinePool nodepool has joined // the cluster // +kubebuilder:default=false + // +required Ready bool `json:"ready"` // Replicas is the most recently observed number of replicas. // +optional @@ -220,9 +222,11 @@ type RosaMachinePoolStatus struct { FailureMessage *string `json:"failureMessage,omitempty"` // ID is the ID given by ROSA. + // +optional ID string `json:"id,omitempty"` // Available upgrades for the ROSA MachinePool. + // +optional AvailableUpgrades []string `json:"availableUpgrades,omitempty"` } @@ -236,9 +240,12 @@ type RosaMachinePoolStatus struct { // ROSAMachinePool is the Schema for the rosamachinepools API. type ROSAMachinePool struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional Spec RosaMachinePoolSpec `json:"spec,omitempty"` + // +optional Status RosaMachinePoolStatus `json:"status,omitempty"` } @@ -247,7 +254,9 @@ type ROSAMachinePool struct { // ROSAMachinePoolList contains a list of RosaMachinePools. type ROSAMachinePoolList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` + // +required Items []ROSAMachinePool `json:"items"` } diff --git a/exp/api/v1beta2/rosanetwork_types.go b/exp/api/v1beta2/rosanetwork_types.go index 0cb9922530..e67420d88c 100644 --- a/exp/api/v1beta2/rosanetwork_types.go +++ b/exp/api/v1beta2/rosanetwork_types.go @@ -30,12 +30,12 @@ const ROSANetworkFinalizer = "rosanetwork.infrastructure.cluster.x-k8s.io" type ROSANetworkSpec struct { // The name of the cloudformation stack under which the network infrastructure would be created // +kubebuilder:validation:XValidation:rule="self == oldSelf", message="stackName is immutable" - // +kubebuilder:validation:Required + // +required StackName string `json:"stackName"` // The AWS region in which the components of ROSA network infrastruture are to be crated // +kubebuilder:validation:XValidation:rule="self == oldSelf", message="region is immutable" - // +kubebuilder:validation:Required + // +required Region string `json:"region"` // The number of availability zones to be used for creation of the network infrastructure. @@ -55,7 +55,7 @@ type ROSANetworkSpec struct { // CIDR block to be used for the VPC // +kubebuilder:validation:Format=cidr - // +kubebuilder:validation:Required + // +required CIDRBlock string `json:"cidrBlock"` // IdentityRef is a reference to an identity to be used when reconciling rosa network. @@ -72,43 +72,54 @@ type ROSANetworkSpec struct { // ROSANetworkSubnet groups public and private subnet and the availability zone in which the two subnets got created type ROSANetworkSubnet struct { // Availability zone of the subnet pair, for example us-west-2a + // +required AvailabilityZone string `json:"availabilityZone"` // ID of the public subnet, for example subnet-0f7e49a3ce68ff338 + // +required PublicSubnet string `json:"publicSubnet"` // ID of the private subnet, for example subnet-07a20d6c41af2b725 + // +required PrivateSubnet string `json:"privateSubnet"` } // CFResource groups information pertaining to a resource created as a part of a cloudformation stack type CFResource struct { // Type of the created resource: AWS::EC2::VPC, AWS::EC2::Subnet, ... + // +required ResourceType string `json:"resource"` // LogicalResourceID of the created resource. + // +required LogicalID string `json:"logicalId"` // PhysicalResourceID of the created resource. + // +required PhysicalID string `json:"physicalId"` // Status of the resource: CREATE_IN_PROGRESS, CREATE_COMPLETE, ... + // +required Status string `json:"status"` // Message pertaining to the status of the resource + // +required Reason string `json:"reason"` } // ROSANetworkStatus defines the observed state of ROSANetwork type ROSANetworkStatus struct { // Array of created private, public subnets and availability zones, grouped by availability zones + // +optional Subnets []ROSANetworkSubnet `json:"subnets,omitempty"` // Resources created in the cloudformation stack + // +optional Resources []CFResource `json:"resources,omitempty"` // Conditions specifies the conditions for ROSANetwork - Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"` + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // +kubebuilder:object:root=true @@ -118,10 +129,13 @@ type ROSANetworkStatus struct { // ROSANetwork is the schema for the rosanetworks API type ROSANetwork struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec ROSANetworkSpec `json:"spec,omitempty"` + // +optional + Spec ROSANetworkSpec `json:"spec,omitempty"` + // +optional Status ROSANetworkStatus `json:"status,omitempty"` } @@ -130,8 +144,10 @@ type ROSANetwork struct { // ROSANetworkList contains a list of ROSANetwork type ROSANetworkList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []ROSANetwork `json:"items"` + // +required + Items []ROSANetwork `json:"items"` } // GetConditions returns the observations of the operational state of the ROSANetwork resource. diff --git a/exp/api/v1beta2/rosaroleconfig_types.go b/exp/api/v1beta2/rosaroleconfig_types.go index 41e0c21add..b4516b9b4b 100644 --- a/exp/api/v1beta2/rosaroleconfig_types.go +++ b/exp/api/v1beta2/rosaroleconfig_types.go @@ -95,9 +95,11 @@ const ( // ROSARoleConfigSpec defines the desired state of ROSARoleConfig type ROSARoleConfigSpec struct { // AccountRoleConfig defines account-wide IAM roles before creating your ROSA cluster. + // +required AccountRoleConfig AccountRoleConfig `json:"accountRoleConfig"` // OperatorRoleConfig defines cluster-specific operator IAM roles based on your cluster configuration. + // +required OperatorRoleConfig OperatorRoleConfig `json:"operatorRoleConfig"` // IdentityRef is a reference to an identity to be used when reconciling the ROSA Role Config. @@ -112,13 +114,14 @@ type ROSARoleConfigSpec struct { // OIDC provider type values are Managed or UnManaged. When set to Unmanged OperatorRoleConfig OIDCID field must be provided. // +kubebuilder:validation:Enum=Managed;Unmanaged // +kubebuilder:default=Managed + // +required OidcProviderType OidcProviderType `json:"oidcProviderType"` } // AccountRoleConfig defines account IAM roles before creating your ROSA cluster. type AccountRoleConfig struct { // User-defined prefix for all generated AWS account role - // +kubebuilder:validation:Required + // +required // +kubebuilder:validation:MaxLength:=4 // +kubebuilder:validation:Pattern:=`^[a-z]([-a-z0-9]*[a-z0-9])?$` // +kubebuilder:validation:XValidation:rule="self == oldSelf", message="prefix is immutable" @@ -134,7 +137,7 @@ type AccountRoleConfig struct { // Version of OpenShift that will be used to the roles tag in formate of x.y.z example; "4.19.0" // Setting the role OpenShift version tag does not affect the associated ROSAControlplane version. - // +kubebuilder:validation:Required + // +required // +kubebuilder:validation:XValidation:rule="self == oldSelf", message="version is immutable" Version string `json:"version"` @@ -146,7 +149,7 @@ type AccountRoleConfig struct { // OperatorRoleConfig defines cluster-specific operator IAM roles based on your cluster configuration. type OperatorRoleConfig struct { // User-defined prefix for generated AWS operator roles. - // +kubebuilder:validation:Required + // +required // +kubebuilder:validation:MaxLength:=4 // +kubebuilder:validation:Pattern:=`^[a-z]([-a-z0-9]*[a-z0-9])?$` // +kubebuilder:validation:XValidation:rule="self == oldSelf", message="prefix is immutable" @@ -170,40 +173,50 @@ type OperatorRoleConfig struct { // SharedVPCConfig is used to set up shared VPC. type SharedVPCConfig struct { // Role ARN associated with the private hosted zone used for Hosted Control Plane cluster shared VPC, this role contains policies to be used with Route 53 + // +optional RouteRoleARN string `json:"routeRoleARN,omitempty"` // Role ARN associated with the shared VPC used for Hosted Control Plane clusters, this role contains policies to be used with the VPC endpoint + // +optional VPCEndpointRoleARN string `json:"vpcEndpointRoleArn,omitempty"` } // ROSARoleConfigStatus defines the observed state of ROSARoleConfig type ROSARoleConfigStatus struct { // ID of created OIDC config + // +optional OIDCID string `json:"oidcID,omitempty"` // Create OIDC provider for operators to authenticate against in an STS cluster. + // +optional OIDCProviderARN string `json:"oidcProviderARN,omitempty"` // Created Account roles that can be used to + // +optional AccountRolesRef AccountRolesRef `json:"accountRolesRef,omitempty"` // AWS IAM roles used to perform credential requests by the openshift operators. + // +optional OperatorRolesRef rosacontrolplanev1.AWSRolesRef `json:"operatorRolesRef,omitempty"` // Conditions specifies the ROSARoleConfig conditions - Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"` + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // AccountRolesRef defscribes ARNs used as Account roles. type AccountRolesRef struct { // InstallerRoleARN is an AWS IAM role that OpenShift Cluster Manager will assume to create the cluster.. + // +optional InstallerRoleARN string `json:"installerRoleARN,omitempty"` // SupportRoleARN is an AWS IAM role used by Red Hat SREs to enable // access to the cluster account in order to provide support. + // +optional SupportRoleARN string `json:"supportRoleARN,omitempty"` // WorkerRoleARN is an AWS IAM role that will be attached to worker instances. + // +optional WorkerRoleARN string `json:"workerRoleARN,omitempty"` } @@ -213,10 +226,13 @@ type AccountRolesRef struct { // +kubebuilder:storageversion // +kubebuilder:subresource:status type ROSARoleConfig struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec ROSARoleConfigSpec `json:"spec,omitempty"` + // +optional + Spec ROSARoleConfigSpec `json:"spec,omitempty"` + // +optional Status ROSARoleConfigStatus `json:"status,omitempty"` } @@ -224,8 +240,10 @@ type ROSARoleConfig struct { // +kubebuilder:object:root=true type ROSARoleConfigList struct { metav1.TypeMeta `json:",inline"` + // +optional metav1.ListMeta `json:"metadata,omitempty"` - Items []ROSARoleConfig `json:"items"` + // +required + Items []ROSARoleConfig `json:"items"` } // SetConditions sets the conditions of the ROSARoleConfig. diff --git a/exp/api/v1beta2/types.go b/exp/api/v1beta2/types.go index b4eca931a8..1917739b1a 100644 --- a/exp/api/v1beta2/types.go +++ b/exp/api/v1beta2/types.go @@ -51,7 +51,7 @@ type EBS struct { // You can specify virtual devices and EBS volumes. type BlockDeviceMapping struct { // The device name exposed to the EC2 instance (for example, /dev/sdh or xvdh). - // +kubebuilder:validation:Required + // +required DeviceName string `json:"deviceName,omitempty"` // You can specify either VirtualName or Ebs, but not both. @@ -62,11 +62,13 @@ type BlockDeviceMapping struct { // AWSLaunchTemplate defines the desired state of AWSLaunchTemplate. type AWSLaunchTemplate struct { // The name of the launch template. + // +optional Name string `json:"name,omitempty"` // The name or the Amazon Resource Name (ARN) of the instance profile associated // with the IAM role for the instance. The instance profile contains the IAM // role. + // +optional IamInstanceProfile string `json:"iamInstanceProfile,omitempty"` // AMI is the reference to the AMI from which to create the machine instance. @@ -88,13 +90,16 @@ type AWSLaunchTemplate struct { ImageLookupFormat string `json:"imageLookupFormat,omitempty"` // ImageLookupOrg is the AWS Organization ID to use for image lookup if AMI is not set. + // +optional ImageLookupOrg string `json:"imageLookupOrg,omitempty"` // ImageLookupBaseOS is the name of the base operating system to use for // image lookup the AMI is not set. + // +optional ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"` // InstanceType is the type of instance to create. Example: m4.xlarge + // +optional InstanceType string `json:"instanceType,omitempty"` // RootVolume encapsulates the configuration options for the root volume @@ -115,6 +120,7 @@ type AWSLaunchTemplate struct { // 1) A new launch template spec is applied. // 2) One or more parameters in an existing template is changed. // 3) A new AMI is discovered. + // +optional VersionNumber *int64 `json:"versionNumber,omitempty"` // AdditionalSecurityGroups is an array of references to security groups that should be applied to the @@ -124,6 +130,7 @@ type AWSLaunchTemplate struct { AdditionalSecurityGroups []infrav1.AWSResourceReference `json:"additionalSecurityGroups,omitempty"` // SpotMarketOptions are options for configuring AWSMachinePool instances to be run using AWS Spot instances. + // +optional SpotMarketOptions *infrav1.SpotMarketOptions `json:"spotMarketOptions,omitempty"` // InstanceMetadataOptions defines the behavior for applying metadata to instances. @@ -159,6 +166,7 @@ type AWSLaunchTemplate struct { // Overrides are used to override the instance type specified by the launch template with multiple // instance types that can be used to launch On-Demand Instances and Spot Instances. type Overrides struct { + // +required InstanceType string `json:"instanceType"` } @@ -204,22 +212,28 @@ var ( type InstancesDistribution struct { // +kubebuilder:validation:Enum=prioritized;lowest-price // +kubebuilder:default=prioritized + // +optional OnDemandAllocationStrategy OnDemandAllocationStrategy `json:"onDemandAllocationStrategy,omitempty"` // +kubebuilder:validation:Enum=lowest-price;capacity-optimized;capacity-optimized-prioritized;price-capacity-optimized // +kubebuilder:default=lowest-price + // +optional SpotAllocationStrategy SpotAllocationStrategy `json:"spotAllocationStrategy,omitempty"` // +kubebuilder:default=0 + // +optional OnDemandBaseCapacity *int64 `json:"onDemandBaseCapacity,omitempty"` // +kubebuilder:default=100 + // +optional OnDemandPercentageAboveBaseCapacity *int64 `json:"onDemandPercentageAboveBaseCapacity,omitempty"` } // MixedInstancesPolicy for an Auto Scaling group. type MixedInstancesPolicy struct { + // +optional InstancesDistribution *InstancesDistribution `json:"instancesDistribution,omitempty"` + // +optional Overrides []Overrides `json:"overrides,omitempty"` } @@ -229,27 +243,43 @@ type Tags map[string]string // AutoScalingGroup describes an AWS autoscaling group. type AutoScalingGroup struct { // The tags associated with the instance. + // +optional ID string `json:"id,omitempty"` + // +optional Tags infrav1.Tags `json:"tags,omitempty"` + // +optional Name string `json:"name,omitempty"` + // +optional DesiredCapacity *int32 `json:"desiredCapacity,omitempty"` + // +optional MaxSize int32 `json:"maxSize,omitempty"` + // +optional MinSize int32 `json:"minSize,omitempty"` + // +optional PlacementGroup string `json:"placementGroup,omitempty"` + // +optional Subnets []string `json:"subnets,omitempty"` + // +optional DefaultCoolDown metav1.Duration `json:"defaultCoolDown,omitempty"` + // +optional DefaultInstanceWarmup metav1.Duration `json:"defaultInstanceWarmup,omitempty"` + // +optional CapacityRebalance bool `json:"capacityRebalance,omitempty"` + // +optional MixedInstancesPolicy *MixedInstancesPolicy `json:"mixedInstancesPolicy,omitempty"` + // +optional Status ASGStatus + // +optional Instances []infrav1.Instance `json:"instances,omitempty"` + // +optional CurrentlySuspendProcesses []string `json:"currentlySuspendProcesses,omitempty"` } // AWSLifecycleHook describes an AWS lifecycle hook type AWSLifecycleHook struct { // The name of the lifecycle hook. + // +required Name string `json:"name"` // The ARN of the notification target that Amazon EC2 Auto Scaling uses to @@ -264,6 +294,7 @@ type AWSLifecycleHook struct { // The state of the EC2 instance to which to attach the lifecycle hook. // +kubebuilder:validation:Enum="autoscaling:EC2_INSTANCE_LAUNCHING";"autoscaling:EC2_INSTANCE_TERMINATING" + // +required LifecycleTransition LifecycleTransition `json:"lifecycleTransition"` // The maximum time, in seconds, that an instance can remain in a Pending:Wait or @@ -337,14 +368,14 @@ var ( // Taint defines the specs for a Kubernetes taint. type Taint struct { // Effect specifies the effect for the taint - // +kubebuilder:validation:Required + // +required // +kubebuilder:validation:Enum=no-schedule;no-execute;prefer-no-schedule Effect TaintEffect `json:"effect"` // Key is the key of the taint - // +kubebuilder:validation:Required + // +required Key string `json:"key"` // Value is the value of the taint - // +kubebuilder:validation:Required + // +required Value string `json:"value"` } diff --git a/exp/controlleridentitycreator/awscontrolleridentity_controller.go b/exp/controlleridentitycreator/awscontrolleridentity_controller.go index 3a7784303f..49b78eb1f8 100644 --- a/exp/controlleridentitycreator/awscontrolleridentity_controller.go +++ b/exp/controlleridentitycreator/awscontrolleridentity_controller.go @@ -40,8 +40,11 @@ import ( // AWSControllerIdentityReconciler reconciles a AWSClusterControllerIdentity object. type AWSControllerIdentityReconciler struct { + // +optional client.Client + // +optional Log logr.Logger + // +optional WatchFilterValue string } diff --git a/exp/controllers/awsfargatepool_controller.go b/exp/controllers/awsfargatepool_controller.go index edda22d59c..3d93723246 100644 --- a/exp/controllers/awsfargatepool_controller.go +++ b/exp/controllers/awsfargatepool_controller.go @@ -43,9 +43,13 @@ import ( // AWSFargateProfileReconciler reconciles a AWSFargateProfile object. type AWSFargateProfileReconciler struct { + // +optional client.Client + // +optional Recorder record.EventRecorder + // +optional EnableIAM bool + // +optional WatchFilterValue string } diff --git a/exp/controllers/awsmachinepool_controller.go b/exp/controllers/awsmachinepool_controller.go index d803db7eb8..cc5ade1633 100644 --- a/exp/controllers/awsmachinepool_controller.go +++ b/exp/controllers/awsmachinepool_controller.go @@ -64,13 +64,21 @@ import ( // AWSMachinePoolReconciler reconciles a AWSMachinePool object. type AWSMachinePoolReconciler struct { + // +optional client.Client + // +optional Recorder record.EventRecorder + // +optional WatchFilterValue string + // +optional asgServiceFactory func(cloud.ClusterScoper) services.ASGInterface + // +optional ec2ServiceFactory func(scope.EC2Scope) services.EC2Interface + // +optional reconcileServiceFactory func(scope.EC2Scope) services.MachinePoolReconcileInterface + // +optional objectStoreServiceFactory func(scope.S3Scope) services.ObjectStoreInterface + // +optional TagUnmanagedNetworkResources bool } diff --git a/exp/controllers/awsmachinepool_controller_test.go b/exp/controllers/awsmachinepool_controller_test.go index 82ba81e8a9..2be1649d73 100644 --- a/exp/controllers/awsmachinepool_controller_test.go +++ b/exp/controllers/awsmachinepool_controller_test.go @@ -55,9 +55,9 @@ import ( "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/sts/mock_stsiface" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/userdata" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" - v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expclusterv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/cluster-api/util/labels/format" "sigs.k8s.io/cluster-api/util/patch" ) @@ -147,12 +147,10 @@ func TestAWSMachinePoolReconciler(t *testing.T) { Client: testEnv.Client, Cluster: &clusterv1.Cluster{ Status: clusterv1.ClusterStatus{ - Initialization: clusterv1.ClusterInitializationStatus{ - InfrastructureProvisioned: ptr.To(true), - }, + InfrastructureReady: true, }, }, - MachinePool: &clusterv1.MachinePool{ + MachinePool: &expclusterv1.MachinePool{ ObjectMeta: metav1.ObjectMeta{ Name: "mp", Namespace: "default", @@ -162,16 +160,11 @@ func TestAWSMachinePoolReconciler(t *testing.T) { APIVersion: "cluster.x-k8s.io/v1beta1", Kind: "MachinePool", }, - Spec: clusterv1.MachinePoolSpec{ + Spec: expclusterv1.MachinePoolSpec{ ClusterName: "test", Template: clusterv1.MachineTemplateSpec{ Spec: clusterv1.MachineSpec{ ClusterName: "test", - InfrastructureRef: clusterv1.ContractVersionedObjectReference{ - Name: "rosa-mp", - Kind: "ROSAMachinePool", - APIGroup: clusterv1.GroupVersion.Group, - }, Bootstrap: clusterv1.Bootstrap{ DataSecretName: ptr.To[string]("bootstrap-data"), }, @@ -270,7 +263,7 @@ func TestAWSMachinePoolReconciler(t *testing.T) { defer teardown(t, g) getASG(t, g) - ms.Cluster.Status.Initialization.InfrastructureProvisioned = ptr.To(false) + ms.Cluster.Status.InfrastructureReady = false buf := new(bytes.Buffer) klog.SetOutput(buf) @@ -278,7 +271,7 @@ func TestAWSMachinePoolReconciler(t *testing.T) { _, err := reconciler.reconcileNormal(context.Background(), ms, cs, cs, cs) g.Expect(err).To(BeNil()) g.Expect(buf.String()).To(ContainSubstring("Cluster infrastructure is not ready yet")) - expectConditions(g, ms.AWSMachinePool, []conditionAssertion{{expinfrav1.ASGReadyCondition, corev1.ConditionFalse, clusterv1beta1.ConditionSeverityInfo, infrav1.WaitingForClusterInfrastructureReason}}) + expectConditions(g, ms.AWSMachinePool, []conditionAssertion{{expinfrav1.ASGReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrav1.WaitingForClusterInfrastructureReason}}) }) t.Run("should exit immediately if bootstrap data secret reference isn't available", func(t *testing.T) { g := NewWithT(t) @@ -294,7 +287,7 @@ func TestAWSMachinePoolReconciler(t *testing.T) { g.Expect(err).To(BeNil()) g.Expect(buf.String()).To(ContainSubstring("Bootstrap data secret reference is not yet available")) - expectConditions(g, ms.AWSMachinePool, []conditionAssertion{{expinfrav1.ASGReadyCondition, corev1.ConditionFalse, clusterv1beta1.ConditionSeverityInfo, infrav1.WaitingForBootstrapDataReason}}) + expectConditions(g, ms.AWSMachinePool, []conditionAssertion{{expinfrav1.ASGReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrav1.WaitingForBootstrapDataReason}}) }) }) t.Run("there's a provider ID", func(t *testing.T) { @@ -425,18 +418,6 @@ func TestAWSMachinePoolReconciler(t *testing.T) { }, Spec: clusterv1.MachineSpec{ ClusterName: "test", - InfrastructureRef: clusterv1.ContractVersionedObjectReference{ - Name: "name-1", - Kind: "ROSAMachine", - APIGroup: clusterv1.GroupVersion.Group, - }, - Bootstrap: clusterv1.Bootstrap{ - ConfigRef: clusterv1.ContractVersionedObjectReference{ - Name: "name-1-config", - Kind: "EKSConfig", - APIGroup: clusterv1.GroupVersion.Group, - }, - }, }, })).To(Succeed()) g.Expect(testEnv.Create(context.Background(), &infrav1.AWSMachine{ @@ -469,18 +450,6 @@ func TestAWSMachinePoolReconciler(t *testing.T) { }, Spec: clusterv1.MachineSpec{ ClusterName: "test", - InfrastructureRef: clusterv1.ContractVersionedObjectReference{ - Name: "name-2", - Kind: "ROSAMachinePool", - APIGroup: clusterv1.GroupVersion.Group, - }, - Bootstrap: clusterv1.Bootstrap{ - ConfigRef: clusterv1.ContractVersionedObjectReference{ - Name: "name-2-config", - Kind: "EKSConfig", - APIGroup: clusterv1.GroupVersion.Group, - }, - }, }, })).To(Succeed()) g.Expect(testEnv.Create(context.Background(), &infrav1.AWSMachine{ @@ -1410,16 +1379,20 @@ func TestAWSMachinePoolReconciler(t *testing.T) { } type conditionAssertion struct { - conditionType clusterv1beta1.ConditionType + // +optional + conditionType clusterv1.ConditionType + // +optional status corev1.ConditionStatus - severity clusterv1beta1.ConditionSeverity + // +optional + severity clusterv1.ConditionSeverity + // +optional reason string } func expectConditions(g *WithT, m *expinfrav1.AWSMachinePool, expected []conditionAssertion) { g.Expect(len(m.Status.Conditions)).To(BeNumerically(">=", len(expected)), "number of conditions") for _, c := range expected { - actual := v1beta1conditions.Get(m, c.conditionType) + actual := conditions.Get(m, c.conditionType) g.Expect(actual).To(Not(BeNil())) g.Expect(actual.Type).To(Equal(c.conditionType)) g.Expect(actual.Status).To(Equal(c.status)) @@ -1459,8 +1432,8 @@ func TestDiffASG(t *testing.T) { name: "replicas != asg.desiredCapacity", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](0), }, }, @@ -1475,8 +1448,8 @@ func TestDiffASG(t *testing.T) { name: "replicas (nil) != asg.desiredCapacity", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: nil, }, }, @@ -1491,8 +1464,8 @@ func TestDiffASG(t *testing.T) { name: "replicas != asg.desiredCapacity (nil)", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](0), }, }, @@ -1507,8 +1480,8 @@ func TestDiffASG(t *testing.T) { name: "maxSize != asg.maxSize", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](1), }, }, @@ -1529,8 +1502,8 @@ func TestDiffASG(t *testing.T) { name: "minSize != asg.minSize", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](1), }, }, @@ -1553,8 +1526,8 @@ func TestDiffASG(t *testing.T) { name: "capacityRebalance != asg.capacityRebalance", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](1), }, }, @@ -1579,8 +1552,8 @@ func TestDiffASG(t *testing.T) { name: "MixedInstancesPolicy != asg.MixedInstancesPolicy", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](1), }, }, @@ -1613,8 +1586,8 @@ func TestDiffASG(t *testing.T) { name: "MixedInstancesPolicy.InstancesDistribution != asg.MixedInstancesPolicy.InstancesDistribution", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](1), }, }, @@ -1666,8 +1639,8 @@ func TestDiffASG(t *testing.T) { name: "MixedInstancesPolicy.InstancesDistribution unset", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](1), }, }, @@ -1713,8 +1686,8 @@ func TestDiffASG(t *testing.T) { name: "SuspendProcesses != asg.SuspendProcesses", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](1), }, }, @@ -1754,8 +1727,8 @@ func TestDiffASG(t *testing.T) { name: "all matches", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](1), }, }, @@ -1792,13 +1765,13 @@ func TestDiffASG(t *testing.T) { name: "externally managed annotation ignores difference between desiredCapacity and replicas", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ + MachinePool: &expclusterv1.MachinePool{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ clusterv1.ReplicasManagedByAnnotation: "", // empty value counts as true (= externally managed) }, }, - Spec: clusterv1.MachinePoolSpec{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](0), }, }, @@ -1816,8 +1789,8 @@ func TestDiffASG(t *testing.T) { name: "without externally managed annotation ignores difference between desiredCapacity and replicas", args: args{ machinePoolScope: &scope.MachinePoolScope{ - MachinePool: &clusterv1.MachinePool{ - Spec: clusterv1.MachinePoolSpec{ + MachinePool: &expclusterv1.MachinePool{ + Spec: expclusterv1.MachinePoolSpec{ Replicas: ptr.To[int32](0), }, }, diff --git a/exp/controllers/awsmanagedmachinepool_controller.go b/exp/controllers/awsmanagedmachinepool_controller.go index efd66cc5e0..eed8128509 100644 --- a/exp/controllers/awsmanagedmachinepool_controller.go +++ b/exp/controllers/awsmanagedmachinepool_controller.go @@ -53,12 +53,19 @@ import ( // AWSManagedMachinePoolReconciler reconciles a AWSManagedMachinePool object. type AWSManagedMachinePoolReconciler struct { + // +optional client.Client + // +optional Recorder record.EventRecorder + // +optional EnableIAM bool + // +optional AllowAdditionalRoles bool + // +optional WatchFilterValue string + // +optional TagUnmanagedNetworkResources bool + // +optional MaxWaitActiveUpdateDelete time.Duration } diff --git a/exp/controllers/rosamachinepool_controller.go b/exp/controllers/rosamachinepool_controller.go index 2666405de2..c3c44c918a 100644 --- a/exp/controllers/rosamachinepool_controller.go +++ b/exp/controllers/rosamachinepool_controller.go @@ -48,10 +48,15 @@ import ( // ROSAMachinePoolReconciler reconciles a ROSAMachinePool object. type ROSAMachinePoolReconciler struct { + // +optional client.Client + // +optional Recorder record.EventRecorder + // +optional WatchFilterValue string + // +optional NewStsClient func(cloud.ScopeUsage, cloud.Session, logger.Wrapper, runtime.Object) stsservice.STSClient + // +optional NewOCMClient func(ctx context.Context, rosaScope *scope.ROSAControlPlaneScope) (rosa.OCMClient, error) } diff --git a/exp/controllers/rosamachinepool_controller_test.go b/exp/controllers/rosamachinepool_controller_test.go index 5e20aa170f..65e2b0a933 100644 --- a/exp/controllers/rosamachinepool_controller_test.go +++ b/exp/controllers/rosamachinepool_controller_test.go @@ -738,6 +738,7 @@ func cleanupObject(g *WithT, obj client.Object) { } type replicasMatcher struct { + // +optional replicas int } diff --git a/exp/controllers/rosanetwork_controller.go b/exp/controllers/rosanetwork_controller.go index c84b360185..d4261669b2 100644 --- a/exp/controllers/rosanetwork_controller.go +++ b/exp/controllers/rosanetwork_controller.go @@ -50,11 +50,17 @@ import ( // ROSANetworkReconciler reconciles a ROSANetwork object. type ROSANetworkReconciler struct { + // +optional client.Client + // +optional Log logr.Logger + // +optional Scheme *runtime.Scheme + // +optional awsClient rosaAWSClient.Client + // +optional cfStack *cloudformationtypes.Stack + // +optional WatchFilterValue string } diff --git a/exp/controllers/rosaroleconfig_controller.go b/exp/controllers/rosaroleconfig_controller.go index 01ff345d4d..801c6b1d1d 100644 --- a/exp/controllers/rosaroleconfig_controller.go +++ b/exp/controllers/rosaroleconfig_controller.go @@ -58,11 +58,17 @@ import ( // ROSARoleConfigReconciler reconciles a ROSARoleConfig object. type ROSARoleConfigReconciler struct { + // +optional client.Client + // +optional Recorder record.EventRecorder + // +optional WatchFilterValue string + // +optional NewStsClient func(cloud.ScopeUsage, cloud.Session, logger.Wrapper, runtime.Object) stsiface.STSClient + // +optional NewOCMClient func(ctx context.Context, scope rosa.OCMSecretsRetriever) (rosa.OCMClient, error) + // +optional Runtime *rosacli.Runtime } diff --git a/exp/instancestate/awsinstancestate_controller.go b/exp/instancestate/awsinstancestate_controller.go index 3f8a09b925..171f426ff2 100644 --- a/exp/instancestate/awsinstancestate_controller.go +++ b/exp/instancestate/awsinstancestate_controller.go @@ -50,10 +50,15 @@ const Ec2InstanceStateLabelKey = "ec2-instance-state" // AwsInstanceStateReconciler reconciles a AwsInstanceState object. type AwsInstanceStateReconciler struct { + // +optional client.Client + // +optional Log logr.Logger + // +optional sqsServiceFactory func() instancestate.SQSAPI + // +optional queueURLs sync.Map + // +optional WatchFilterValue string } @@ -238,17 +243,24 @@ func queueNotFoundError(err error) bool { } type queueParams struct { + // +optional region string + // +optional URL string } type message struct { + // +required Source string `json:"source"` + // +optional DetailType string `json:"detail-type,omitempty"` + // +optional MessageDetail *messageDetail `json:"detail,omitempty"` } type messageDetail struct { + // +optional InstanceID string `json:"instance-id,omitempty"` + // +optional State infrav1.InstanceState `json:"state,omitempty"` } diff --git a/iam/api/v1beta1/types.go b/iam/api/v1beta1/types.go index 527c857be9..700724fe73 100644 --- a/iam/api/v1beta1/types.go +++ b/iam/api/v1beta1/types.go @@ -83,19 +83,29 @@ const ( // PolicyDocument represents an AWS IAM policy document, and can be // converted into JSON using "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/converters". type PolicyDocument struct { + // +optional Version string `json:"Version,omitempty"` + // +optional Statement Statements `json:"Statement,omitempty"` + // +optional ID string `json:"Id,omitempty"` } // StatementEntry represents each "statement" block in an AWS IAM policy document. type StatementEntry struct { + // +optional Sid string `json:",omitempty"` + // +optional Principal Principals `json:",omitempty"` + // +optional NotPrincipal Principals `json:",omitempty"` + // +required Effect Effect `json:"Effect"` + // +required Action Actions `json:"Action"` + // +optional Resource Resources `json:",omitempty"` + // +optional Condition Conditions `json:"Condition,omitempty"` } diff --git a/pkg/cloud/awserrors/errors.go b/pkg/cloud/awserrors/errors.go index f3ea60ae42..90dbe5b608 100644 --- a/pkg/cloud/awserrors/errors.go +++ b/pkg/cloud/awserrors/errors.go @@ -85,15 +85,20 @@ func Message(err error) string { // EC2Error is an error exposed to users of this library. type EC2Error struct { + // +optional msg string + // +optional Code int } // SmithyError holds parsed smithy errors from aws-sdk-go-v2 API calls. type SmithyError struct { + // +optional errCode string + // +optional errMessage string + // +optional statusCode int } diff --git a/pkg/cloud/endpoints/endpoints.go b/pkg/cloud/endpoints/endpoints.go index 29996737a1..1b44c3575e 100644 --- a/pkg/cloud/endpoints/endpoints.go +++ b/pkg/cloud/endpoints/endpoints.go @@ -62,8 +62,11 @@ var ( // serviceEndpoint contains AWS Service resolution information for SDK V2. type serviceEndpoint struct { + // +optional ServiceID string + // +optional URL string + // +optional SigningRegion string } @@ -149,6 +152,7 @@ func GetPartitionFromRegion(region string) string { // MultiServiceEndpointResolver implements EndpointResolverV2 interface for services. type MultiServiceEndpointResolver struct { + // +optional endpoints map[string]serviceEndpoint } @@ -161,6 +165,7 @@ func NewMultiServiceEndpointResolver() *MultiServiceEndpointResolver { // S3EndpointResolver implements EndpointResolverV2 interface for S3. type S3EndpointResolver struct { + // +optional *MultiServiceEndpointResolver } @@ -183,6 +188,7 @@ func (s *S3EndpointResolver) ResolveEndpoint(ctx context.Context, params s3.Endp // ELBEndpointResolver implements EndpointResolverV2 interface for ELB. type ELBEndpointResolver struct { + // +optional *MultiServiceEndpointResolver } @@ -205,6 +211,7 @@ func (s *ELBEndpointResolver) ResolveEndpoint(ctx context.Context, params elb.En // ELBV2EndpointResolver implements EndpointResolverV2 interface for ELBV2. type ELBV2EndpointResolver struct { + // +optional *MultiServiceEndpointResolver } @@ -227,6 +234,7 @@ func (s *ELBV2EndpointResolver) ResolveEndpoint(ctx context.Context, params elbv // EC2EndpointResolver implements EndpointResolverV2 interface for EC2. type EC2EndpointResolver struct { + // +optional *MultiServiceEndpointResolver } @@ -249,6 +257,7 @@ func (s *EC2EndpointResolver) ResolveEndpoint(ctx context.Context, params ec2.En // RGAPIEndpointResolver implements EndpointResolverV2 interface for RGAPI. type RGAPIEndpointResolver struct { + // +optional *MultiServiceEndpointResolver } @@ -271,6 +280,7 @@ func (s *RGAPIEndpointResolver) ResolveEndpoint(ctx context.Context, params rgap // SQSEndpointResolver implements EndpointResolverV2 interface for SQS. type SQSEndpointResolver struct { + // +optional *MultiServiceEndpointResolver } @@ -293,6 +303,7 @@ func (s *SQSEndpointResolver) ResolveEndpoint(ctx context.Context, params sqs.En // EventBridgeEndpointResolver implements EndpointResolverV2 interface for EventBridge. type EventBridgeEndpointResolver struct { + // +optional *MultiServiceEndpointResolver } @@ -315,6 +326,7 @@ func (s *EventBridgeEndpointResolver) ResolveEndpoint(ctx context.Context, param // EKSEndpointResolver implements EndpointResolverV2 interface for EKS. type EKSEndpointResolver struct { + // +optional *MultiServiceEndpointResolver } @@ -337,6 +349,7 @@ func (s *EKSEndpointResolver) ResolveEndpoint(ctx context.Context, params eks.En // SSMEndpointResolver implements EndpointResolverV2 interface for SSM. type SSMEndpointResolver struct { + // +optional *MultiServiceEndpointResolver } @@ -359,6 +372,7 @@ func (s *SSMEndpointResolver) ResolveEndpoint(ctx context.Context, params ssm.En // STSEndpointResolver implements EndpointResolverV2 interface for STS. type STSEndpointResolver struct { + // +optional *MultiServiceEndpointResolver } @@ -381,6 +395,7 @@ func (s *STSEndpointResolver) ResolveEndpoint(ctx context.Context, params sts.En // SecretsManagerEndpointResolver implements EndpointResolverV2 interface for Secrets Manager. type SecretsManagerEndpointResolver struct { + // +optional *MultiServiceEndpointResolver } diff --git a/pkg/cloud/endpoints/partition.go b/pkg/cloud/endpoints/partition.go index b90cb3f2ed..5af11a95a7 100644 --- a/pkg/cloud/endpoints/partition.go +++ b/pkg/cloud/endpoints/partition.go @@ -26,9 +26,13 @@ import "regexp" // Partition provides the metadata describing an AWS partition. type Partition struct { + // +required ID string `json:"id"` + // +required Regions map[string]RegionOverrides `json:"regions"` + // +required RegionRegex string `json:"regionRegex"` + // +required DefaultConfig PartitionConfig `json:"outputs"` } @@ -36,11 +40,17 @@ type Partition struct { // //nolint:revive type PartitionConfig struct { + // +required Name string `json:"name"` + // +required DnsSuffix string `json:"dnsSuffix"` + // +required DualStackDnsSuffix string `json:"dualStackDnsSuffix"` + // +required SupportsFIPS bool `json:"supportsFIPS"` + // +required SupportsDualStack bool `json:"supportsDualStack"` + // +required ImplicitGlobalRegion string `json:"implicitGlobalRegion"` } @@ -48,10 +58,15 @@ type PartitionConfig struct { // //nolint:revive type RegionOverrides struct { + // +required Name *string `json:"name"` + // +required DnsSuffix *string `json:"dnsSuffix"` + // +required DualStackDnsSuffix *string `json:"dualStackDnsSuffix"` + // +required SupportsFIPS *bool `json:"supportsFIPS"` + // +required SupportsDualStack *bool `json:"supportsDualStack"` } diff --git a/pkg/cloud/identity/identity.go b/pkg/cloud/identity/identity.go index 0d92d891b3..1f88750d3c 100644 --- a/pkg/cloud/identity/identity.go +++ b/pkg/cloud/identity/identity.go @@ -106,11 +106,16 @@ func NewAWSRolePrincipalTypeProvider(identity *infrav1.AWSClusterRoleIdentity, s // AWSStaticPrincipalTypeProvider defines the specs for a static AWSPrincipalTypeProvider. type AWSStaticPrincipalTypeProvider struct { + // +optional Principal *infrav1.AWSClusterStaticIdentity + // +optional credentials *aws.CredentialsCache // these are for tests :/ + // +optional AccessKeyID string + // +optional SecretAccessKey string + // +optional SessionToken string } @@ -137,11 +142,17 @@ func (p *AWSStaticPrincipalTypeProvider) Name() string { // AWSRolePrincipalTypeProvider defines the specs for a AWSPrincipalTypeProvider with a role. type AWSRolePrincipalTypeProvider struct { + // +optional Principal *infrav1.AWSClusterRoleIdentity + // +optional credentials *aws.CredentialsCache + // +optional region string + // +optional sourceProvider AWSPrincipalTypeProvider + // +optional log logger.Wrapper + // +optional stsClient stsservice.STSClient } diff --git a/pkg/cloud/metrics/metrics.go b/pkg/cloud/metrics/metrics.go index 82187e02ad..e285a52704 100644 --- a/pkg/cloud/metrics/metrics.go +++ b/pkg/cloud/metrics/metrics.go @@ -80,15 +80,25 @@ type requestContextKey struct{} // RequestData holds information related to request metrics. type RequestData struct { + // +optional RequestStartTime time.Time + // +optional RequestEndTime time.Time + // +optional StatusCode int + // +optional ErrorCode string + // +optional Service string + // +optional OperationName string + // +optional Region string + // +optional Controller string + // +optional Target runtime.Object + // +optional Attempts int } diff --git a/pkg/cloud/scope/clients.go b/pkg/cloud/scope/clients.go index cbb8f1bb6e..210dea8975 100644 --- a/pkg/cloud/scope/clients.go +++ b/pkg/cloud/scope/clients.go @@ -337,10 +337,16 @@ func NewS3Client(scopeUser cloud.ScopeUsage, session cloud.Session, logger logge // AWSClients contains all the aws clients used by the scopes. type AWSClients struct { + // +optional ELB *elb.Client + // +optional SecretsManager *secretsmanager.Client + // +optional ResourceTagging *rgapi.Client + // +optional ASG *autoscaling.Client + // +optional EC2 *ec2.Client + // +optional ELBV2 *elbv2.Client } diff --git a/pkg/cloud/scope/cluster.go b/pkg/cloud/scope/cluster.go index cd51b966f2..a42918a8c4 100644 --- a/pkg/cloud/scope/cluster.go +++ b/pkg/cloud/scope/cluster.go @@ -41,14 +41,22 @@ import ( // ClusterScopeParams defines the input parameters used to create a new Scope. type ClusterScopeParams struct { - Client client.Client - Logger *logger.Logger - Cluster *clusterv1.Cluster - AWSCluster *infrav1.AWSCluster - ControllerName string - Session aws.Config + // +optional + Client client.Client + // +optional + Logger *logger.Logger + // +optional + Cluster *clusterv1.Cluster + // +optional + AWSCluster *infrav1.AWSCluster + // +optional + ControllerName string + // +optional + Session aws.Config + // +optional TagUnmanagedNetworkResources bool - MaxWaitActiveUpdateDelete time.Duration + // +optional + MaxWaitActiveUpdateDelete time.Duration } // NewClusterScope creates a new Scope from the supplied parameters. @@ -95,19 +103,29 @@ func NewClusterScope(params ClusterScopeParams) (*ClusterScope, error) { // ClusterScope defines the basic context for an actuator to operate upon. type ClusterScope struct { + // +optional logger.Logger - client client.Client + // +optional + client client.Client + // +optional patchHelper *v1beta1patch.Helper - Cluster *clusterv1.Cluster + // +optional + Cluster *clusterv1.Cluster + // +optional AWSCluster *infrav1.AWSCluster - session aws.Config + // +optional + session aws.Config + // +optional serviceLimiters throttle.ServiceLimiters - controllerName string + // +optional + controllerName string + // +optional tagUnmanagedNetworkResources bool - maxWaitActiveUpdateDelete time.Duration + // +optional + maxWaitActiveUpdateDelete time.Duration } // Network returns the cluster network object. diff --git a/pkg/cloud/scope/fargate.go b/pkg/cloud/scope/fargate.go index 44ec604e27..e648d03e1e 100644 --- a/pkg/cloud/scope/fargate.go +++ b/pkg/cloud/scope/fargate.go @@ -31,22 +31,29 @@ import ( "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/endpoints" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/throttle" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" - v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions" - v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/util/conditions" + "sigs.k8s.io/cluster-api/util/patch" ) // FargateProfileScopeParams defines the input parameters used to create a new Scope. type FargateProfileScopeParams struct { + // +optional Client client.Client + // +optional Logger *logger.Logger + // +optional Cluster *clusterv1.Cluster + // +optional ControlPlane *ekscontrolplanev1.AWSManagedControlPlane + // +optional FargateProfile *expinfrav1.AWSFargateProfile + // +optional ControllerName string + // +optional Session aws.Config + // +optional EnableIAM bool } @@ -74,7 +81,7 @@ func NewFargateProfileScope(params FargateProfileScopeParams) (*FargateProfileSc return nil, errors.Errorf("failed to create aws v2 session: %v", err) } - helper, err := v1beta1patch.NewHelper(params.FargateProfile, params.Client) + helper, err := patch.NewHelper(params.FargateProfile, params.Client) if err != nil { return nil, errors.Wrap(err, "failed to init patch helper") } @@ -95,18 +102,28 @@ func NewFargateProfileScope(params FargateProfileScopeParams) (*FargateProfileSc // FargateProfileScope defines the basic context for an actuator to operate upon. type FargateProfileScope struct { + // +optional logger.Logger + // +optional Client client.Client - patchHelper *v1beta1patch.Helper + // +optional + patchHelper *patch.Helper + // +optional Cluster *clusterv1.Cluster + // +optional ControlPlane *ekscontrolplanev1.AWSManagedControlPlane + // +optional FargateProfile *expinfrav1.AWSFargateProfile + // +optional session aws.Config + // +optional serviceLimiters throttle.ServiceLimiters + // +optional controllerName string + // +optional enableIAM bool } @@ -169,11 +186,11 @@ func (s *FargateProfileScope) Partition() string { // IAMReadyFalse marks the ready condition false using warning if error isn't // empty. func (s *FargateProfileScope) IAMReadyFalse(reason string, err string) error { - severity := clusterv1beta1.ConditionSeverityWarning + severity := clusterv1.ConditionSeverityWarning if err == "" { - severity = clusterv1beta1.ConditionSeverityInfo + severity = clusterv1.ConditionSeverityInfo } - v1beta1conditions.MarkFalse( + conditions.MarkFalse( s.FargateProfile, expinfrav1.IAMFargateRolesReadyCondition, reason, @@ -192,7 +209,7 @@ func (s *FargateProfileScope) PatchObject() error { return s.patchHelper.Patch( context.TODO(), s.FargateProfile, - v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{ + patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{ expinfrav1.EKSFargateProfileReadyCondition, expinfrav1.EKSFargateCreatingCondition, expinfrav1.EKSFargateDeletingCondition, @@ -211,7 +228,7 @@ func (s *FargateProfileScope) InfraCluster() cloud.ClusterObject { } // ClusterObj returns the cluster object. -func (s *FargateProfileScope) ClusterObj() *clusterv1.Cluster { +func (s *FargateProfileScope) ClusterObj() cloud.ClusterObject { return s.Cluster } diff --git a/pkg/cloud/scope/global.go b/pkg/cloud/scope/global.go index d2d6436bfb..b9e13499f3 100644 --- a/pkg/cloud/scope/global.go +++ b/pkg/cloud/scope/global.go @@ -46,14 +46,19 @@ func NewGlobalScope(params GlobalScopeParams) (*GlobalScope, error) { // GlobalScopeParams defines the parameters acceptable for GlobalScope. type GlobalScopeParams struct { + // +optional ControllerName string + // +optional Region string } // GlobalScope defines the specs for the GlobalScope. type GlobalScope struct { + // +optional session awsv2.Config + // +optional serviceLimiters throttle.ServiceLimiters + // +optional controllerName string } diff --git a/pkg/cloud/scope/launchtemplate.go b/pkg/cloud/scope/launchtemplate.go index f67a082783..215a65dddf 100644 --- a/pkg/cloud/scope/launchtemplate.go +++ b/pkg/cloud/scope/launchtemplate.go @@ -53,7 +53,9 @@ type LaunchTemplateScope interface { // ResourceServiceToUpdate is a struct that contains the resource ID and the resource service to update. type ResourceServiceToUpdate struct { + // +optional ResourceID *string + // +optional ResourceService ResourceService } diff --git a/pkg/cloud/scope/machine.go b/pkg/cloud/scope/machine.go index c0a8d8122a..c211c1db1b 100644 --- a/pkg/cloud/scope/machine.go +++ b/pkg/cloud/scope/machine.go @@ -31,21 +31,26 @@ import ( ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/v2/controlplane/eks/api/v1beta2" "sigs.k8s.io/cluster-api-provider-aws/v2/exp/api/v1beta2" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/annotations" - v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions" - v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch" + "sigs.k8s.io/cluster-api/util/conditions" + "sigs.k8s.io/cluster-api/util/patch" ) // MachineScopeParams defines the input parameters used to create a new MachineScope. type MachineScopeParams struct { + // +optional Client client.Client + // +optional Logger *logger.Logger + // +optional Cluster *clusterv1.Cluster + // +optional Machine *clusterv1.Machine + // +optional InfraCluster EC2Scope + // +optional AWSMachine *infrav1.AWSMachine } @@ -73,7 +78,7 @@ func NewMachineScope(params MachineScopeParams) (*MachineScope, error) { params.Logger = logger.NewLogger(log) } - helper, err := v1beta1patch.NewHelper(params.AWSMachine, params.Client) + helper, err := patch.NewHelper(params.AWSMachine, params.Client) if err != nil { return nil, errors.Wrap(err, "failed to init patch helper") } @@ -90,13 +95,20 @@ func NewMachineScope(params MachineScopeParams) (*MachineScope, error) { // MachineScope defines a scope defined around a machine and its cluster. type MachineScope struct { + // +optional logger.Logger + // +optional client client.Client - patchHelper *v1beta1patch.Helper + // +optional + patchHelper *patch.Helper + // +optional Cluster *clusterv1.Cluster + // +optional Machine *clusterv1.Machine + // +optional InfraCluster EC2Scope + // +optional AWSMachine *infrav1.AWSMachine } @@ -259,7 +271,7 @@ func (m *MachineScope) SetSecretCount(i int32) { } // SetAddresses sets the AWSMachine address status. -func (m *MachineScope) SetAddresses(addrs []clusterv1beta1.MachineAddress) { +func (m *MachineScope) SetAddresses(addrs []clusterv1.MachineAddress) { m.AWSMachine.Status.Addresses = addrs } @@ -303,7 +315,7 @@ func (m *MachineScope) GetRawBootstrapDataWithFormat() ([]byte, string, error) { func (m *MachineScope) PatchObject() error { // Always update the readyCondition by summarizing the state of other conditions. // A step counter is added to represent progress during the provisioning process (instead we are hiding during the deletion process). - applicableConditions := []clusterv1beta1.ConditionType{ + applicableConditions := []clusterv1.ConditionType{ infrav1.InstanceReadyCondition, infrav1.SecurityGroupsReadyCondition, } @@ -312,17 +324,17 @@ func (m *MachineScope) PatchObject() error { applicableConditions = append(applicableConditions, infrav1.ELBAttachedCondition) } - v1beta1conditions.SetSummary(m.AWSMachine, - v1beta1conditions.WithConditions(applicableConditions...), - v1beta1conditions.WithStepCounterIf(m.AWSMachine.ObjectMeta.DeletionTimestamp.IsZero()), - v1beta1conditions.WithStepCounter(), + conditions.SetSummary(m.AWSMachine, + conditions.WithConditions(applicableConditions...), + conditions.WithStepCounterIf(m.AWSMachine.ObjectMeta.DeletionTimestamp.IsZero()), + conditions.WithStepCounter(), ) return m.patchHelper.Patch( context.TODO(), m.AWSMachine, - v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{ - clusterv1beta1.ReadyCondition, + patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{ + clusterv1.ReadyCondition, infrav1.InstanceReadyCondition, infrav1.SecurityGroupsReadyCondition, infrav1.ELBAttachedCondition, diff --git a/pkg/cloud/scope/machinepool.go b/pkg/cloud/scope/machinepool.go index c817e2971f..2118e34d22 100644 --- a/pkg/cloud/scope/machinepool.go +++ b/pkg/cloud/scope/machinepool.go @@ -34,36 +34,49 @@ import ( ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/v2/controlplane/eks/api/v1beta2" expinfrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/exp/api/v1beta2" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/controllers/remote" + expclusterv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/util" - v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions" - v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch" + "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/cluster-api/util/patch" ) // MachinePoolScope defines a scope defined around a machine and its cluster. type MachinePoolScope struct { + // +optional logger.Logger + // +optional client.Client - patchHelper *v1beta1patch.Helper + // +optional + patchHelper *patch.Helper + // +optional capiMachinePoolPatchHelper *patch.Helper + // +optional Cluster *clusterv1.Cluster - MachinePool *clusterv1.MachinePool + // +optional + MachinePool *expclusterv1.MachinePool + // +optional InfraCluster EC2Scope + // +optional AWSMachinePool *expinfrav1.AWSMachinePool } // MachinePoolScopeParams defines a scope defined around a machine and its cluster. type MachinePoolScopeParams struct { + // +optional client.Client + // +optional Logger *logger.Logger + // +optional Cluster *clusterv1.Cluster - MachinePool *clusterv1.MachinePool + // +optional + MachinePool *expclusterv1.MachinePool + // +optional InfraCluster EC2Scope + // +optional AWSMachinePool *expinfrav1.AWSMachinePool } @@ -99,7 +112,7 @@ func NewMachinePoolScope(params MachinePoolScopeParams) (*MachinePoolScope, erro params.Logger = logger.NewLogger(log) } - ampHelper, err := v1beta1patch.NewHelper(params.AWSMachinePool, params.Client) + ampHelper, err := patch.NewHelper(params.AWSMachinePool, params.Client) if err != nil { return nil, errors.Wrap(err, "failed to init AWSMachinePool patch helper") } @@ -176,7 +189,7 @@ func (m *MachinePoolScope) PatchObject() error { return m.patchHelper.Patch( context.TODO(), m.AWSMachinePool, - v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{ + patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{ expinfrav1.ASGReadyCondition, expinfrav1.LaunchTemplateReadyCondition, }}) @@ -239,7 +252,7 @@ func (m *MachinePoolScope) GetObjectMeta() *metav1.ObjectMeta { } // GetSetter returns the AWSMachinePool object setter. -func (m *MachinePoolScope) GetSetter() v1beta1conditions.Setter { +func (m *MachinePoolScope) GetSetter() conditions.Setter { return m.AWSMachinePool } @@ -294,7 +307,9 @@ func (m *MachinePoolScope) SubnetIDs(subnetIDs []string) ([]string, error) { // NodeStatus represents the status of a Kubernetes node. type NodeStatus struct { + // +optional Ready bool + // +optional Version string } @@ -381,7 +396,7 @@ func (m *MachinePoolScope) GetLaunchTemplate() *expinfrav1.AWSLaunchTemplate { } // GetMachinePool returns the machine pool object. -func (m *MachinePoolScope) GetMachinePool() *clusterv1.MachinePool { +func (m *MachinePoolScope) GetMachinePool() *expclusterv1.MachinePool { return m.MachinePool } diff --git a/pkg/cloud/scope/managedcontrolplane.go b/pkg/cloud/scope/managedcontrolplane.go index 1571dbb4e2..cecdbacddd 100644 --- a/pkg/cloud/scope/managedcontrolplane.go +++ b/pkg/cloud/scope/managedcontrolplane.go @@ -30,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/klog/v2" - "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2" @@ -39,13 +38,14 @@ import ( "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/endpoints" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/throttle" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/controllers/remote" - v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch" + "sigs.k8s.io/cluster-api/util/patch" ) -var scheme = runtime.NewScheme() +var ( + scheme = runtime.NewScheme() +) func init() { _ = amazoncni.AddToScheme(scheme) @@ -56,16 +56,26 @@ func init() { // ManagedControlPlaneScopeParams defines the input parameters used to create a new Scope. type ManagedControlPlaneScopeParams struct { + // +optional Client client.Client + // +optional Logger *logger.Logger + // +optional Cluster *clusterv1.Cluster + // +optional ControlPlane *ekscontrolplanev1.AWSManagedControlPlane + // +optional ControllerName string + // +optional Session aws.Config + // +optional MaxWaitActiveUpdateDelete time.Duration + // +optional EnableIAM bool + // +optional AllowAdditionalRoles bool + // +optional TagUnmanagedNetworkResources bool } @@ -104,7 +114,7 @@ func NewManagedControlPlaneScope(params ManagedControlPlaneScopeParams) (*Manage managedScope.session = *session managedScope.serviceLimiters = serviceLimiters - helper, err := v1beta1patch.NewHelper(params.ControlPlane, params.Client) + helper, err := patch.NewHelper(params.ControlPlane, params.Client) if err != nil { return nil, errors.Wrap(err, "failed to init patch helper") } @@ -115,20 +125,32 @@ func NewManagedControlPlaneScope(params ManagedControlPlaneScopeParams) (*Manage // ManagedControlPlaneScope defines the basic context for an actuator to operate upon. type ManagedControlPlaneScope struct { + // +optional logger.Logger + // +optional Client client.Client - patchHelper *v1beta1patch.Helper + // +optional + patchHelper *patch.Helper + // +optional Cluster *clusterv1.Cluster + // +optional ControlPlane *ekscontrolplanev1.AWSManagedControlPlane + // +optional MaxWaitActiveUpdateDelete time.Duration + // +optional session aws.Config + // +optional serviceLimiters throttle.ServiceLimiters + // +optional controllerName string + // +optional enableIAM bool + // +optional allowAdditionalRoles bool + // +optional tagUnmanagedNetworkResources bool } @@ -268,7 +290,7 @@ func (s *ManagedControlPlaneScope) PatchObject() error { return s.patchHelper.Patch( context.TODO(), s.ControlPlane, - v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{ + patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{ infrav1.VpcReadyCondition, infrav1.SubnetsReadyCondition, infrav1.ClusterSecurityGroupsReadyCondition, @@ -305,14 +327,11 @@ func (s *ManagedControlPlaneScope) APIServerPort() int32 { } // SetFailureDomain sets the infrastructure provider failure domain key to the spec given as input. -func (s *ManagedControlPlaneScope) SetFailureDomain(id string, spec clusterv1.FailureDomain) { +func (s *ManagedControlPlaneScope) SetFailureDomain(id string, spec clusterv1.FailureDomainSpec) { if s.ControlPlane.Status.FailureDomains == nil { - s.ControlPlane.Status.FailureDomains = make(clusterv1beta1.FailureDomains) - } - s.ControlPlane.Status.FailureDomains[id] = clusterv1beta1.FailureDomainSpec{ - ControlPlane: ptr.Deref(spec.ControlPlane, false), - Attributes: spec.Attributes, + s.ControlPlane.Status.FailureDomains = make(clusterv1.FailureDomains) } + s.ControlPlane.Status.FailureDomains[id] = spec } // InfraCluster returns the AWS infrastructure cluster or control plane object. @@ -321,7 +340,7 @@ func (s *ManagedControlPlaneScope) InfraCluster() cloud.ClusterObject { } // ClusterObj returns the cluster object. -func (s *ManagedControlPlaneScope) ClusterObj() *clusterv1.Cluster { +func (s *ManagedControlPlaneScope) ClusterObj() cloud.ClusterObject { return s.Cluster } @@ -450,8 +469,12 @@ func (s *ManagedControlPlaneScope) OIDCIdentityProviderConfig() *ekscontrolplane // ServiceCidrs returns the CIDR blocks used for services. func (s *ManagedControlPlaneScope) ServiceCidrs() *clusterv1.NetworkRanges { - if len(s.Cluster.Spec.ClusterNetwork.Services.CIDRBlocks) > 0 { - return &s.Cluster.Spec.ClusterNetwork.Services + if s.Cluster.Spec.ClusterNetwork != nil { + if s.Cluster.Spec.ClusterNetwork.Services != nil { + if len(s.Cluster.Spec.ClusterNetwork.Services.CIDRBlocks) > 0 { + return s.Cluster.Spec.ClusterNetwork.Services + } + } } return nil diff --git a/pkg/cloud/scope/managednodegroup.go b/pkg/cloud/scope/managednodegroup.go index d0b2116706..2a0d04553f 100644 --- a/pkg/cloud/scope/managednodegroup.go +++ b/pkg/cloud/scope/managednodegroup.go @@ -37,28 +37,39 @@ import ( "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/endpoints" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/throttle" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" - v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions" - v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expclusterv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/cluster-api/util/patch" ) // ManagedMachinePoolScopeParams defines the input parameters used to create a new Scope. type ManagedMachinePoolScopeParams struct { + // +optional Client client.Client + // +optional Logger *logger.Logger + // +optional Cluster *clusterv1.Cluster + // +optional ControlPlane *ekscontrolplanev1.AWSManagedControlPlane + // +optional ManagedMachinePool *expinfrav1.AWSManagedMachinePool - MachinePool *clusterv1.MachinePool + // +optional + MachinePool *expclusterv1.MachinePool + // +optional ControllerName string + // +optional Session awsv2.Config + // +optional MaxWaitActiveUpdateDelete time.Duration + // +optional EnableIAM bool + // +optional AllowAdditionalRoles bool + // +optional InfraCluster EC2Scope } @@ -93,7 +104,7 @@ func NewManagedMachinePoolScope(params ManagedMachinePoolScopeParams) (*ManagedM return nil, errors.Errorf("failed to create aws V2 session: %v", err) } - ammpHelper, err := v1beta1patch.NewHelper(params.ManagedMachinePool, params.Client) + ammpHelper, err := patch.NewHelper(params.ManagedMachinePool, params.Client) if err != nil { return nil, errors.Wrap(err, "failed to init AWSManagedMachinePool patch helper") } @@ -124,23 +135,38 @@ func NewManagedMachinePoolScope(params ManagedMachinePoolScopeParams) (*ManagedM // ManagedMachinePoolScope defines the basic context for an actuator to operate upon. type ManagedMachinePoolScope struct { + // +optional logger.Logger + // +optional client.Client - patchHelper *v1beta1patch.Helper + // +optional + patchHelper *patch.Helper + // +optional capiMachinePoolPatchHelper *patch.Helper + // +optional Cluster *clusterv1.Cluster + // +optional ControlPlane *ekscontrolplanev1.AWSManagedControlPlane + // +optional ManagedMachinePool *expinfrav1.AWSManagedMachinePool - MachinePool *clusterv1.MachinePool + // +optional + MachinePool *expclusterv1.MachinePool + // +optional EC2Scope EC2Scope + // +optional MaxWaitActiveUpdateDelete time.Duration + // +optional session awsv2.Config + // +optional serviceLimiters throttle.ServiceLimiters + // +optional controllerName string + // +optional enableIAM bool + // +optional allowAdditionalRoles bool } @@ -202,10 +228,7 @@ func (s *ManagedMachinePoolScope) RoleName() string { // Version returns the nodegroup Kubernetes version. func (s *ManagedMachinePoolScope) Version() *string { - if s.MachinePool.Spec.Template.Spec.Version == "" { - return nil - } - return &s.MachinePool.Spec.Template.Spec.Version + return s.MachinePool.Spec.Template.Spec.Version } // ControlPlaneSubnets returns the control plane subnets. @@ -232,11 +255,11 @@ func (s *ManagedMachinePoolScope) SubnetIDs() ([]string, error) { // NodegroupReadyFalse marks the ready condition false using warning if error isn't // empty. func (s *ManagedMachinePoolScope) NodegroupReadyFalse(reason string, err string) error { - severity := clusterv1beta1.ConditionSeverityWarning + severity := clusterv1.ConditionSeverityWarning if err == "" { - severity = clusterv1beta1.ConditionSeverityInfo + severity = clusterv1.ConditionSeverityInfo } - v1beta1conditions.MarkFalse( + conditions.MarkFalse( s.ManagedMachinePool, expinfrav1.EKSNodegroupReadyCondition, reason, @@ -253,11 +276,11 @@ func (s *ManagedMachinePoolScope) NodegroupReadyFalse(reason string, err string) // IAMReadyFalse marks the ready condition false using warning if error isn't // empty. func (s *ManagedMachinePoolScope) IAMReadyFalse(reason string, err string) error { - severity := clusterv1beta1.ConditionSeverityWarning + severity := clusterv1.ConditionSeverityWarning if err == "" { - severity = clusterv1beta1.ConditionSeverityInfo + severity = clusterv1.ConditionSeverityInfo } - v1beta1conditions.MarkFalse( + conditions.MarkFalse( s.ManagedMachinePool, expinfrav1.IAMNodegroupRolesReadyCondition, reason, @@ -276,7 +299,7 @@ func (s *ManagedMachinePoolScope) PatchObject() error { return s.patchHelper.Patch( context.TODO(), s.ManagedMachinePool, - v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{ + patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{ expinfrav1.EKSNodegroupReadyCondition, expinfrav1.IAMNodegroupRolesReadyCondition, }}) @@ -301,7 +324,7 @@ func (s *ManagedMachinePoolScope) InfraCluster() cloud.ClusterObject { } // ClusterObj returns the cluster object. -func (s *ManagedMachinePoolScope) ClusterObj() *clusterv1.Cluster { +func (s *ManagedMachinePoolScope) ClusterObj() cloud.ClusterObject { return s.Cluster } @@ -368,7 +391,7 @@ func (s *ManagedMachinePoolScope) GetObjectMeta() *metav1.ObjectMeta { } // GetSetter returns the condition setter. -func (s *ManagedMachinePoolScope) GetSetter() v1beta1conditions.Setter { +func (s *ManagedMachinePoolScope) GetSetter() conditions.Setter { return s.ManagedMachinePool } @@ -414,7 +437,7 @@ func (s *ManagedMachinePoolScope) GetLaunchTemplate() *expinfrav1.AWSLaunchTempl } // GetMachinePool returns the machine pool. -func (s *ManagedMachinePoolScope) GetMachinePool() *clusterv1.MachinePool { +func (s *ManagedMachinePoolScope) GetMachinePool() *expclusterv1.MachinePool { return s.MachinePool } diff --git a/pkg/cloud/scope/providerid.go b/pkg/cloud/scope/providerid.go index 1b11135ce4..4231f7058e 100644 --- a/pkg/cloud/scope/providerid.go +++ b/pkg/cloud/scope/providerid.go @@ -41,8 +41,11 @@ var ( // ProviderID is a struct representation of a Kubernetes ProviderID. // Format: cloudProvider://optional/segments/etc/id type ProviderID struct { + // +optional original string + // +optional cloudProvider string + // +optional id string } diff --git a/pkg/cloud/scope/rosacontrolplane.go b/pkg/cloud/scope/rosacontrolplane.go index 373cd02f14..c25d8a6d6f 100644 --- a/pkg/cloud/scope/rosacontrolplane.go +++ b/pkg/cloud/scope/rosacontrolplane.go @@ -35,18 +35,23 @@ import ( stsservice "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/sts" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/throttle" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" - v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/util/patch" ) // ROSAControlPlaneScopeParams defines the input parameters used to create a new ROSAControlPlaneScope. type ROSAControlPlaneScopeParams struct { + // +optional Client client.Client + // +optional Logger *logger.Logger + // +optional Cluster *clusterv1.Cluster + // +optional ControlPlane *rosacontrolplanev1.ROSAControlPlane + // +optional ControllerName string + // +optional NewStsClient func(cloud.ScopeUsage, cloud.Session, logger.Wrapper, runtime.Object) stsservice.STSClient } @@ -77,7 +82,7 @@ func NewROSAControlPlaneScope(params ROSAControlPlaneScopeParams) (*ROSAControlP return nil, errors.Errorf("failed to create aws V2 session: %v", err) } - helper, err := v1beta1patch.NewHelper(params.ControlPlane, params.Client) + helper, err := patch.NewHelper(params.ControlPlane, params.Client) if err != nil { return nil, errors.Wrap(err, "failed to init patch helper") } @@ -98,16 +103,25 @@ func NewROSAControlPlaneScope(params ROSAControlPlaneScopeParams) (*ROSAControlP // ROSAControlPlaneScope defines the basic context for an actuator to operate upon. type ROSAControlPlaneScope struct { + // +optional logger.Logger + // +optional Client client.Client - patchHelper *v1beta1patch.Helper + // +optional + patchHelper *patch.Helper + // +optional Cluster *clusterv1.Cluster + // +optional ControlPlane *rosacontrolplanev1.ROSAControlPlane + // +optional session awsv2.Config + // +optional serviceLimiters throttle.ServiceLimiters + // +optional controllerName string + // +optional Identity *stsv2.GetCallerIdentityOutput } @@ -139,11 +153,9 @@ func (s *ROSAControlPlaneScope) ControllerName() string { return s.controllerName } -var ( - _ cloud.ScopeUsage = (*ROSAControlPlaneScope)(nil) - _ cloud.Session = (*ROSAControlPlaneScope)(nil) - _ cloud.SessionMetadata = (*ROSAControlPlaneScope)(nil) -) +var _ cloud.ScopeUsage = (*ROSAControlPlaneScope)(nil) +var _ cloud.Session = (*ROSAControlPlaneScope)(nil) +var _ cloud.SessionMetadata = (*ROSAControlPlaneScope)(nil) // Name returns the CAPI cluster name. func (s *ROSAControlPlaneScope) Name() string { @@ -215,7 +227,7 @@ func (s *ROSAControlPlaneScope) PatchObject() error { return s.patchHelper.Patch( context.TODO(), s.ControlPlane, - v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{ + patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{ rosacontrolplanev1.ROSAControlPlaneReadyCondition, rosacontrolplanev1.ROSAControlPlaneValidCondition, rosacontrolplanev1.ROSAControlPlaneUpgradingCondition, diff --git a/pkg/cloud/scope/rosamachinepool.go b/pkg/cloud/scope/rosamachinepool.go index aa93ad8e56..aac07c6374 100644 --- a/pkg/cloud/scope/rosamachinepool.go +++ b/pkg/cloud/scope/rosamachinepool.go @@ -30,21 +30,27 @@ import ( "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/throttle" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" - v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions" - v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expclusterv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/cluster-api/util/patch" ) // RosaMachinePoolScopeParams defines the input parameters used to create a new Scope. type RosaMachinePoolScopeParams struct { + // +optional Client client.Client + // +optional Logger *logger.Logger + // +optional Cluster *clusterv1.Cluster + // +optional ControlPlane *rosacontrolplanev1.ROSAControlPlane + // +optional RosaMachinePool *expinfrav1.ROSAMachinePool - MachinePool *clusterv1.MachinePool + // +optional + MachinePool *expclusterv1.MachinePool + // +optional ControllerName string } @@ -65,7 +71,7 @@ func NewRosaMachinePoolScope(params RosaMachinePoolScopeParams) (*RosaMachinePoo params.Logger = logger.NewLogger(log) } - ammpHelper, err := v1beta1patch.NewHelper(params.RosaMachinePool, params.Client) + ammpHelper, err := patch.NewHelper(params.RosaMachinePool, params.Client) if err != nil { return nil, errors.Wrap(err, "failed to init RosaMachinePool patch helper") } @@ -102,19 +108,30 @@ var _ cloud.SessionMetadata = &RosaMachinePoolScope{} // RosaMachinePoolScope defines the basic context for an actuator to operate upon. type RosaMachinePoolScope struct { + // +optional logger.Logger + // +optional client.Client - patchHelper *v1beta1patch.Helper + // +optional + patchHelper *patch.Helper + // +optional capiMachinePoolPatchHelper *patch.Helper + // +optional Cluster *clusterv1.Cluster + // +optional ControlPlane *rosacontrolplanev1.ROSAControlPlane + // +optional RosaMachinePool *expinfrav1.ROSAMachinePool - MachinePool *clusterv1.MachinePool + // +optional + MachinePool *expclusterv1.MachinePool + // +optional session awsv2.Config + // +optional serviceLimiters throttle.ServiceLimiters + // +optional controllerName string } @@ -144,7 +161,7 @@ func (s *RosaMachinePoolScope) InfraCluster() cloud.ClusterObject { } // ClusterObj returns the cluster object. -func (s *RosaMachinePoolScope) ClusterObj() *clusterv1.Cluster { +func (s *RosaMachinePoolScope) ClusterObj() cloud.ClusterObject { return s.Cluster } @@ -155,7 +172,7 @@ func (s *RosaMachinePoolScope) ControllerName() string { } // GetSetter returns the condition setter for the RosaMachinePool. -func (s *RosaMachinePoolScope) GetSetter() v1beta1conditions.Setter { +func (s *RosaMachinePoolScope) GetSetter() conditions.Setter { return s.RosaMachinePool } @@ -190,11 +207,11 @@ func (s *RosaMachinePoolScope) Namespace() string { // RosaMachinePoolReadyFalse marks the ready condition false using warning if error isn't // empty. func (s *RosaMachinePoolScope) RosaMachinePoolReadyFalse(reason string, err string) error { - severity := clusterv1beta1.ConditionSeverityWarning + severity := clusterv1.ConditionSeverityWarning if err == "" { - severity = clusterv1beta1.ConditionSeverityInfo + severity = clusterv1.ConditionSeverityInfo } - v1beta1conditions.MarkFalse( + conditions.MarkFalse( s.RosaMachinePool, expinfrav1.RosaMachinePoolReadyCondition, reason, @@ -213,7 +230,7 @@ func (s *RosaMachinePoolScope) PatchObject() error { return s.patchHelper.Patch( context.TODO(), s.RosaMachinePool, - v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{ + patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{ expinfrav1.RosaMachinePoolReadyCondition, }}) } diff --git a/pkg/cloud/scope/rosanetwork.go b/pkg/cloud/scope/rosanetwork.go index 33613165bd..75ec4dd675 100644 --- a/pkg/cloud/scope/rosanetwork.go +++ b/pkg/cloud/scope/rosanetwork.go @@ -29,26 +29,37 @@ import ( "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/throttle" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger" - clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1" - v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/util/patch" ) // ROSANetworkScopeParams defines the input parameters used to create a new ROSANetworkScope. type ROSANetworkScopeParams struct { + // +optional Client client.Client + // +optional ControllerName string + // +optional Logger *logger.Logger + // +optional ROSANetwork *expinfrav1.ROSANetwork } // ROSANetworkScope defines the basic context for an actuator to operate upon. type ROSANetworkScope struct { + // +optional logger.Logger + // +optional Client client.Client + // +optional controllerName string - patchHelper *v1beta1patch.Helper + // +optional + patchHelper *patch.Helper + // +optional ROSANetwork *expinfrav1.ROSANetwork + // +optional serviceLimiters throttle.ServiceLimiters + // +optional session awsv2.Config } @@ -72,7 +83,7 @@ func NewROSANetworkScope(params ROSANetworkScopeParams) (*ROSANetworkScope, erro return nil, errors.Errorf("failed to create aws V2 session: %v", err) } - patchHelper, err := v1beta1patch.NewHelper(params.ROSANetwork, params.Client) + patchHelper, err := patch.NewHelper(params.ROSANetwork, params.Client) if err != nil { return nil, errors.Wrap(err, "failed to init patch helper") } @@ -130,7 +141,7 @@ func (s *ROSANetworkScope) PatchObject() error { return s.patchHelper.Patch( context.TODO(), s.ROSANetwork, - v1beta1patch.WithOwnedConditions{Conditions: []clusterv1beta1.ConditionType{ + patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{ expinfrav1.ROSANetworkReadyCondition, }}) } diff --git a/pkg/cloud/scope/rosaroleconfig.go b/pkg/cloud/scope/rosaroleconfig.go index 1ee4c0d2c3..0697b7016a 100644 --- a/pkg/cloud/scope/rosaroleconfig.go +++ b/pkg/cloud/scope/rosaroleconfig.go @@ -32,26 +32,38 @@ import ( "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/throttle" "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger" - v1beta1patch "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch" + "sigs.k8s.io/cluster-api/util/patch" ) // RosaRoleConfigScopeParams defines the input parameters used to create a new RosaRoleConfigScope. type RosaRoleConfigScopeParams struct { + // +optional Client client.Client + // +optional ControllerName string + // +optional Logger *logger.Logger + // +optional RosaRoleConfig *expinfrav1.ROSARoleConfig } // RosaRoleConfigScope defines the basic context for an actuator to operate upon. type RosaRoleConfigScope struct { + // +optional logger.Logger + // +optional Client client.Client + // +optional controllerName string - patchHelper *v1beta1patch.Helper + // +optional + patchHelper *patch.Helper + // +optional RosaRoleConfig *expinfrav1.ROSARoleConfig + // +optional serviceLimiters throttle.ServiceLimiters + // +optional session aws.Config + // +optional iamClient *iam.Client } @@ -71,13 +83,14 @@ func NewRosaRoleConfigScope(params RosaRoleConfigScopeParams) (*RosaRoleConfigSc } session, serviceLimiters, err := sessionForClusterWithRegion(params.Client, RosaRoleConfigScope, "", params.Logger) + if err != nil { return nil, errors.Errorf("failed to create aws V2 session: %v", err) } iamClient := iam.NewFromConfig(*session) - patchHelper, err := v1beta1patch.NewHelper(params.RosaRoleConfig, params.Client) + patchHelper, err := patch.NewHelper(params.RosaRoleConfig, params.Client) if err != nil { return nil, errors.Wrap(err, "failed to init patch helper") } diff --git a/pkg/cloud/scope/session.go b/pkg/cloud/scope/session.go index 541ecc97bb..6365b9958f 100644 --- a/pkg/cloud/scope/session.go +++ b/pkg/cloud/scope/session.go @@ -56,13 +56,16 @@ var ( ) type sessionCacheEntry struct { + // +optional session *aws.Config + // +optional serviceLimiters throttle.ServiceLimiters } // ChainCredentialsProvider defines custom CredentialsProvider chain // NewChainCredentialsProvider can be used to initialize this struct. type ChainCredentialsProvider struct { + // +optional providers []aws.CredentialsProvider } diff --git a/pkg/cloud/scope/shared.go b/pkg/cloud/scope/shared.go index 099b112db0..5e84a04a33 100644 --- a/pkg/cloud/scope/shared.go +++ b/pkg/cloud/scope/shared.go @@ -42,10 +42,15 @@ var ( ) type placementInput struct { + // +optional SpecSubnetIDs []string + // +optional SpecAvailabilityZones []string + // +optional ParentAvailabilityZones []string + // +optional ControlplaneSubnets infrav1.Subnets + // +optional SubnetPlacementType *expinfrav1.AZSubnetType } @@ -65,6 +70,7 @@ func newDefaultSubnetPlacementStrategy(logger logger.Wrapper) (subnetsPlacementS // defaultSubnetPlacementStrategy is the default strategy for subnet placement. type defaultSubnetPlacementStrategy struct { + // +optional logger logger.Wrapper } diff --git a/pkg/cloud/services/autoscaling/service.go b/pkg/cloud/services/autoscaling/service.go index d88c762ee4..13f52aa42d 100644 --- a/pkg/cloud/services/autoscaling/service.go +++ b/pkg/cloud/services/autoscaling/service.go @@ -30,8 +30,11 @@ import ( // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the asg client. type Service struct { + // +optional scope cloud.ClusterScoper + // +optional ASGClient AutoScalingAPI + // +optional EC2Client common.EC2API } diff --git a/pkg/cloud/services/awsnode/cni_test.go b/pkg/cloud/services/awsnode/cni_test.go index ff08781e6b..75f92326ab 100644 --- a/pkg/cloud/services/awsnode/cni_test.go +++ b/pkg/cloud/services/awsnode/cni_test.go @@ -258,8 +258,11 @@ func TestReconcileCniVpcCniValues(t *testing.T) { } type cachingClient struct { + // +optional client.Client + // +optional getValue client.Object + // +optional updateChain []client.Object } @@ -281,11 +284,17 @@ func (c *cachingClient) List(_ context.Context, _ client.ObjectList, _ ...client } type mockScope struct { + // +optional scope.AWSNodeScope + // +optional client client.Client + // +optional cni ekscontrolplanev1.VpcCni + // +optional secondaryCidrBlock *string + // +optional securityGroups map[infrav1.SecurityGroupRole]infrav1.SecurityGroup + // +optional subnets infrav1.Subnets } diff --git a/pkg/cloud/services/awsnode/service.go b/pkg/cloud/services/awsnode/service.go index ddc8d52251..41950db79a 100644 --- a/pkg/cloud/services/awsnode/service.go +++ b/pkg/cloud/services/awsnode/service.go @@ -23,6 +23,7 @@ import ( // Service defines the spec for a service. type Service struct { + // +optional scope scope.AWSNodeScope } diff --git a/pkg/cloud/services/ec2/ami.go b/pkg/cloud/services/ec2/ami.go index aa657313d8..c53746ce62 100644 --- a/pkg/cloud/services/ec2/ami.go +++ b/pkg/cloud/services/ec2/ami.go @@ -99,7 +99,9 @@ const ( // AMILookup contains the parameters used to template AMI names used for lookup. type AMILookup struct { + // +optional BaseOS string + // +optional K8sVersion string } diff --git a/pkg/cloud/services/ec2/service.go b/pkg/cloud/services/ec2/service.go index fc237e1991..11beb767f6 100644 --- a/pkg/cloud/services/ec2/service.go +++ b/pkg/cloud/services/ec2/service.go @@ -28,15 +28,20 @@ import ( // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the ec2 client. type Service struct { + // +optional scope scope.EC2Scope + // +optional EC2Client common.EC2API + // +optional netService *network.Service // SSMClient is used to look up the official EKS AMI ID + // +optional SSMClient ssm.SSMAPI // RetryEC2Client is used for dedicated host operations with enhanced retry configuration // If nil, a new retry client will be created as needed + // +optional RetryEC2Client common.EC2API } diff --git a/pkg/cloud/services/eks/iam/iam.go b/pkg/cloud/services/eks/iam/iam.go index bf39dd228a..412ec5d8c4 100644 --- a/pkg/cloud/services/eks/iam/iam.go +++ b/pkg/cloud/services/eks/iam/iam.go @@ -48,8 +48,11 @@ const ( // IAMService defines the specs for an IAM service. type IAMService struct { + // +optional logger.Wrapper + // +optional IAMClient iamauth.IAMAPI + // +optional Client *http.Client } diff --git a/pkg/cloud/services/eks/service.go b/pkg/cloud/services/eks/service.go index 9d1ab00c7f..3c09c75c8f 100644 --- a/pkg/cloud/services/eks/service.go +++ b/pkg/cloud/services/eks/service.go @@ -78,6 +78,7 @@ type EKSAPI interface { // EKSClient is a wrapper over eks.Client for implementing custom methods of EKSAPI. type EKSClient struct { + // +optional *eks.Client } @@ -85,10 +86,15 @@ type EKSClient struct { // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the ec2 client. type Service struct { + // +optional scope *scope.ManagedControlPlaneScope + // +optional EC2Client common.EC2API + // +optional EKSClient EKSAPI + // +optional iam.IAMService + // +optional STSClient stsservice.STSClient } @@ -129,11 +135,17 @@ func NewService(controlPlaneScope *scope.ManagedControlPlaneScope, opts ...Servi // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the ec2 client. type NodegroupService struct { + // +optional scope *scope.ManagedMachinePoolScope + // +optional ASGService services.ASGInterface + // +optional AutoscalingClient *autoscaling.Client + // +optional EKSClient EKSAPI + // +optional iam.IAMService + // +optional STSClient stsservice.STSClient } @@ -156,9 +168,13 @@ func NewNodegroupService(machinePoolScope *scope.ManagedMachinePoolScope) *Nodeg // FargateService holds a collection of interfaces. // The interfaces are broken down like this to group functions together. type FargateService struct { + // +optional scope *scope.FargateProfileScope + // +optional EKSClient EKSAPI + // +optional iam.IAMService + // +optional STSClient stsservice.STSClient } diff --git a/pkg/cloud/services/elb/errors.go b/pkg/cloud/services/elb/errors.go index 60a04e43ba..0110b5993a 100644 --- a/pkg/cloud/services/elb/errors.go +++ b/pkg/cloud/services/elb/errors.go @@ -29,8 +29,10 @@ var _ error = &ELBError{} // ELBError is an error exposed to users of this library. type ELBError struct { + // +optional msg string + // +optional Code int } diff --git a/pkg/cloud/services/elb/service.go b/pkg/cloud/services/elb/service.go index e2847438a2..9128bee3cc 100644 --- a/pkg/cloud/services/elb/service.go +++ b/pkg/cloud/services/elb/service.go @@ -34,11 +34,17 @@ import ( // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the ec2 client. type Service struct { + // +optional scope scope.ELBScope + // +optional EC2Client common.EC2API + // +optional ELBClient ELBAPI + // +optional ELBV2Client ELBV2API + // +optional ResourceTaggingClient ResourceGroupsTaggingAPIAPI + // +optional netService *network.Service } @@ -102,16 +108,19 @@ type ResourceGroupsTaggingAPIAPI interface { // ELBClient is a wrapper over elb.Client for implementing custom methods of ELBAPI. type ELBClient struct { + // +optional *elb.Client } // ELBV2Client is a wrapper over elbv2.Client for implementing custom methods of ELBV2API. type ELBV2Client struct { + // +optional *elbv2.Client } // ResourceGroupsTaggingAPIClient is a wrapper over rgapi.Client for implementing custom methods of ResourceGroupsTaggingAPI. type ResourceGroupsTaggingAPIClient struct { + // +optional *rgapi.Client } diff --git a/pkg/cloud/services/gc/service.go b/pkg/cloud/services/gc/service.go index 7ac856d9ae..b0c337f525 100644 --- a/pkg/cloud/services/gc/service.go +++ b/pkg/cloud/services/gc/service.go @@ -30,12 +30,19 @@ import ( // Service is used to perform operations against a tenant/workload/child cluster. type Service struct { + // +optional scope cloud.ClusterScoper + // +optional elbClient elb.ELBAPI + // +optional elbv2Client elb.ELBV2API + // +optional resourceTaggingClient elb.ResourceGroupsTaggingAPIAPI + // +optional ec2Client common.EC2API + // +optional cleanupFuncs ResourceCleanupFuncs + // +optional collectFuncs ResourceCollectFuncs } @@ -90,7 +97,9 @@ func addAlternativeCollectFuncs(s *Service) { // AWSResource represents a resource in AWS. type AWSResource struct { + // +optional ARN *arn.ARN + // +optional Tags map[string]string } diff --git a/pkg/cloud/services/iamauth/configmap.go b/pkg/cloud/services/iamauth/configmap.go index 05810afb1e..534cdbb476 100644 --- a/pkg/cloud/services/iamauth/configmap.go +++ b/pkg/cloud/services/iamauth/configmap.go @@ -41,6 +41,7 @@ const ( ) type configMapBackend struct { + // +optional client crclient.Client } diff --git a/pkg/cloud/services/iamauth/crd.go b/pkg/cloud/services/iamauth/crd.go index cb2b3847f4..fc5c308595 100644 --- a/pkg/cloud/services/iamauth/crd.go +++ b/pkg/cloud/services/iamauth/crd.go @@ -29,6 +29,7 @@ import ( ) type crdBackend struct { + // +optional client crclient.Client } diff --git a/pkg/cloud/services/iamauth/service.go b/pkg/cloud/services/iamauth/service.go index cda3218ccf..a547ae282f 100644 --- a/pkg/cloud/services/iamauth/service.go +++ b/pkg/cloud/services/iamauth/service.go @@ -28,9 +28,13 @@ import ( // Service defines the specs for a service. type Service struct { + // +optional scope scope.IAMAuthScope + // +optional backend BackendType + // +optional client client.Client + // +optional IAMClient IAMAPI } diff --git a/pkg/cloud/services/instancestate/queue.go b/pkg/cloud/services/instancestate/queue.go index 20733a034c..f6e8df3c48 100644 --- a/pkg/cloud/services/instancestate/queue.go +++ b/pkg/cloud/services/instancestate/queue.go @@ -112,7 +112,10 @@ func queueNotFoundError(err error) bool { } type createPolicyForRuleInput struct { + // +optional QueueArn string + // +optional QueueURL string + // +optional RuleArn string } diff --git a/pkg/cloud/services/instancestate/rule.go b/pkg/cloud/services/instancestate/rule.go index 4b95ee42a4..bb14e9bd50 100644 --- a/pkg/cloud/services/instancestate/rule.go +++ b/pkg/cloud/services/instancestate/rule.go @@ -262,12 +262,17 @@ func resourceNotFoundError(err error) bool { } type eventPattern struct { + // +required Source []string `json:"source"` + // +optional DetailType []string `json:"detail-type,omitempty"` + // +optional EventDetail *eventDetail `json:"detail,omitempty"` } type eventDetail struct { + // +optional InstanceIDs []string `json:"instance-id,omitempty"` + // +optional States []infrav1.InstanceState `json:"state,omitempty"` } diff --git a/pkg/cloud/services/instancestate/service.go b/pkg/cloud/services/instancestate/service.go index 8b4d90c625..bc69f71eb6 100644 --- a/pkg/cloud/services/instancestate/service.go +++ b/pkg/cloud/services/instancestate/service.go @@ -28,8 +28,11 @@ import ( // Service defines the specs for a service. type Service struct { + // +optional scope scope.EC2Scope + // +optional EventBridgeClient EventBridgeAPI + // +optional SQSClient SQSAPI } diff --git a/pkg/cloud/services/kubeproxy/service.go b/pkg/cloud/services/kubeproxy/service.go index 17a4bd73af..a5853782e7 100644 --- a/pkg/cloud/services/kubeproxy/service.go +++ b/pkg/cloud/services/kubeproxy/service.go @@ -23,6 +23,7 @@ import ( // Service defines the spec for a service. type Service struct { + // +optional scope scope.KubeProxyScope } diff --git a/pkg/cloud/services/network/routetables_test.go b/pkg/cloud/services/network/routetables_test.go index 526ec1d537..e512fabb68 100644 --- a/pkg/cloud/services/network/routetables_test.go +++ b/pkg/cloud/services/network/routetables_test.go @@ -853,6 +853,7 @@ func TestDeleteRouteTable(t *testing.T) { } type routeTableInputMatcher struct { + // +optional routeTableInput *ec2.CreateRouteTableInput } diff --git a/pkg/cloud/services/network/service.go b/pkg/cloud/services/network/service.go index 0279221b53..affd7299ba 100644 --- a/pkg/cloud/services/network/service.go +++ b/pkg/cloud/services/network/service.go @@ -26,7 +26,9 @@ import ( // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the ec2 client. type Service struct { + // +optional scope scope.NetworkScope + // +optional EC2Client common.EC2API } diff --git a/pkg/cloud/services/network/subnets_test.go b/pkg/cloud/services/network/subnets_test.go index af10b34712..882e42edd5 100644 --- a/pkg/cloud/services/network/subnets_test.go +++ b/pkg/cloud/services/network/subnets_test.go @@ -4559,6 +4559,7 @@ func NewClusterScope() *ClusterScopeBuilder { } type ClusterScopeBuilder struct { + // +optional customizers []func(p *scope.ClusterScopeParams) } @@ -4608,6 +4609,7 @@ func NewManagedControlPlaneScope() *ManagedControlPlaneScopeBuilder { } type ManagedControlPlaneScopeBuilder struct { + // +optional customizers []func(p *scope.ManagedControlPlaneScopeParams) } diff --git a/pkg/cloud/services/s3/s3.go b/pkg/cloud/services/s3/s3.go index 6da0d7b433..e14f91c83d 100644 --- a/pkg/cloud/services/s3/s3.go +++ b/pkg/cloud/services/s3/s3.go @@ -50,9 +50,13 @@ const AWSDefaultRegion string = "us-east-1" // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the ec2 client. type Service struct { + // +optional scope scope.S3Scope + // +optional S3Client S3API + // +optional S3PresignClient *s3.PresignClient + // +optional STSClient stsservice.STSClient } diff --git a/pkg/cloud/services/s3/s3_test.go b/pkg/cloud/services/s3/s3_test.go index 0f4dbb2e78..73a5f573ba 100644 --- a/pkg/cloud/services/s3/s3_test.go +++ b/pkg/cloud/services/s3/s3_test.go @@ -885,7 +885,9 @@ func TestDeleteObject(t *testing.T) { } type testServiceInput struct { + // +optional Bucket *infrav1.S3Bucket + // +optional Region string } diff --git a/pkg/cloud/services/secretsmanager/service.go b/pkg/cloud/services/secretsmanager/service.go index 405e88f197..126e99a5a6 100644 --- a/pkg/cloud/services/secretsmanager/service.go +++ b/pkg/cloud/services/secretsmanager/service.go @@ -30,7 +30,9 @@ import ( // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the ec2 client. type Service struct { + // +optional scope cloud.ClusterScoper + // +optional SecretsManagerClient SecretsManagerAPI } diff --git a/pkg/cloud/services/securitygroup/service.go b/pkg/cloud/services/securitygroup/service.go index 860a55776c..f60f41bfb6 100644 --- a/pkg/cloud/services/securitygroup/service.go +++ b/pkg/cloud/services/securitygroup/service.go @@ -27,8 +27,11 @@ import ( // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the ec2 client. type Service struct { + // +optional scope scope.SGScope + // +optional roles []infrav1.SecurityGroupRole + // +optional EC2Client common.EC2API } diff --git a/pkg/cloud/services/ssm/secret_test.go b/pkg/cloud/services/ssm/secret_test.go index 0f15dc9f48..f8582c23b3 100644 --- a/pkg/cloud/services/ssm/secret_test.go +++ b/pkg/cloud/services/ssm/secret_test.go @@ -42,7 +42,9 @@ import ( ) type mockAPIError struct { + // +optional Code string + // +optional Message string } diff --git a/pkg/cloud/services/ssm/service.go b/pkg/cloud/services/ssm/service.go index ca8b729d9b..0105e902f6 100644 --- a/pkg/cloud/services/ssm/service.go +++ b/pkg/cloud/services/ssm/service.go @@ -29,7 +29,9 @@ import ( // The interfaces are broken down like this to group functions together. // One alternative is to have a large list of functions from the ec2 client. type Service struct { + // +optional scope cloud.ClusterScoper + // +optional SSMClient SSMAPI } diff --git a/pkg/cloud/services/sts/sts.go b/pkg/cloud/services/sts/sts.go index 7ab8e7b3f8..f0eaf69145 100644 --- a/pkg/cloud/services/sts/sts.go +++ b/pkg/cloud/services/sts/sts.go @@ -33,7 +33,9 @@ type STSClient interface { // ClientWrapper wraps both the regular STS client and presign client to implement STSClient interface. type ClientWrapper struct { + // +optional client *sts.Client + // +optional presignClient *sts.PresignClient } diff --git a/pkg/cloud/services/userdata/bastion.go b/pkg/cloud/services/userdata/bastion.go index 256a3b4985..909186390b 100644 --- a/pkg/cloud/services/userdata/bastion.go +++ b/pkg/cloud/services/userdata/bastion.go @@ -35,6 +35,7 @@ pip install --upgrade pip &> /dev/null // BastionInput defines the context to generate a bastion instance user data. type BastionInput struct { + // +optional baseUserData } diff --git a/pkg/cloud/services/userdata/files.go b/pkg/cloud/services/userdata/files.go index 723b5e383d..6f7d470d36 100644 --- a/pkg/cloud/services/userdata/files.go +++ b/pkg/cloud/services/userdata/files.go @@ -33,14 +33,18 @@ write_files:{{ range . }} // Files defines the input for generating write_files in cloud-init. type Files struct { // Path specifies the full path on disk where to store the file. + // +required Path string `json:"path"` // Owner specifies the ownership of the file, e.g. "root:root". + // +required Owner string `json:"owner"` // Permissions specifies the permissions to assign to the file, e.g. "0640". + // +required Permissions string `json:"permissions"` // Content is the actual content of the file. + // +required Content string `json:"content"` } diff --git a/pkg/cloud/services/userdata/userdata.go b/pkg/cloud/services/userdata/userdata.go index f7953b6b09..cadd94b2a2 100644 --- a/pkg/cloud/services/userdata/userdata.go +++ b/pkg/cloud/services/userdata/userdata.go @@ -49,7 +49,9 @@ set -o pipefail ) type baseUserData struct { + // +optional Header string + // +optional WriteFiles []Files } diff --git a/pkg/cloud/tags/tags.go b/pkg/cloud/tags/tags.go index 0b8b362d41..2ca9ed4b0b 100644 --- a/pkg/cloud/tags/tags.go +++ b/pkg/cloud/tags/tags.go @@ -56,7 +56,9 @@ type BuilderOption func(*Builder) // Builder is the interface for a tags builder. type Builder struct { + // +optional params *infrav1.BuildParams + // +optional applyFunc func(params *infrav1.BuildParams) error } diff --git a/pkg/cloud/throttle/throttle.go b/pkg/cloud/throttle/throttle.go index 1ee1e773ea..4ebd1dc209 100644 --- a/pkg/cloud/throttle/throttle.go +++ b/pkg/cloud/throttle/throttle.go @@ -42,10 +42,15 @@ func NewMultiOperationMatch(strs ...string) string { // OperationLimiter defines the specs of an operation limiter. type OperationLimiter struct { + // +optional Operation string + // +optional RefillRate rate.Limit + // +optional Burst int + // +optional regexp *regexp.Regexp + // +optional limiter *rate.Limiter } diff --git a/pkg/eks/addons/plan.go b/pkg/eks/addons/plan.go index 7df3ba6ced..7cc35e2adc 100644 --- a/pkg/eks/addons/plan.go +++ b/pkg/eks/addons/plan.go @@ -40,10 +40,15 @@ func NewPlan(clusterName string, desiredAddons, installedAddons []*EKSAddon, cli // Plan is a plan that will manage EKS addons. type plan struct { + // +optional installedAddons []*EKSAddon + // +optional desiredAddons []*EKSAddon + // +optional eksClient eks.Client + // +optional clusterName string + // +optional maxWaitActiveUpdateDelete time.Duration } diff --git a/pkg/eks/addons/procedures.go b/pkg/eks/addons/procedures.go index de1cff4af6..21f9faab44 100644 --- a/pkg/eks/addons/procedures.go +++ b/pkg/eks/addons/procedures.go @@ -40,8 +40,11 @@ var ( // DeleteAddonProcedure is a procedure that will delete an EKS addon. type DeleteAddonProcedure struct { + // +optional plan *plan + // +optional name string + // +optional preserve bool } @@ -67,7 +70,9 @@ func (p *DeleteAddonProcedure) Name() string { // UpdateAddonProcedure is a procedure that will update an EKS addon. type UpdateAddonProcedure struct { + // +optional plan *plan + // +optional name string } @@ -102,7 +107,9 @@ func (p *UpdateAddonProcedure) Name() string { // UpdateAddonTagsProcedure is a procedure that will update an EKS addon tags. type UpdateAddonTagsProcedure struct { + // +optional plan *plan + // +optional name string } @@ -137,7 +144,9 @@ func (p *UpdateAddonTagsProcedure) Name() string { // CreateAddonProcedure is a procedure that will create an EKS addon for a cluster. type CreateAddonProcedure struct { + // +optional plan *plan + // +optional name string } @@ -179,8 +188,11 @@ func (p *CreateAddonProcedure) Name() string { // to be active in a cluster. Abd optionally include the degraded state. // Note: addons may be degraded until there are worker nodes. type WaitAddonActiveProcedure struct { + // +optional plan *plan + // +optional name string + // +optional includeDegraded bool } @@ -221,7 +233,9 @@ func (p *WaitAddonActiveProcedure) Name() string { // WaitAddonDeleteProcedure is a procedure that will wait for an EKS addon // to be deleted from a cluster. type WaitAddonDeleteProcedure struct { + // +optional plan *plan + // +optional name string } diff --git a/pkg/eks/addons/types.go b/pkg/eks/addons/types.go index a4dacd8dda..e2cfb63520 100644 --- a/pkg/eks/addons/types.go +++ b/pkg/eks/addons/types.go @@ -24,14 +24,23 @@ import ( // EKSAddon represents an EKS addon. type EKSAddon struct { + // +optional Name *string + // +optional Version *string + // +optional ServiceAccountRoleARN *string + // +optional Configuration *string + // +optional Tags infrav1.Tags + // +optional ResolveConflict *string + // +optional Preserve bool + // +optional ARN *string + // +optional Status *string } diff --git a/pkg/eks/identityprovider/plan.go b/pkg/eks/identityprovider/plan.go index 39f7658111..daa8f61254 100644 --- a/pkg/eks/identityprovider/plan.go +++ b/pkg/eks/identityprovider/plan.go @@ -40,10 +40,15 @@ func NewPlan(clusterName string, currentIdentityProvider, desiredIdentityProvide // Plan is a plan that will manage EKS OIDC identity provider association. type plan struct { + // +optional currentIdentityProvider *OidcIdentityProviderConfig + // +optional desiredIdentityProvider *OidcIdentityProviderConfig + // +optional eksClient eks.Client + // +optional log logger.Wrapper + // +optional clusterName string } diff --git a/pkg/eks/identityprovider/procedures.go b/pkg/eks/identityprovider/procedures.go index ff88bcfb13..f747acb740 100644 --- a/pkg/eks/identityprovider/procedures.go +++ b/pkg/eks/identityprovider/procedures.go @@ -31,6 +31,7 @@ var oidcType = aws.String("oidc") // WaitIdentityProviderAssociatedProcedure waits for the identity provider to be associated. type WaitIdentityProviderAssociatedProcedure struct { + // +optional plan *plan } @@ -68,6 +69,7 @@ func (w *WaitIdentityProviderAssociatedProcedure) Do(ctx context.Context) error // DisassociateIdentityProviderConfig disassociates the identity provider. type DisassociateIdentityProviderConfig struct { + // +optional plan *plan } @@ -101,6 +103,7 @@ func (d *DisassociateIdentityProviderConfig) Do(ctx context.Context) error { // AssociateIdentityProviderProcedure associates the identity provider. type AssociateIdentityProviderProcedure struct { + // +optional plan *plan } @@ -140,6 +143,7 @@ func (a *AssociateIdentityProviderProcedure) Do(ctx context.Context) error { // UpdatedIdentityProviderTagsProcedure updates the tags for the identity provider. type UpdatedIdentityProviderTagsProcedure struct { + // +optional plan *plan } @@ -165,6 +169,7 @@ func (u *UpdatedIdentityProviderTagsProcedure) Do(ctx context.Context) error { // RemoveIdentityProviderTagsProcedure removes the tags from the identity provider. type RemoveIdentityProviderTagsProcedure struct { + // +optional plan *plan } diff --git a/pkg/eks/identityprovider/types.go b/pkg/eks/identityprovider/types.go index 940e8870e5..27759d45e0 100644 --- a/pkg/eks/identityprovider/types.go +++ b/pkg/eks/identityprovider/types.go @@ -26,16 +26,27 @@ import ( // identity provider configuration. To reconcile the config we are going to get the version from EKS and // AWSManagedControlPlane and will need to have one consistent version of string values from each API. type OidcIdentityProviderConfig struct { + // +optional ClientID string + // +optional GroupsClaim string + // +optional GroupsPrefix string + // +optional IdentityProviderConfigArn string + // +optional IdentityProviderConfigName string + // +optional IssuerURL string + // +optional RequiredClaims map[string]string + // +optional Status string + // +optional Tags infrav1.Tags + // +optional UsernameClaim string + // +optional UsernamePrefix string } diff --git a/pkg/internal/mime/mime.go b/pkg/internal/mime/mime.go index 6f15b29e16..9f8240a6d8 100644 --- a/pkg/internal/mime/mime.go +++ b/pkg/internal/mime/mime.go @@ -47,9 +47,13 @@ var ( ) type scriptVariables struct { + // +optional SecretPrefix string + // +optional Chunks int32 + // +optional Region string + // +optional Endpoint string } diff --git a/pkg/internal/rate/rate.go b/pkg/internal/rate/rate.go index 607f13f799..5d43fe4c9b 100644 --- a/pkg/internal/rate/rate.go +++ b/pkg/internal/rate/rate.go @@ -67,13 +67,19 @@ func Every(interval time.Duration) Limit { // // The methods AllowN, ReserveN, and WaitN consume n tokens. type Limiter struct { + // +optional mu sync.Mutex + // +optional limit Limit + // +optional burst int + // +optional tokens float64 // last is the last time the limiter's tokens field was updated + // +optional last time.Time // lastEvent is the latest time of a rate-limited event (past or future) + // +optional lastEvent time.Time } @@ -118,11 +124,16 @@ func (lim *Limiter) AllowN(now time.Time, n int) bool { // A Reservation holds information about events that are permitted by a Limiter to happen after a delay. // A Reservation may be canceled, which may enable the Limiter to permit additional events. type Reservation struct { + // +optional ok bool + // +optional lim *Limiter + // +optional tokens int + // +optional timeToAct time.Time // This is the Limit at reservation time, it can change later. + // +optional limit Limit } diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 0ee7b190c5..76897edbfd 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -48,7 +48,9 @@ type Wrapper interface { // Logger is a concrete logger using logr underneath. type Logger struct { + // +optional callStackHelper func() + // +optional logger logr.Logger } diff --git a/pkg/rosa/externalauthproviders.go b/pkg/rosa/externalauthproviders.go index 04573ff392..562d33c89e 100644 --- a/pkg/rosa/externalauthproviders.go +++ b/pkg/rosa/externalauthproviders.go @@ -13,6 +13,7 @@ import ( // ExternalAuthClient handles externalAuth operations. type ExternalAuthClient struct { + // +optional ocm *sdk.Connection } diff --git a/pkg/rosa/oauth.go b/pkg/rosa/oauth.go index 299dfb01d3..055fa42c24 100644 --- a/pkg/rosa/oauth.go +++ b/pkg/rosa/oauth.go @@ -16,7 +16,9 @@ import ( // TokenResponse contains the access token and the duration until it expires. type TokenResponse struct { + // +optional AccessToken string + // +optional ExpiresIn time.Duration } diff --git a/pkg/rosa/ocmclient.go b/pkg/rosa/ocmclient.go index d13292cb67..5cb56bdbcf 100644 --- a/pkg/rosa/ocmclient.go +++ b/pkg/rosa/ocmclient.go @@ -29,6 +29,7 @@ import ( ) type ocmclient struct { + // +optional ocmClient *ocm.Client } diff --git a/test/helpers/envtest.go b/test/helpers/envtest.go index 56030a879d..5d9dfe9692 100644 --- a/test/helpers/envtest.go +++ b/test/helpers/envtest.go @@ -89,22 +89,31 @@ func init() { } type webhookConfiguration struct { + // +optional tag string + // +optional relativeFilePath string } // TestEnvironmentConfiguration encapsulates the interim, mutable configuration of the Kubernetes local test environment. type TestEnvironmentConfiguration struct { + // +optional env *envtest.Environment + // +optional webhookConfigurations []webhookConfiguration } // TestEnvironment encapsulates a Kubernetes local test environment. type TestEnvironment struct { + // +optional manager.Manager + // +optional client.Client + // +optional Config *rest.Config + // +optional env *envtest.Environment + // +optional cancel context.CancelFunc } diff --git a/test/helpers/kubernetesversions/template.go b/test/helpers/kubernetesversions/template.go index aab1915763..abf879e3d6 100644 --- a/test/helpers/kubernetesversions/template.go +++ b/test/helpers/kubernetesversions/template.go @@ -49,21 +49,27 @@ var ( type GenerateCIArtifactsInjectedTemplateForDebianInput struct { //nolint:revive // ArtifactsDirectory is where conformance suite output will go. Defaults to _artifacts + // +optional ArtifactsDirectory string // SourceTemplate is an input YAML clusterctl template which is to have // the CI artifact script injection + // +optional SourceTemplate []byte // PlatformKustomization is an SMP (strategic-merge-style) patch for adding // platform specific kustomizations required for use with CI, such as // referencing a specific image + // +optional PlatformKustomization []byte // KubeadmConfigTemplateName is the name of the KubeadmConfigTemplate resource // that needs to have the Debian install script injected. Defaults to "${CLUSTER_NAME}-md-0". + // +optional KubeadmConfigTemplateName string // KubeadmControlPlaneName is the name of the KubeadmControlPlane resource // that needs to have the Debian install script injected. Defaults to "${CLUSTER_NAME}-control-plane". + // +optional KubeadmControlPlaneName string // KubeadmConfigName is the name of a KubeadmConfig that needs kustomizing. To be used in conjunction with MachinePools. Optional. + // +optional KubeadmConfigName string } @@ -140,8 +146,11 @@ func GenerateCIArtifactsInjectedTemplateForDebian(input GenerateCIArtifactsInjec } type jsonPatch struct { + // +required Op string `json:"op"` + // +required Path string `json:"path"` + // +required Value interface{} `json:"value"` } diff --git a/test/helpers/matchers.go b/test/helpers/matchers.go index 1aa0d799a5..81332cd51c 100644 --- a/test/helpers/matchers.go +++ b/test/helpers/matchers.go @@ -38,7 +38,9 @@ func PartialMatchCreateTargetGroupInput(t *testing.T, i *elbv2.CreateTargetGroup // CreateTargetGroupInput expected value. // In particular, the TargetGroupName expected value is used as a prefix, in order to support generated names. type createTargetGroupInputPartialMatcher struct { + // +optional in *elbv2.CreateTargetGroupInput + // +optional t *testing.T } diff --git a/version/version.go b/version/version.go index 0d50180f87..4bd10b2d3b 100644 --- a/version/version.go +++ b/version/version.go @@ -35,15 +35,25 @@ var ( // Info defines the version. type Info struct { + // +optional Major string `json:"major,omitempty"` + // +optional Minor string `json:"minor,omitempty"` + // +optional GitVersion string `json:"gitVersion,omitempty"` + // +optional GitCommit string `json:"gitCommit,omitempty"` + // +optional GitTreeState string `json:"gitTreeState,omitempty"` + // +optional BuildDate string `json:"buildDate,omitempty"` + // +optional GoVersion string `json:"goVersion,omitempty"` + // +optional AwsSdkVersion string `json:"awsSdkVersion,omitempty"` + // +optional Compiler string `json:"compiler,omitempty"` + // +optional Platform string `json:"platform,omitempty"` }