Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
367a9fdd
Commit
367a9fdd
authored
7 years ago
by
Benjamin Bollen
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into master
parents
565213a9
74cc19b2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
permission/types/util.go
+10
-10
10 additions, 10 deletions
permission/types/util.go
with
10 additions
and
10 deletions
permission/types/util.go
+
10
−
10
View file @
367a9fdd
...
@@ -14,12 +14,12 @@
...
@@ -14,12 +14,12 @@
package
types
package
types
// ConvertMapStringIntToPermissions converts a map of string-
integer
pairs and a slice of
// ConvertMapStringIntToPermissions converts a map of string-
bool
pairs and a slice of
// strings for the roles to an AccountPermissions type.
The integer needs to be greater
// strings for the roles to an AccountPermissions type.
If the value in the
//
than zero to set the permission. For all unmentioned permissions the ZeroBaseP
ermission
s
//
permissions map is true for a particular permission string then the p
ermission
//
is defaulted to.
//
will be set in the AccountsPermissions. For all unmentioned permissions the
//
TODO: [ben] re-evaluate the use of int for setting the permission
.
//
ZeroBasePermissions is defaulted to
.
func
ConvertPermissionsMapAndRolesToAccountPermissions
(
permissions
map
[
string
]
int
,
roles
[]
string
)
(
*
AccountPermissions
,
error
)
{
func
ConvertPermissionsMapAndRolesToAccountPermissions
(
permissions
map
[
string
]
bool
,
roles
[]
string
)
(
*
AccountPermissions
,
error
)
{
var
err
error
var
err
error
accountPermissions
:=
&
AccountPermissions
{}
accountPermissions
:=
&
AccountPermissions
{}
accountPermissions
.
Base
,
err
=
convertPermissionsMapStringIntToBasePermissions
(
permissions
)
accountPermissions
.
Base
,
err
=
convertPermissionsMapStringIntToBasePermissions
(
permissions
)
...
@@ -30,9 +30,9 @@ func ConvertPermissionsMapAndRolesToAccountPermissions(permissions map[string]in
...
@@ -30,9 +30,9 @@ func ConvertPermissionsMapAndRolesToAccountPermissions(permissions map[string]in
return
accountPermissions
,
nil
return
accountPermissions
,
nil
}
}
// convertPermissionsMapStringIntToBasePermissions converts a map of string-
integer pairs to
// convertPermissionsMapStringIntToBasePermissions converts a map of string-
bool
// BasePermissions.
//
pairs to
BasePermissions.
func
convertPermissionsMapStringIntToBasePermissions
(
permissions
map
[
string
]
int
)
(
BasePermissions
,
error
)
{
func
convertPermissionsMapStringIntToBasePermissions
(
permissions
map
[
string
]
bool
)
(
BasePermissions
,
error
)
{
// initialise basePermissions as ZeroBasePermissions
// initialise basePermissions as ZeroBasePermissions
basePermissions
:=
ZeroBasePermissions
basePermissions
:=
ZeroBasePermissions
...
@@ -42,7 +42,7 @@ func convertPermissionsMapStringIntToBasePermissions(permissions map[string]int)
...
@@ -42,7 +42,7 @@ func convertPermissionsMapStringIntToBasePermissions(permissions map[string]int)
return
basePermissions
,
err
return
basePermissions
,
err
}
}
// sets the permissions bitflag and the setbit flag for the permission.
// sets the permissions bitflag and the setbit flag for the permission.
basePermissions
.
Set
(
permissionsFlag
,
value
>
0
)
basePermissions
.
Set
(
permissionsFlag
,
value
)
}
}
return
basePermissions
,
nil
return
basePermissions
,
nil
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment