Skip to content

Commit 61f47d4

Browse files
author
Joshua Seidel
committed
correct space, fix reading of file
1 parent 090248f commit 61f47d4

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

builtin/provisioners/chef/resource_provisioner.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ func (r *ResourceProvisioner) Validate(c *terraform.ResourceConfig) (ws []string
175175
if p.ServerURL == "" {
176176
es = append(es, fmt.Errorf("Key not found: server_url"))
177177
}
178+
if p.SecretKeyPath == "" {
179+
es = append(es, fmt.Errorf("Key not found: secret_key_path"))
180+
}
178181
if p.ValidationClientName == "" {
179182
es = append(es, fmt.Errorf("Key not found: validation_client_name"))
180183
}
@@ -224,13 +227,19 @@ func (r *ResourceProvisioner) decodeConfig(c *terraform.ResourceConfig) (*Provis
224227
}
225228

226229
if p.ValidationKeyPath != "" {
227-
keyPath, err := homedir.Expand(p.ValidationKeyPath)
230+
vkeyPath, err := homedir.Expand(p.ValidationKeyPath)
228231
if err != nil {
229232
return nil, fmt.Errorf("Error expanding the validation key path: %v", err)
230233
}
231-
p.ValidationKeyPath = keyPath
232-
}
233-
234+
p.ValidationKeyPath = vkeyPath
235+
}
236+
if p.SecretKeyPath != "" {
237+
skeyPath, err := homedir.Expand(p.SecretKeyPath)
238+
if err != nil {
239+
return nil, fmt.Errorf("Error expanding the secret key path: %v", err)
240+
}
241+
p.SecretKeyPath = skeyPath
242+
}
234243
if attrs, ok := c.Config["attributes"]; ok {
235244
p.Attributes, err = rawToJSON(attrs)
236245
if err != nil {
@@ -336,7 +345,7 @@ func (p *Provisioner) deployConfigFiles(
336345
o terraform.UIOutput,
337346
comm communicator.Communicator,
338347
confDir string) error {
339-
// Open the validation key file
348+
// Open the validation key file
340349
f, err := os.Open(p.ValidationKeyPath)
341350
if err != nil {
342351
return err

0 commit comments

Comments
 (0)