Skip to content

Commit

Permalink
Temporary add of structure_helper.go
Browse files Browse the repository at this point in the history
Commit will probably will be removed once #138 and #139 are merged.
  • Loading branch information
vancluever committed Aug 27, 2017
1 parent 38b39f9 commit d66c855
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions vsphere/structure_helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package vsphere

import (
"fmt"

"github.com/hashicorp/terraform/helper/schema"
)

// sliceInterfacesToStrings converts an interface slice to a string slice. The
// function does not attempt to do any sanity checking and will panic if one of
// the items in the slice is not a string.
func sliceInterfacesToStrings(s []interface{}) []string {
var d []string
for _, v := range s {
d = append(d, v.(string))
}
return d
}

// sliceStringsToInterfaces converts a string slice to an interface slice.
func sliceStringsToInterfaces(s []string) []interface{} {
var d []interface{}
for _, v := range s {
d = append(d, v)
}
return d
}

// mergeSchema merges the map[string]*schema.Schema from src into dst. Safety
// against conflicts is enforced by panicing.
func mergeSchema(dst, src map[string]*schema.Schema) {
for k, v := range src {
if _, ok := dst[k]; ok {
panic(fmt.Errorf("conflicting schema key: %s", k))
}
dst[k] = v
}
}

0 comments on commit d66c855

Please sign in to comment.