-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporary add of structure_helper.go
- Loading branch information
1 parent
38b39f9
commit d66c855
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |