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
8c2549f8
Commit
8c2549f8
authored
9 years ago
by
Nathaniel Kofalt
Browse files
Options
Downloads
Patches
Plain Diff
Tolerate optional file keys
parent
b54eaced
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
+13
-2
13 additions, 2 deletions
api/rules.py
with
13 additions
and
2 deletions
api/rules.py
+
13
−
2
View file @
8c2549f8
...
...
@@ -51,6 +51,9 @@ HARDCODED_RULES = [
}
]
def
_log_file_key_error
(
file_
,
container
,
error
):
log
.
warning
(
'
file
'
+
file_
[
'
name
'
]
+
'
in container
'
+
str
(
container
[
'
_id
'
])
+
'
'
+
error
)
def
eval_match
(
match_type
,
match_param
,
file_
,
container
):
"""
Given a match entry, return if the match succeeded.
...
...
@@ -61,7 +64,11 @@ def eval_match(match_type, match_param, file_, container):
# Match the file's type
if
match_type
==
'
file.type
'
:
return
file_
[
'
type
'
]
==
match_param
try
:
return
file_
[
'
type
'
]
==
match_param
except
KeyError
:
_log_file_key_error
(
file_
,
container
,
'
has no type key
'
)
return
False
# Match a shell glob for the file name
elif
match_type
==
'
file.name
'
:
...
...
@@ -69,7 +76,11 @@ def eval_match(match_type, match_param, file_, container):
# Match any of the file's measurements
elif
match_type
==
'
file.measurements
'
:
return
match_param
in
file_
[
measurements
]
try
:
return
match_param
in
file_
[
measurements
]
except
KeyError
:
_log_file_key_error
(
file_
,
container
,
'
has no measurements key
'
)
return
False
# Match the container's primary measurment
elif
match_type
==
'
container.measurement
'
:
...
...
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