Skip to content

Commit

Permalink
feat: remove protocol state function
Browse files Browse the repository at this point in the history
  • Loading branch information
yoogledev committed Nov 29, 2022
1 parent 04ebceb commit 33811bb
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions ncloud/resource_ncloud_access_control_group_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func resourceNcloudAccessControlGroupRule() *schema.Resource {
validation.StringMatch(regexp.MustCompile(`TCP|UDP|ICMP|\b([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-2])\b`), "only TCP, UDP, ICMP and 1-252 are valid values."),
validation.StringNotInSlice([]string{"1", "6", "17"}, false),
)),
StateFunc: ProtocolStateFunc,
},
"port_range": {
Type: schema.TypeString,
Expand Down Expand Up @@ -83,7 +82,6 @@ func resourceNcloudAccessControlGroupRule() *schema.Resource {
validation.StringMatch(regexp.MustCompile(`TCP|UDP|ICMP|\b([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-2])\b`), "only TCP, UDP, ICMP and 1-252 are valid values."),
validation.StringNotInSlice([]string{"1", "6", "17"}, false),
)),
StateFunc: ProtocolStateFunc,
},
"port_range": {
Type: schema.TypeString,
Expand Down Expand Up @@ -467,22 +465,3 @@ var allowedProtocolCodes = map[string]bool{
"UDP": true,
"ICMP": true,
}

var allowedProtocolNumbers = map[int]string{
6: "TCP",
17: "UDP",
1: "ICMP",
}

func ProtocolStateFunc(v interface{}) string {
switch v := v.(type) {
case string:
if number, err := strconv.Atoi(v); err == nil {
if code, ok := allowedProtocolNumbers[number]; ok {
return code
}
}
return v
}
return ""
}

0 comments on commit 33811bb

Please sign in to comment.