Merge pull request #3977 from pulumi/jen20/remove-pkg-errors-from-sdk
Remove use of `github.com/pkg/errors` from Go SDK
This commit is contained in:
commit
ec539bbb6c
|
@ -15,9 +15,8 @@
|
|||
package pulumi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Alias is a partial description of prior named used for a resource. It can be processed in the
|
||||
|
|
|
@ -16,10 +16,10 @@ package config
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/go/pulumi"
|
||||
|
@ -196,7 +196,7 @@ func TestSecretConfig(t *testing.T) {
|
|||
if val == "a string value" {
|
||||
result <- val.(string)
|
||||
} else {
|
||||
errChan <- errors.Errorf("Invalid result: %v", val)
|
||||
errChan <- fmt.Errorf("Invalid result: %v", val)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ func TestSecretConfig(t *testing.T) {
|
|||
if reflect.DeepEqual(expectedTestStruct, *ts) {
|
||||
objResult <- *ts
|
||||
} else {
|
||||
errChan <- errors.Errorf("Invalid result: %v", val)
|
||||
errChan <- fmt.Errorf("Invalid result: %v", val)
|
||||
}
|
||||
}
|
||||
return v, nil
|
||||
|
@ -263,7 +263,7 @@ func TestSecretConfig(t *testing.T) {
|
|||
if val == true {
|
||||
resultBool <- val.(bool)
|
||||
} else {
|
||||
errChan <- errors.Errorf("Invalid result: %v", val)
|
||||
errChan <- fmt.Errorf("Invalid result: %v", val)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ func TestSecretConfig(t *testing.T) {
|
|||
if val == 42 {
|
||||
resultInt <- val.(int)
|
||||
} else {
|
||||
errChan <- errors.Errorf("Invalid result: %v", val)
|
||||
errChan <- fmt.Errorf("Invalid result: %v", val)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ package config
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/go/pulumi"
|
||||
|
@ -27,8 +27,7 @@ import (
|
|||
func Try(ctx *pulumi.Context, key string) (string, error) {
|
||||
v, ok := ctx.GetConfig(key)
|
||||
if !ok {
|
||||
return "",
|
||||
errors.Errorf("missing required configuration variable '%s'; run `pulumi config` to set", key)
|
||||
return "", fmt.Errorf("missing required configuration variable '%s'; run `pulumi config` to set", key)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
package pulumi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
|
@ -24,8 +27,6 @@ import (
|
|||
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/pulumi/pulumi/pkg/resource"
|
||||
|
@ -59,7 +60,7 @@ func NewContext(ctx context.Context, info RunInfo) (*Context, error) {
|
|||
if addr := info.MonitorAddr; addr != "" {
|
||||
conn, err := grpc.Dial(info.MonitorAddr, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "connecting to resource monitor over RPC")
|
||||
return nil, fmt.Errorf("connecting to resource monitor over RPC: %w", err)
|
||||
}
|
||||
monitorConn = conn
|
||||
monitor = pulumirpc.NewResourceMonitorClient(monitorConn)
|
||||
|
@ -70,7 +71,7 @@ func NewContext(ctx context.Context, info RunInfo) (*Context, error) {
|
|||
if addr := info.EngineAddr; addr != "" {
|
||||
conn, err := grpc.Dial(info.EngineAddr, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "connecting to engine over RPC")
|
||||
return nil, fmt.Errorf("connecting to engine over RPC: %w", err)
|
||||
}
|
||||
engineConn = conn
|
||||
engine = pulumirpc.NewEngineClient(engineConn)
|
||||
|
@ -162,7 +163,7 @@ func (ctx *Context) Invoke(tok string, args interface{}, result interface{}, opt
|
|||
}
|
||||
resolvedArgs, _, err := marshalInput(args, anyType, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "marshaling arguments")
|
||||
return fmt.Errorf("marshaling arguments: %w", err)
|
||||
}
|
||||
|
||||
resolvedArgsMap := resource.PropertyMap{}
|
||||
|
@ -174,7 +175,7 @@ func (ctx *Context) Invoke(tok string, args interface{}, result interface{}, opt
|
|||
resolvedArgsMap,
|
||||
plugin.MarshalOptions{KeepUnknowns: false, KeepSecrets: true})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "marshaling arguments")
|
||||
return fmt.Errorf("marshaling arguments: %w", err)
|
||||
}
|
||||
|
||||
// Note that we're about to make an outstanding RPC request, so that we can rendezvous during shutdown.
|
||||
|
@ -201,7 +202,7 @@ func (ctx *Context) Invoke(tok string, args interface{}, result interface{}, opt
|
|||
var ferr error
|
||||
for _, failure := range resp.Failures {
|
||||
ferr = multierror.Append(ferr,
|
||||
errors.Errorf("%s invoke failed: %s (%s)", tok, failure.Reason, failure.Property))
|
||||
fmt.Errorf("%s invoke failed: %s (%s)", tok, failure.Reason, failure.Property))
|
||||
}
|
||||
return ferr
|
||||
}
|
||||
|
@ -218,7 +219,7 @@ func (ctx *Context) Invoke(tok string, args interface{}, result interface{}, opt
|
|||
return err
|
||||
}
|
||||
if hasSecret {
|
||||
return errors.Errorf("Unexpected secret result returned to invoke call.")
|
||||
return errors.New("unexpected secret result returned to invoke call")
|
||||
}
|
||||
logging.V(9).Infof("Invoke(%s, ...): success: w/ %d outs (err=%v)", tok, len(outProps), err)
|
||||
return nil
|
||||
|
@ -531,7 +532,7 @@ func (ctx *Context) collapseAliases(aliases []Alias, t, name string, parent Reso
|
|||
for _, alias := range aliases {
|
||||
urn, err := alias.collapseToURN(name, t, parent, project, stack)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error collapsing alias to URN")
|
||||
return nil, fmt.Errorf("error collapsing alias to URN: %w", err)
|
||||
}
|
||||
aliasURNs = append(aliasURNs, urn)
|
||||
}
|
||||
|
@ -702,13 +703,13 @@ func (ctx *Context) prepareResourceInputs(props Input, t string,
|
|||
parent, optDeps, protect, provider, deleteBeforeReplace,
|
||||
importID, ignoreChanges, additionalSecretOutputs, err := ctx.getOpts(t, providers, opts)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "resolving options")
|
||||
return nil, fmt.Errorf("resolving options: %w", err)
|
||||
}
|
||||
|
||||
// Serialize all properties, first by awaiting them, and then marshaling them to the requisite gRPC values.
|
||||
resolvedProps, propertyDeps, rpcDeps, err := marshalInputs(props)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "marshaling properties")
|
||||
return nil, fmt.Errorf("marshaling properties: %w", err)
|
||||
}
|
||||
|
||||
// Marshal all properties for the RPC call.
|
||||
|
@ -717,7 +718,7 @@ func (ctx *Context) prepareResourceInputs(props Input, t string,
|
|||
resolvedProps,
|
||||
plugin.MarshalOptions{KeepUnknowns: keepUnknowns, KeepSecrets: true})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "marshaling properties")
|
||||
return nil, fmt.Errorf("marshaling properties: %w", err)
|
||||
}
|
||||
|
||||
// Convert the property dependencies map for RPC and remove duplicates.
|
||||
|
@ -754,7 +755,7 @@ func (ctx *Context) prepareResourceInputs(props Input, t string,
|
|||
for i, alias := range resource.aliases {
|
||||
urn, _, _, err := alias.awaitURN(context.Background())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error waiting for alias URN to resolve")
|
||||
return nil, fmt.Errorf("error waiting for alias URN to resolve: %w", err)
|
||||
}
|
||||
aliases[i] = string(urn)
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
package pulumi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/pulumi/pulumi/pkg/resource"
|
||||
|
@ -47,7 +48,7 @@ func mapStructTypes(from, to reflect.Type) func(reflect.Value, int) (reflect.Str
|
|||
fieldName := from.Field(i).Name
|
||||
j, ok := nameToIndex[fieldName]
|
||||
if !ok {
|
||||
panic(errors.Errorf("unknown field %v when marshaling inputs of type %v to %v", fieldName, from, to))
|
||||
panic(fmt.Errorf("unknown field %v when marshaling inputs of type %v to %v", fieldName, from, to))
|
||||
}
|
||||
|
||||
field := to.Field(j)
|
||||
|
@ -96,7 +97,7 @@ func marshalInputs(props Input) (resource.PropertyMap, map[string][]URN, []URN,
|
|||
// Get the underlying value, possibly waiting for an output to arrive.
|
||||
v, resourceDeps, err := marshalInput(pv.Field(i).Interface(), destField.Type, true)
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrapf(err, "awaiting input property %s", tag)
|
||||
return nil, nil, nil, fmt.Errorf("awaiting input property %s: %w", tag, err)
|
||||
}
|
||||
|
||||
// Record all dependencies accumulated from reading this property.
|
||||
|
@ -168,7 +169,7 @@ func marshalInputAndDetermineSecret(v interface{},
|
|||
// We were able to convert the input. Use the result as the new input value.
|
||||
input, valueType = newOutput, destType
|
||||
} else if !valueType.AssignableTo(destType) {
|
||||
err := errors.Errorf("cannot marshal an input of type %T as a value of type %v", input, destType)
|
||||
err := fmt.Errorf("cannot marshal an input of type %T as a value of type %v", input, destType)
|
||||
return resource.PropertyValue{}, nil, false, err
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +177,7 @@ func marshalInputAndDetermineSecret(v interface{},
|
|||
// If the input is an Output, await its value. The returned value is fully resolved.
|
||||
if output, ok := input.(Output); ok {
|
||||
if !await {
|
||||
return resource.PropertyValue{}, nil, false, errors.Errorf(cannotAwaitFmt, output)
|
||||
return resource.PropertyValue{}, nil, false, fmt.Errorf(cannotAwaitFmt, output)
|
||||
}
|
||||
|
||||
// Await the output.
|
||||
|
@ -290,7 +291,7 @@ func marshalInputAndDetermineSecret(v interface{},
|
|||
case reflect.Map:
|
||||
if rv.Type().Key().Kind() != reflect.String {
|
||||
return resource.PropertyValue{}, nil, false,
|
||||
errors.Errorf("expected map keys to be strings; got %v", rv.Type().Key())
|
||||
fmt.Errorf("expected map keys to be strings; got %v", rv.Type().Key())
|
||||
}
|
||||
|
||||
if rv.IsNil() {
|
||||
|
@ -336,7 +337,7 @@ func marshalInputAndDetermineSecret(v interface{},
|
|||
}
|
||||
return resource.NewObjectProperty(obj), deps, secret, nil
|
||||
}
|
||||
return resource.PropertyValue{}, nil, false, errors.Errorf("unrecognized input property type: %v (%T)", v, v)
|
||||
return resource.PropertyValue{}, nil, false, fmt.Errorf("unrecognized input property type: %v (%T)", v, v)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -434,7 +435,7 @@ func unmarshalOutput(v resource.PropertyValue, dest reflect.Value) (bool, error)
|
|||
switch {
|
||||
case v.IsAsset():
|
||||
if !assetType.AssignableTo(dest.Type()) {
|
||||
return false, errors.Errorf("expected a %s, got an asset", dest.Type())
|
||||
return false, fmt.Errorf("expected a %s, got an asset", dest.Type())
|
||||
}
|
||||
|
||||
asset, secret, err := unmarshalPropertyValue(v)
|
||||
|
@ -445,7 +446,7 @@ func unmarshalOutput(v resource.PropertyValue, dest reflect.Value) (bool, error)
|
|||
return secret, nil
|
||||
case v.IsArchive():
|
||||
if !archiveType.AssignableTo(dest.Type()) {
|
||||
return false, errors.Errorf("expected a %s, got an archive", dest.Type())
|
||||
return false, fmt.Errorf("expected a %s, got an archive", dest.Type())
|
||||
}
|
||||
|
||||
archive, secret, err := unmarshalPropertyValue(v)
|
||||
|
@ -465,37 +466,37 @@ func unmarshalOutput(v resource.PropertyValue, dest reflect.Value) (bool, error)
|
|||
switch dest.Kind() {
|
||||
case reflect.Bool:
|
||||
if !v.IsBool() {
|
||||
return false, errors.Errorf("expected a %v, got a %s", dest.Type(), v.TypeString())
|
||||
return false, fmt.Errorf("expected a %v, got a %s", dest.Type(), v.TypeString())
|
||||
}
|
||||
dest.SetBool(v.BoolValue())
|
||||
return false, nil
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
if !v.IsNumber() {
|
||||
return false, errors.Errorf("expected an %v, got a %s", dest.Type(), v.TypeString())
|
||||
return false, fmt.Errorf("expected an %v, got a %s", dest.Type(), v.TypeString())
|
||||
}
|
||||
dest.SetInt(int64(v.NumberValue()))
|
||||
return false, nil
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
if !v.IsNumber() {
|
||||
return false, errors.Errorf("expected an %v, got a %s", dest.Type(), v.TypeString())
|
||||
return false, fmt.Errorf("expected an %v, got a %s", dest.Type(), v.TypeString())
|
||||
}
|
||||
dest.SetUint(uint64(v.NumberValue()))
|
||||
return false, nil
|
||||
case reflect.Float32, reflect.Float64:
|
||||
if !v.IsNumber() {
|
||||
return false, errors.Errorf("expected an %v, got a %s", dest.Type(), v.TypeString())
|
||||
return false, fmt.Errorf("expected an %v, got a %s", dest.Type(), v.TypeString())
|
||||
}
|
||||
dest.SetFloat(v.NumberValue())
|
||||
return false, nil
|
||||
case reflect.String:
|
||||
if !v.IsString() {
|
||||
return false, errors.Errorf("expected a %v, got a %s", dest.Type(), v.TypeString())
|
||||
return false, fmt.Errorf("expected a %v, got a %s", dest.Type(), v.TypeString())
|
||||
}
|
||||
dest.SetString(v.StringValue())
|
||||
return false, nil
|
||||
case reflect.Slice:
|
||||
if !v.IsArray() {
|
||||
return false, errors.Errorf("expected a %v, got a %s", dest.Type(), v.TypeString())
|
||||
return false, fmt.Errorf("expected a %v, got a %s", dest.Type(), v.TypeString())
|
||||
}
|
||||
arr := v.ArrayValue()
|
||||
slice := reflect.MakeSlice(dest.Type(), len(arr), len(arr))
|
||||
|
@ -511,12 +512,12 @@ func unmarshalOutput(v resource.PropertyValue, dest reflect.Value) (bool, error)
|
|||
return secret, nil
|
||||
case reflect.Map:
|
||||
if !v.IsObject() {
|
||||
return false, errors.Errorf("expected a %v, got a %s", dest.Type(), v.TypeString())
|
||||
return false, fmt.Errorf("expected a %v, got a %s", dest.Type(), v.TypeString())
|
||||
}
|
||||
|
||||
keyType, elemType := dest.Type().Key(), dest.Type().Elem()
|
||||
if keyType.Kind() != reflect.String {
|
||||
return false, errors.Errorf("map keys must be assignable from type string")
|
||||
return false, fmt.Errorf("map keys must be assignable from type string")
|
||||
}
|
||||
|
||||
result := reflect.MakeMap(dest.Type())
|
||||
|
@ -538,7 +539,7 @@ func unmarshalOutput(v resource.PropertyValue, dest reflect.Value) (bool, error)
|
|||
return secret, nil
|
||||
case reflect.Interface:
|
||||
if !anyType.Implements(dest.Type()) {
|
||||
return false, errors.Errorf("cannot unmarshal into non-empty interface type %v", dest.Type())
|
||||
return false, fmt.Errorf("cannot unmarshal into non-empty interface type %v", dest.Type())
|
||||
}
|
||||
|
||||
// If we're unmarshaling into the empty interface type, use the property type as the type of the result.
|
||||
|
@ -550,7 +551,7 @@ func unmarshalOutput(v resource.PropertyValue, dest reflect.Value) (bool, error)
|
|||
return secret, nil
|
||||
case reflect.Struct:
|
||||
if !v.IsObject() {
|
||||
return false, errors.Errorf("expected a %v, got a %s", dest.Type(), v.TypeString())
|
||||
return false, fmt.Errorf("expected a %v, got a %s", dest.Type(), v.TypeString())
|
||||
}
|
||||
|
||||
obj := v.ObjectValue()
|
||||
|
@ -580,6 +581,6 @@ func unmarshalOutput(v resource.PropertyValue, dest reflect.Value) (bool, error)
|
|||
}
|
||||
return secret, nil
|
||||
default:
|
||||
return false, errors.Errorf("cannot unmarshal into type %v", dest.Type())
|
||||
return false, fmt.Errorf("cannot unmarshal into type %v", dest.Type())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
package pulumi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/pulumi/pulumi/pkg/util/contract"
|
||||
)
|
||||
|
@ -53,7 +53,7 @@ func RunErr(body RunFunc, opts ...RunOption) error {
|
|||
|
||||
// Validate some properties.
|
||||
if info.Project == "" {
|
||||
return errors.Errorf("missing project name")
|
||||
return errors.New("missing project name")
|
||||
} else if info.Stack == "" {
|
||||
return errors.New("missing stack name")
|
||||
} else if info.MonitorAddr == "" && info.Mocks == nil {
|
||||
|
|
|
@ -16,8 +16,8 @@ package config
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/go/pulumi"
|
||||
|
@ -28,7 +28,7 @@ func Try(ctx *pulumi.Context, key string) (string, error) {
|
|||
v, ok := ctx.GetConfig(key)
|
||||
if !ok {
|
||||
return "",
|
||||
errors.Errorf("missing required configuration variable '%s'; run `pulumi config` to set", key)
|
||||
fmt.Errorf("missing required configuration variable '%s'; run `pulumi config` to set", key)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ package pulumi
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@ package pulumi
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pulumi/pulumi/pkg/util/contract"
|
||||
)
|
||||
|
||||
|
@ -58,7 +59,7 @@ func RegisterOutputType(output Output) {
|
|||
elementType := output.ElementType()
|
||||
existing, hasExisting := concreteTypeToOutputType.LoadOrStore(elementType, reflect.TypeOf(output))
|
||||
if hasExisting {
|
||||
panic(errors.Errorf("an output type for %v is already registered: %v", elementType, existing))
|
||||
panic(fmt.Errorf("an output type for %v is already registered: %v", elementType, existing))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,7 +243,7 @@ func makeContextful(fn interface{}, elementType reflect.Type) interface{} {
|
|||
|
||||
ft := fv.Type()
|
||||
if ft.NumIn() != 1 || !elementType.AssignableTo(ft.In(0)) {
|
||||
panic(errors.Errorf("applier must have 1 input parameter assignable from %v", elementType))
|
||||
panic(fmt.Errorf("applier must have 1 input parameter assignable from %v", elementType))
|
||||
}
|
||||
|
||||
var outs []reflect.Type
|
||||
|
@ -277,7 +278,7 @@ func checkApplier(fn interface{}, elementType reflect.Type) reflect.Value {
|
|||
|
||||
ft := fv.Type()
|
||||
if ft.NumIn() != 2 || !contextType.AssignableTo(ft.In(0)) || !elementType.AssignableTo(ft.In(1)) {
|
||||
panic(errors.Errorf("applier's input parameters must be assignable from %v and %v", contextType, elementType))
|
||||
panic(fmt.Errorf("applier's input parameters must be assignable from %v and %v", contextType, elementType))
|
||||
}
|
||||
|
||||
switch ft.NumOut() {
|
||||
|
@ -541,7 +542,7 @@ func awaitInputs(ctx context.Context, v, resolved reflect.Value) (bool, bool, er
|
|||
// If the value type is not assignable to the destination, see if we can assign the input value itself
|
||||
// to the destination.
|
||||
if !v.Type().AssignableTo(resolved.Type()) {
|
||||
panic(errors.Errorf("cannot convert an input of type %T to a value of type %v",
|
||||
panic(fmt.Errorf("cannot convert an input of type %T to a value of type %v",
|
||||
input, resolved.Type()))
|
||||
} else {
|
||||
assignInput = true
|
||||
|
@ -848,7 +849,7 @@ func (o URNOutput) awaitURN(ctx context.Context) (URN, bool, bool, error) {
|
|||
func convert(v interface{}, to reflect.Type) interface{} {
|
||||
rv := reflect.ValueOf(v)
|
||||
if !rv.Type().ConvertibleTo(to) {
|
||||
panic(errors.Errorf("cannot convert output value of type %s to %s", rv.Type(), to))
|
||||
panic(fmt.Errorf("cannot convert output value of type %s to %s", rv.Type(), to))
|
||||
}
|
||||
return rv.Convert(to).Interface()
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ package pulumi
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@ package pulumi
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -328,7 +329,7 @@ func TestSecrets(t *testing.T) {
|
|||
// validate the value
|
||||
resultChan <- val
|
||||
} else {
|
||||
errChan <- errors.Errorf("Invalid result: %v", val)
|
||||
errChan <- fmt.Errorf("Invalid result: %v", val)
|
||||
}
|
||||
return val, nil
|
||||
})
|
||||
|
@ -372,7 +373,7 @@ func TestSecretApply(t *testing.T) {
|
|||
// validate the value
|
||||
resultChan <- val
|
||||
} else {
|
||||
errChan <- errors.Errorf("Invalid result: %v", val)
|
||||
errChan <- fmt.Errorf("Invalid result: %v", val)
|
||||
}
|
||||
return val, nil
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue