Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(eks): Add accessConfig LateInit & Observation #2098

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading