-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprovider_util.go
42 lines (36 loc) · 873 Bytes
/
provider_util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/terraform/helper/schema"
"time"
)
func forget(d *schema.ResourceData, m interface{}) error {
d.SetId("")
_ = m
return nil
}
func noop(d *schema.ResourceData, m interface{}) error {
_ = d
_ = m
return nil
}
func MustDuration(dur string) time.Duration {
actual, err := time.ParseDuration(dur)
if err != nil {
panic(err)
}
return actual
}
func getClient(d *schema.ResourceData) *api.Client {
conf := api.DefaultConfig()
conf.Address = d.Get("address").(string)
conf.TLSConfig.CACert = d.Get("ca_file").(string)
conf.TLSConfig.ClientCert = d.Get("cert_file").(string)
conf.TLSConfig.ClientKey = d.Get("key_file").(string)
conf.TLSConfig.TLSServerName = d.Get("tls_server_name").(string)
client, err := api.NewClient(conf)
if err != nil {
panic(err)
}
return client
}