Skip to content

Commit

Permalink
Merge pull request #13427 from hashicorp/jbardin/context-keys
Browse files Browse the repository at this point in the history
Fix context key types in schema
  • Loading branch information
jbardin authored Apr 10, 2017
2 parents 7819a3e + 8a1089a commit 735dfc4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions helper/schema/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type Backend struct {
config *ResourceData
}

const (
backendConfigKey = iota
var (
backendConfigKey = contextKey("backend config")
)

// FromContextBackendConfig extracts a ResourceData with the configuration
Expand Down
16 changes: 8 additions & 8 deletions helper/schema/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ type Provisioner struct {
stopOnce sync.Once
}

// These constants are the keys that can be used to access data in
// the context parameters for Provisioners.
const (
connDataInvalid int = iota
// Keys that can be used to access data in the context parameters for
// Provisioners.
var (
connDataInvalid = contextKey("data invalid")

// This returns a *ResourceData for the connection information.
// Guaranteed to never be nil.
ProvConnDataKey
ProvConnDataKey = contextKey("provider conn data")

// This returns a *ResourceData for the config information.
// Guaranteed to never be nil.
ProvConfigDataKey
ProvConfigDataKey = contextKey("provider config data")

// This returns a terraform.UIOutput. Guaranteed to never be nil.
ProvOutputKey
ProvOutputKey = contextKey("provider output")

// This returns the raw InstanceState passed to Apply. Guaranteed to
// be set, but may be nil.
ProvRawStateKey
ProvRawStateKey = contextKey("provider raw state")
)

// InternalValidate should be called to validate the structure
Expand Down
3 changes: 3 additions & 0 deletions helper/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import (
"github.com/mitchellh/mapstructure"
)

// type used for schema package context keys
type contextKey string

// Schema is used to describe the structure of a value.
//
// Read the documentation of the struct elements for important details.
Expand Down

0 comments on commit 735dfc4

Please sign in to comment.