本文整理匯總了Golang中github.com/whitepages/terraform-provider-stingray/Godeps/_workspace/src/github.com/hashicorp/terraform/helper/schema.ResourceData.GetOk方法的典型用法代碼示例。如果您正苦於以下問題:Golang ResourceData.GetOk方法的具體用法?Golang ResourceData.GetOk怎麽用?Golang ResourceData.GetOk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/whitepages/terraform-provider-stingray/Godeps/_workspace/src/github.com/hashicorp/terraform/helper/schema.Res
的用法示例。
在下文中一共展示了ResourceData.GetOk方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setNodesTable
func setNodesTable(target **stingray.NodesTable, d *schema.ResourceData, key string) {
if _, ok := d.GetOk(key); ok {
var nodes []string
if v := d.Get(key).(*schema.Set); v.Len() > 0 {
nodes = make([]string, v.Len())
for i, v := range v.List() {
nodes[i] = v.(string)
}
}
nodesTable := nodesToNodesTable(nodes)
*target = &nodesTable
}
}
示例2: resourceVirtualServerSet
func resourceVirtualServerSet(d *schema.ResourceData, meta interface{}) error {
c := meta.(*providerConfig).client
r := stingray.NewVirtualServer(d.Get("name").(string))
setString(&r.ConnectionErrors.ErrorFile, d, "connection_errors_error_file")
setInt(&r.Connection.KeepaliveTimeout, d, "connection_keepalive_timeout")
setInt(&r.Connection.Timeout, d, "connection_timeout")
setInt(&r.Basic.ConnectTimeout, d, "connect_timeout")
setBool(&r.Basic.Enabled, d, "enabled")
// NOTE: Set default for gzip_include_mime
//
// Default does not work for sets (only for primitive types),
// so we must use GetOK. This means we will get the default
// value if the parameter is unset OR set to the empty value.
if _, ok := d.GetOk("gzip_include_mime"); ok {
setStringSet(&r.Gzip.IncludeMIME, d, "gzip_include_mime")
} else {
r.Gzip.IncludeMIME = &[]string{"text/html", "text/plain"}
}
setBool(&r.Gzip.Enabled, d, "gzip_enabled")
setString(&r.HTTP.LocationRewrite, d, "http_location_rewrite")
setBool(&r.Basic.ListenOnAny, d, "listen_on_any")
setStringSet(&r.Basic.ListenOnTrafficIPs, d, "listen_on_traffic_ips")
setBool(&r.Log.Enabled, d, "log_enabled")
setString(&r.Log.Filename, d, "log_filename")
setString(&r.Log.Format, d, "log_format")
setBool(&r.Log.ServerConnectionFailures, d, "log_server_connection_failures")
setString(&r.Basic.Note, d, "note")
setString(&r.Basic.Pool, d, "pool")
setInt(&r.Basic.Port, d, "port")
setString(&r.Basic.Protocol, d, "protocol")
setBool(&r.RecentConnections.SaveAll, d, "recent_connections_save_all")
setStringList(&r.Basic.RequestRules, d, "request_rules")
setStringList(&r.Basic.ResponseRules, d, "response_rules")
setBool(&r.SSL.AddHTTPHeaders, d, "ssl_add_http_headers")
setBool(&r.Basic.SSLDecrypt, d, "ssl_decrypt")
setString(&r.SSL.ServerCertDefault, d, "ssl_server_cert_default")
setServerCertHostMappingTable(&r.SSL.ServerCertHostMapping, d, "ssl_server_cert_host_mapping")
setString(&r.Syslog.Format, d, "syslog_format")
setBool(&r.WebCache.Enabled, d, "web_cache_enabled")
setInt(&r.WebCache.MaxTime, d, "web_cache_max_time")
_, err := c.Set(r)
if err != nil {
return err
}
d.SetId(d.Get("name").(string))
return nil
}
示例3: setServerCertHostMappingTable
func setServerCertHostMappingTable(target **stingray.ServerCertHostMappingTable, d *schema.ResourceData, key string) {
if _, ok := d.GetOk(key); ok {
table := d.Get(key).(*schema.Set).List()
*target, _ = expandServerCertHostMappingTable(table)
}
}
示例4: setScriptArgumentsTable
func setScriptArgumentsTable(target **stingray.ScriptArgumentsTable, d *schema.ResourceData, key string) {
if _, ok := d.GetOk(key); ok {
table := d.Get(key).(*schema.Set).List()
*target, _ = expandScriptArgumentsTable(table)
}
}