Skip to content

Commit 2d45d45

Browse files
committed
also set the groupname for a bootstrap user by default if it is empty
1 parent 5b0528a commit 2d45d45

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

cmd/clusterawsadm/api/bootstrap/v1beta1/defaults.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20-
runtime "k8s.io/apimachinery/pkg/runtime"
20+
"k8s.io/apimachinery/pkg/runtime"
2121
"k8s.io/utils/pointer"
2222

2323
infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
@@ -27,6 +27,8 @@ import (
2727
const (
2828
// DefaultBootstrapUserName is the default bootstrap user name.
2929
DefaultBootstrapUserName = "bootstrapper.cluster-api-provider-aws.sigs.k8s.io"
30+
// DefaultBootstrapGroupName is the default bootstrap user name.
31+
DefaultBootstrapGroupName = "bootstrapper.cluster-api-provider-aws.sigs.k8s.io"
3032
// DefaultStackName is the default CloudFormation stack name.
3133
DefaultStackName = "cluster-api-provider-aws-sigs-k8s-io"
3234
// DefaultPartitionName is the default security partition for AWS ARNs.
@@ -43,8 +45,13 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
4345

4446
// SetDefaults_BootstrapUser is used by defaulter-gen.
4547
func SetDefaults_BootstrapUser(obj *BootstrapUser) { //nolint:golint,stylecheck
46-
if obj != nil && obj.UserName == "" {
47-
obj.UserName = DefaultBootstrapUserName
48+
if obj != nil {
49+
if obj.UserName == "" {
50+
obj.UserName = DefaultBootstrapUserName
51+
}
52+
if obj.GroupName == "" {
53+
obj.GroupName = DefaultBootstrapGroupName
54+
}
4855
}
4956
}
5057

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_bootstrap_user.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
AWSTemplateFormatVersion: 2010-09-09
22
Resources:
33
AWSIAMGroupBootstrapper:
4-
Properties: {}
4+
Properties:
5+
GroupName: bootstrapper.cluster-api-provider-aws.sigs.k8s.io
56
Type: AWS::IAM::Group
67
AWSIAMInstanceProfileControlPlane:
78
Properties:

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_custom_bootstrap_user.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
AWSTemplateFormatVersion: 2010-09-09
22
Resources:
33
AWSIAMGroupBootstrapper:
4-
Properties: {}
4+
Properties:
5+
GroupName: bootstrapper.cluster-api-provider-aws.sigs.k8s.io
56
Type: AWS::IAM::Group
67
AWSIAMInstanceProfileControlPlane:
78
Properties:

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_extra_statements.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
AWSTemplateFormatVersion: 2010-09-09
22
Resources:
33
AWSIAMGroupBootstrapper:
4-
Properties: {}
4+
Properties:
5+
GroupName: bootstrapper.cluster-api-provider-aws.sigs.k8s.io
56
Type: AWS::IAM::Group
67
AWSIAMInstanceProfileControlPlane:
78
Properties:

0 commit comments

Comments
 (0)