Skip to content

Commit e7a0201

Browse files
Merge branch 'GoogleCloudPlatform:main' into deletion-protection-memcache-new
2 parents f9f61a3 + 19ff13a commit e7a0201

File tree

118 files changed

+3649
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+3649
-214
lines changed
Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
11
package cmd
22

33
import (
4-
"magician/exec"
5-
"magician/github"
6-
"os"
74
"testing"
85
)
96

107
func TestFetchPRNumber(t *testing.T) {
11-
rnr, err := exec.NewRunner()
12-
if err != nil {
13-
t.Errorf("error creating Runner: %s", err)
14-
}
15-
16-
githubToken, ok := os.LookupEnv("GITHUB_TOKEN_CLASSIC")
17-
if !ok {
18-
t.Errorf("did not provide GITHUB_TOKEN_CLASSIC environment variable")
8+
mr := NewMockRunner()
9+
gh := &mockGithub{
10+
calledMethods: make(map[string][][]any),
11+
commitMessage: "Add `additional_group_keys` attribute to `google_cloud_identity_group` resource (#9217) (#6504)\n\n* Add `additional_group_keys` attribute to `google_cloud_identity_group` resource\n\n* Update acceptance test to check for attribute\n\n* Fix test check\n\n* Add `output: true` to nested properties in output field\n[upstream:49d3741f9d4d810a0a4768363bb8498afa21c688]\n\nSigned-off-by: Modular Magician <[email protected]>",
1912
}
2013

21-
gh := github.NewClient(githubToken)
22-
23-
prNumber, err := fetchPRNumber("8c6e61bb62d52c950008340deafc1e2a2041898a", "main", rnr, gh)
24-
14+
// Call function with mocks
15+
prNumber, err := fetchPRNumber("8c6e61bb62d52c950008340deafc1e2a2041898a", "main", mr, gh)
2516
if err != nil {
2617
t.Errorf("error fetching PR number: %s", err)
2718
}
2819

2920
if prNumber != "6504" {
3021
t.Errorf("PR number is %s, expected 6504", prNumber)
3122
}
23+
24+
// Verify GitHub API was called
25+
if calls, ok := gh.calledMethods["GetCommitMessage"]; !ok || len(calls) == 0 {
26+
t.Errorf("Expected GetCommitMessage to be called")
27+
} else {
28+
args := calls[0]
29+
if len(args) != 3 {
30+
t.Errorf("Expected GetCommitMessage to be called with 3 arguments, got %d", len(args))
31+
} else {
32+
if args[0] != "hashicorp" {
33+
t.Errorf("Expected owner to be 'hashicorp', got '%s'", args[0])
34+
}
35+
if args[1] != "terraform-provider-google-beta" {
36+
t.Errorf("Expected repo to be 'terraform-provider-google-beta', got '%s'", args[1])
37+
}
38+
if args[2] != "8c6e61bb62d52c950008340deafc1e2a2041898a" {
39+
t.Errorf("Expected SHA to be '8c6e61bb62d52c950008340deafc1e2a2041898a', got '%s'", args[2])
40+
}
41+
}
42+
}
3243
}

.ci/magician/cmd/mock_github_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type mockGithub struct {
2929
pullRequestComments []github.PullRequestComment
3030
teamMembers map[string][]github.User
3131
calledMethods map[string][][]any
32+
commitMessage string
3233
}
3334

3435
func (m *mockGithub) GetPullRequest(prNumber string) (github.PullRequest, error) {
@@ -63,7 +64,7 @@ func (m *mockGithub) GetPullRequestComments(prNumber string) ([]github.PullReque
6364

6465
func (m *mockGithub) GetCommitMessage(owner, repo, sha string) (string, error) {
6566
m.calledMethods["GetCommitMessage"] = append(m.calledMethods["GetCommitMessage"], []any{owner, repo, sha})
66-
return "commit message", nil
67+
return m.commitMessage, nil
6768
}
6869

6970
func (m *mockGithub) GetTeamMembers(organization, team string) ([]github.User, error) {

.ci/magician/github/set.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"fmt"
2020
utils "magician/utility"
2121
"strings"
22+
"time"
2223
)
2324

2425
func (gh *Client) PostBuildStatus(prNumber, title, state, targetURL, commitSha string) error {
@@ -165,7 +166,10 @@ func (gh *Client) MergePullRequest(owner, repo, prNumber, commitSha string) erro
165166
// Check if the error is "Merge already in progress" (405)
166167
if strings.Contains(err.Error(), "Merge already in progress") {
167168
fmt.Printf("Pull request %s is already being merged\n", prNumber)
168-
return nil
169+
// This status does not indicate that the Pull Request was merged
170+
// Try again after 20s
171+
time.Sleep(20 * time.Second)
172+
return gh.MergePullRequest(owner, repo, prNumber, commitSha)
169173
}
170174
// Check if the PR is already merged (returns 405 Pull Request is not mergeable)
171175
if strings.Contains(err.Error(), "Pull Request is not mergeable") {

.ci/magician/utility/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func makeHTTPRequest(url, method, credentials string, body any) (*http.Response,
6262
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", credentials))
6363
req.Header.Set("Content-Type", "application/json")
6464
req.Header.Set("Accept", "application/json")
65+
6566
fmt.Println("")
6667
fmt.Println("request url: ", url)
6768
fmt.Println("request body: ", string(jsonBody))
@@ -79,6 +80,7 @@ func makeHTTPRequest(url, method, credentials string, body any) (*http.Response,
7980
}
8081

8182
fmt.Println("response status-code: ", resp.StatusCode)
83+
fmt.Println("response body: ", string(respBodyBytes))
8284
fmt.Println("")
8385

8486
return resp, respBodyBytes, nil

mmv1/products/alloydb/Instance.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ properties:
363363
The network attachment must be in the same region as the instance.
364364
- name: 'networkConfig'
365365
type: NestedObject
366+
default_from_api: true
366367
description: |
367368
Instance level network configuration.
368369
properties:

mmv1/products/apigee/Organization.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ description: |
1818
references:
1919
guides:
2020
'Creating an API organization': 'https://cloud.google.com/apigee/docs/api-platform/get-started/create-org'
21+
'Setting a custom endpoint (required for data residency)': 'https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#advanced-settings-configuration'
2122
api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations'
2223
docs:
2324
base_url: 'organizations'
@@ -75,6 +76,20 @@ examples:
7576
exclude_docs: true
7677
# Resource creation race
7778
skip_vcr: true
79+
- name: 'apigee_organization_cloud_basic_data_residency'
80+
exclude_test: true
81+
# This is a more verbose version of the above that creates all
82+
# the resources needed for the acceptance test.
83+
- name: 'apigee_organization_cloud_basic_data_residency_test'
84+
primary_resource_id: 'org'
85+
test_env_vars:
86+
org_id: 'ORG_ID'
87+
billing_account: 'BILLING_ACCT'
88+
ignore_read_extra:
89+
- 'properties'
90+
exclude_docs: true
91+
# Resource creation race
92+
skip_vcr: true
7893
- name: 'apigee_organization_cloud_full'
7994
exclude_test: true
8095
# This is a more verbose version of the above that creates all
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'SecurityProfileV2'
16+
description: |
17+
Security profile for risk assessment version 2 in Apigee.
18+
references:
19+
guides:
20+
'Creating a security profile': 'https://cloud.google.com/apigee/docs/api-security/security-scores#security-profiles-v2'
21+
api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.securityProfilesV2/create'
22+
docs:
23+
base_url: '{{org_id}}/securityProfilesV2'
24+
self_link: '{{org_id}}/securityProfilesV2/{{profile_id}}'
25+
create_url: '{{org_id}}/securityProfilesV2?security_profile_v2_id={{profile_id}}'
26+
update_verb: 'PATCH'
27+
update_mask: true
28+
import_format:
29+
- '{{org_id}}/securityProfilesV2/{{profile_id}}'
30+
- '{{org_id}}/{{profile_id}}'
31+
custom_code:
32+
custom_import: "templates/terraform/custom_import/apigee_security_profile_v2.go.tmpl"
33+
examples:
34+
- name: 'apigee_security_profile_v2_basic'
35+
vars:
36+
security_profile_id: "my-profile"
37+
exclude_test: true
38+
- name: 'apigee_security_profile_v2_basic_test'
39+
primary_resource_id: 'security_profile_v2'
40+
test_env_vars:
41+
org_id: 'ORG_ID'
42+
billing_account: 'BILLING_ACCT'
43+
exclude_docs: true
44+
skip_vcr: true
45+
external_providers: ["time"]
46+
parameters:
47+
- name: 'orgId'
48+
type: String
49+
description: |
50+
The Apigee Organization associated with the Apigee Security Profile V2,
51+
in the format `organizations/{{org_name}}`.
52+
url_param_only: true
53+
required: true
54+
immutable: true
55+
- name: 'profileId'
56+
type: String
57+
description: |
58+
Resource ID of the security profile.
59+
required: true
60+
immutable: true
61+
url_param_only: true
62+
properties:
63+
- name: 'name'
64+
type: String
65+
description: |
66+
Name of the security profile v2 resource,
67+
in the format `organizations/{{org_name}}/securityProfilesV2/{{profile_id}}`.
68+
output: true
69+
- name: 'description'
70+
type: String
71+
description: |
72+
Description of the security profile.
73+
- name: 'profileAssessmentConfigs'
74+
type: Map
75+
description: |
76+
A map of the assessment name and the assessment config.
77+
required: true
78+
key_name: 'assessment'
79+
value_type:
80+
name: profileAssessmentConfig
81+
type: NestedObject
82+
properties:
83+
- name: 'weight'
84+
type: Enum
85+
description: |
86+
The weight of the assessment.
87+
required: true
88+
enum_values:
89+
- 'MINOR'
90+
- 'MODERATE'
91+
- 'MAJOR'
92+
- name: 'createTime'
93+
type: String
94+
description: |
95+
The timestamp at which this profile was created.
96+
output: true
97+
- name: 'updateTime'
98+
type: String
99+
description: |
100+
The timestamp at which this profile was most recently updated.
101+
output: true

mmv1/products/beyondcorp/Application.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ examples:
3737
vars:
3838
security_gateway_name: default
3939
application_name: google
40+
- name: beyondcorp_security_gateway_application_vpc
41+
primary_resource_id: example
42+
primary_resource_name: 'fmt.Sprintf("default%s", context["random_suffix"]), fmt.Sprintf("google%s", context["random_suffix"])'
43+
vars:
44+
security_gateway_name: default
45+
application_name: my-vm-service
4046
autogen_async: true
4147
async:
4248
operation:
@@ -109,6 +115,32 @@ properties:
109115
description: Optional. Ports of the application.
110116
item_type:
111117
type: Integer
118+
- name: upstreams
119+
type: Array
120+
description: Optional. List of which upstream resource(s) to forward traffic to.
121+
item_type:
122+
type: NestedObject
123+
properties:
124+
- name: egressPolicy
125+
type: NestedObject
126+
description: Optional. Routing policy information.
127+
properties:
128+
- name: regions
129+
type: Array
130+
description: Required. List of regions where the application sends traffic to.
131+
required: true
132+
item_type:
133+
type: String
134+
- name: network
135+
type: NestedObject
136+
description: Network to forward traffic to.
137+
properties:
138+
- name: name
139+
type: string
140+
description: |-
141+
Required. Network name is of the format:
142+
`projects/{project}/global/networks/{network}`
143+
required: true
112144
- name: name
113145
type: String
114146
description: Identifier. Name of the resource.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copyright 2025 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'LogicalView'
16+
kind: 'bigtable#logicalView'
17+
description: |
18+
A logical view object that can be referenced in SQL queries.
19+
references:
20+
guides:
21+
api: 'https://cloud.google.com/bigtable/docs/reference/admin/rest/v2/projects.instances.logicalViews'
22+
docs:
23+
id_format: 'projects/{{project}}/instances/{{instance}}/logicalViews/{{logical_view_id}}'
24+
base_url: 'projects/{{project}}/instances/{{instance}}/logicalViews?logicalViewId={{logical_view_id}}'
25+
self_link: 'projects/{{project}}/instances/{{instance}}/logicalViews/{{logical_view_id}}'
26+
create_url: 'projects/{{project}}/instances/{{instance}}/logicalViews?logicalViewId={{logical_view_id}}'
27+
update_url: 'projects/{{project}}/instances/{{instance}}/logicalViews/{{logical_view_id}}'
28+
update_verb: 'PATCH'
29+
update_mask: true
30+
delete_url: 'projects/{{project}}/instances/{{instance}}/logicalViews/{{logical_view_id}}'
31+
import_format:
32+
- 'projects/{{project}}/instances/{{instance}}/logicalViews/{{logical_view_id}}'
33+
timeouts:
34+
insert_minutes: 120
35+
update_minutes: 20
36+
delete_minutes: 20
37+
exclude_sweeper: true
38+
examples:
39+
- name: 'bigtable_logical_view'
40+
primary_resource_id: 'logical_view'
41+
vars:
42+
instance_name: 'bt-instance'
43+
table_name: 'bt-table'
44+
logical_view_name: 'bt-logical-view'
45+
# bigtable instance does not use the shared HTTP client, this test creates an instance
46+
skip_vcr: true
47+
parameters:
48+
- name: 'logicalViewId'
49+
type: String
50+
description:
51+
'The unique name of the logical view in the form
52+
`[_a-zA-Z0-9][-_.a-zA-Z0-9]*`.'
53+
url_param_only: true
54+
required: true
55+
immutable: true
56+
- name: 'instance'
57+
type: String
58+
description: 'The name of the instance to create the logical view within.'
59+
url_param_only: true
60+
immutable: true
61+
diff_suppress_func: 'tpgresource.CompareResourceNames'
62+
properties:
63+
- name: 'name'
64+
type: String
65+
description:
66+
'The unique name of the requested logical view. Values are of the form
67+
`projects/<project>/instances/<instance>/logicalViews/<logicalViewId>`.'
68+
output: true
69+
- name: 'query'
70+
type: String
71+
description:
72+
'The logical view''s select query.'
73+
required: true

0 commit comments

Comments
 (0)