Skip to content

Commit

Permalink
make golint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed Aug 26, 2018
1 parent 34cd77a commit 4936bca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
1 change: 1 addition & 0 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
)

// Provider returns the terraform provider schema.
func Provider() *schema.Provider {
return &schema.Provider{
ConfigureFunc: vagrantConfigure,
Expand Down
32 changes: 14 additions & 18 deletions resource_vagrant_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,51 +24,51 @@ func resourceVagrantVM() *schema.Resource {

SchemaVersion: 1,
Schema: map[string]*schema.Schema{
"vagrantfile_dir": &schema.Schema{
"vagrantfile_dir": {
Description: "Path to the directory where the Vagrantfile can be found. Defaults to the current directory.",
Type: schema.TypeString,
Optional: true,
Default: ".",
ValidateFunc: resourceVagrantVMPathToVagrantfileValidate,
},

"ssh_config": &schema.Schema{
"ssh_config": {
Description: "SSH connection information.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": &schema.Schema{
"type": {
Description: "Connection type. Only valid option is ssh at this time.",
Type: schema.TypeString,
Computed: true,
},

"user": &schema.Schema{
"user": {
Description: "The user for the connection.",
Type: schema.TypeString,
Computed: true,
},

"host": &schema.Schema{
"host": {
Description: "The address of the resource to connect to.",
Type: schema.TypeString,
Computed: true,
},

"port": &schema.Schema{
"port": {
Description: "The port to connect to.",
Type: schema.TypeString,
Computed: true,
},

"private_key": &schema.Schema{
"private_key": {
Description: "Private SSH key for the connection.",
Type: schema.TypeString,
Computed: true,
},

"agent": &schema.Schema{
"agent": {
Description: "Whether or not to use the agent to authenticate.",
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -97,7 +97,7 @@ func resourceVagrantVMCreate(d *schema.ResourceData, m interface{}) error {

d.SetId(buildId(cmd.VMInfo))

return readVagrantInfo(client, ctx, d)
return readVagrantInfo(ctx, client, d)
}

func resourceVagrantVMRead(d *schema.ResourceData, m interface{}) error {
Expand All @@ -109,7 +109,7 @@ func resourceVagrantVMRead(d *schema.ResourceData, m interface{}) error {
return err
}

return readVagrantInfo(client, ctx, d)
return readVagrantInfo(ctx, client, d)
}

func resourceVagrantVMUpdate(d *schema.ResourceData, m interface{}) error {
Expand All @@ -127,7 +127,7 @@ func resourceVagrantVMUpdate(d *schema.ResourceData, m interface{}) error {
return nil
}

return readVagrantInfo(client, ctx, d)
return readVagrantInfo(ctx, client, d)
}

func resourceVagrantVMDelete(d *schema.ResourceData, m interface{}) error {
Expand All @@ -141,11 +141,7 @@ func resourceVagrantVMDelete(d *schema.ResourceData, m interface{}) error {

cmd := client.Destroy()
cmd.Context = ctx
if err := cmd.Run(); err != nil {
return err
}

return nil
return cmd.Run()
}

func resourceVagrantVMExists(d *schema.ResourceData, m interface{}) (bool, error) {
Expand Down Expand Up @@ -200,15 +196,15 @@ func buildId(info map[string]*vagrant.VMInfo) string {
var keys sort.StringSlice = make([]string, len(info)+1)
keys[0] = "vagrant"
i := 1
for key, _ := range info {
for key := range info {
keys[i] = key
i++
}
keys[1:].Sort()
return strings.Join(keys, ":")
}

func readVagrantInfo(client *vagrant.VagrantClient, ctx context.Context, d *schema.ResourceData) error {
func readVagrantInfo(ctx context.Context, client *vagrant.VagrantClient, d *schema.ResourceData) error {
cmd := client.SSHConfig()
cmd.Context = ctx
if err := cmd.Run(); err != nil {
Expand Down
1 change: 1 addition & 0 deletions vagrant_config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package main

// VagrantConfig is for provider-level configuration.
type VagrantConfig struct {
}

0 comments on commit 4936bca

Please sign in to comment.