Skip to content

Commit

Permalink
Fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1999 committed Mar 4, 2024
1 parent a572d44 commit 07f965f
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion config/crd/bases/anywhere.eks.amazonaws.com_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ spec:
apiServerExtraArgs:
additionalProperties:
type: string
description: ApiServerExtraArgs defines the flags to configure
description: APIServerExtraArgs defines the flags to configure
for the API server.
type: object
certSans:
Expand Down
2 changes: 1 addition & 1 deletion config/manifest/eksa-components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3857,7 +3857,7 @@ spec:
apiServerExtraArgs:
additionalProperties:
type: string
description: ApiServerExtraArgs defines the flags to configure
description: APIServerExtraArgs defines the flags to configure
for the API server.
type: object
certSans:
Expand Down
16 changes: 9 additions & 7 deletions internal/pkg/api/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,21 @@ func WithControlPlaneLabel(key string, val string) ClusterFiller {
}
}

func WithControlPlaneApiServerExtraArgs(key string, val string) ClusterFiller {
// WithControlPlaneAPIServerExtraArgs adds the APIServerExtraArgs to the cluster spec.
func WithControlPlaneAPIServerExtraArgs(key string, val string) ClusterFiller {
return func(c *anywherev1.Cluster) {
if c.Spec.ControlPlaneConfiguration.ApiServerExtraArgs == nil {
c.Spec.ControlPlaneConfiguration.ApiServerExtraArgs = map[string]string{}
if c.Spec.ControlPlaneConfiguration.APIServerExtraArgs == nil {
c.Spec.ControlPlaneConfiguration.APIServerExtraArgs = map[string]string{}
}
c.Spec.ControlPlaneConfiguration.ApiServerExtraArgs[key] = val
c.Spec.ControlPlaneConfiguration.APIServerExtraArgs[key] = val
}
}

func RemoveAllApiServerExtraArgs() ClusterFiller {
// RemoveAllAPIServerExtraArgs removes all the API server flags from the cluster spec.
func RemoveAllAPIServerExtraArgs() ClusterFiller {
return func(c *anywherev1.Cluster) {
for k := range c.Spec.ControlPlaneConfiguration.ApiServerExtraArgs {
delete(c.Spec.ControlPlaneConfiguration.ApiServerExtraArgs, k)
for k := range c.Spec.ControlPlaneConfiguration.APIServerExtraArgs {
delete(c.Spec.ControlPlaneConfiguration.APIServerExtraArgs, k)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/v1alpha1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ var clusterConfigValidations = []func(*Cluster) error{
validatePackageControllerConfiguration,
validateEksaVersion,
validateControlPlaneCertSANs,
validateControlPlaneApiServerExtraArgs,
validateControlPlaneAPIServerExtraArgs,
}

// GetClusterConfig parses a Cluster object from a multiobject yaml file in disk
Expand Down Expand Up @@ -495,11 +495,11 @@ func validateControlPlaneCertSANs(cfg *Cluster) error {
return nil
}

func validateControlPlaneApiServerExtraArgs(clusterConfig *Cluster) error {
func validateControlPlaneAPIServerExtraArgs(clusterConfig *Cluster) error {
allowedFlags := map[string]string{"service-account-issuer": "", "service-account-jwks-uri": ""}
for k := range clusterConfig.Spec.ControlPlaneConfiguration.ApiServerExtraArgs {
for k := range clusterConfig.Spec.ControlPlaneConfiguration.APIServerExtraArgs {
if _, ok := allowedFlags[k]; !ok {
return fmt.Errorf("invalid ControlPlaneConfiguration.ApiServerExtraArgs; only 'service-account-issuer' and 'service-account-jwks-uri' flags are accepted currently")
return fmt.Errorf("invalid ControlPlaneConfiguration.APIServerExtraArgs; only 'service-account-issuer' and 'service-account-jwks-uri' flags are accepted currently")
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1alpha1/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ func TestGetAndValidateClusterConfig(t *testing.T) {
Kind: VSphereMachineConfigKind,
Name: "eksa-unit-test",
},
ApiServerExtraArgs: map[string]string{
APIServerExtraArgs: map[string]string{
"service-account-issuer": "https://test-issuer-url",
"service-account-jwks-uri": "https://test-issuer-url/openid/v1/jwks",
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ type ControlPlaneConfiguration struct {
CertSANs []string `json:"certSans,omitempty"`
// MachineHealthCheck is a control-plane level override for the timeouts and maxUnhealthy specified in the top-level MHC configuration. If not configured, the defaults in the top-level MHC configuration are used.
MachineHealthCheck *MachineHealthCheck `json:"machineHealthCheck,omitempty"`
// ApiServerExtraArgs defines the flags to configure for the API server.
ApiServerExtraArgs map[string]string `json:"apiServerExtraArgs,omitempty"`
// APIServerExtraArgs defines the flags to configure for the API server.
APIServerExtraArgs map[string]string `json:"apiServerExtraArgs,omitempty"`
}

// MachineHealthCheck allows to configure timeouts for machine health checks. Machine Health Checks are responsible for remediating unhealthy Machines.
Expand Down Expand Up @@ -365,7 +365,7 @@ func (n *ControlPlaneConfiguration) Equal(o *ControlPlaneConfiguration) bool {
}
return n.Count == o.Count && n.MachineGroupRef.Equal(o.MachineGroupRef) &&
TaintsSliceEqual(n.Taints, o.Taints) && MapEqual(n.Labels, o.Labels) &&
SliceEqual(n.CertSANs, o.CertSANs) && MapEqual(n.ApiServerExtraArgs, o.ApiServerExtraArgs)
SliceEqual(n.CertSANs, o.CertSANs) && MapEqual(n.APIServerExtraArgs, o.APIServerExtraArgs)
}

type Endpoint struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 2 additions & 1 deletion pkg/clusterapi/extraargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func EtcdEncryptionExtraArgs(config *[]v1alpha1.EtcdEncryption) ExtraArgs {
return args
}

func ApiServerExtraArgs(apiServerExtraArgs map[string]string) ExtraArgs {
// APIServerExtraArgs takes a map of API Server extra args and returns the relevant API server extra args if it's not nil or empty.
func APIServerExtraArgs(apiServerExtraArgs map[string]string) ExtraArgs {
args := ExtraArgs{}
for k, v := range apiServerExtraArgs {
args.AddIfNotEmpty(k, v)
Expand Down
2 changes: 1 addition & 1 deletion pkg/clusterapi/extraargs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestApiServerExtraArgs(t *testing.T) {

for _, tt := range tests {
t.Run(tt.testName, func(t *testing.T) {
if got := clusterapi.ApiServerExtraArgs(tt.apiServerExtraArgs); !reflect.DeepEqual(got, tt.want) {
if got := clusterapi.APIServerExtraArgs(tt.apiServerExtraArgs); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ApiServerExtraArgs() = %v, want %v", got, tt.want)
}
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/cloudstack/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func buildTemplateMapCP(clusterSpec *cluster.Spec) (map[string]interface{}, erro
Append(clusterapi.AwsIamAuthExtraArgs(clusterSpec.AWSIamConfig)).
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig)).
Append(clusterapi.EtcdEncryptionExtraArgs(clusterSpec.Cluster.Spec.EtcdEncryption)).
Append(clusterapi.ApiServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.ApiServerExtraArgs)).
Append(clusterapi.APIServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.APIServerExtraArgs)).
Append(sharedExtraArgs)

controllerManagerExtraArgs := clusterapi.SecureTlsCipherSuitesExtraArgs().
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func buildTemplateMapCP(clusterSpec *cluster.Spec) (map[string]interface{}, erro
apiServerExtraArgs := clusterapi.OIDCToExtraArgs(clusterSpec.OIDCConfig).
Append(clusterapi.AwsIamAuthExtraArgs(clusterSpec.AWSIamConfig)).
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig)).
Append(clusterapi.ApiServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.ApiServerExtraArgs)).
Append(clusterapi.APIServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.APIServerExtraArgs)).
Append(sharedExtraArgs)
controllerManagerExtraArgs := clusterapi.SecureTlsCipherSuitesExtraArgs().
Append(clusterapi.NodeCIDRMaskExtraArgs(&clusterSpec.Cluster.Spec.ClusterNetwork))
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/nutanix/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func buildTemplateMapCP(
Append(clusterapi.AwsIamAuthExtraArgs(clusterSpec.AWSIamConfig)).
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig)).
Append(clusterapi.EtcdEncryptionExtraArgs(clusterSpec.Cluster.Spec.EtcdEncryption)).
Append(clusterapi.ApiServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.ApiServerExtraArgs))
Append(clusterapi.APIServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.APIServerExtraArgs))
kubeletExtraArgs := clusterapi.SecureTlsCipherSuitesExtraArgs().
Append(clusterapi.ResolvConfExtraArgs(clusterSpec.Cluster.Spec.ClusterNetwork.DNS.ResolvConf)).
Append(clusterapi.ControlPlaneNodeLabelsExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration))
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/tinkerbell/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func buildTemplateMapCP(
apiServerExtraArgs := clusterapi.OIDCToExtraArgs(clusterSpec.OIDCConfig).
Append(clusterapi.AwsIamAuthExtraArgs(clusterSpec.AWSIamConfig)).
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig)).
Append(clusterapi.ApiServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.ApiServerExtraArgs))
Append(clusterapi.APIServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.APIServerExtraArgs))

kubeletExtraArgs := clusterapi.SecureTlsCipherSuitesExtraArgs().
Append(clusterapi.ResolvConfExtraArgs(clusterSpec.Cluster.Spec.ClusterNetwork.DNS.ResolvConf)).
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/vsphere/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func buildTemplateMapCP(
Append(clusterapi.AwsIamAuthExtraArgs(clusterSpec.AWSIamConfig)).
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig)).
Append(clusterapi.EtcdEncryptionExtraArgs(clusterSpec.Cluster.Spec.EtcdEncryption)).
Append(clusterapi.ApiServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.ApiServerExtraArgs)).
Append(clusterapi.APIServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.APIServerExtraArgs)).
Append(sharedExtraArgs)
controllerManagerExtraArgs := clusterapi.SecureTlsCipherSuitesExtraArgs().
Append(clusterapi.NodeCIDRMaskExtraArgs(&clusterSpec.Cluster.Spec.ClusterNetwork))
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/cloudstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func TestCloudStackKubernetes129RedHat8ApiServerExtraArgsSimpleFlow(t *testing.T
t,
framework.NewCloudStack(t, framework.WithCloudStackRedhat129()),
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube129)),
framework.WithClusterFiller(api.WithControlPlaneApiServerExtraArgs("service-account-issuer", "https://my-custom-issuer-url")),
framework.WithClusterFiller(api.WithControlPlaneApiServerExtraArgs("service-account-jwks-uri", "https://my-custom-issuer-url/openid/v1/jwks")),
framework.WithClusterFiller(api.WithControlPlaneAPIServerExtraArgs("service-account-issuer", "https://my-custom-issuer-url")),
framework.WithClusterFiller(api.WithControlPlaneAPIServerExtraArgs("service-account-jwks-uri", "https://my-custom-issuer-url/openid/v1/jwks")),
)
runSimpleFlow(test)
}
Expand All @@ -40,14 +40,14 @@ func TestCloudStackKubernetes129Redhat8ApiServerExtraArgsUpgradeFlow(t *testing.
addApiServerExtraArgsclusterOpts = append(
addApiServerExtraArgsclusterOpts,
framework.WithClusterUpgrade(
api.WithControlPlaneApiServerExtraArgs("service-account-issuer", "https://my-custom-issuer-url"),
api.WithControlPlaneApiServerExtraArgs("service-account-jwks-uri", "https://my-custom-issuer-url/openid/v1/jwks"),
api.WithControlPlaneAPIServerExtraArgs("service-account-issuer", "https://my-custom-issuer-url"),
api.WithControlPlaneAPIServerExtraArgs("service-account-jwks-uri", "https://my-custom-issuer-url/openid/v1/jwks"),
),
)
removeApiServerExtraArgsclusterOpts = append(
removeApiServerExtraArgsclusterOpts,
framework.WithClusterUpgrade(
api.RemoveAllApiServerExtraArgs(),
api.RemoveAllAPIServerExtraArgs(),
),
)
runApiServerExtraArgsUpgradeFlow(
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func TestVSphereKubernetes129BottlerocketApiServerExtraArgsSimpleFlow(t *testing
t,
framework.NewVSphere(t, framework.WithBottleRocket129()),
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube129)),
framework.WithClusterFiller(api.WithControlPlaneApiServerExtraArgs("service-account-issuer", "https://my-custom-issuer-url")),
framework.WithClusterFiller(api.WithControlPlaneApiServerExtraArgs("service-account-jwks-uri", "https://my-custom-issuer-url/openid/v1/jwks")),
framework.WithClusterFiller(api.WithControlPlaneAPIServerExtraArgs("service-account-issuer", "https://my-custom-issuer-url")),
framework.WithClusterFiller(api.WithControlPlaneAPIServerExtraArgs("service-account-jwks-uri", "https://my-custom-issuer-url/openid/v1/jwks")),
)
runSimpleFlow(test)
}
Expand All @@ -41,14 +41,14 @@ func TestVSphereKubernetes129BottlerocketApiServerExtraArgsUpgradeFlow(t *testin
addApiServerExtraArgsclusterOpts = append(
addApiServerExtraArgsclusterOpts,
framework.WithClusterUpgrade(
api.WithControlPlaneApiServerExtraArgs("service-account-issuer", "https://my-custom-issuer-url"),
api.WithControlPlaneApiServerExtraArgs("service-account-jwks-uri", "https://my-custom-issuer-url/openid/v1/jwks"),
api.WithControlPlaneAPIServerExtraArgs("service-account-issuer", "https://my-custom-issuer-url"),
api.WithControlPlaneAPIServerExtraArgs("service-account-jwks-uri", "https://my-custom-issuer-url/openid/v1/jwks"),
),
)
removeApiServerExtraArgsclusterOpts = append(
removeApiServerExtraArgsclusterOpts,
framework.WithClusterUpgrade(
api.RemoveAllApiServerExtraArgs(),
api.RemoveAllAPIServerExtraArgs(),
),
)
runApiServerExtraArgsUpgradeFlow(
Expand Down

0 comments on commit 07f965f

Please sign in to comment.