provider/ignition: mount and path are mutually exclusive (#11409)

* Fix generation of ignition filesystems section: don't add a path key
  if not needed.
* Check that mount and path are not used together.
This commit is contained in:
Yves Blusseau 2017-01-27 20:28:42 +01:00 committed by Paul Stack
parent 544c21c5f1
commit 607ced955b
1 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,8 @@
package ignition
import (
"fmt"
"github.com/coreos/ignition/config/types"
"github.com/hashicorp/terraform/helper/schema"
)
@ -103,11 +105,19 @@ func buildFilesystem(d *schema.ResourceData, c *cache) (string, error) {
}
}
path := types.Path(d.Get("path").(string))
var path *types.Path
if p, ok := d.GetOk("path"); ok {
tp := types.Path(p.(string))
path = &tp
}
if mount != nil && path != nil {
return "", fmt.Errorf("mount and path are mutually exclusive")
}
return c.addFilesystem(&types.Filesystem{
Name: d.Get("name").(string),
Mount: mount,
Path: &path,
Path: path,
}), nil
}