Skip to content

Commit 1a00987

Browse files
authored
tgc-revival: add cloudbuild resources (#14953)
1 parent c166d33 commit 1a00987

File tree

7 files changed

+31
-1
lines changed

7 files changed

+31
-1
lines changed

mmv1/api/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2164,7 +2164,7 @@ func (r Resource) TGCTestIgnorePropertiesToStrings(e resource.Examples) []string
21642164
// Filters out computed properties during cai2hcl
21652165
func (r Resource) ReadPropertiesForTgc() []*Type {
21662166
return google.Reject(r.AllUserProperties(), func(v *Type) bool {
2167-
return v.Output || v.UrlParamOnly
2167+
return v.Output || v.UrlParamOnly || v.TGCIgnoreRead
21682168
})
21692169
}
21702170

mmv1/api/type.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ type Type struct {
327327

328328
// If true, the custom flatten function is not applied during cai2hcl
329329
TGCIgnoreTerraformCustomFlatten bool `yaml:"tgc_ignore_terraform_custom_flatten,omitempty"`
330+
331+
TGCIgnoreRead bool `yaml:"tgc_ignore_read,omitempty"`
330332
}
331333

332334
const MAX_NAME = 20

mmv1/products/cloudbuild/BitbucketServerConfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ async:
4040
base_url: '{{op_id}}'
4141
result:
4242
resource_inside_response: true
43+
include_in_tgc_next_DO_NOT_USE: true
4344
custom_code:
4445
encoder: 'templates/terraform/encoders/cloudbuild_bitbucketserver_config.go.tmpl'
4546
post_create: 'templates/terraform/post_create/cloudbuild_bitbucketserver_config.go.tmpl'

mmv1/products/cloudbuildv2/Connection.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ iam_policy:
4949
custom_code:
5050
exclude_tgc: true
5151
legacy_long_form_project: true
52+
include_in_tgc_next_DO_NOT_USE: true
5253
sweeper:
5354
url_substitutions:
5455
- region: "us-central1"
@@ -59,6 +60,8 @@ examples:
5960
primary_resource_name: 'fmt.Sprintf("tf-test-connection%s", context["random_suffix"])'
6061
vars:
6162
connection_name: 'tf-test-connection'
63+
tgc_test_ignore_extra:
64+
- github_config.app_installation_id # It has 0 in Terraform configuration
6265
- name: 'cloudbuildv2_connection_ghe'
6366
exclude_test: true
6467
- name: 'cloudbuildv2_connection_github'
@@ -70,6 +73,7 @@ parameters:
7073
url_param_only: true
7174
required: true
7275
immutable: true
76+
custom_tgc_expand: 'templates/tgc_next/custom_expand/cloudbuildv2_repository_name.go.tmpl'
7377
- name: 'location'
7478
type: String
7579
description: The location for the resource

mmv1/products/cloudbuildv2/Repository.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ custom_code:
3939
encoder: 'templates/terraform/encoders/cloudbuildv2_repository.go.tmpl'
4040
exclude_tgc: true
4141
legacy_long_form_project: true
42+
include_in_tgc_next_DO_NOT_USE: true
4243
examples:
4344
# These tests depend on secrets stored in a separate project, so we prefer not
4445
# to show them in the docs.
@@ -48,18 +49,24 @@ examples:
4849
connection_name: 'connection'
4950
repository_name: 'repository'
5051
exclude_docs: true
52+
tgc_test_ignore_extra:
53+
- annotations # It has empty object in Terraform configuration
5154
- name: 'cloudbuildv2_repository_github'
5255
primary_resource_id: 'primary'
5356
vars:
5457
connection_name: 'connection'
5558
repository_name: 'repository'
5659
exclude_docs: true
60+
tgc_test_ignore_extra:
61+
- annotations # It has empty object in Terraform configuration
5762
- name: 'cloudbuildv2_repository_gle'
5863
primary_resource_id: 'primary'
5964
vars:
6065
connection_name: 'connection'
6166
repository_name: 'repository'
6267
exclude_docs: true
68+
tgc_test_ignore_extra:
69+
- annotations # It has empty object in Terraform configuration
6370
- name: 'cloudbuildv2_repository_ghe_doc'
6471
exclude_test: true
6572
- name: 'cloudbuildv2_repository_github_doc'
@@ -88,6 +95,8 @@ properties:
8895
required: true
8996
immutable: true
9097
ignore_read: true
98+
tgc_ignore_read: true
99+
custom_tgc_expand: 'templates/tgc_next/custom_expand/cloudbuildv2_repository_name.go.tmpl'
91100
- name: 'remoteUri'
92101
type: String
93102
description: Required. Git Clone HTTPS URI.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
func expand{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2+
m, err := tpgresource.ReplaceVarsForId(d, config, "{{"projects/{{project}}/locations/{{location}}/connections/{{name}}"}}")
3+
if err != nil {
4+
return nil, fmt.Errorf("Error constructing name: %s", err)
5+
}
6+
return m, nil
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
func expand{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2+
m, err := tpgresource.ReplaceVarsForId(d, config, "{{"projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/repositories/{{name}}"}}")
3+
if err != nil {
4+
return nil, fmt.Errorf("Error constructing name: %s", err)
5+
}
6+
return m, nil
7+
}

0 commit comments

Comments
 (0)