diff --git a/.ci/gcb-generate-diffs-new.yml b/.ci/gcb-generate-diffs-new.yml index 5beac1aa4a95..57aa9241c48a 100644 --- a/.ci/gcb-generate-diffs-new.yml +++ b/.ci/gcb-generate-diffs-new.yml @@ -169,17 +169,17 @@ steps: - $_PR_NUMBER - name: 'gcr.io/graphite-docker-images/go-plus' - entrypoint: '/workspace/.ci/scripts/go-plus/github-differ/generate_comment.sh' + entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh' id: diff secretEnv: ["GITHUB_TOKEN"] + args: + - 'generate-comment' env: - BUILD_ID=$BUILD_ID - PROJECT_ID=$PROJECT_ID - BUILD_STEP=17 - COMMIT_SHA=$COMMIT_SHA - PR_NUMBER=$_PR_NUMBER - args: - - $_PR_NUMBER - name: 'gcr.io/graphite-docker-images/go-plus' id: tgc-test diff --git a/.ci/magician/cloudbuild/build_trigger.go b/.ci/magician/cloudbuild/build_trigger.go index 676e5a5b64a6..f776af1222cd 100644 --- a/.ci/magician/cloudbuild/build_trigger.go +++ b/.ci/magician/cloudbuild/build_trigger.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cloudbuild import ( diff --git a/.ci/magician/cloudbuild/community.go b/.ci/magician/cloudbuild/community.go index 09b8d2d6345a..4e7a84091778 100644 --- a/.ci/magician/cloudbuild/community.go +++ b/.ci/magician/cloudbuild/community.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cloudbuild import ( diff --git a/.ci/magician/cloudbuild/constants.go b/.ci/magician/cloudbuild/constants.go index a64c5fce7c61..1286bd2a54b2 100644 --- a/.ci/magician/cloudbuild/constants.go +++ b/.ci/magician/cloudbuild/constants.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cloudbuild const PROJECT_ID = "graphite-docker-images" diff --git a/.ci/magician/cloudbuild/init.go b/.ci/magician/cloudbuild/init.go index 52f65318aa0c..908351d741d3 100644 --- a/.ci/magician/cloudbuild/init.go +++ b/.ci/magician/cloudbuild/init.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cloudbuild type Client struct { diff --git a/.ci/magician/cmd/community_checker.go b/.ci/magician/cmd/community_checker.go index 3630bbb323f1..f968ca74abff 100644 --- a/.ci/magician/cmd/community_checker.go +++ b/.ci/magician/cmd/community_checker.go @@ -1,6 +1,18 @@ /* -Copyright © 2023 NAME HERE -*/ +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/community_checker_test.go b/.ci/magician/cmd/community_checker_test.go index f429a7910cb1..364524cc2a52 100644 --- a/.ci/magician/cmd/community_checker_test.go +++ b/.ci/magician/cmd/community_checker_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/generate_comment.go b/.ci/magician/cmd/generate_comment.go index 2d2aa39f3b73..b6d457382111 100644 --- a/.ci/magician/cmd/generate_comment.go +++ b/.ci/magician/cmd/generate_comment.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( @@ -124,7 +139,9 @@ func execGenerateComment(buildID, projectID, buildStep, commit, prNumber, github os.Exit(1) } } - diffs += "\n" + repoDiffs + if repoDiffs != "" { + diffs += "\n" + repoDiffs + } } var showBreakingChangesFailed bool @@ -156,7 +173,7 @@ func execGenerateComment(buildID, projectID, buildStep, commit, prNumber, github fmt.Println("Error computing TPG breaking changes: ", err) showBreakingChangesFailed = true } - versionedBreakingChanges[repo.Version] = output + versionedBreakingChanges[repo.Version] = strings.TrimSuffix(output, "\n") err = addLabels(diffProcessorPath, githubToken, prNumber, r) if err != nil { fmt.Println("Error adding TPG labels to PR: ", err) @@ -209,7 +226,7 @@ The breaking change detector crashed during execution. This is usually due to th if diffs == "" { message += "## Diff report\nYour PR hasn't generated any diffs, but I'll let you know if a future commit does." } else { - message += "## Diff report\nYour PR generated some diffs in downstreams - here they are.\n" + diffs + message += "## Diff report\nYour PR generated some diffs in downstreams - here they are.\n" + diffs + "\n" if missingTests != "" { message += "\n" + missingTests + "\n" } @@ -344,14 +361,14 @@ func combineBreakingChanges(tpgBreaking, tpgbBreaking string) string { allMessages = append(tpgUnique, tpgbMessages...) } if len(allMessages) > 0 { - return `Breaking Change(s) Detected + return `## Breaking Change(s) Detected The following breaking change(s) were detected within your pull request. * ` + strings.Join(allMessages, "\n* ") + ` If you believe this detection to be incorrect please raise the concern with your reviewer. If you intend to make this change you will need to wait for a [major release](https://www.terraform.io/plugin/sdkv2/best-practices/versioning#example-major-number-increments) window. -An ` + "`override-breaking-change`" + `label can be added to allow merging. +An ` + "`override-breaking-change`" + ` label can be added to allow merging. ` } return "" diff --git a/.ci/magician/cmd/generate_comment_test.go b/.ci/magician/cmd/generate_comment_test.go index b05acfa4f8e3..88b0a28f38d8 100644 --- a/.ci/magician/cmd/generate_comment_test.go +++ b/.ci/magician/cmd/generate_comment_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/interfaces.go b/.ci/magician/cmd/interfaces.go index ef99df1723bd..a03bce062439 100644 --- a/.ci/magician/cmd/interfaces.go +++ b/.ci/magician/cmd/interfaces.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/membership_checker.go b/.ci/magician/cmd/membership_checker.go index b5fcd8b85160..8b3eee525035 100644 --- a/.ci/magician/cmd/membership_checker.go +++ b/.ci/magician/cmd/membership_checker.go @@ -1,6 +1,18 @@ /* -Copyright © 2023 NAME HERE -*/ +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/membership_checker_test.go b/.ci/magician/cmd/membership_checker_test.go index 184c9ec5d8eb..a71fa110164c 100644 --- a/.ci/magician/cmd/membership_checker_test.go +++ b/.ci/magician/cmd/membership_checker_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/mock_cloudbuild_test.go b/.ci/magician/cmd/mock_cloudbuild_test.go index f4da97a06771..e75c76949f06 100644 --- a/.ci/magician/cmd/mock_cloudbuild_test.go +++ b/.ci/magician/cmd/mock_cloudbuild_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd type mockCloudBuild struct { diff --git a/.ci/magician/cmd/mock_github_test.go b/.ci/magician/cmd/mock_github_test.go index 49bd98b624bb..e017700c41ad 100644 --- a/.ci/magician/cmd/mock_github_test.go +++ b/.ci/magician/cmd/mock_github_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import "magician/github" diff --git a/.ci/magician/cmd/mock_runner_test.go b/.ci/magician/cmd/mock_runner_test.go index 16867dca123a..6743e3a1e6c5 100644 --- a/.ci/magician/cmd/mock_runner_test.go +++ b/.ci/magician/cmd/mock_runner_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/root.go b/.ci/magician/cmd/root.go index b19c57e6ea24..f39a0e69e0a2 100644 --- a/.ci/magician/cmd/root.go +++ b/.ci/magician/cmd/root.go @@ -1,6 +1,18 @@ /* -Copyright © 2023 NAME HERE -*/ +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/test_tgc.go b/.ci/magician/cmd/test_tgc.go index a5610daaedb9..9f0edf2f29bf 100644 --- a/.ci/magician/cmd/test_tgc.go +++ b/.ci/magician/cmd/test_tgc.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/test_tgc_test.go b/.ci/magician/cmd/test_tgc_test.go index f9004ddf0e8a..daf4b94409fe 100644 --- a/.ci/magician/cmd/test_tgc_test.go +++ b/.ci/magician/cmd/test_tgc_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/test_tpg.go b/.ci/magician/cmd/test_tpg.go index 75398c7a4281..c8923ad42106 100644 --- a/.ci/magician/cmd/test_tpg.go +++ b/.ci/magician/cmd/test_tpg.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/cmd/test_tpg_test.go b/.ci/magician/cmd/test_tpg_test.go index ad77c7596f21..d1ca8882471d 100644 --- a/.ci/magician/cmd/test_tpg_test.go +++ b/.ci/magician/cmd/test_tpg_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package cmd import ( diff --git a/.ci/magician/exec/runner.go b/.ci/magician/exec/runner.go index 3bc21e23116d..5d746f7a963d 100644 --- a/.ci/magician/exec/runner.go +++ b/.ci/magician/exec/runner.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package exec import ( diff --git a/.ci/magician/github/get.go b/.ci/magician/github/get.go index 30df68d4db4a..9b1dbc7acdd8 100644 --- a/.ci/magician/github/get.go +++ b/.ci/magician/github/get.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package github import ( diff --git a/.ci/magician/github/init.go b/.ci/magician/github/init.go index ff63ae2c1ef5..a931ad5efca5 100644 --- a/.ci/magician/github/init.go +++ b/.ci/magician/github/init.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package github import ( diff --git a/.ci/magician/github/membership.go b/.ci/magician/github/membership.go index adac576f2f68..21aaea6f459b 100644 --- a/.ci/magician/github/membership.go +++ b/.ci/magician/github/membership.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package github import ( diff --git a/.ci/magician/github/membership_test.go b/.ci/magician/github/membership_test.go index 1f2264bdf3c2..88598107012b 100644 --- a/.ci/magician/github/membership_test.go +++ b/.ci/magician/github/membership_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package github import ( diff --git a/.ci/magician/github/reviewer_assignment.go b/.ci/magician/github/reviewer_assignment.go index 820bb76a4f81..b57a0ae311ce 100644 --- a/.ci/magician/github/reviewer_assignment.go +++ b/.ci/magician/github/reviewer_assignment.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package github import ( diff --git a/.ci/magician/github/reviewer_assignment_test.go b/.ci/magician/github/reviewer_assignment_test.go index 779d308cfb22..6514a8dd5b67 100644 --- a/.ci/magician/github/reviewer_assignment_test.go +++ b/.ci/magician/github/reviewer_assignment_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package github import ( diff --git a/.ci/magician/github/set.go b/.ci/magician/github/set.go index e1575a4e505c..a5d4adffe53f 100644 --- a/.ci/magician/github/set.go +++ b/.ci/magician/github/set.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package github import ( diff --git a/.ci/magician/main.go b/.ci/magician/main.go index 41c664080c04..a018e0eaee5c 100644 --- a/.ci/magician/main.go +++ b/.ci/magician/main.go @@ -1,6 +1,18 @@ /* -Copyright © 2023 NAME HERE -*/ +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package main import "magician/cmd" diff --git a/.ci/magician/utility/utils.go b/.ci/magician/utility/utils.go index 6bc778f97e3f..cdec5a6d0fc2 100644 --- a/.ci/magician/utility/utils.go +++ b/.ci/magician/utility/utils.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package utility import ( diff --git a/.ci/magician/utility/utils_test.go b/.ci/magician/utility/utils_test.go index 2f82538ab7c1..5bc47df94996 100644 --- a/.ci/magician/utility/utils_test.go +++ b/.ci/magician/utility/utils_test.go @@ -1,3 +1,18 @@ +/* +* Copyright 2023 Google LLC. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package utility import ( diff --git a/mmv1/products/vertexai/FeatureOnlineStore.yaml b/mmv1/products/vertexai/FeatureOnlineStore.yaml index eb1f84fce715..1f60a6d64b31 100644 --- a/mmv1/products/vertexai/FeatureOnlineStore.yaml +++ b/mmv1/products/vertexai/FeatureOnlineStore.yaml @@ -135,7 +135,7 @@ properties: - !ruby/object:Api::Type::NestedObject name: 'dedicatedServingEndpoint' description: | - The dedicated serving endpoint for this FeatureOnlineStore, which is different from common vertex service endpoint. + The dedicated serving endpoint for this FeatureOnlineStore, which is different from common vertex service endpoint. Only need to set when you choose Optimized storage type or enable EmbeddingManagement. Will use public endpoint by default. min_version: beta default_from_api: true properties: @@ -163,7 +163,6 @@ properties: If set to true, customers will use private service connection to send request. Otherwise, the connection will set to public endpoint. - !ruby/object:Api::Type::Array name: 'projectAllowlist' - required: true default_from_api: true description: | A list of Projects from which the forwarding rule will target the service attachment. diff --git a/mmv1/provider/terraform/common~copy.yaml b/mmv1/provider/terraform/common~copy.yaml index 4953b9ccca91..7a61c213c988 100644 --- a/mmv1/provider/terraform/common~copy.yaml +++ b/mmv1/provider/terraform/common~copy.yaml @@ -154,3 +154,4 @@ '.teamcity/Makefile': 'third_party/terraform/.teamcity/Makefile' 'version/version.go': 'third_party/terraform/version/version.go' 'go.sum': 'third_party/terraform/go.sum' +'.go-version': 'third_party/terraform/.go-version' diff --git a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb index 20647969e4bd..b6cc034d97ac 100644 --- a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb +++ b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_with_beta_fields_bigtable.tf.erb @@ -15,12 +15,6 @@ resource "google_vertex_ai_feature_online_store" "<%= ctx[:primary_resource_id] embedding_management { enabled = true } - dedicated_serving_endpoint { - private_service_connect_config { - enable_private_service_connect = true - project_allowlist = [data.google_project.project.number] - } -} force_destroy = true } diff --git a/mmv1/third_party/terraform/.go-version b/mmv1/third_party/terraform/.go-version new file mode 100644 index 000000000000..5fb5a6b4f547 --- /dev/null +++ b/mmv1/third_party/terraform/.go-version @@ -0,0 +1 @@ +1.20 diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb index 8b9fa8414480..d73fb6bf1d99 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb +++ b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb @@ -2381,11 +2381,28 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er cluster.SecurityPostureConfig = expandSecurityPostureConfig(v) } + needUpdateAfterCreate := false + // For now PSC based cluster don't support `enable_private_endpoint` on `create`, but only on `update` API call. // If cluster is PSC based and enable_private_endpoint is set to true we will ignore it on `create` call and update cluster right after creation. enablePrivateEndpointPSCCluster := isEnablePrivateEndpointPSCCluster(cluster) if enablePrivateEndpointPSCCluster { cluster.PrivateClusterConfig.EnablePrivateEndpoint = false + needUpdateAfterCreate = true + } + + enablePDCSI := isEnablePDCSI(cluster); + if !enablePDCSI { + // GcePersistentDiskCsiDriver cannot be disabled at cluster create, only on cluster update. Ignore on create then update after creation. + // If pdcsi is disabled, the config should be defined. But we will be paranoid and double-check. + needUpdateAfterCreate = true + if cluster.AddonsConfig == nil { + cluster.AddonsConfig = &container.AddonsConfig{} + } + if cluster.AddonsConfig.GcePersistentDiskCsiDriverConfig == nil { + cluster.AddonsConfig.GcePersistentDiskCsiDriverConfig = &container.GcePersistentDiskCsiDriverConfig{} + } + cluster.AddonsConfig.GcePersistentDiskCsiDriverConfig.Enabled = true } req := &container.CreateClusterRequest{ @@ -2472,14 +2489,22 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er } } - if enablePrivateEndpointPSCCluster { + if needUpdateAfterCreate { name := containerClusterFullName(project, location, clusterName) - req := &container.UpdateClusterRequest{ - Update: &container.ClusterUpdate{ - DesiredEnablePrivateEndpoint: true, - ForceSendFields: []string{"DesiredEnablePrivateEndpoint"}, - }, + update := &container.ClusterUpdate{} + if enablePrivateEndpointPSCCluster { + update.DesiredEnablePrivateEndpoint = true + update.ForceSendFields = append(update.ForceSendFields, "DesiredEnablePrivateEndpoint"); + } + if !enablePDCSI { + update.DesiredAddonsConfig = &container.AddonsConfig{ + GcePersistentDiskCsiDriverConfig: &container.GcePersistentDiskCsiDriverConfig{ + Enabled: false, + }, + } + update.ForceSendFields = append(update.ForceSendFields, "DesiredAddonsConfig.GcePersistentDiskCsiDriverConfig.Enabled"); } + req := &container.UpdateClusterRequest{Update: update} err = transport_tpg.Retry(transport_tpg.RetryOptions{ RetryFunc: func() error { @@ -2492,12 +2517,12 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er }, }) if err != nil { - return errwrap.Wrapf("Error updating enable private endpoint: {{err}}", err) + return errwrap.Wrapf(fmt.Sprintf("Error updating cluster for %v: {{err}}", update.ForceSendFields), err) } err = ContainerOperationWait(config, op, project, location, "updating enable private endpoint", userAgent, d.Timeout(schema.TimeoutCreate)) if err != nil { - return errwrap.Wrapf("Error while waiting to enable private endpoint: {{err}}", err) + return errwrap.Wrapf(fmt.Sprintf("Error while waiting on cluster update for %v: {{err}}", update.ForceSendFields), err) } } @@ -4946,6 +4971,13 @@ func isEnablePrivateEndpointPSCCluster(cluster *container.Cluster) bool { return false } +func isEnablePDCSI(cluster *container.Cluster) bool { + if cluster.AddonsConfig == nil || cluster.AddonsConfig.GcePersistentDiskCsiDriverConfig == nil { + return true; // PDCSI is enabled by default. + } + return cluster.AddonsConfig.GcePersistentDiskCsiDriverConfig.Enabled +} + func expandPrivateClusterConfig(configured interface{}) *container.PrivateClusterConfig { l := configured.([]interface{}) if len(l) == 0 { diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.erb b/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.erb index 2428c885beef..34f0aa301a43 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.erb +++ b/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.erb @@ -127,7 +127,6 @@ func TestAccContainerCluster_misc(t *testing.T) { } func TestAccContainerCluster_withAddons(t *testing.T) { - t.Skipf("Skipping test %s due to https://github.com/hashicorp/terraform-provider-google/issues/16114", t.Name()) t.Parallel() clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10)) @@ -4803,6 +4802,7 @@ resource "google_container_cluster" "primary" { enabled = true } <% end -%> + } deletion_protection = false network = "%s" subnetwork = "%s" diff --git a/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard.go b/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard.go index 458b5cfbb1c8..0da5fbbac8b1 100644 --- a/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard.go +++ b/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard.go @@ -31,7 +31,7 @@ func removeComputedKeys(old map[string]interface{}, new map[string]interface{}) if reflect.ValueOf(v).Kind() == reflect.Slice { for i, j := range v.([]interface{}) { - if reflect.ValueOf(j).Kind() == reflect.Map { + if reflect.ValueOf(j).Kind() == reflect.Map && len(new[k].([]interface{})) > i { old[k].([]interface{})[i] = removeComputedKeys(j.(map[string]interface{}), new[k].([]interface{})[i].(map[string]interface{})) } } diff --git a/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard_test.go b/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard_test.go index 5c1a5d28afd7..0729ce06c1ed 100644 --- a/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard_test.go +++ b/mmv1/third_party/terraform/services/monitoring/resource_monitoring_dashboard_test.go @@ -117,6 +117,15 @@ func TestAccMonitoringDashboard_update(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"project"}, }, + { + Config: testAccMonitoringDashboard_gridLayoutUpdate(), + }, + { + ResourceName: "google_monitoring_dashboard.dashboard", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"project"}, + }, }, }) } @@ -242,6 +251,52 @@ EOF `) } +func testAccMonitoringDashboard_gridLayoutUpdate() string { + return fmt.Sprintf(` +resource "google_monitoring_dashboard" "dashboard" { + dashboard_json = <