Skip to content

Commit 768e064

Browse files
authored
Cluster command nit fixes (#2306)
1 parent d21d50d commit 768e064

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

pkg/lib/configreader/errors.go

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const (
3535
ErrLeadingWhitespace = "configreader.leading_whitespace"
3636
ErrTrailingWhitespace = "configreader.trailing_whitespace"
3737
ErrAlphaNumericDashUnderscore = "configreader.alpha_numeric_dash_underscore"
38+
ErrAlphaNumericDash = "configreader.alpha_numeric_dash"
3839
ErrAlphaNumericDotUnderscore = "configreader.alpha_numeric_dot_underscore"
3940
ErrAlphaNumericDashDotUnderscore = "configreader.alpha_numeric_dash_dot_underscore"
4041
ErrInvalidAWSTag = "configreader.invalid_aws_tag"
@@ -140,6 +141,13 @@ func ErrorAlphaNumericDashUnderscore(provided string) error {
140141
})
141142
}
142143

144+
func ErrorAlphaNumericDash(provided string) error {
145+
return errors.WithStack(&errors.Error{
146+
Kind: ErrAlphaNumericDash,
147+
Message: fmt.Sprintf("%s must contain only letters, numbers, and dashes", s.UserStr(provided)),
148+
})
149+
}
150+
143151
func ErrorAlphaNumericDotUnderscore(provided string) error {
144152
return errors.WithStack(&errors.Error{
145153
Kind: ErrAlphaNumericDotUnderscore,

pkg/lib/configreader/string.go

+7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type StringValidation struct {
5454
AlphaNumericDashUnderscoreOrEmpty bool
5555
AlphaNumericDashUnderscore bool
5656
AlphaNumericDotUnderscore bool
57+
AlphaNumericDash bool
5758
AWSTag bool
5859
DNS1035 bool
5960
DNS1123 bool
@@ -334,6 +335,12 @@ func ValidateStringVal(val string, v *StringValidation) error {
334335
}
335336
}
336337

338+
if v.AlphaNumericDash {
339+
if !regex.IsAlphaNumericDash(val) {
340+
return ErrorAlphaNumericDash(val)
341+
}
342+
}
343+
337344
if v.AlphaNumericDashUnderscoreOrEmpty {
338345
if !regex.IsAlphaNumericDashUnderscore(val) && val != "" {
339346
return ErrorAlphaNumericDashUnderscore(val)

pkg/lib/regex/regex.go

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ func IsAlphaNumericDotUnderscore(s string) bool {
6767
return _alphaNumericDotUnderscoreRegex.MatchString(s)
6868
}
6969

70+
var _alphaNumericDashRegex = regexp.MustCompile(`^[a-zA-Z0-9\-]+$`)
71+
72+
func IsAlphaNumericDash(s string) bool {
73+
return _alphaNumericDashRegex.MatchString(s)
74+
}
75+
7076
// used the evaluated form of
7177
// https://github.com/docker/distribution/blob/3150937b9f2b1b5b096b2634d0e7c44d4a0f89fb/reference/regexp.go#L68-L70
7278
var _dockerValidImage = regexp.MustCompile(

pkg/types/clusterconfig/cluster_config.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,9 @@ var nodeGroupsFieldValidation *cr.StructValidation = &cr.StructValidation{
718718
{
719719
StructField: "Name",
720720
StringValidation: &cr.StringValidation{
721-
Required: true,
722-
AlphaNumericDashUnderscore: true,
723-
MaxLength: _maxNodeGroupLength,
721+
Required: true,
722+
AlphaNumericDash: true,
723+
MaxLength: _maxNodeGroupLength,
724724
},
725725
},
726726
{

pkg/types/clusterstate/clusterstate.go

+4
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,13 @@ func GetClusterState(stacks ClusterStacks) State {
142142
}
143143

144144
if slices.HasString([]string{
145+
cloudformation.StackStatusCreateInProgress,
145146
cloudformation.StackStatusCreateComplete,
147+
cloudformation.StackStatusUpdateInProgress,
146148
cloudformation.StackStatusUpdateComplete,
149+
cloudformation.StackStatusRollbackInProgress,
147150
cloudformation.StackStatusRollbackComplete,
151+
cloudformation.StackStatusUpdateRollbackInProgress,
148152
cloudformation.StackStatusUpdateRollbackComplete,
149153
}, controlPlaneStatus) {
150154
return StateClusterExists

0 commit comments

Comments
 (0)