Skip to content

Commit cbbd8ab

Browse files
committed
remove the flag control (api errors are sufficient)
1 parent a038a4d commit cbbd8ab

File tree

3 files changed

+0
-67
lines changed

3 files changed

+0
-67
lines changed

internal/cmd/beta/security-group/rule/create/create.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -163,28 +163,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
163163
ProtocolName: flags.FlagToStringPointer(p, cmd, protocolNameFlag),
164164
}
165165

166-
if model.ProtocolName != nil {
167-
if *model.ProtocolName == "icmp" || *model.ProtocolName == "ipv6-icmp" {
168-
if model.PortRangeMin != nil || model.PortRangeMax != nil {
169-
return nil, &cliErr.SecurityGroupRuleProtocolPortRangeConflictError{
170-
Cmd: cmd,
171-
}
172-
}
173-
} else {
174-
if model.IcmpParameterCode != nil || model.IcmpParameterType != nil {
175-
return nil, &cliErr.SecurityGroupRuleProtocolParametersConflictError{
176-
Cmd: cmd,
177-
}
178-
}
179-
}
180-
}
181-
182-
if (model.PortRangeMin != nil || model.PortRangeMax != nil) && (model.ProtocolNumber == nil && model.ProtocolName == nil) {
183-
return nil, &cliErr.SecurityGroupRuleProtocolMissingForPortRangeError{
184-
Cmd: cmd,
185-
}
186-
}
187-
188166
if p.IsVerbosityDebug() {
189167
modelStr, err := print.BuildDebugStrFromInputModel(model)
190168
if err != nil {

internal/cmd/beta/security-group/rule/create/create_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,6 @@ func TestParseInput(t *testing.T) {
176176
}),
177177
isValid: false,
178178
},
179-
{
180-
description: "protocol is icmp and port range values are provided",
181-
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
182-
delete(flagValues, protocolNumberFlag)
183-
}),
184-
isValid: false,
185-
},
186179
{
187180
description: "protocol is not icmp and port range values are provided",
188181
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
@@ -199,14 +192,6 @@ func TestParseInput(t *testing.T) {
199192
model.ProtocolNumber = nil
200193
}),
201194
},
202-
{
203-
description: "protocol is not icmp and icmp parameters are provided",
204-
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
205-
flagValues[protocolNameFlag] = "not-icmp"
206-
delete(flagValues, protocolNumberFlag)
207-
}),
208-
isValid: false,
209-
},
210195
{
211196
description: "no values",
212197
flagValues: map[string]string{},

internal/pkg/errors/errors.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -147,41 +147,11 @@ To enable it, run:
147147

148148
IAAS_SERVER_MISSING_IMAGE_OR_VOLUME_FLAGS = `Either "image-id" or "boot-volume-source-type" and "boot-volume-source-id" flags must be provided.`
149149

150-
IAAS_SECURITY_GROUP_RULE_PROTOCOL_PORT_RANGE_CONFLICT = `"port-range-min" and "port-range-max" attributes can't be provided if "protocol-name" is set to "icmp" or "ipv6-icmp"`
151-
152-
IAAS_SECURITY_GROUP_RULE_PROTOCOL_PARAMETERS_CONFLICT = `"icmp-parameter-code" and "icmp-parameter-type" attributes can't be provided if "protocol-name" is not "icmp" or "ipv6-icmp"`
153-
154-
IAAS_SECURITY_GROUP_RULE_PROTOCOL_MISSING_FOR_PORT_RANGE = `"protocol-name" or "protocol-number" must be provided if "port-range-min" and "port-range-max" attributes are given`
155-
156150
IAAS_SERVER_NIC_ATTACH_MISSING_NIC_ID = `The "network-interface-id" flag must be provided if the "create" flag is not provided.`
157151

158152
IAAS_SERVER_NIC_DETACH_MISSING_NIC_ID = `The "network-interface-id" flag must be provided if the "delete" flag is not provided.`
159153
)
160154

161-
type SecurityGroupRuleProtocolMissingForPortRangeError struct {
162-
Cmd *cobra.Command
163-
}
164-
165-
func (e *SecurityGroupRuleProtocolMissingForPortRangeError) Error() string {
166-
return IAAS_SECURITY_GROUP_RULE_PROTOCOL_MISSING_FOR_PORT_RANGE
167-
}
168-
169-
type SecurityGroupRuleProtocolParametersConflictError struct {
170-
Cmd *cobra.Command
171-
}
172-
173-
func (e *SecurityGroupRuleProtocolParametersConflictError) Error() string {
174-
return IAAS_SECURITY_GROUP_RULE_PROTOCOL_PARAMETERS_CONFLICT
175-
}
176-
177-
type SecurityGroupRuleProtocolPortRangeConflictError struct {
178-
Cmd *cobra.Command
179-
}
180-
181-
func (e *SecurityGroupRuleProtocolPortRangeConflictError) Error() string {
182-
return IAAS_SECURITY_GROUP_RULE_PROTOCOL_PORT_RANGE_CONFLICT
183-
}
184-
185155
type ServerNicAttachMissingNicIdError struct {
186156
Cmd *cobra.Command
187157
}

0 commit comments

Comments
 (0)