Skip to content

Commit

Permalink
Merge branch 'GoogleCloudPlatform:main' into alloydb-crr-support
Browse files Browse the repository at this point in the history
  • Loading branch information
199201shubhamsahu authored Sep 25, 2023
2 parents fa38462 + aef0da0 commit 3578c66
Show file tree
Hide file tree
Showing 78 changed files with 5,817 additions and 1,085 deletions.
1 change: 1 addition & 0 deletions .ci/containers/membership-checker/membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (

// This is for reviewers who are "on vacation": will not receive new review assignments but will still receive re-requests for assigned PRs.
onVacationReviewers = []string{
"melinath",
"roaks3",
}
)
Expand Down
25 changes: 12 additions & 13 deletions .ci/gcb-community-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,31 @@ steps:
- user.name
- "Modular Magician Diff Process"

# Fetch main (only if it's not already present)
- name: "gcr.io/cloud-builders/git"
args:
- fetch
- origin
- main

# Display commit log for clarity
- name: "gcr.io/cloud-builders/git"
args:
- log
- "--oneline"
- "-n 10"

# Find common ancestor commit and apply diff for the .ci folder
# Find common ancestor commit and apply diff for the .ci folder.
- name: "gcr.io/cloud-builders/git"
id: findMergeBase
entrypoint: "bash"
args:
- "-c"
- |
base_commit=$(git merge-base origin/main HEAD)
echo "Common ancestor commit: $base_commit"
git diff $base_commit origin/main -- .ci/
git diff $base_commit origin/main -- .ci/ > /workspace/ci.diff
git apply /workspace/ci.diff --allow-empty
git fetch origin main
if [ "$_BASE_BRANCH" != "main" ]; then
echo "Checking out .ci/ folder from main"
git checkout origin/main -- .ci/
else
base_commit=$(git merge-base origin/main HEAD)
echo "Common ancestor commit: $base_commit"
git diff $base_commit origin/main -- .ci/
git diff $base_commit origin/main -- .ci/ > /workspace/ci.diff
git apply ./ci.diff --allow-empty
fi
- name: 'gcr.io/graphite-docker-images/go-plus'
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
Expand Down
25 changes: 12 additions & 13 deletions .ci/gcb-contributor-membership-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,31 @@ steps:
- user.name
- "Modular Magician Diff Process"

# Fetch main (only if it's not already present)
- name: "gcr.io/cloud-builders/git"
args:
- fetch
- origin
- main

# Display commit log for clarity
- name: "gcr.io/cloud-builders/git"
args:
- log
- "--oneline"
- "-n 10"

# Find common ancestor commit and apply diff for the .ci folder
# Find common ancestor commit and apply diff for the .ci folder.
- name: "gcr.io/cloud-builders/git"
id: findMergeBase
entrypoint: "bash"
args:
- "-c"
- |
base_commit=$(git merge-base origin/main HEAD)
echo "Common ancestor commit: $base_commit"
git diff $base_commit origin/main -- .ci/
git diff $base_commit origin/main -- .ci/ > /workspace/ci.diff
git apply /workspace/ci.diff --allow-empty
git fetch origin main
if [ "$_BASE_BRANCH" != "main" ]; then
echo "Checking out .ci/ folder from main"
git checkout origin/main -- .ci/
else
base_commit=$(git merge-base origin/main HEAD)
echo "Common ancestor commit: $base_commit"
git diff $base_commit origin/main -- .ci/
git diff $base_commit origin/main -- .ci/ > /workspace/ci.diff
git apply ./ci.diff --allow-empty
fi
- name: "gcr.io/graphite-docker-images/go-plus"
entrypoint: "/workspace/.ci/scripts/go-plus/magician/exec.sh"
Expand Down
18 changes: 7 additions & 11 deletions .ci/gcb-generate-diffs-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,29 +240,25 @@ steps:
- "19" # Build step
- terraform-google-conversion

- name: 'gcr.io/graphite-docker-images/bash-plus'
- name: 'gcr.io/graphite-docker-images/go-plus'
id: tpgb-test
entrypoint: '/workspace/.ci/scripts/bash-plus/terraform-tester/test_terraform.sh'
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
secretEnv: ["GITHUB_TOKEN"]
waitFor: ["tpgb-head", "tpgb-base"]
args:
- 'test-tpg'
env:
- VERSION=beta
- COMMIT_SHA=$COMMIT_SHA
- PR_NUMBER=$_PR_NUMBER

