Skip to content

Commit 50cf9b9

Browse files
authored
generator-go-sdk - expose function to programatically obtain the API version in use (#5353)
* expose func to programatically obtain the API version in use * fix version test and include goimports into make tools
1 parent 3f592f0 commit 50cf9b9

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

tools/generator-go-sdk/internal/generator/templater_version.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ const defaultApiVersion = "%[2]s"
2929
func userAgent() string {
3030
return "hashicorp/go-azure-sdk/%[1]s/%[3]s"
3131
}
32+
33+
func ApiVersion() string {
34+
return defaultApiVersion
35+
}
3236
`, data.packageName, apiVersion, data.apiVersion, *copyrightLines)
3337
return &template, nil
3438
}

tools/generator-go-sdk/internal/generator/templater_version_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ const defaultApiVersion = "2022-02-01"
2929
3030
func userAgent() string {
3131
return "hashicorp/go-azure-sdk/somepackage/2022-02-01"
32-
}`
32+
}
33+
34+
func ApiVersion() string {
35+
return defaultApiVersion
36+
}
37+
`
3338
assertTemplatedCodeMatches(t, expected, *actual)
3439
}

tools/importer-rest-api-specs/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ test: build
3636
go test -v ./... -timeout=90m
3737

3838
tools:
39-
@echo "==> no tools required..."
39+
@go install golang.org/x/tools/cmd/goimports@latest
4040

4141
.PHONY: build fmt import import-with-api test tools

0 commit comments

Comments
 (0)