-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcloudbuild.yaml
89 lines (84 loc) · 4.24 KB
/
cloudbuild.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
steps:
- id: "Authenticate to gcloud"
name: gcr.io/cloud-builders/gcloud
entrypoint: /bin/bash
args:
- -c
- |
gcloud auth application-default print-access-token > /workspace/creds
gcloud run services describe mockserver --format 'value(status.url)' --region=us-central1 > /workspace/cloudrunendpoint
- id: "Install Dependencies"
name: node:12
entrypoint: npm
args: ['install', '--silent', '--no-fund']
- id: "API Standard Conformance Check"
name: node:12
entrypoint: npm
args: ['run', 'lint']
- id: "Create/Update API in Registry"
#name: 'ghcr.io/apigee/registry-linters:main'
name: 'gcr.io/$PROJECT_ID/custom-linter:latest'
entrypoint: /bin/bash
args:
- -c
- |
export APG_REGISTRY_TOKEN=$(cat /workspace/creds)
#Create API
registry rpc update-api --api.name projects/$PROJECT_ID/locations/global/apis/petstore \
--api.annotations "[email protected]" \
--api.annotations "apihub-primary-contact-description=Team email" \
--api.labels "apihub-business-unit=example" \
--api.labels "apihub-lifecycle=concept" \
--api.labels "apihub-style=apihub-openapi" \
--api.labels "apihub-target-users=public" \
--api.labels "apihub-team=example" \
--api.description "Petstore API to manage Pets" \
--api.display_name Petstore --allow_missing
#Create API Version
registry rpc update-api-version --api_version.name \
projects/$PROJECT_ID/locations/global/apis/petstore/versions/v1 --api_version.display_name v1 \
--allow_missing
#Create API Version Spec
registry rpc update-api-spec --api_spec.filename=openapi.yaml \
--api_spec.name=projects/$PROJECT_ID/locations/global/apis/petstore/versions/v1/specs/openapi.yaml \
--api_spec.contents `cat openapi.yaml | gzip --stdout | xxd -p | tr -d '\n'` --api_spec.mime_type "application/x.openapi+gzip;version=3" \
--json --allow_missing > /workspace/spec_output
apt update && apt install jq -y
echo $(cat /workspace/spec_output) | jq '.revisionId' -r > /workspace/revisionId
- id: "Fetch Spec scorecard and lint errors"
#name: 'ghcr.io/apigee/registry-linters:main'
name: 'gcr.io/$PROJECT_ID/custom-linter:latest'
entrypoint: /bin/bash
args:
- -c
- |
export APG_REGISTRY_TOKEN=$(cat /workspace/creds)
export APG_REGISTRY_ADDRESS=apigeeregistry.googleapis.com:443
registry apply -f registry -R --parent=projects/$PROJECT_ID/locations/global
# For generating lint results
registry resolve projects/$PROJECT_ID/locations/global/artifacts/demo-manifest --jobs 1
sleep 5
# For generating scores
registry resolve projects/$PROJECT_ID/locations/global/artifacts/demo-manifest --jobs 1
sleep 5
# For generating scorecards
registry resolve projects/$PROJECT_ID/locations/global/artifacts/demo-manifest --jobs 1
registry get projects/$PROJECT_ID/locations/global/apis/petstore/versions/v1/specs/openapi.yaml/artifacts/conformance-apihub-styleguide --contents
registry get projects/$PROJECT_ID/locations/global/apis/petstore/versions/v1/specs/openapi.yaml/artifacts/scorecard-lint-summary --contents
- id: "Create/Update API Deployment"
name: 'gcr.io/$PROJECT_ID/custom-linter:latest'
entrypoint: /bin/bash
args:
- -c
- |
export APG_REGISTRY_TOKEN=$(cat /workspace/creds)
registry rpc update-api-deployment \
--api_deployment.name projects/$PROJECT_ID/locations/global/apis/petstore/deployments/mock-service \
--api_deployment.api_spec_revision projects/$PROJECT_ID/locations/global/apis/petstore/versions/v1/specs/openapi.yaml@$(cat /workspace/revisionId) \
--api_deployment.display_name "Mock endpoint" \
--api_deployment.endpoint_uri "$(cat /workspace/cloudrunendpoint)/projects/$PROJECT_ID/locations/global/apis/petstore/versions/v1/specs/openapi.yaml" \
--api_deployment.external_channel_uri "$(cat /workspace/cloudrunendpoint)/projects/$PROJECT_ID/locations/global/apis/petstore/versions/v1/specs/openapi.yaml" \
--api_deployment.annotations "apihub-external-channel-name=Mock" \
--api_deployment.intended_audience "This is a Mock endpoint" \
--api_deployment.labels "apihub-gateway=apihub-unmanaged" \
--allow_missing