- name: 'gcr.io/graphite-docker-images/bash-plus'
- name: 'gcr.io/graphite-docker-images/go-plus'
id: tpg-test
entrypoint: '/workspace/.ci/scripts/bash-plus/terraform-tester/test_terraform.sh'
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
secretEnv: ["GITHUB_TOKEN"]
waitFor: ["tpg-head", "tpg-base"]
args:
- 'ga' # remove after 07/2023
- $_PR_NUMBER # remove after 07/2023
- $COMMIT_SHA # remove after 07/2023
- $BUILD_ID # remove after 07/2023
- $PROJECT_ID # remove after 07/2023
- GoogleCloudPlatform/magic-modules # remove after 07/2023
- "21" # remove after 07/2023
- 'test-tpg'
env:
- VERSION=ga
- COMMIT_SHA=$COMMIT_SHA
Expand Down
5 changes: 5 additions & 0 deletions .ci/magician/cmd/mock_github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ func (m *mockGithub) PostBuildStatus(prNumber string, title string, state string
m.calledMethods["PostBuildStatus"] = true
return nil
}

func (m *mockGithub) CreateWorkflowDispatchEvent(workflowFileName string, inputs map[string]any) error {
m.calledMethods["CreateWorkflowDispatchEvent"] = true
return nil
}
61 changes: 61 additions & 0 deletions .ci/magician/cmd/test_tpg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package cmd

import (
"fmt"
"magician/github"
"os"

"github.com/spf13/cobra"
)

type ttGithub interface {
CreateWorkflowDispatchEvent(string, map[string]any) error
}

var testTPGCmd = &cobra.Command{
Use: "test-tpg",
Short: "Run provider unit tests via workflow dispatch",
Long: `This command runs provider unit tests via workflow dispatch
The following PR details are expected as environment variables:
1. VERSION (beta or ga)
2. COMMIT_SHA
3. PR_NUMBER
`,
Run: func(cmd *cobra.Command, args []string) {
version := os.Getenv("VERSION")
commit := os.Getenv("COMMIT_SHA")
pr := os.Getenv("PR_NUMBER")

gh := github.NewGithubService()

execTestTPG(version, commit, pr, gh)
},
}

func execTestTPG(version, commit, pr string, gh ttGithub) {
var repo string
if version == "ga" {
repo = "terraform-provider-google"
} else if version == "beta" {
repo = "terraform-provider-google-beta"
} else {
fmt.Println("invalid version specified")
os.Exit(1)
}

inputs := map[string]any{
"owner": "modular-magician",
"repo": repo,
"branch": "auto-pr-" + pr,
"sha": commit,
}

if err := gh.CreateWorkflowDispatchEvent("test-tpg.yml", inputs); err != nil {
fmt.Printf("Error creating workflow dispatch event: %v\n", err)
}
}

func init() {
rootCmd.AddCommand(testTPGCmd)
}
17 changes: 17 additions & 0 deletions .ci/magician/cmd/test_tpg_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"testing"
)

func TestExecTestTPG(t *testing.T) {
gh := &mockGithub{
calledMethods: make(map[string]bool),
}

execTestTPG("beta", "sha1", "pr1", gh)

if !gh.calledMethods["CreateWorkflowDispatchEvent"] {
t.Fatal("workflow dispatch event not created")
}
}
1 change: 1 addition & 0 deletions .ci/magician/github/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type GithubService interface {
RequestPullRequestReviewer(prNumber, assignee string) error
AddLabel(prNumber, label string) error
RemoveLabel(prNumber, label string) error
CreateWorkflowDispatchEvent(workflowFileName string, inputs map[string]any) error
}

