Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
b1d93a7f
Commit
b1d93a7f
authored
9 years ago
by
Nathaniel Kofalt
Browse files
Options
Downloads
Patches
Plain Diff
update rule hierarchy walking for project objects
parent
84b182f4
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
api/rules.py
+7
-6
7 additions, 6 deletions
api/rules.py
with
7 additions
and
6 deletions
api/rules.py
+
7
−
6
View file @
b1d93a7f
...
...
@@ -136,8 +136,7 @@ def create_jobs(db, container, container_type, file_):
job_list
=
[]
# Get configured rules for this project
project
=
get_project_for_container
(
db
,
container
)
rules
=
project
.
get
(
'
rules
'
,
[])
rules
=
get_rules_for_container
(
db
,
container
)
# Add hardcoded rules that cannot be removed or changed
for
hardcoded_rule
in
HARDCODED_RULES
:
...
...
@@ -153,14 +152,16 @@ def create_jobs(db, container, container_type, file_):
return
job_list
# TODO: consider moving to a module that has a variety of hierarchy-management helper functions
def
get_
project
_for_container
(
db
,
container
):
def
get_
rules
_for_container
(
db
,
container
):
"""
Recursively walk the hierarchy until the project object is found.
"""
if
'
session
'
in
container
:
session
=
db
.
sessions
.
find_one
({
'
_id
'
:
container
[
'
session
'
]})
return
get_
project
_for_container
(
db
,
session
)
return
get_
rules
_for_container
(
db
,
session
)
elif
'
project
'
in
container
:
project
=
db
.
projects
.
find_one
({
'
_id
'
:
container
[
'
project
'
]})
return
project
raise
Exception
(
'
Hierarchy walking not implemented for container
'
+
str
(
container
[
'
_id
'
]))
return
get_rules_for_container
(
db
,
project
)
else
:
# Assume container is a project, or a collection (which currently cannot have a rules property)
return
container
.
get
(
'
rules
'
,
[])
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