Skip to content

Commit 154d1e9

Browse files
authored
feat(gcp-resources): Add Cloud Deploy (#6321)
#### Summary Relevant API https://cloud.google.com/deploy/docs/api/reference/rest Tested by following https://cloud.google.com/deploy/docs/deploy-app-gke <!--
1 parent 90da209 commit 154d1e9

18 files changed

Lines changed: 1013 additions & 0 deletions
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package recipes
2+
3+
import (
4+
deploy "cloud.google.com/go/deploy/apiv1"
5+
pb "cloud.google.com/go/deploy/apiv1/deploypb"
6+
)
7+
8+
func init() {
9+
resources := []*Resource{
10+
{
11+
SubService: "targets",
12+
Struct: &pb.Target{},
13+
PrimaryKeys: []string{ProjectIdColumn.Name, "name"},
14+
RequestStructFields: `Parent: "projects/" + c.ProjectId + "/locations/-",`,
15+
Description: "https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.targets#Target",
16+
},
17+
{
18+
SubService: "delivery_pipelines",
19+
Struct: &pb.DeliveryPipeline{},
20+
PrimaryKeys: []string{ProjectIdColumn.Name, "name"},
21+
RequestStructFields: `Parent: "projects/" + c.ProjectId + "/locations/-",`,
22+
Description: "https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines#DeliveryPipeline",
23+
Relations: []string{"Releases()"},
24+
SkipMock: true,
25+
},
26+
{
27+
SubService: "releases",
28+
Struct: &pb.Release{},
29+
PrimaryKeys: []string{ProjectIdColumn.Name, "name"},
30+
RequestStructFields: `Parent: parent.Item.(*pb.DeliveryPipeline).Name,`,
31+
Description: "https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines.releases#Release",
32+
ChildTable: true,
33+
SkipMock: true,
34+
Relations: []string{"Rollouts()"},
35+
},
36+
{
37+
SubService: "rollouts",
38+
Struct: &pb.Rollout{},
39+
PrimaryKeys: []string{ProjectIdColumn.Name, "name"},
40+
RequestStructFields: `Parent: parent.Item.(*pb.Release).Name,`,
41+
Description: "https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines.releases.rollouts#Rollout",
42+
ChildTable: true,
43+
SkipMock: true,
44+
Relations: []string{"JobRuns()"},
45+
},
46+
{
47+
SubService: "job_runs",
48+
Struct: &pb.JobRun{},
49+
PrimaryKeys: []string{ProjectIdColumn.Name, "name"},
50+
RequestStructFields: `Parent: parent.Item.(*pb.Rollout).Name,`,
51+
Description: "https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines.releases.rollouts.jobRuns#JobRun",
52+
ChildTable: true,
53+
SkipMock: true,
54+
},
55+
}
56+
57+
for _, resource := range resources {
58+
resource.Service = "clouddeploy"
59+
resource.ServiceAPIOverride = "deploy"
60+
resource.Template = "newapi_list"
61+
resource.MockTemplate = "newapi_list_grpc_mock"
62+
resource.ProtobufImport = "cloud.google.com/go/deploy/apiv1/deploypb"
63+
resource.MockImports = []string{"cloud.google.com/go/deploy/apiv1"}
64+
resource.NewFunction = deploy.NewCloudDeployClient
65+
resource.RegisterServer = pb.RegisterCloudDeployServer
66+
}
67+
68+
Resources = append(Resources, resources...)
69+
}

plugins/source/gcp/docs/tables/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
- [gcp_billing_billing_accounts](gcp_billing_billing_accounts.md)
7474
- [gcp_billing_budgets](gcp_billing_budgets.md)
7575
- [gcp_billing_services](gcp_billing_services.md)
76+
- [gcp_clouddeploy_targets](gcp_clouddeploy_targets.md)
77+
- [gcp_clouddeploy_delivery_pipelines](gcp_clouddeploy_delivery_pipelines.md)
78+
- [gcp_clouddeploy_releases](gcp_clouddeploy_releases.md)
79+
- [gcp_clouddeploy_rollouts](gcp_clouddeploy_rollouts.md)
80+
- [gcp_clouddeploy_job_runs](gcp_clouddeploy_job_runs.md)
7681
- [gcp_clouderrorreporting_error_group_stats](gcp_clouderrorreporting_error_group_stats.md)
7782
- [gcp_clouderrorreporting_error_events](gcp_clouderrorreporting_error_events.md)
7883
- [gcp_compute_addresses](gcp_compute_addresses.md)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Table: gcp_clouddeploy_delivery_pipelines
2+
3+
https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines#DeliveryPipeline
4+
5+
The composite primary key for this table is (**project_id**, **name**).
6+
7+
## Relations
8+
9+
The following tables depend on gcp_clouddeploy_delivery_pipelines:
10+
- [gcp_clouddeploy_releases](gcp_clouddeploy_releases.md)
11+
12+
## Columns
13+
14+
| Name | Type |
15+
| ------------- | ------------- |
16+
|_cq_source_name|String|
17+
|_cq_sync_time|Timestamp|
18+
|_cq_id|UUID|
19+
|_cq_parent_id|UUID|
20+
|project_id (PK)|String|
21+
|name (PK)|String|
22+
|uid|String|
23+
|description|String|
24+
|annotations|JSON|
25+
|labels|JSON|
26+
|create_time|Timestamp|
27+
|update_time|Timestamp|
28+
|condition|JSON|
29+
|etag|String|
30+
|suspended|Bool|
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Table: gcp_clouddeploy_job_runs
2+
3+
https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines.releases.rollouts.jobRuns#JobRun
4+
5+
The composite primary key for this table is (**project_id**, **name**).
6+
7+
## Relations
8+
9+
This table depends on [gcp_clouddeploy_rollouts](gcp_clouddeploy_rollouts.md).
10+
11+
## Columns
12+
13+
| Name | Type |
14+
| ------------- | ------------- |
15+
|_cq_source_name|String|
16+
|_cq_sync_time|Timestamp|
17+
|_cq_id|UUID|
18+
|_cq_parent_id|UUID|
19+
|project_id (PK)|String|
20+
|name (PK)|String|
21+
|uid|String|
22+
|phase_id|String|
23+
|job_id|String|
24+
|create_time|Timestamp|
25+
|start_time|Timestamp|
26+
|end_time|Timestamp|
27+
|state|String|
28+
|etag|String|
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Table: gcp_clouddeploy_releases
2+
3+
https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines.releases#Release
4+
5+
The composite primary key for this table is (**project_id**, **name**).
6+
7+
## Relations
8+
9+
This table depends on [gcp_clouddeploy_delivery_pipelines](gcp_clouddeploy_delivery_pipelines.md).
10+
11+
The following tables depend on gcp_clouddeploy_releases:
12+
- [gcp_clouddeploy_rollouts](gcp_clouddeploy_rollouts.md)
13+
14+
## Columns
15+
16+
| Name | Type |
17+
| ------------- | ------------- |
18+
|_cq_source_name|String|
19+
|_cq_sync_time|Timestamp|
20+
|_cq_id|UUID|
21+
|_cq_parent_id|UUID|
22+
|project_id (PK)|String|
23+
|name (PK)|String|
24+
|uid|String|
25+
|description|String|
26+
|annotations|JSON|
27+
|labels|JSON|
28+
|abandoned|Bool|
29+
|create_time|Timestamp|
30+
|render_start_time|Timestamp|
31+
|render_end_time|Timestamp|
32+
|skaffold_config_uri|String|
33+
|skaffold_config_path|String|
34+
|build_artifacts|JSON|
35+
|delivery_pipeline_snapshot|JSON|
36+
|target_snapshots|JSON|
37+
|render_state|String|
38+
|etag|String|
39+
|skaffold_version|String|
40+
|target_artifacts|JSON|
41+
|target_renders|JSON|
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Table: gcp_clouddeploy_rollouts
2+
3+
https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines.releases.rollouts#Rollout
4+
5+
The composite primary key for this table is (**project_id**, **name**).
6+
7+
## Relations
8+
9+
This table depends on [gcp_clouddeploy_releases](gcp_clouddeploy_releases.md).
10+
11+
The following tables depend on gcp_clouddeploy_rollouts:
12+
- [gcp_clouddeploy_job_runs](gcp_clouddeploy_job_runs.md)
13+
14+
## Columns
15+
16+
| Name | Type |
17+
| ------------- | ------------- |
18+
|_cq_source_name|String|
19+
|_cq_sync_time|Timestamp|
20+
|_cq_id|UUID|
21+
|_cq_parent_id|UUID|
22+
|project_id (PK)|String|
23+
|name (PK)|String|
24+
|uid|String|
25+
|description|String|
26+
|annotations|JSON|
27+
|labels|JSON|
28+
|create_time|Timestamp|
29+
|approve_time|Timestamp|
30+
|enqueue_time|Timestamp|
31+
|deploy_start_time|Timestamp|
32+
|deploy_end_time|Timestamp|
33+
|target_id|String|
34+
|approval_state|String|
35+
|state|String|
36+
|failure_reason|String|
37+
|deploying_build|String|
38+
|etag|String|
39+
|deploy_failure_cause|String|
40+
|phases|JSON|
41+
|metadata|JSON|
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Table: gcp_clouddeploy_targets
2+
3+
https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.targets#Target
4+
5+
The composite primary key for this table is (**project_id**, **name**).
6+
7+
## Columns
8+
9+
| Name | Type |
10+
| ------------- | ------------- |
11+
|_cq_source_name|String|
12+
|_cq_sync_time|Timestamp|
13+
|_cq_id|UUID|
14+
|_cq_parent_id|UUID|
15+
|project_id (PK)|String|
16+
|name (PK)|String|
17+
|target_id|String|
18+
|uid|String|
19+
|description|String|
20+
|annotations|JSON|
21+
|labels|JSON|
22+
|require_approval|Bool|
23+
|create_time|Timestamp|
24+
|update_time|Timestamp|
25+
|etag|String|
26+
|execution_configs|JSON|

plugins/source/gcp/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
cloud.google.com/go/compute v1.14.0
1717
cloud.google.com/go/container v1.8.0
1818
cloud.google.com/go/containeranalysis v0.6.0
19+
cloud.google.com/go/deploy v1.5.0
1920
cloud.google.com/go/domains v0.7.0
2021
cloud.google.com/go/errorreporting v0.3.0
2122
cloud.google.com/go/functions v1.9.0

plugins/source/gcp/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ cloud.google.com/go/containeranalysis v0.6.0 h1:2824iym832ljKdVpCBnpqm5K94YT/uHT
5151
cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4=
5252
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
5353
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
54+
cloud.google.com/go/deploy v1.5.0 h1:kI6dxt8Ml0is/x7YZjLveTvR7YPzXAUD/8wQZ2nH5zA=
55+
cloud.google.com/go/deploy v1.5.0/go.mod h1:ffgdD0B89tToyW/U/D2eL0jN2+IEV/3EMuXHA0l4r+s=
5456
cloud.google.com/go/domains v0.7.0 h1:pu3JIgC1rswIqi5romW0JgNO6CTUydLYX8zyjiAvO1c=
5557
cloud.google.com/go/domains v0.7.0/go.mod h1:PtZeqS1xjnXuRPKE/88Iru/LdfoRyEHYA9nFQf4UKpg=
5658
cloud.google.com/go/errorreporting v0.3.0 h1:kj1XEWMu8P0qlLhm3FwcaFsUvXChV/OraZwA70trRR0=

plugins/source/gcp/resources/plugin/autogen_tables.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)