Skip to content

Commit

Permalink
Add exceptions for resources where the user needs to specify the API …
Browse files Browse the repository at this point in the history
…version (#3985)

Resolves #3524 

This PR adds an exception for two resources where the `api-version`
query parameter works differently. Here, the endpoints receiving the API
version merely pass it on to another service, and it's meant to express
the API version the second service should use. Therefore, our usual
logic of auto-adding the API version doesn't work. The user must instead
specify the API version for the second service.

Example:
```go
resources.NewResource(ctx, "acc", &resources.ResourceArgs{
	ResourceProviderNamespace: pulumi.String("Microsoft.Storage"),
	ResourceType:              pulumi.String("storageAccounts"),
	ApiVersion:                pulumi.String("2022-09-01"),
})
```

The provider will make a request to the `resources` service (RP) here.
The `resources` service will then in turn make a request to the
Microsoft.Storage service. The API version is meant for the latter to
receive, so we cannot use whatever API version we have as default for
`resources.Resource`.

This PR, specifically fixing `resource.Resource`, unlocks the creation
of `GitHub.Network/networkSettings` and other resources that are not in
the Azure spec. It will also allow users to use `Resource` as an escape
hatch when there are problems with the provider schema.

#2467 is closely related - it's just a matter of adding the `ApiVersion`
property for _all_ resources, maybe with a different name.

Potential improvement: the description _"The API version to use for the
operation."_ for `ApiVersion` is not useful, we could replace it.
  • Loading branch information
thomas11 authored Feb 26, 2025
1 parent 6e70edd commit 6196cc4
Show file tree
Hide file tree
Showing 56 changed files with 1,172 additions and 18 deletions.
7 changes: 7 additions & 0 deletions examples/azure-native-sdk-v2/go-generic-resource/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: go-simple
description: A minimal Azure Native Go Pulumi program
runtime: go
config:
pulumi:tags:
value:
pulumi:template: azure-go
100 changes: 100 additions & 0 deletions examples/azure-native-sdk-v2/go-generic-resource/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
module go-simple

go 1.23.1

toolchain go1.24.0

require (
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.88.0
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.88.0
github.com/pulumi/pulumi/sdk/v3 v3.152.0
)

require (
dario.cat/mergo v1.0.1 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.1.5 // indirect
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/charmbracelet/bubbles v0.20.0 // indirect
github.com/charmbracelet/bubbletea v1.3.3 // indirect
github.com/charmbracelet/lipgloss v1.0.0 // indirect
github.com/charmbracelet/x/ansi v0.8.0 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/cheggaaa/pb v1.0.29 // indirect
github.com/cloudflare/circl v1.6.0 // indirect
github.com/containerd/console v1.0.4 // indirect
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
github.com/djherbis/times v1.6.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.2 // indirect
github.com/go-git/go-git/v5 v5.13.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.4 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl/v2 v2.23.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/opentracing/basictracer-go v1.1.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pgavlin/fx v0.1.6 // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
github.com/pulumi/esc v0.12.0 // indirect
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.88.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.14.0 // indirect
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/zclconf/go-cty v1.16.2 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/crypto v0.35.0 // indirect
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa // indirect
golang.org/x/mod v0.23.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/term v0.29.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/tools v0.30.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250224174004-546df14abb99 // indirect
google.golang.org/grpc v1.70.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/frand v1.5.1 // indirect
)
Loading

0 comments on commit 6196cc4

Please sign in to comment.