github.com/cbroglie/terraform@v0.7.0-rc3.0.20170410193827-735dfc416d46/builtin/providers/alicloud/common.go (about) 1 package alicloud 2 3 import ( 4 "github.com/denverdino/aliyungo/common" 5 "github.com/denverdino/aliyungo/ecs" 6 "github.com/hashicorp/terraform/helper/schema" 7 ) 8 9 type InstanceNetWork string 10 11 const ( 12 ClassicNet = InstanceNetWork("classic") 13 VpcNet = InstanceNetWork("vpc") 14 ) 15 16 // timeout for common product, ecs e.g. 17 const defaultTimeout = 120 18 19 // timeout for long time progerss product, rds e.g. 20 const defaultLongTimeout = 800 21 22 func getRegion(d *schema.ResourceData, meta interface{}) common.Region { 23 return meta.(*AliyunClient).Region 24 } 25 26 func notFoundError(err error) bool { 27 if e, ok := err.(*common.Error); ok && (e.StatusCode == 404 || e.ErrorResponse.Message == "Not found") { 28 return true 29 } 30 31 return false 32 } 33 34 // Protocal represents network protocal 35 type Protocal string 36 37 // Constants of protocal definition 38 const ( 39 Http = Protocal("http") 40 Https = Protocal("https") 41 Tcp = Protocal("tcp") 42 Udp = Protocal("udp") 43 ) 44 45 // ValidProtocals network protocal list 46 var ValidProtocals = []Protocal{Http, Https, Tcp, Udp} 47 48 // simple array value check method, support string type only 49 func isProtocalValid(value string) bool { 50 res := false 51 for _, v := range ValidProtocals { 52 if string(v) == value { 53 res = true 54 } 55 } 56 return res 57 } 58 59 var DefaultBusinessInfo = ecs.BusinessInfo{ 60 Pack: "terraform", 61 } 62 63 // default region for all resource 64 const DEFAULT_REGION = "cn-beijing" 65 66 // default security ip for db 67 const DEFAULT_DB_SECURITY_IP = "127.0.0.1" 68 69 // we the count of create instance is only one 70 const DEFAULT_INSTANCE_COUNT = 1 71 72 // symbol of multiIZ 73 const MULTI_IZ_SYMBOL = "MAZ" 74 75 // default connect port of db 76 const DB_DEFAULT_CONNECT_PORT = "3306" 77 78 const COMMA_SEPARATED = "," 79 80 const LOCAL_HOST_IP = "127.0.0.1"