func NewGithubService() GithubService {
Expand Down
2 changes: 1 addition & 1 deletion .ci/magician/github/membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (

// This is for reviewers who are "on vacation": will not receive new review assignments but will still receive re-requests for assigned PRs.
onVacationReviewers = []string{
"slevenick",
"melinath",
"roaks3",
}
)
Expand Down
20 changes: 20 additions & 0 deletions .ci/magician/github/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,23 @@ func (gh *github) RemoveLabel(prNumber, label string) error {

return nil
}

func (gh *github) CreateWorkflowDispatchEvent(workflowFileName string, inputs map[string]any) error {
url := fmt.Sprintf("https://api.github.com/repos/GoogleCloudPlatform/magic-modules/actions/workflows/%s/dispatches", workflowFileName)
resp, err := utils.RequestCall(url, "POST", gh.token, nil, map[string]any{
"ref": "main",
"inputs": inputs,
})

if resp != 200 {
return fmt.Errorf("server returned %d creating workflow dispatch event", resp)
}

if err != nil {
return fmt.Errorf("failed to create workflow dispatch event: %s", err)
}

fmt.Printf("Successfully created workflow dispatch event for %s with inputs %v", workflowFileName, inputs)

return nil
}
6 changes: 3 additions & 3 deletions .ci/magician/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230303212802-e74f57abe488 // indirect
google.golang.org/grpc v1.53.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions .ci/magician/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw=
golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw=
Expand All @@ -92,13 +92,13 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
Expand Down
2 changes: 2 additions & 0 deletions .ci/scripts/go-plus/magician/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ GO_PROGRAM="$DIR/../../../magician/"

pushd $GO_PROGRAM

set -x
# Pass all arguments to the child command
go run . "$@"
set +x
8 changes: 8 additions & 0 deletions mmv1/products/compute/Instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,14 @@ properties:
should be specified.
# networkInterfaces.kind is not necessary for convergence.
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.erb'
- !ruby/object:Api::Type::ResourceRef
name: 'networkAttachment'
resource: 'networkAttachment'
min_version: beta
imports: 'selfLink'
description: |
The URL of the network attachment that this interface should connect to in the following format:
projects/{projectNumber}/regions/{region_name}/networkAttachments/{network_attachment_name}.
- !ruby/object:Api::Type::NestedObject
name: 'scheduling'
description: Sets the scheduling options for this instance.
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/identityplatform/Config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ examples:
org_id: :ORG_ID
billing_acct:
:BILLING_ACCT
skip_vcr: true
skip_docs: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_create: 'templates/terraform/custom_create/identity_platform_config.go'
Expand All @@ -77,6 +76,7 @@ properties:
name: 'signIn'
description: |
Configuration related to local sign in methods.
default_from_api: true
properties:
- !ruby/object:Api::Type::NestedObject
name: email
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/monitoring/NotificationChannel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ custom_code: !ruby/object:Provider::Terraform::CustomCode
encoder: templates/terraform/encoders/monitoring_notification_channel.go.erb
decoder: templates/terraform/decoders/monitoring_notification_channel.go.erb
constants: templates/terraform/constants/monitoring_notification_channel.go.erb
custom_import: templates/terraform/custom_import/self_link_as_name.erb
custom_import: templates/terraform/custom_import/self_link_as_name_set_project.go.erb
post_create: templates/terraform/post_create/set_computed_name.erb
custom_diff: [
'sensitiveLabelCustomizeDiff',
Expand Down
13 changes: 10 additions & 3 deletions mmv1/products/osconfig/PatchDeployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,12 @@ properties:
properties:
- !ruby/object:Api::Type::Array
name: 'classifications'
exactly_one_of:
at_least_one_of:
- patch_config.0.windows_update.0.classifications
- patch_config.0.windows_update.0.excludes
- patch_config.0.windows_update.0.exclusive_patches
conflicts:
- patch_config.0.windows_update.0.exclusive_patches
description: |
Only apply updates of these windows update classifications. If empty, all updates are applied.
item_type: !ruby/object:Api::Type::Enum
Expand All @@ -417,19 +419,24 @@ properties:
- :UPDATE
- !ruby/object:Api::Type::Array
name: 'excludes'
exactly_one_of:
at_least_one_of:
- patch_config.0.windows_update.0.classifications
- patch_config.0.windows_update.0.excludes
- patch_config.0.windows_update.0.exclusive_patches
conflicts:
- patch_config.0.windows_update.0.exclusive_patches
description: |
List of KBs to exclude from update.
item_type: Api::Type::String
- !ruby/object:Api::Type::Array
name: 'exclusivePatches'
exactly_one_of:
at_least_one_of:
- patch_config.0.windows_update.0.classifications
- patch_config.0.windows_update.0.excludes
- patch_config.0.windows_update.0.exclusive_patches
conflicts:
- patch_config.0.windows_update.0.classifications
- patch_config.0.windows_update.0.excludes
description: |
An exclusive list of kbs to be updated. These are the only patches that will be updated.
This field must not be used with other patch configurations.
Expand Down
Loading

0 comments on commit 3578c66

Please sign in to comment.