in marketplace/deployer_util/validate_app_resource.py [0:0]
def main():
parser = ArgumentParser(description=_PROG_HELP)
schema_values_common.add_to_argument_parser(parser)
parser.add_argument(
'--manifests',
required=True,
help='The yaml file containing all resources')
args = parser.parse_args()
schema = schema_values_common.load_schema(args)
resources = load_resources_yaml(args.manifests)
app = find_application_resource(resources)
mp_deploy_info = app.get('metadata', {}).get(
'annotations', {}).get('marketplace.cloud.google.com/deploy-info')
if not mp_deploy_info:
raise Exception('Application resource is missing '
'"marketplace.cloud.google.com/deploy-info" annotation')
validate_deploy_info_annotation(mp_deploy_info, schema)
version = app.get('spec', {}).get('descriptor', {}).get('version')
if not version or not isinstance(version, str):
raise Exception(
'Application resource must have a valid spec.descriptor.version value')
if schema.is_v2():
published_version = schema.x_google_marketplace.published_version
if version != published_version:
raise Exception(
'Application resource\'s spec.descriptor.version "{}" does not match '
'schema.yaml\'s publishedVersion "{}"'.format(version,
published_version))