diff options
author | Flavio Castelli <fcastelli@suse.com> | 2017-05-03 11:37:08 +0200 |
---|---|---|
committer | Alvaro <alvaro.saurin@gmail.com> | 2017-05-03 11:40:31 +0200 |
commit | ee12004ab93e54f326896e9909ba9e6a2bd11e89 (patch) | |
tree | 1ea30d204b04425ebd1dadaf8cc991d572c7f0fb /vendor/github.com/hashicorp/terraform/builtin/providers/ignition/resource_ignition_group.go | |
parent | a286dc5494691c2b04c48ef6695ed0c902912c0f (diff) | |
download | terraform-provider-libvirt-ee12004ab93e54f326896e9909ba9e6a2bd11e89.tar terraform-provider-libvirt-ee12004ab93e54f326896e9909ba9e6a2bd11e89.tar.gz |
Vendor dependencies with vndr
This fixes issue #123
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/builtin/providers/ignition/resource_ignition_group.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/builtin/providers/ignition/resource_ignition_group.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/builtin/providers/ignition/resource_ignition_group.go b/vendor/github.com/hashicorp/terraform/builtin/providers/ignition/resource_ignition_group.go new file mode 100644 index 00000000..125e97e7 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/builtin/providers/ignition/resource_ignition_group.go @@ -0,0 +1,57 @@ +package ignition + +import ( + "github.com/coreos/ignition/config/types" + "github.com/hashicorp/terraform/helper/schema" +) + +func resourceGroup() *schema.Resource { + return &schema.Resource{ + Exists: resourceGroupExists, + Read: resourceGroupRead, + Schema: map[string]*schema.Schema{ + "name": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "gid": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + }, + "password_hash": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + }, + } +} + +func resourceGroupRead(d *schema.ResourceData, meta interface{}) error { + id, err := buildGroup(d, globalCache) + if err != nil { + return err + } + + d.SetId(id) + return nil +} + +func resourceGroupExists(d *schema.ResourceData, meta interface{}) (bool, error) { + id, err := buildGroup(d, globalCache) + if err != nil { + return false, err + } + + return id == d.Id(), nil +} + +func buildGroup(d *schema.ResourceData, c *cache) (string, error) { + return c.addGroup(&types.Group{ + Name: d.Get("name").(string), + PasswordHash: d.Get("password_hash").(string), + Gid: getUInt(d, "gid"), + }), nil +} |