-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding check for project-version-violations and report back #55
Open
jmvanryn
wants to merge
6
commits into
blackducksoftware:master
Choose a base branch
from
jmvanryn:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2b96b12
Adding in example to report on project violations.
481371b
Adding in example to report on project violations.
345d2f2
Merge remote-tracking branch 'upstream/master'
42b3032
Updates as per review
bda7092
revert change
0594ef6
Merge pull request #1 from blackducksoftware/master
jmvanryn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,5 @@ venv.bak/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
/.idea/ | ||
/examples/.restconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
''' | ||
Created on Nov 14, 2018 | ||
|
||
@author: gsnyder | ||
|
||
Print a project given its name | ||
|
||
''' | ||
|
||
from blackduck.HubRestApi import HubInstance | ||
|
||
import argparse | ||
import json | ||
|
||
parser = argparse.ArgumentParser(description='Use this to check the status of a given version for a given project. If no version is given then it will return the status of the highest version.') | ||
|
||
parser.add_argument("--limit") | ||
parser.add_argument("project_name") | ||
parser.add_argument("--version", default="empty", help="If provided, will result in if that version passed policy check") | ||
|
||
args = parser.parse_args() | ||
|
||
hub = HubInstance() | ||
|
||
status=hub.get_project_violation_status(args.project_name, args.version) | ||
print(status) | ||
if(status == "IN_VIOLATION"): | ||
exit(0) | ||
elif(status == "NOT_IN_VIOLATION"): | ||
exit(0) | ||
else: | ||
exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you consider using self.get_project_version_by_name? would replace use of get_project_by_name and the subsequent code to retrieve the version if present, e.g. this method would then become,
def get_project_violation_status(self, project_name, version):
version = self.get_project_version_by_name(project_name, version)
if version:
return version.get('policyStatus', None)
else:
return "{}:{} not found".format(project_name, version)
or something along those lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, well I believe I was looking at it this way because it is a more precise error. If I remember get_project_version_by_name will return a non 200 on both missing projects or versions. and I wanted to tell my users what was missing the project or the version or if the server was just miss-behaving