def parse_args(): parser = argparse.ArgumentParser( description='Tool for checking STDCIv2 configuration files.') parser.add_argument( '-p', '--project', action='store', dest='project_dir', help=('Path to project root directory. Default current directory.'), default=os.getcwd(), ) parser.add_argument('stage', action='store', help='STDCIv2 stage') add_logging_args(parser) return parser.parse_args()
def parse_args(args=None): parser = argparse.ArgumentParser( description='Utilities for managing Dockerfiles') add_logging_args(parser) subparsers = parser.add_subparsers(title='Subcommands') parent_image_update_parser = subparsers.add_parser( 'parent-image-update', help='Update the parent image reference based on a floating tag', description=dedent(""" Dockerfile syntax: #@follow_tag(ubi8-minimal:8-released) FROM ubi8-minimal:8-released ... The image in the FROM instruction will be replaced by the NVR of the current image that is tagged with the tag in the follow_tag decorator. A Docker config file with tokens to the container registries can be specified using the "REGISTRY_AUTH_FILE" environment variable. """)) parent_image_update_parser.set_defaults(handler=parent_image_update_main) parent_image_update_parser.add_argument('dockerfiles', metavar='DOCKERFILE', nargs='+') parent_image_update_parser.add_argument( '--lookup-registry', default='', help='The registery that will be used when looking up for new images') parent_image_update_parser.add_argument( '--dry-run', action='store_true', help='Do not update anything, just print what will be updated') parent_image_update_parser.add_argument( '--use-sha', action='store_true', default=False, help='Use the SHA sum of the latest image when' ' injecting it to the Dockerfile') return parser.parse_args(args=args)
def parse_args(): parser = argparse.ArgumentParser( description='Safe cleanup of Docker images with whitelist filter') parser.add_argument( '-c', '--client', help=('Pocal path or base URL to docker socket.' ' If not specified, will try from env as Docker\'s CLI.'), nargs=1, type=str, default='from-env', action='store') parser.add_argument( '-w', '--whitelist', help=( 'Whitelisted repositories: images from those repositories will not' ' be deleted'), nargs="+", default=[]) add_logging_args(parser) return parser.parse_args()
def parse_args(args=None): parser = argparse.ArgumentParser( description='Utilities for managing Dockerfiles') add_logging_args(parser) subparsers = parser.add_subparsers(title='Subcommands') parent_image_update_parser = subparsers.add_parser( 'parent-image-update', help='Update the parent image reference based on a floating tag', description=dedent(""" Dockerfile syntax: #@follow_tag(ubi8-minimal:8-released) FROM ubi8-minimal:8-released ... The image in the FROM instruction will be replaced by the NVR of the current image that is tagged with the tag in the follow_tag decorator. """)) parent_image_update_parser.set_defaults(handler=parent_image_update_main) parent_image_update_parser.add_argument('dockerfiles', metavar='DOCKERFILE', nargs='+') parent_image_update_parser.add_argument( '--lookup-registry', default='', help='The registery that will be used when looking up for new images') parent_image_update_parser.add_argument( '--dry-run', action='store_true', help='Do not update anything, just print what will be updated') parent_image_update_parser.add_argument( '--flat-nested-repositories', action='store_true', help='Flat nested repositories (replace / with -) for the images that' ' were discovered') return parser.parse_args(args=args)
def parse_args(): parser = argparse.ArgumentParser( description='Tool for automated pushing of patches to SCMs') add_logging_args(parser) subparsers = parser.add_subparsers(dest='COMMAND') subparsers.required = True push_parser = subparsers.add_parser( 'push', help='Push commit in $CWD', description='Push the local commit into the appropriate remote SCM', ) push_parser.set_defaults(handler=push_main) push_parser.add_argument( 'branch', help='Which branch to push changes into', ) push_parser.add_argument( '--push-map', default=DEFAULT_PUSH_MAP, help=('Path to a push map YAML file that specifies details about how' ' to connect to the remote SCM servers and push changes.'), ) push_parser.add_argument( '--unless-hash', help=('Push only if HEAD is different than the specified Git hash' 'or commit reference'), ) push_parser.add_argument( '--if-not-exists', action='store_true', help='Avoid pushing if similar commit was already pushed', ) can_merge_parser = subparsers.add_parser( 'can_merge', help='Check if allowed to merge specified commit in $CWD', description=( 'Check if the local commit is allowed to be automatically merged' ' into the appropriate remote SCM. For a commit to be auto merged,' ' a certain header must be set if specified, and the commit owner' ' must be one of the project maintainers.'), ) can_merge_parser.set_defaults(handler=can_merge_main) can_merge_parser.add_argument( 'commit', help='A ref of the commit to merge. Defaults to HEAD', nargs='?', default='HEAD', ) can_merge_parser.add_argument( '--push-map', default=DEFAULT_PUSH_MAP, help=('Path to a push map YAML file that specifies details about how' ' to connect to the remote SCM servers and merge changes.'), ) can_merge_mxg = can_merge_parser.add_mutually_exclusive_group() can_merge_mxg.add_argument( '--check-header', nargs=1, default='automerge', help=('Set the name of the commit message header to check in order to' ' confirm running a merge. If option is not specified, The' ' "automerge" header will be checked.')) can_merge_mxg.add_argument( '--no-check-header', const=None, action='store_const', dest='check_header', help='Skip commit message header check.', ) merge_parser = subparsers.add_parser( 'merge', help='Merge specified commit in $CWD', description='Merge the local commit into the appropriate remote SCM', ) merge_parser.set_defaults(handler=merge_main) merge_parser.add_argument( 'commit', help='A ref of the commit to merge. Defaults to HEAD', nargs='?', default='HEAD', ) merge_parser.add_argument( '--push-map', default=DEFAULT_PUSH_MAP, help=('Path to a push map YAML file that specifies details about how' ' to connect to the remote SCM servers and merge changes.'), ) merge_mxg = merge_parser.add_mutually_exclusive_group() merge_mxg.add_argument( '--check-header', nargs=1, default='automerge', help=('Set the name of the commit message header to check in order to' ' confirm running a merge. If option is not specified, The' ' "automerge" header will be checked.')) merge_mxg.add_argument( '--no-check-header', const=None, action='store_const', dest='check_header', help='Skip commit message header check.', ) get_header_parser = subparsers.add_parser( 'get_header', help='Get commit message header value', description=( 'Get commit message header value for a specified commit in $PWD'), ) get_header_parser.set_defaults(handler=get_header_main) get_header_parser.add_argument('header', help='The header to get a value for') get_header_parser.add_argument( 'commit', help=('A ref of the commit to get value from. Defaults to HEAD'), nargs='?', default='HEAD', ) get_header_parser.add_argument( '--default-value', default=None, help=( 'A default value to return if the header was not specified in the' ' commit. If unspecified, the command will raise an error if the' ' header is missing')) is_header_true_parser = subparsers.add_parser( 'is_header_true', help='Check commit message header for truth', description=( 'Check if commit message header value for a specified commit in ' '$PWD is set to "true" or "on"'), ) is_header_true_parser.set_defaults(handler=is_header_true_main) is_header_true_parser.add_argument('header', help='The header to check') is_header_true_parser.add_argument( 'commit', help=('A ref of the commit to get header from. Defaults to HEAD'), nargs='?', default='HEAD', ) map_check_parser = subparsers.add_parser( 'map_check', help='Check push map file', description=('Check correctness of push map file'), ) map_check_parser.set_defaults(handler=map_check_main) map_check_parser.add_argument( 'remote_url', help='The remote URL to lookup in the push map') map_check_parser.add_argument( '--push-map', default=DEFAULT_PUSH_MAP, help=('Path to a push map YAML file that specifies details about how' ' to connect to the remote SCM servers and merge changes.'), ) return parser.parse_args()