github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/alicloud/common.go (about)

     1  package alicloud
     2  
     3  import (
     4  	"github.com/denverdino/aliyungo/common"
     5  	"github.com/hashicorp/terraform/helper/schema"
     6  )
     7  
     8  type InstanceNetWork string
     9  
    10  const (
    11  	ClassicNet = InstanceNetWork("classic")
    12  	VpcNet     = InstanceNetWork("vpc")
    13  )
    14  
    15  const defaultTimeout = 120
    16  
    17  func getRegion(d *schema.ResourceData, meta interface{}) common.Region {
    18  	return meta.(*AliyunClient).Region
    19  }
    20  
    21  func notFoundError(err error) bool {
    22  	if e, ok := err.(*common.Error); ok && (e.StatusCode == 404 || e.ErrorResponse.Message == "Not found") {
    23  		return true
    24  	}
    25  
    26  	return false
    27  }
    28  
    29  // Protocal represents network protocal
    30  type Protocal string
    31  
    32  // Constants of protocal definition
    33  const (
    34  	Http  = Protocal("http")
    35  	Https = Protocal("https")
    36  	Tcp   = Protocal("tcp")
    37  	Udp   = Protocal("udp")
    38  )
    39  
    40  // ValidProtocals network protocal list
    41  var ValidProtocals = []Protocal{Http, Https, Tcp, Udp}
    42  
    43  // simple array value check method, support string type only
    44  func isProtocalValid(value string) bool {
    45  	res := false
    46  	for _, v := range ValidProtocals {
    47  		if string(v) == value {
    48  			res = true
    49  		}
    50  	}
    51  	return res
    52  }