pulumi/tests/testdata/codegen/output-funcs-go-generics-only/go/mypkg/getClientConfig.go

73 lines
2.6 KiB
Go
Raw Permalink Normal View History

[go/sdk-gen] Fix generics-only option missing ToOutput(...) methods (#14584) # Description PR #14492 removed `ToOutput(...)` methods for output types when generating non-generic SDK variants. The fix there was added to only include these when `side-by-side` is enabled, which implicitly included `generics-only` except for a _single_ place where that wasn't the case 😓 (see comment below in `gen.go`) This PR fixes issue and includes tests for go sdkgen where `generics` setting is set to `generics-only`: - `output-funcs-go-generics-only` - `plain-and-default-go-generics-only` - `secrets-go-generics-only` - `simple-enum-schema-go-generics-only` - `simple-plain-schema-go-generics-only` ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-11-16 18:41:57 +00:00
// Code generated by test DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package mypkg
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
"output-funcs-go-generics-only/mypkg/internal"
)
// Failing example taken from azure-native. Original doc: Use this function to access the current configuration of the native Azure provider.
func GetClientConfig(ctx *pulumi.Context, opts ...pulumi.InvokeOption) (*GetClientConfigResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv GetClientConfigResult
err := ctx.Invoke("mypkg::getClientConfig", nil, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// Configuration values returned by getClientConfig.
type GetClientConfigResult struct {
// Azure Client ID (Application Object ID).
ClientId string `pulumi:"clientId"`
// Azure Object ID of the current user or service principal.
ObjectId string `pulumi:"objectId"`
// Azure Subscription ID
SubscriptionId string `pulumi:"subscriptionId"`
// Azure Tenant ID
TenantId string `pulumi:"tenantId"`
}
func GetClientConfigOutput(ctx *pulumi.Context, opts ...pulumi.InvokeOption) GetClientConfigResultOutput {
outputResult := pulumix.ApplyErr[int](pulumix.Val(0), func(_ int) (*GetClientConfigResult, error) {
return GetClientConfig(ctx, opts...)
})
return pulumix.Cast[GetClientConfigResultOutput, *GetClientConfigResult](outputResult)
}
type GetClientConfigResultOutput struct{ *pulumi.OutputState }
func (GetClientConfigResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*GetClientConfigResult)(nil)).Elem()
}
func (o GetClientConfigResultOutput) ToOutput(context.Context) pulumix.Output[*GetClientConfigResult] {
return pulumix.Output[*GetClientConfigResult]{
OutputState: o.OutputState,
}
}
func (o GetClientConfigResultOutput) ClientId() pulumix.Output[string] {
return pulumix.Apply[*GetClientConfigResult](o, func(v *GetClientConfigResult) string { return v.ClientId })
}
func (o GetClientConfigResultOutput) ObjectId() pulumix.Output[string] {
return pulumix.Apply[*GetClientConfigResult](o, func(v *GetClientConfigResult) string { return v.ObjectId })
}
func (o GetClientConfigResultOutput) SubscriptionId() pulumix.Output[string] {
return pulumix.Apply[*GetClientConfigResult](o, func(v *GetClientConfigResult) string { return v.SubscriptionId })
}
func (o GetClientConfigResultOutput) TenantId() pulumix.Output[string] {
return pulumix.Apply[*GetClientConfigResult](o, func(v *GetClientConfigResult) string { return v.TenantId })
}