Fix a bunch of lint warnings
This commit is contained in:
parent
2e8bbcc9dd
commit
6e52490706
|
@ -37,21 +37,29 @@ type asset struct {
|
|||
uri string
|
||||
}
|
||||
|
||||
// NewFileAsset creates an asset backed by a file and specified by that file's path.
|
||||
func NewFileAsset(path string) Asset {
|
||||
return &asset{path: path}
|
||||
}
|
||||
|
||||
// NewStringAsset creates an asset backed by a piece of in-memory text.
|
||||
func NewStringAsset(text string) Asset {
|
||||
return &asset{text: text}
|
||||
}
|
||||
|
||||
// NewRemoteAsset creates an asset backed by a remote file and specified by that file's URL.
|
||||
func NewRemoteAsset(uri string) Asset {
|
||||
return &asset{uri: uri}
|
||||
}
|
||||
|
||||
// Path returns the asset's file path, if this is a file asset, or an empty string otherwise.
|
||||
func (a *asset) Path() string { return a.path }
|
||||
|
||||
// Text returns the asset's textual string, if this is a string asset, or an empty string otherwise.
|
||||
func (a *asset) Text() string { return a.text }
|
||||
func (a *asset) URI() string { return a.uri }
|
||||
|
||||
// URI returns the asset's URL, if this is a remote asset, or an empty string otherwise.
|
||||
func (a *asset) URI() string { return a.uri }
|
||||
|
||||
// Archive represents a collection of Assets.
|
||||
type Archive interface {
|
||||
|
@ -82,14 +90,21 @@ func NewAssetArchive(assets map[string]interface{}) Archive {
|
|||
return &archive{assets: assets}
|
||||
}
|
||||
|
||||
// NewFileArchive creates an archive backed by a file and specified by that file's path.
|
||||
func NewFileArchive(path string) Archive {
|
||||
return &archive{path: path}
|
||||
}
|
||||
|
||||
// NewRemoteArchive creates an archive backed by a remote file and specified by that file's URL.
|
||||
func NewRemoteArchive(uri string) Archive {
|
||||
return &archive{uri: uri}
|
||||
}
|
||||
|
||||
// Assets returns the archive's asset map, if this is a collection of archives/assets, or nil otherwise.
|
||||
func (a *archive) Assets() map[string]interface{} { return a.assets }
|
||||
func (a *archive) Path() string { return a.path }
|
||||
func (a *archive) URI() string { return a.uri }
|
||||
|
||||
// Path returns the archive's file path, if this is a file archive, or an empty string otherwise.
|
||||
func (a *archive) Path() string { return a.path }
|
||||
|
||||
// URI returns the archive's URL, if this is a remote archive, or an empty string otherwise.
|
||||
func (a *archive) URI() string { return a.uri }
|
||||
|
|
|
@ -212,7 +212,7 @@ func (ctx *Context) RegisterResource(
|
|||
reject(err)
|
||||
}
|
||||
} else {
|
||||
glog.V(9).Infof("RegisterResource(%s, %s): success: %s %s %d", resp.Urn, resp.Id, len(outprops))
|
||||
glog.V(9).Infof("RegisterResource(%s, %s): success: %s %s %d", t, name, resp.Urn, resp.Id, len(outprops))
|
||||
resolveURN(URN(resp.Urn))
|
||||
if resolveID != nil {
|
||||
resolveID(ID(resp.Id))
|
||||
|
|
|
@ -151,7 +151,7 @@ func (out *Output) Asset() (asset.Asset, error) {
|
|||
return v.(asset.Asset), nil
|
||||
}
|
||||
|
||||
/// Bool retrives the underlying value for this output property as a bool.
|
||||
// Bool retrives the underlying value for this output property as a bool.
|
||||
func (out *Output) Bool() (bool, error) {
|
||||
v, err := out.Value()
|
||||
if err != nil {
|
||||
|
@ -250,7 +250,7 @@ func (out *Output) String() (string, error) {
|
|||
return cast.ToString(v), nil
|
||||
}
|
||||
|
||||
// Uuint retrives the underlying value for this output property as a uint.
|
||||
// Uint retrives the underlying value for this output property as a uint.
|
||||
func (out *Output) Uint() (uint, error) {
|
||||
v, err := out.Value()
|
||||
if err != nil {
|
||||
|
@ -259,7 +259,7 @@ func (out *Output) Uint() (uint, error) {
|
|||
return cast.ToUint(v), nil
|
||||
}
|
||||
|
||||
// Uuint8 retrives the underlying value for this output property as a uint8.
|
||||
// Uint8 retrives the underlying value for this output property as a uint8.
|
||||
func (out *Output) Uint8() (uint8, error) {
|
||||
v, err := out.Value()
|
||||
if err != nil {
|
||||
|
@ -268,7 +268,7 @@ func (out *Output) Uint8() (uint8, error) {
|
|||
return cast.ToUint8(v), nil
|
||||
}
|
||||
|
||||
// Uuint16 retrives the underlying value for this output property as a uint16.
|
||||
// Uint16 retrives the underlying value for this output property as a uint16.
|
||||
func (out *Output) Uint16() (uint16, error) {
|
||||
v, err := out.Value()
|
||||
if err != nil {
|
||||
|
@ -277,7 +277,7 @@ func (out *Output) Uint16() (uint16, error) {
|
|||
return cast.ToUint16(v), nil
|
||||
}
|
||||
|
||||
// Uuint32 retrives the underlying value for this output property as a uint32.
|
||||
// Uint32 retrives the underlying value for this output property as a uint32.
|
||||
func (out *Output) Uint32() (uint32, error) {
|
||||
v, err := out.Value()
|
||||
if err != nil {
|
||||
|
@ -286,7 +286,7 @@ func (out *Output) Uint32() (uint32, error) {
|
|||
return cast.ToUint32(v), nil
|
||||
}
|
||||
|
||||
// Uuint64 retrives the underlying value for this output property as a uint64.
|
||||
// Uint64 retrives the underlying value for this output property as a uint64.
|
||||
func (out *Output) Uint64() (uint64, error) {
|
||||
v, err := out.Value()
|
||||
if err != nil {
|
||||
|
|
|
@ -61,6 +61,7 @@ func marshalInputs(props map[string]interface{}) ([]string, *structpb.Struct, []
|
|||
}
|
||||
|
||||
const (
|
||||
// nolint: gas, linter thinks these are creds, but they aren't.
|
||||
rpcTokenSpecialSigKey = "4dabf18193072939515e22adb298388d"
|
||||
rpcTokenSpecialAssetSig = "c44067f5952c0a294b673a41bacd8c17"
|
||||
rpcTokenSpecialArchiveSig = "0def7320c3a5731c473e5ecbe6d01bc7"
|
||||
|
@ -106,12 +107,12 @@ func marshalInput(v interface{}) (interface{}, []Resource, error) {
|
|||
}, nil, nil
|
||||
case *Output:
|
||||
// Await the value and return its raw value.
|
||||
v, err := t.Value()
|
||||
ov, err := t.Value()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
// TODO: unknownValue
|
||||
e, d, err := marshalInput(v)
|
||||
e, d, err := marshalInput(ov)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -153,12 +154,12 @@ func marshalInput(v interface{}) (interface{}, []Resource, error) {
|
|||
errors.Errorf("expected map keys to be strings; got %v", reflect.TypeOf(key.Interface()))
|
||||
}
|
||||
value := rv.MapIndex(key)
|
||||
v, d, err := marshalInput(value.Interface())
|
||||
mv, d, err := marshalInput(value.Interface())
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
obj[k] = v
|
||||
obj[k] = mv
|
||||
deps = append(deps, d...)
|
||||
}
|
||||
return obj, deps, nil
|
||||
|
@ -243,19 +244,19 @@ func unmarshalOutput(v interface{}) (interface{}, error) {
|
|||
return arr, nil
|
||||
case reflect.Map:
|
||||
// For maps, only support string-based keys, and recurse into the values.
|
||||
var obj map[string]interface{}
|
||||
obj := make(map[string]interface{})
|
||||
for _, key := range rv.MapKeys() {
|
||||
k, ok := key.Interface().(string)
|
||||
if !ok {
|
||||
return nil, errors.Errorf("expected map keys to be strings; got %v", reflect.TypeOf(key.Interface()))
|
||||
}
|
||||
value := rv.MapIndex(key)
|
||||
v, err := unmarshalOutput(value)
|
||||
mv, err := unmarshalOutput(value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
obj[k] = v
|
||||
obj[k] = mv
|
||||
}
|
||||
return obj, nil
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import (
|
|||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/pulumi/pulumi/pkg/util/contract"
|
||||
)
|
||||
|
||||
// Run executes the body of a Pulumi program, granting it access to a deployment context that it may use
|
||||
|
@ -34,7 +36,7 @@ func Run(body RunFunc) {
|
|||
}
|
||||
}
|
||||
|
||||
// Run executes the body of a Pulumi program, granting it access to a deployment context that it may use
|
||||
// RunErr executes the body of a Pulumi program, granting it access to a deployment context that it may use
|
||||
// to register resources and orchestrate deployment activities. This connects back to the Pulumi engine using gRPC.
|
||||
func RunErr(body RunFunc) error {
|
||||
// Parse the info out of environment variables. This is a lame contract with the caller, but helps to keep
|
||||
|
@ -47,7 +49,7 @@ func RunErr(body RunFunc) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer ctx.Close()
|
||||
defer contract.IgnoreClose(ctx)
|
||||
|
||||
// Create a root stack resource that we'll parent everything to.
|
||||
reg, err := ctx.RegisterResource(
|
||||
|
@ -75,7 +77,7 @@ func RunErr(body RunFunc) error {
|
|||
}
|
||||
|
||||
// Propagate the error from the body, if any.
|
||||
return err
|
||||
return result
|
||||
}
|
||||
|
||||
// RunFunc executes the body of a Pulumi program. It may register resources using the deployment context
|
||||
|
|
Loading…
Reference in a new issue