コード例 #1
0
def validate_configuration(configuration: Configuration) -> Configuration:
    """
    Validates the configuration.  If configuration is `None`, it will be
    read from disk.
    """

    if not configuration:
        configuration = Configuration.create_from_config_file()

    if not configuration.exclude:
        configuration.exclude = read_gitignore()

    if configuration.layer_output and not configuration.requirements:
        raise ValueError(
            "Layer output parameter cannot be given without requirements parameter"
        )

    return configuration
コード例 #2
0
def main():
    """
    Main entry point of the Command
    """
    parser = argparse.ArgumentParser("lambda_package")
    add_arguments(parser)
    args = parser.parse_args()
    configuration = Configuration.create_from_config_file()
    configuration.output = args.output if args.output else configuration.output

    (_, tree) = package(root_path=args.path, configuration=configuration)

    if not configuration.output and not configuration.layer_output:
        print_tree(tree)
    else:
        if configuration.output:
            print(f"Successfully created package {configuration.output}")
        if configuration.requirements and configuration.layer_output:
            print(
                f"Successfully created layer package {configuration.layer_output}"
            )