Skip to content

Commit

Permalink
Merge pull request #2098 from simwak/feat/eks-acessconfig-lateinit-ob…
Browse files Browse the repository at this point in the history
…servation

feat(eks): Add accessConfig LateInit & Observation
  • Loading branch information
MisterMX authored Oct 4, 2024
2 parents bb2b23e + 7040ad2 commit b94bc2b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
9 changes: 9 additions & 0 deletions apis/eks/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ type ClusterObservation struct {
// in the Amazon EKS User Guide.
ResourcesVpcConfig VpcConfigResponse `json:"resourcesVpcConfig,omitempty"`

// The access configuration for the cluster.
AccessConfig AccessConfigResponse `json:"accessConfig,omitempty"`

// The current status of the cluster.
Status ClusterStatusType `json:"status,omitempty"`
}
Expand Down Expand Up @@ -464,6 +467,12 @@ type VpcConfigResponse struct {
VpcID string `json:"vpcId,omitempty"`
}

// AccessConfigResponse is the observed access configuration for a cluster.
type AccessConfigResponse struct {
// The authentication mode used for the cluster.
AuthenticationMode AuthenticationMode `json:"authenticationMode,omitempty"`
}

// A ClusterSpec defines the desired state of an EKS Cluster.
type ClusterSpec struct {
xpv1.ResourceSpec `json:",inline"`
Expand Down
16 changes: 16 additions & 0 deletions apis/eks/v1beta1/zz_generated.deepcopy.go

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

7 changes: 7 additions & 0 deletions package/crds/eks.aws.crossplane.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,13 @@ spec:
atProvider:
description: ClusterObservation is the observed state of a cluster.
properties:
accessConfig:
description: The access configuration for the cluster.
properties:
authenticationMode:
description: The authentication mode used for the cluster.
type: string
type: object
arn:
description: The Amazon Resource Name (ARN) of the cluster.
type: string
Expand Down
18 changes: 15 additions & 3 deletions pkg/clients/eks/eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
"k8s.io/utils/ptr"

"github.com/crossplane-contrib/provider-aws/apis/eks/v1beta1"
"github.com/crossplane-contrib/provider-aws/pkg/utils/jsonpatch"
Expand Down Expand Up @@ -294,6 +293,12 @@ func GenerateObservation(cluster *ekstypes.Cluster) v1beta1.ClusterObservation {
}
}

if cluster.AccessConfig != nil {
o.AccessConfig = v1beta1.AccessConfigResponse{
AuthenticationMode: v1beta1.AuthenticationMode(cluster.AccessConfig.AuthenticationMode),
}
}

if cluster.CertificateAuthority != nil {
o.CertificateAuthorityData = pointer.StringValue(cluster.CertificateAuthority.Data)
}
Expand Down Expand Up @@ -361,8 +366,15 @@ func LateInitialize(in *v1beta1.ClusterParameters, cluster *ekstypes.Cluster) {
}
}
if cluster.AccessConfig != nil {
in.AccessConfig = &v1beta1.AccessConfig{
AuthenticationMode: ptr.To(v1beta1.AuthenticationMode(string(cluster.AccessConfig.AuthenticationMode))),
currentAuthenticationMode := v1beta1.AuthenticationMode(cluster.AccessConfig.AuthenticationMode)
if in.AccessConfig == nil {
in.AccessConfig = &v1beta1.AccessConfig{
AuthenticationMode: &currentAuthenticationMode,
}
} else {
in.AccessConfig = &v1beta1.AccessConfig{
AuthenticationMode: pointer.LateInitialize(in.AccessConfig.AuthenticationMode, &currentAuthenticationMode),
}
}
}

Expand Down

0 comments on commit b94bc2b

Please sign in to comment.