Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
server
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
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
m-team
oidc
mytoken
server
Commits
a7cc51d3
Verified
Commit
a7cc51d3
authored
2 years ago
by
Gabriel Zachmann
Browse files
Options
Downloads
Patches
Plain Diff
improve code
parent
0668d04f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
internal/db/dbrepo/mytokenrepo/tree/tree.go
+6
-6
6 additions, 6 deletions
internal/db/dbrepo/mytokenrepo/tree/tree.go
internal/endpoints/consent/pkg/capability.go
+3
-0
3 additions, 0 deletions
internal/endpoints/consent/pkg/capability.go
with
9 additions
and
6 deletions
internal/db/dbrepo/mytokenrepo/tree/tree.go
+
6
−
6
View file @
a7cc51d3
...
...
@@ -25,7 +25,7 @@ type MytokenEntry struct {
// MytokenEntryTree is a tree of MytokenEntry
type
MytokenEntryTree
struct
{
Token
MytokenEntry
`json:"token"`
Token
*
MytokenEntry
`json:"token"`
Children
[]
MytokenEntryTree
`json:"children,omitempty"`
}
...
...
@@ -64,7 +64,7 @@ func TokenSubTree(rlog log.Ext1FieldLogger, tx *sqlx.Tx, tokenID mtid.MTID) (Myt
break
}
}
tree
,
_
:=
tokensToTree
(
root
,
tokens
)
tree
,
_
:=
tokensToTree
(
&
root
,
tokens
)
return
tree
,
nil
}
...
...
@@ -81,26 +81,26 @@ func tokensToTrees(tokens []MytokenEntry) (trees []MytokenEntryTree) {
}
var
tmp
MytokenEntryTree
for
_
,
r
:=
range
roots
{
tmp
,
tokens
=
tokensToTree
(
r
,
tokens
)
tmp
,
tokens
=
tokensToTree
(
&
r
,
tokens
)
trees
=
append
(
trees
,
tmp
)
}
return
}
func
tokensToTree
(
root
MytokenEntry
,
tokens
[]
MytokenEntry
)
(
MytokenEntryTree
,
[]
MytokenEntry
)
{
func
tokensToTree
(
root
*
MytokenEntry
,
tokens
[]
MytokenEntry
)
(
MytokenEntryTree
,
[]
MytokenEntry
)
{
tree
:=
MytokenEntryTree
{
Token
:
root
,
}
children
:=
popChildren
(
root
,
&
tokens
)
var
cTree
MytokenEntryTree
for
_
,
c
:=
range
children
{
cTree
,
tokens
=
tokensToTree
(
c
,
tokens
)
cTree
,
tokens
=
tokensToTree
(
&
c
,
tokens
)
tree
.
Children
=
append
(
tree
.
Children
,
cTree
)
}
return
tree
,
tokens
}
func
popChildren
(
root
MytokenEntry
,
tokens
*
[]
MytokenEntry
)
(
children
[]
MytokenEntry
)
{
func
popChildren
(
root
*
MytokenEntry
,
tokens
*
[]
MytokenEntry
)
(
children
[]
MytokenEntry
)
{
i
:=
0
for
i
<
len
(
*
tokens
)
{
t
:=
(
*
tokens
)[
i
]
...
...
This diff is collapsed.
Click to expand it.
internal/endpoints/consent/pkg/capability.go
+
3
−
0
View file @
a7cc51d3
...
...
@@ -168,11 +168,13 @@ func (c webCapability) getDangerLevel() int {
}
// ColorClass returns the html class for coloring this Capability
// skipcq: CRT-P0003
func
(
c
webCapability
)
ColorClass
()
string
{
return
textColorByDanger
(
c
.
getDangerLevel
())
}
// CapabilityLevel returns a string describing the power of this capability
// skipcq: CRT-P0003
func
(
c
webCapability
)
CapabilityLevel
()
string
{
intClass
:=
c
.
getIntClass
()
switch
intClass
{
...
...
@@ -187,6 +189,7 @@ func (c webCapability) CapabilityLevel() string {
}
// IsCreateMT checks if this WebCapability is api.CapabilityCreateMT
// skipcq: CRT-P0003
func
(
c
WebCapability
)
IsCreateMT
()
bool
{
return
c
.
ReadWriteCapability
.
Name
==
api
.
CapabilityCreateMT
.
Name
}
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