Skip to content

Commit ee8513f

Browse files
Update manage_project_structure.py
added logic to skip base layer
1 parent e274af8 commit ee8513f

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

examples/client/multi-image/manage_project_structure.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
Sub-projects could be specified in a text file with -ssf --subproject-spec-file parameter
4949
Each line will have to contain full image specification.
5050
Specification will be parsed and image name prefixed by -str parameter will be used as a sub-project name
51-
In this mode any image that is not residing on ciena.com repository will be skipped.
51+
In this mode any image that is not residing on //your domain for example abc.com// repository will be skipped.
5252
If -str parameter is empty, Project Name will be used instead.
5353
5454
Container image name scanned will be written into project version nickname field
@@ -84,6 +84,7 @@ def __init__(self, args):
8484
else:
8585
self.init_project_data(args)
8686
self.serialize = args.serialize
87+
self.skip_group=args.skip_group
8788

8889
def connect(self):
8990
self.client = Client(base_url=self.base_url, token=self.access_token, verify=self.no_verify, timeout=60.0, retries=4)
@@ -314,15 +315,17 @@ def process_text_spec_file(self,args):
314315
prefix = args.string_to_put_in_front_of_subproject_name
315316
if not prefix:
316317
prefix = args.project_name
317-
with open(args.subproject_spec_file, "r") as f:
318-
lines = f.read().splitlines()
319-
for line in lines:
320-
image_name = line.split('/')[-1].split(':')[0] # Don't look at me, you wrote it!
321-
sub_project_name = "_".join((prefix, image_name))
322-
spec_line = ":".join((sub_project_name, line))
323-
# if "ciena.com" in spec_line:
324-
project_list.append(spec_line)
325-
return (project_list)
318+
if args.subproject_spec_file is not None :
319+
with open(args.subproject_spec_file, "r") as f:
320+
lines = f.read().splitlines()
321+
for line in lines:
322+
#print(line)
323+
image_name = line.split('/')[-1].split(':')[0] # Don't look at me, you wrote it!
324+
sub_project_name = "_".join((prefix, image_name))
325+
spec_line = ":".join((sub_project_name, line))
326+
# if "//your domain ex. abc.com //" in spec_line:
327+
project_list.append(spec_line)
328+
return (project_list)
326329

327330
def get_child_spec_list(self,args):
328331
if args.subproject_list:
@@ -459,7 +462,8 @@ def scan_container_images(self):
459462
parent_version,
460463
detect_options,
461464
hub=hub,
462-
binary=self.binary
465+
binary=self.binary,
466+
skip_group = self.skip_group
463467
)
464468
child['scan_results'] = results
465469
except Exception as e:
@@ -537,6 +541,7 @@ def parse_command_args():
537541
parser.add_argument("-ifm", "--individual-file-matching", action='store_true', help="Turn Individual file matching on")
538542
parser.add_argument("--reprocess-run-file", help="Reprocess Failures from previous run report.")
539543
parser.add_argument("--serialize", action='store_true', help="Serialize scan submissions by adding --detect.wait.for.results=true to scan invocations")
544+
parser.add_argument("--skip-group", required=False, help="exclude layers belog to specific groups, ex. 'base' ")
540545
args = parser.parse_args()
541546
if not args.reprocess_run_file and not (args.project_name and args.version_name):
542547
parser.error("[ -p/--project-name and -pv/--version-name ] or --reprocess-run-file are required")
@@ -565,3 +570,5 @@ def main():
565570

566571
if __name__ == "__main__":
567572
sys.exit(main())
573+
574+

0 commit comments

Comments
 (0)