|
| 1 | +package gitlab |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/xanzy/go-gitlab" |
| 5 | +) |
| 6 | + |
| 7 | +// NOTE: |
| 8 | +// The access level story in the GitLab API is a bit tricky. |
| 9 | +// There are different resources using the same access level names |
| 10 | +// with an identical mapping to int ids. As also defined in the |
| 11 | +// `gitlab.AccessLevelValue` types. However, different endpoints |
| 12 | +// allow all of them or just a subset. There is also endpoints |
| 13 | +// defining an additional `admin` access level, which is nowhere |
| 14 | +// documented and probably not used at all - this provider ignores it. |
| 15 | +// Point being, be careful when using them in a resource or data source |
| 16 | +// and consult the upstream API docs to verify what's possible and keep |
| 17 | +// your fingers crossed it's correct :) |
| 18 | + |
| 19 | +// see the source of truth for `accessLevelNameToValue` and `accessLevelValueToName` |
| 20 | +// here: https://docs.gitlab.com/ee/api/members.html#valid-access-levels |
| 21 | +var validGroupAccessLevelNames = []string{ |
| 22 | + "no one", |
| 23 | + "minimal", |
| 24 | + "guest", |
| 25 | + "reporter", |
| 26 | + "developer", |
| 27 | + "maintainer", |
| 28 | + "owner", |
| 29 | + |
| 30 | + // Deprecated and should be removed in v4 of this provider |
| 31 | + "master", |
| 32 | +} |
| 33 | +var validProjectAccessLevelNames = []string{ |
| 34 | + "no one", |
| 35 | + "minimal", |
| 36 | + "guest", |
| 37 | + "reporter", |
| 38 | + "developer", |
| 39 | + "maintainer", |
| 40 | + |
| 41 | + // Deprecated and should be removed in v4 of this provider |
| 42 | + "master", |
| 43 | +} |
| 44 | + |
| 45 | +// NOTE(TF): the documentation here https://docs.gitlab.com/ee/api/protected_branches.html |
| 46 | +// mentions an `60 => Admin access` level, but it actually seems to not exist. |
| 47 | +// Ignoring here that I've every read about this ... |
| 48 | +var validProtectedBranchTagAccessLevelNames = []string{ |
| 49 | + "no one", "developer", "maintainer", |
| 50 | +} |
| 51 | + |
| 52 | +var accessLevelNameToValue = map[string]gitlab.AccessLevelValue{ |
| 53 | + "no one": gitlab.NoPermissions, |
| 54 | + "minimal": gitlab.MinimalAccessPermissions, |
| 55 | + "guest": gitlab.GuestPermissions, |
| 56 | + "reporter": gitlab.ReporterPermissions, |
| 57 | + "developer": gitlab.DeveloperPermissions, |
| 58 | + "maintainer": gitlab.MaintainerPermissions, |
| 59 | + "owner": gitlab.OwnerPermission, |
| 60 | + |
| 61 | + // Deprecated and should be removed in v4 of this provider |
| 62 | + "master": gitlab.MaintainerPermissions, |
| 63 | +} |
| 64 | + |
| 65 | +var accessLevelValueToName = map[gitlab.AccessLevelValue]string{ |
| 66 | + gitlab.NoPermissions: "no one", |
| 67 | + gitlab.MinimalAccessPermissions: "minimal", |
| 68 | + gitlab.GuestPermissions: "guest", |
| 69 | + gitlab.ReporterPermissions: "reporter", |
| 70 | + gitlab.DeveloperPermissions: "developer", |
| 71 | + gitlab.MaintainerPermissions: "maintainer", |
| 72 | + gitlab.OwnerPermissions: "owner", |
| 73 | +} |
0 commit comments