Skip to content

Commit 1cc95b7

Browse files
committed
provider/consul: Change to GetOk with schema.Helper
1 parent 269c5be commit 1cc95b7

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

builtin/providers/consul/resource_consul_keys.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func resourceConsulKeysCreate(d *schema.ResourceData, meta interface{}) error {
8989
// Resolve the datacenter first, all the other keys are dependent
9090
// on this.
9191
var dc string
92-
if v := d.Get("datacenter"); v != nil {
92+
if v, ok := d.GetOk("datacenter"); ok {
9393
dc = v.(string)
9494
log.Printf("[DEBUG] Consul datacenter: %s", dc)
9595
} else {
@@ -101,7 +101,7 @@ func resourceConsulKeysCreate(d *schema.ResourceData, meta interface{}) error {
101101
}
102102
}
103103
var token string
104-
if v := d.Get("token"); v != nil {
104+
if v, ok := d.GetOk("token"); ok {
105105
token = v.(string)
106106
}
107107

@@ -160,14 +160,14 @@ func resourceConsulKeysRead(d *schema.ResourceData, meta interface{}) error {
160160

161161
// Get the DC, error if not available.
162162
var dc string
163-
if v := d.Get("datacenter"); v != nil {
163+
if v, ok := d.GetOk("datacenter"); ok {
164164
dc = v.(string)
165165
log.Printf("[DEBUG] Consul datacenter: %s", dc)
166166
} else {
167167
return fmt.Errorf("Missing datacenter configuration")
168168
}
169169
var token string
170-
if v := d.Get("token"); v != nil {
170+
if v, ok := d.GetOk("token"); ok {
171171
token = v.(string)
172172
}
173173

@@ -208,14 +208,14 @@ func resourceConsulKeysDelete(d *schema.ResourceData, meta interface{}) error {
208208

209209
// Get the DC, error if not available.
210210
var dc string
211-
if v := d.Get("datacenter"); v != nil {
211+
if v, ok := d.GetOk("datacenter"); ok {
212212
dc = v.(string)
213213
log.Printf("[DEBUG] Consul datacenter: %s", dc)
214214
} else {
215215
return fmt.Errorf("Missing datacenter configuration")
216216
}
217217
var token string
218-
if v := d.Get("token"); v != nil {
218+
if v, ok := d.GetOk("token"); ok {
219219
token = v.(string)
220220
}
221221

0 commit comments

Comments
 (0)