opentofu/builtin/providers/github/util.go
Jacob Severson 7721348b0b Adding privacy argument for GitHub teams for #6015 (#6116)
Added the ability to set the "privacy" of a github_team resource so all teams won't automatically set to private.

* Added the privacy argument to github_team

* Refactored parameter validation to be general for any argument

* Updated testing
2016-04-11 13:09:25 +01:00

48 lines
928 B
Go

package github
import (
"fmt"
"strconv"
"strings"
"github.com/hashicorp/terraform/helper/schema"
)
func toGithubID(id string) int {
githubID, _ := strconv.Atoi(id)
return githubID
}
func fromGithubID(id *int) string {
return strconv.Itoa(*id)
}
func validateValueFunc(values []string) schema.SchemaValidateFunc {
return func(v interface{}, k string) (we []string, errors []error) {
value := v.(string)
valid := false
for _, role := range values {
if value == role {
valid = true
break
}
}
if !valid {
errors = append(errors, fmt.Errorf("%s is an invalid value for argument %s", value, k))
}
return
}
}
// return the pieces of id `a:b` as a, b
func parseTwoPartID(id string) (string, string) {
parts := strings.SplitN(id, ":", 2)
return parts[0], parts[1]
}
// format the strings into an id `a:b`
func buildTwoPartID(a, b *string) string {
return fmt.Sprintf("%s:%s", *a, *b)
}