From 2efa13670ad9b508345c0be021e913d4af828ee3 Mon Sep 17 00:00:00 2001 From: Jesten Herrild Date: Mon, 18 Mar 2024 14:50:54 -0700 Subject: [PATCH] Added new fields for cluster access. --- internal/models/ekscluster/access_entry.go | 49 +++++++++++++++++++ .../models/ekscluster/authentication_mode.go | 38 ++++++++++++++ .../models/ekscluster/control_plane_config.go | 3 ++ internal/models/ekscluster/spec.go | 3 ++ 4 files changed, 93 insertions(+) create mode 100644 internal/models/ekscluster/access_entry.go create mode 100644 internal/models/ekscluster/authentication_mode.go diff --git a/internal/models/ekscluster/access_entry.go b/internal/models/ekscluster/access_entry.go new file mode 100644 index 000000000..b4470511b --- /dev/null +++ b/internal/models/ekscluster/access_entry.go @@ -0,0 +1,49 @@ +/* +Copyright 2022 VMware, Inc. All Rights Reserved. +SPDX-License-Identifier: MPL-2.0 +*/ + +package models + +import ( + "github.com/go-openapi/swag" +) + +// VmwareTanzuManageV1alpha1EksclusterAccessEntry EKS cluster IAM Access Entry. +// +// swagger:model vmware.tanzu.manage.v1alpha1.ekscluster.AccessEntry +type VmwareTanzuManageV1alpha1EksclusterAccessEntry struct { + + // The AccessEntry will be primary if the value is set to true. + IsPrimary bool `json:"isPrimary,omitempty"` + + // The user name to which the access entry is associated. + UserName string `json:"userName,omitempty"` + + // The group names to which the access entry is associated. + GroupNames []string `json:"groupNames,omitempty"` + + // Tags applied to AccessEntry. + Tags map[string]string `json:"tags,omitempty"` +} + +// MarshalBinary interface implementation. +func (m *VmwareTanzuManageV1alpha1EksclusterAccessEntry) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation. +func (m *VmwareTanzuManageV1alpha1EksclusterAccessEntry) UnmarshalBinary(b []byte) error { + var res VmwareTanzuManageV1alpha1EksclusterAccessEntry + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + + *m = res + + return nil +} diff --git a/internal/models/ekscluster/authentication_mode.go b/internal/models/ekscluster/authentication_mode.go new file mode 100644 index 000000000..cce874f7f --- /dev/null +++ b/internal/models/ekscluster/authentication_mode.go @@ -0,0 +1,38 @@ +/* +Copyright 2024 VMware, Inc. All Rights Reserved. +SPDX-License-Identifier: MPL-2.0 +*/ + +package models + +const () + +// VmwareTanzuManageV1alpha1EksclusterAuthenticationMode The EKS authentication mode. +// +// - API: Controlled only by API. +// - API_AND_CONFIG_MAP: Controlled by API and by config map. +// - CONFIG_MAP: Controlled only by config map. +// +// swagger:model vmware.tanzu.manage.v1alpha1.ekscluster.AuthenticationMode +type VmwareTanzuManageV1alpha1EksclusterAuthenticationMode string + +func NewVmwareTanzuManageV1alpha1EksAuthenticationMode(value VmwareTanzuManageV1alpha1EksclusterPhase) *VmwareTanzuManageV1alpha1EksclusterPhase { + return &value +} + +// Pointer returns a pointer to a freshly-allocated VmwareTanzuManageV1alpha1EksclusterAuthenticationMode. +func (m VmwareTanzuManageV1alpha1EksclusterAuthenticationMode) Pointer() *VmwareTanzuManageV1alpha1EksclusterAuthenticationMode { + return &m +} + +const ( + + // VmwareTanzuManageV1alpha1EksclusterAuthenticationModeAPI captures enum value "API". + VmwareTanzuManageV1alpha1EksclusterAuthenticationModeAPI VmwareTanzuManageV1alpha1EksclusterPhase = "API" + + // VmwareTanzuManageV1alpha1EksclusterAuthenticationModeAPIANDCONFIGMAP captures enum value "API_AND_CONFIG_MAP". + VmwareTanzuManageV1alpha1EksclusterAuthenticationModeAPIANDCONFIGMAP VmwareTanzuManageV1alpha1EksclusterPhase = "API_AND_CONFIG_MAP" + + // VmwareTanzuManageV1alpha1EksclusterAuthenticationModeCONFIGMAP captures enum value "CONFIG_MAP". + VmwareTanzuManageV1alpha1EksclusterAuthenticationModeCONFIGMAP VmwareTanzuManageV1alpha1EksclusterPhase = "CONFIG_MAP" +) diff --git a/internal/models/ekscluster/control_plane_config.go b/internal/models/ekscluster/control_plane_config.go index 59e8eeb02..5e5d92ea6 100644 --- a/internal/models/ekscluster/control_plane_config.go +++ b/internal/models/ekscluster/control_plane_config.go @@ -34,6 +34,9 @@ type VmwareTanzuManageV1alpha1EksclusterControlPlaneConfig struct { // EKS addons configuration. AddonsConfig *VmwareTanzuManageV1alpha1EksclusterAddonsConfig `json:"addonsConfig,omitempty"` + + // Authentication mode for the cluster. + AuthenticationMode VmwareTanzuManageV1alpha1EksclusterAuthenticationMode `json:"authenticationMode,omitempty"` } // MarshalBinary interface implementation. diff --git a/internal/models/ekscluster/spec.go b/internal/models/ekscluster/spec.go index c8d6aa31c..566ae0254 100644 --- a/internal/models/ekscluster/spec.go +++ b/internal/models/ekscluster/spec.go @@ -34,6 +34,9 @@ type VmwareTanzuManageV1alpha1EksclusterSpec struct { // Arn of the cluster. Arn string `json:"arn,omitempty"` + + // Authentication entries for AWS + IAMAccessEntries []VmwareTanzuManageV1alpha1EksclusterAccessEntry `json:"iamAccessEntries,omitempty"` } // MarshalBinary interface implementation