From 95a4635f520a6c25b4421e4a369af95a097363e1 Mon Sep 17 00:00:00 2001 From: jasonwalsh Date: Tue, 9 Jul 2019 17:21:40 -0400 Subject: [PATCH] feat: add flag to specify type of integrity check --- filestoreIntegrity/filestoreIntegrity.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/filestoreIntegrity/filestoreIntegrity.py b/filestoreIntegrity/filestoreIntegrity.py index d7b8681..a436aed 100755 --- a/filestoreIntegrity/filestoreIntegrity.py +++ b/filestoreIntegrity/filestoreIntegrity.py @@ -8,7 +8,7 @@ import urllib.error # check the integrity, and print the results to stdout or the specified file -def runCheck(conn, outfile): +def runCheck(conn, outfile, _type): # open the output file for writing, or use stdout try: if outfile != None and outfile != '-': @@ -20,7 +20,7 @@ def runCheck(conn, outfile): count = 0 # iterate through every artifact, and print the ones that don't check with outf: - for repo in getRepoList(conn): + for repo in getRepoList(conn, _type): for artif in getArtifactList(conn, repo): response = checkArtifact(conn, repo, artif) if response != None: @@ -32,8 +32,8 @@ def runCheck(conn, outfile): print(msg, file=outf) # request a list of all local repositories, and return them -def getRepoList(conn): - stat, msg = runRequest(conn, '/api/repositories?type=local') +def getRepoList(conn, _type): + stat, msg = runRequest(conn, '/api/repositories?type={}'.format(_type)) if stat != 200: print('Error getting repository list: {}'.format(msg), file=sys.stderr) sys.exit(1) @@ -93,12 +93,14 @@ def getArgs(): "Check Artifactory for filestore integrity.", "the Artifactory base url", "your Artifactory username (or username:password)", - "output to the given file, rather than to stdout" + "output to the given file, rather than to stdout", + "The type of filestore integrity check (local or remote)" ] parser = argparse.ArgumentParser(description=help[0]) parser.add_argument('url', nargs=1, help=help[1]) parser.add_argument('-u', '--user', help=help[2]) parser.add_argument('-o', '--output-file', help=help[3]) + parser.add_argument('-t', '--type', default='local', help=help[4]) return parser.parse_args() if __name__ == "__main__": @@ -108,4 +110,4 @@ def getArgs(): auth = getAuth(args.user) urlbase = args.url[0] if urlbase[-1] == '/': urlbase = urlbase[:-1] - runCheck((urlbase, auth), args.output_file) + runCheck((urlbase, auth), args.output_file, args.type)