Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Tool: update-go-azure-sdk #23498

Merged
merged 9 commits into from
Oct 11, 2023
3 changes: 3 additions & 0 deletions internal/tools/update-go-azure-sdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tmp/
vendor/
update-go-azure-sdk
47 changes: 47 additions & 0 deletions internal/tools/update-go-azure-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## Tool: `update-go-azure-sdk`

This tool updates the version of `hashicorp/go-azure-sdk` which is vendored in this repository, and then subsequently tries to update the Provider to account for any new API Versions.

Whilst this isn't going to be infallible, the intention is that when a new API Version is added to `hashicorp/go-azure-sdk` (via `hashicorp/pandora`) then the AzureRM Provider can be automatically updated to use that API Version - with any errors output for human review.

This tool makes a number of assumptions about the repository design, namely that an `internal` folder exists and that `hashicorp/go-azure-sdk` is not referenced outside of this directory - and in addition also tool assumes that Git is available and pre-configured.

Whilst this tool is intended to primarily be run in automation - [the `update-api-version` tool](../update-api-version) is better suited for interactive usage (since it won't perform rollbacks, and assumes the `hashicorp/go-azure-sdk` dependency is up-to-date).

### Example Usage

```bash
$ go build . && ./update-go-azure-sdk --old-sdk-version=v0.20230918.1115907 --new-sdk-version=v0.20231005.1153009 --working-directory=../../../ --output-file=pr-description.txt
2023-10-10T15:14:12.249+0200 [INFO] Old SDK Version is "v0.20230918.1115907"
2023-10-10T15:14:12.249+0200 [INFO] New SDK Version is "v0.20231005.1153009"
2023-10-10T15:14:12.249+0200 [INFO] Output File Name is "pr-description.txt"
2023-10-10T15:14:12.249+0200 [INFO] Working Directory is "../../../"
2023-10-10T15:14:12.249+0200 [INFO] Checking the changes between "v0.20230918.1115907" and "v0.20231005.1153009" of `hashicorp/go-azure-sdk`..
2023-10-10T15:14:34.275+0200 [INFO] Updating `hashicorp/go-azure-sdk`..
2023-10-10T15:14:50.939+0200 [INFO] Committed as "b5b40b0b49d9f192f9d65d620ecba98862764e6b"
2023-10-10T15:14:53.958+0200 [INFO] Processing Service "connectedvmware"..
2023-10-10T15:14:54.552+0200 [INFO] Processed Service "connectedvmware".
2023-10-10T15:14:57.578+0200 [INFO] Processing Service "cosmosdb"..
2023-10-10T15:14:58.148+0200 [INFO] Attempting to update API Version "2022-05-15" to "2023-09-15" for Service "cosmosdb"..
2023-10-10T15:15:03.823+0200 [INFO] Updated the Imports for Service "cosmosdb" to use API Version "2023-09-15" rather than "2022-05-15"..
2023-10-10T15:15:03.823+0200 [INFO] Running `go mod tidy` / `go mod vendor`..
2023-10-10T15:15:15.022+0200 [INFO] Running `make test` within "../../../"..
2023-10-10T15:18:04.450+0200 [INFO] Committed as "a88ab1b1be8344a07bcf316a62c3ea31a87be507"
2023-10-10T15:18:04.450+0200 [INFO] Updated Service "cosmosdb" from "2022-05-15" to "2023-09-15"
2023-10-10T15:18:04.450+0200 [INFO] Attempting to update API Version "2022-11-15" to "2023-09-15" for Service "cosmosdb"..
2023-10-10T15:18:10.035+0200 [INFO] Updated the Imports for Service "cosmosdb" to use API Version "2023-09-15" rather than "2022-11-15"..
2023-10-10T15:18:10.035+0200 [INFO] Running `go mod tidy` / `go mod vendor`..
2023-10-10T15:18:22.087+0200 [INFO] Running `make test` within "../../../"..
2023-10-10T15:19:46.236+0200 [INFO] Resetting the working directory since `make test` failed..
2023-10-10T15:19:56.549+0200 [INFO] Attempting to update API Version "2023-04-15" to "2023-09-15" for Service "cosmosdb"..
2023-10-10T15:20:02.211+0200 [INFO] Updated the Imports for Service "cosmosdb" to use API Version "2023-09-15" rather than "2023-04-15"..
2023-10-10T15:20:02.211+0200 [INFO] Running `go mod tidy` / `go mod vendor`..
2023-10-10T15:20:12.584+0200 [INFO] Running `make test` within "../../../"..
```

### Command Line Arguments

* `--old-sdk-version` - (Required) - Specifies the current (out of date) version of `hashicorp/go-azure-sdk` being used by the Provider. Example: `v0.20230918.1115907`.
* `--new-sdk-version` - (Required) - Specifies the version of `hashicorp/go-azure-sdk` that the Provider should be updated to. Example: `v0.20231005.1153009`.
* `--working-directory` - (Required) - Specifies the path to the root of the Provider repository (typically this is `../../../`, when run from this repository). Example: `../../../`.
* `--output-file` - (Required) - Specifies the path to the output file containing the summary of changes performed by this tool, primarily intended to be used as a Pull Request body. Example: `pr-description.txt`.
37 changes: 37 additions & 0 deletions internal/tools/update-go-azure-sdk/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module github.com/hashicorp/terraform-provider-azurerm/internal/tools/update-go-azure-sdk

go 1.21.0

require (
github.com/go-git/go-git/v5 v5.9.0
github.com/hashicorp/go-azure-helpers v0.61.0
github.com/hashicorp/go-hclog v1.5.0
golang.org/x/tools v0.13.0
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/skeema/knownhosts v1.2.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)
Loading