github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/builtin/providers/azurerm/network_security_rule.go (about)

     1  package azurerm
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  )
     7  
     8  func validateNetworkSecurityRuleProtocol(v interface{}, k string) (ws []string, errors []error) {
     9  	value := strings.ToLower(v.(string))
    10  	protocols := map[string]bool{
    11  		"tcp": true,
    12  		"udp": true,
    13  		"*":   true,
    14  	}
    15  
    16  	if !protocols[value] {
    17  		errors = append(errors, fmt.Errorf("Network Security Rule Protocol can only be Tcp, Udp or *"))
    18  	}
    19  	return
    20  }
    21  
    22  func validateNetworkSecurityRuleAccess(v interface{}, k string) (ws []string, errors []error) {
    23  	value := strings.ToLower(v.(string))
    24  	accessTypes := map[string]bool{
    25  		"allow": true,
    26  		"deny":  true,
    27  	}
    28  
    29  	if !accessTypes[value] {
    30  		errors = append(errors, fmt.Errorf("Network Security Rule Access can only be Allow or Deny"))
    31  	}
    32  	return
    33  }
    34  
    35  func validateNetworkSecurityRuleDirection(v interface{}, k string) (ws []string, errors []error) {
    36  	value := strings.ToLower(v.(string))
    37  	directions := map[string]bool{
    38  		"inbound":  true,
    39  		"outbound": true,
    40  	}
    41  
    42  	if !directions[value] {
    43  		errors = append(errors, fmt.Errorf("Network Security Rule Directions can only be Inbound or Outbound"))
    44  	}
    45  	return
    46  }