-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate YAML formatting into its own plugin
This commit separates the yaml reporting code currently under Tern's core code and puts it in its own plugin that Stevedore can utilize. Specifically, the following changes were made: 1) Add yaml entrypoint to setup.cfg. 2) Remove the -y and --yaml command line option in tern/__main__.py. Moving forward we will utilize Stevedore to manage the plugin selection at runtime. Similar to the spdxtagvalue plugin, users can invoke the json reporting format by using "-m yaml" on the command line. 3) Copy the body of generate_yaml() in tern/report/report.py and move it under generate() in tern/formats/json/generator.py. Also copy print_yaml_report() function to tern/formats/json/generator.py so all the yaml-related formatting code is contained within the plugin. 4) Remove code corresponding to the -y command line option in tern/report/report.py. 5) Remove yaml_file constant in tern/utils/constants.py as it is no longer used. 6) Update the circleci test to run the yaml reporting using "-m yaml" instead of the deprecated -y command line option. Resolves #370 Signed-off-by: Rose Judge <[email protected]>
- Loading branch information
Showing
8 changed files
with
37 additions
and
28 deletions.
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
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,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2019 VMware, Inc. All Rights Reserved. | ||
# SPDX-License-Identifier: BSD-2-Clause |
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,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2019 VMware, Inc. All Rights Reserved. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
|
||
""" | ||
YAML document generator | ||
""" | ||
|
||
import yaml | ||
from tern.report import formats | ||
from tern.utils.general import get_git_rev_or_version | ||
from tern.formats import generator | ||
|
||
|
||
def print_yaml_report(image): | ||
'''Given an image object, create a yaml report''' | ||
image_dict = {} | ||
image_dict.update({'image': image.to_dict()}) | ||
return yaml.dump(image_dict, default_flow_style=False) | ||
|
||
|
||
class YAML(generator.Generate): | ||
def generate(self, image_obj_list): | ||
'''Generate a yaml report''' | ||
report = formats.disclaimer_yaml.format( | ||
version_info=get_git_rev_or_version()) | ||
for image in image_obj_list: | ||
report = report + print_yaml_report(image) | ||
return report |
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 |
---|---|---|
|
@@ -43,4 +43,3 @@ | |
mergedir = 'mergedir' | ||
# report file | ||
report_file = 'report.txt' | ||
yaml_file = 'report.yml' |