github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/github/util_permissions.go (about) 1 package github 2 3 import "errors" 4 5 const pullPermission string = "pull" 6 const pushPermission string = "push" 7 const adminPermission string = "admin" 8 9 func getRepoPermission(p *map[string]bool) (string, error) { 10 11 // Permissions are returned in this map format such that if you have a certain level 12 // of permission, all levels below are also true. For example, if a team has push 13 // permission, the map will be: {"pull": true, "push": true, "admin": false} 14 if (*p)[adminPermission] { 15 return adminPermission, nil 16 } else if (*p)[pushPermission] { 17 return pushPermission, nil 18 } else { 19 if (*p)[pullPermission] { 20 return pullPermission, nil 21 } 22 return "", errors.New("At least one permission expected from permissions map.") 23 } 24 }