de-linting
This commit is contained in:
parent
34325d5b66
commit
863963e7a6
|
@ -194,14 +194,10 @@ func (r AbsResource) absMoveableSigil() {
|
||||||
// AbsResource is moveable
|
// AbsResource is moveable
|
||||||
}
|
}
|
||||||
|
|
||||||
type absResourceKey string
|
|
||||||
|
|
||||||
func (r AbsResource) UniqueKey() UniqueKey {
|
func (r AbsResource) UniqueKey() UniqueKey {
|
||||||
return absResourceInstanceKey(r.String())
|
return absResourceInstanceKey(r.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rk absResourceKey) uniqueKeySigil() {}
|
|
||||||
|
|
||||||
// AbsResourceInstance is an absolute address for a resource instance under a
|
// AbsResourceInstance is an absolute address for a resource instance under a
|
||||||
// given module path.
|
// given module path.
|
||||||
type AbsResourceInstance struct {
|
type AbsResourceInstance struct {
|
||||||
|
|
|
@ -888,7 +888,7 @@ func (b *Remote) VerifyWorkspaceTerraformVersion(workspaceName string) tfdiags.D
|
||||||
|
|
||||||
// If the workspace has remote operations disabled, the remote Terraform
|
// If the workspace has remote operations disabled, the remote Terraform
|
||||||
// version is effectively meaningless, so we'll skip version verification.
|
// version is effectively meaningless, so we'll skip version verification.
|
||||||
if workspace.Operations == false {
|
if !workspace.Operations {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -963,22 +963,6 @@ func (b *Remote) IsLocalOperations() bool {
|
||||||
return b.forceLocal
|
return b.forceLocal
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colorize returns the Colorize structure that can be used for colorizing
|
|
||||||
// output. This is guaranteed to always return a non-nil value and so useful
|
|
||||||
// as a helper to wrap any potentially colored strings.
|
|
||||||
//
|
|
||||||
// TODO SvH: Rename this back to Colorize as soon as we can pass -no-color.
|
|
||||||
func (b *Remote) cliColorize() *colorstring.Colorize {
|
|
||||||
if b.CLIColor != nil {
|
|
||||||
return b.CLIColor
|
|
||||||
}
|
|
||||||
|
|
||||||
return &colorstring.Colorize{
|
|
||||||
Colors: colorstring.DefaultColors,
|
|
||||||
Disable: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func generalError(msg string, err error) error {
|
func generalError(msg string, err error) error {
|
||||||
var diags tfdiags.Diagnostics
|
var diags tfdiags.Diagnostics
|
||||||
|
|
||||||
|
|
|
@ -1594,7 +1594,7 @@ func TestRemote_applyVersionCheck(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RUN: prepare the apply operation and run it
|
// RUN: prepare the apply operation and run it
|
||||||
op, configCleanup, done := testOperationApply(t, "./testdata/apply")
|
op, configCleanup, _ := testOperationApply(t, "./testdata/apply")
|
||||||
defer configCleanup()
|
defer configCleanup()
|
||||||
|
|
||||||
streams, done := terminal.StreamsForTesting(t)
|
streams, done := terminal.StreamsForTesting(t)
|
||||||
|
|
|
@ -45,8 +45,7 @@ func (c *ApplyCommand) Run(rawArgs []string) int {
|
||||||
|
|
||||||
// Instantiate the view, even if there are flag errors, so that we render
|
// Instantiate the view, even if there are flag errors, so that we render
|
||||||
// diagnostics according to the desired view
|
// diagnostics according to the desired view
|
||||||
var view views.Apply
|
view := views.NewApply(args.ViewType, c.Destroy, c.View)
|
||||||
view = views.NewApply(args.ViewType, c.Destroy, c.View)
|
|
||||||
|
|
||||||
if diags.HasErrors() {
|
if diags.HasErrors() {
|
||||||
view.Diagnostics(diags)
|
view.Diagnostics(diags)
|
||||||
|
|
|
@ -1779,6 +1779,7 @@ func TestApply_terraformEnvNonDefault(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if code := newCmd.Run([]string{"test"}); code != 0 {
|
if code := newCmd.Run([]string{"test"}); code != 0 {
|
||||||
|
t.Fatal("error creating workspace")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1792,6 +1793,7 @@ func TestApply_terraformEnvNonDefault(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if code := selCmd.Run(args); code != 0 {
|
if code := selCmd.Run(args); code != 0 {
|
||||||
|
t.Fatal("error switching workspace")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ func ResourceChange(
|
||||||
buf.WriteString(color.Color(fmt.Sprintf("[bold] # %s[reset] will be [bold][red]destroyed", dispAddr)))
|
buf.WriteString(color.Color(fmt.Sprintf("[bold] # %s[reset] will be [bold][red]destroyed", dispAddr)))
|
||||||
if change.DeposedKey != states.NotDeposed {
|
if change.DeposedKey != states.NotDeposed {
|
||||||
// Some extra context about this unusual situation.
|
// Some extra context about this unusual situation.
|
||||||
buf.WriteString(color.Color(fmt.Sprint("\n # (left over from a partially-failed replacement of this instance)")))
|
buf.WriteString(color.Color("\n # (left over from a partially-failed replacement of this instance)"))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// should never happen, since the above is exhaustive
|
// should never happen, since the above is exhaustive
|
||||||
|
@ -755,8 +755,6 @@ func (p *blockBodyDiffPrinter) writeNestedAttrDiff(
|
||||||
p.buf.WriteString(" -> (known after apply)")
|
p.buf.WriteString(" -> (known after apply)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *blockBodyDiffPrinter) writeNestedBlockDiffs(name string, blockS *configschema.NestedBlock, old, new cty.Value, blankBefore bool, indent int, path cty.Path) int {
|
func (p *blockBodyDiffPrinter) writeNestedBlockDiffs(name string, blockS *configschema.NestedBlock, old, new cty.Value, blankBefore bool, indent int, path cty.Path) int {
|
||||||
|
|
|
@ -274,28 +274,3 @@ func marshalPlanModules(
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// marshalSensitiveValues returns a map of sensitive attributes, with the value
|
|
||||||
// set to true. It returns nil if the value is nil or if there are no sensitive
|
|
||||||
// vals.
|
|
||||||
func marshalSensitiveValues(value cty.Value) map[string]bool {
|
|
||||||
if value.RawEquals(cty.NilVal) || value.IsNull() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ret := make(map[string]bool)
|
|
||||||
|
|
||||||
it := value.ElementIterator()
|
|
||||||
for it.Next() {
|
|
||||||
k, v := it.Element()
|
|
||||||
s := jsonstate.SensitiveAsBool(v)
|
|
||||||
if !s.RawEquals(cty.False) {
|
|
||||||
ret[k.AsString()] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(ret) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
|
@ -311,13 +311,9 @@ func (c *LoginCommand) outputDefaultTFELoginSuccess(dispHostname string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *LoginCommand) outputDefaultTFCLoginSuccess() {
|
func (c *LoginCommand) outputDefaultTFCLoginSuccess() {
|
||||||
c.Ui.Output(
|
c.Ui.Output(c.Colorize().Color(strings.TrimSpace(`
|
||||||
fmt.Sprintf(
|
|
||||||
c.Colorize().Color(strings.TrimSpace(`
|
|
||||||
[green][bold]Success![reset] [bold]Logged in to Terraform Cloud[reset]
|
[green][bold]Success![reset] [bold]Logged in to Terraform Cloud[reset]
|
||||||
`)),
|
` + "\n")))
|
||||||
) + "\n",
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *LoginCommand) logMOTDError(err error) {
|
func (c *LoginCommand) logMOTDError(err error) {
|
||||||
|
|
|
@ -15,8 +15,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
plugin "github.com/hashicorp/go-plugin"
|
plugin "github.com/hashicorp/go-plugin"
|
||||||
"github.com/hashicorp/hcl/v2"
|
|
||||||
"github.com/hashicorp/hcl/v2/hclsyntax"
|
|
||||||
"github.com/hashicorp/terraform-svchost/disco"
|
"github.com/hashicorp/terraform-svchost/disco"
|
||||||
"github.com/hashicorp/terraform/internal/addrs"
|
"github.com/hashicorp/terraform/internal/addrs"
|
||||||
"github.com/hashicorp/terraform/internal/backend"
|
"github.com/hashicorp/terraform/internal/backend"
|
||||||
|
@ -554,43 +552,6 @@ func (m *Meta) extendedFlagSet(n string) *flag.FlagSet {
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseTargetFlags must be called for any commands supporting -target
|
|
||||||
// arguments. This method attempts to parse each -target flag into an
|
|
||||||
// addrs.Target, storing in the Meta.targets slice.
|
|
||||||
//
|
|
||||||
// If any flags cannot be parsed, we rewrap the first error diagnostic with a
|
|
||||||
// custom title to clarify the source of the error. The normal approach of
|
|
||||||
// directly returning the diags from HCL or the addrs package results in
|
|
||||||
// confusing incorrect "source" results when presented.
|
|
||||||
func (m *Meta) parseTargetFlags() tfdiags.Diagnostics {
|
|
||||||
var diags tfdiags.Diagnostics
|
|
||||||
m.targets = nil
|
|
||||||
for _, tf := range m.targetFlags {
|
|
||||||
traversal, syntaxDiags := hclsyntax.ParseTraversalAbs([]byte(tf), "", hcl.Pos{Line: 1, Column: 1})
|
|
||||||
if syntaxDiags.HasErrors() {
|
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
|
||||||
tfdiags.Error,
|
|
||||||
fmt.Sprintf("Invalid target %q", tf),
|
|
||||||
syntaxDiags[0].Detail,
|
|
||||||
))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
target, targetDiags := addrs.ParseTarget(traversal)
|
|
||||||
if targetDiags.HasErrors() {
|
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
|
||||||
tfdiags.Error,
|
|
||||||
fmt.Sprintf("Invalid target %q", tf),
|
|
||||||
targetDiags[0].Description().Detail,
|
|
||||||
))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
m.targets = append(m.targets, target.Subject)
|
|
||||||
}
|
|
||||||
return diags
|
|
||||||
}
|
|
||||||
|
|
||||||
// process will process any -no-color entries out of the arguments. This
|
// process will process any -no-color entries out of the arguments. This
|
||||||
// will potentially modify the args in-place. It will return the resulting
|
// will potentially modify the args in-place. It will return the resulting
|
||||||
// slice, and update the Meta and Ui.
|
// slice, and update the Meta and Ui.
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/errwrap"
|
|
||||||
"github.com/hashicorp/hcl/v2"
|
"github.com/hashicorp/hcl/v2"
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
"github.com/hashicorp/terraform/internal/backend"
|
"github.com/hashicorp/terraform/internal/backend"
|
||||||
|
@ -244,7 +243,7 @@ func (m *Meta) BackendForPlan(settings plans.Backend) (backend.Enhanced, tfdiags
|
||||||
schema := b.ConfigSchema()
|
schema := b.ConfigSchema()
|
||||||
configVal, err := settings.Config.Decode(schema.ImpliedType())
|
configVal, err := settings.Config.Decode(schema.ImpliedType())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
diags = diags.Append(errwrap.Wrapf("saved backend configuration is invalid: {{err}}", err))
|
diags = diags.Append(fmt.Errorf("saved backend configuration is invalid: %w", err))
|
||||||
return nil, diags
|
return nil, diags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,7 @@ func (c *RefreshCommand) Run(rawArgs []string) int {
|
||||||
|
|
||||||
// Instantiate the view, even if there are flag errors, so that we render
|
// Instantiate the view, even if there are flag errors, so that we render
|
||||||
// diagnostics according to the desired view
|
// diagnostics according to the desired view
|
||||||
var view views.Refresh
|
view := views.NewRefresh(args.ViewType, c.View)
|
||||||
view = views.NewRefresh(args.ViewType, c.View)
|
|
||||||
|
|
||||||
if diags.HasErrors() {
|
if diags.HasErrors() {
|
||||||
view.Diagnostics(diags)
|
view.Diagnostics(diags)
|
||||||
|
|
|
@ -121,7 +121,7 @@ func (c *StateMeta) lookupResourceInstanceAddr(state *states.State, allowMissing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if found == false && !allowMissing {
|
if !found && !allowMissing {
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Unknown module",
|
"Unknown module",
|
||||||
|
|
|
@ -9,17 +9,11 @@ import (
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/mitchellh/cli"
|
"github.com/mitchellh/cli"
|
||||||
"github.com/mitchellh/colorstring"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/internal/addrs"
|
"github.com/hashicorp/terraform/internal/addrs"
|
||||||
"github.com/hashicorp/terraform/internal/states"
|
"github.com/hashicorp/terraform/internal/states"
|
||||||
)
|
)
|
||||||
|
|
||||||
var disabledColorize = &colorstring.Colorize{
|
|
||||||
Colors: colorstring.DefaultColors,
|
|
||||||
Disable: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStateMv(t *testing.T) {
|
func TestStateMv(t *testing.T) {
|
||||||
state := states.BuildState(func(s *states.SyncState) {
|
state := states.BuildState(func(s *states.SyncState) {
|
||||||
s.SetResourceInstanceCurrent(
|
s.SetResourceInstanceCurrent(
|
||||||
|
|
|
@ -256,7 +256,7 @@ func (v *addHuman) writeConfigNestedBlock(buf *strings.Builder, name string, sch
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *addHuman) writeConfigNestedTypeAttribute(buf *strings.Builder, name string, schema *configschema.Attribute, indent int) error {
|
func (v *addHuman) writeConfigNestedTypeAttribute(buf *strings.Builder, name string, schema *configschema.Attribute, indent int) error {
|
||||||
if schema.Required == false && v.optional == false {
|
if !schema.Required && !v.optional {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,7 +521,6 @@ func writeAttrTypeConstraint(buf *strings.Builder, schema *configschema.Attribut
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(fmt.Sprintf("%s\n", schema.Type.FriendlyName()))
|
buf.WriteString(fmt.Sprintf("%s\n", schema.Type.FriendlyName()))
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeBlockTypeConstraint(buf *strings.Builder, schema *configschema.NestedBlock) {
|
func writeBlockTypeConstraint(buf *strings.Builder, schema *configschema.NestedBlock) {
|
||||||
|
@ -530,7 +529,6 @@ func writeBlockTypeConstraint(buf *strings.Builder, schema *configschema.NestedB
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(" # OPTIONAL block\n")
|
buf.WriteString(" # OPTIONAL block\n")
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// copied from command/format/diff
|
// copied from command/format/diff
|
||||||
|
|
|
@ -74,6 +74,9 @@ func TestOutputsFromMap(t *testing.T) {
|
||||||
func TestOutputsFromChanges(t *testing.T) {
|
func TestOutputsFromChanges(t *testing.T) {
|
||||||
root := addrs.RootModuleInstance
|
root := addrs.RootModuleInstance
|
||||||
num, err := plans.NewDynamicValue(cty.NumberIntVal(1234), cty.Number)
|
num, err := plans.NewDynamicValue(cty.NumberIntVal(1234), cty.Number)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error creating dynamic value: %v", err)
|
||||||
|
}
|
||||||
str, err := plans.NewDynamicValue(cty.StringVal("1234"), cty.String)
|
str, err := plans.NewDynamicValue(cty.StringVal("1234"), cty.String)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error creating dynamic value: %v", err)
|
t.Fatalf("unexpected error creating dynamic value: %v", err)
|
||||||
|
|
|
@ -105,10 +105,6 @@ func (v *OutputHuman) Diagnostics(diags tfdiags.Diagnostics) {
|
||||||
// type of an output value is not important.
|
// type of an output value is not important.
|
||||||
type OutputRaw struct {
|
type OutputRaw struct {
|
||||||
view *View
|
view *View
|
||||||
|
|
||||||
// Unit tests may set rawPrint to capture the output from the Output
|
|
||||||
// method, which would normally go to stdout directly.
|
|
||||||
rawPrint func(string)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Output = (*OutputRaw)(nil)
|
var _ Output = (*OutputRaw)(nil)
|
||||||
|
|
|
@ -19,7 +19,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/apparentlymart/go-shquot/shquot"
|
"github.com/apparentlymart/go-shquot/shquot"
|
||||||
"github.com/hashicorp/errwrap"
|
|
||||||
"github.com/hashicorp/terraform/internal/communicator/remote"
|
"github.com/hashicorp/terraform/internal/communicator/remote"
|
||||||
"github.com/hashicorp/terraform/internal/provisioners"
|
"github.com/hashicorp/terraform/internal/provisioners"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
|
@ -192,7 +191,7 @@ func (c *Communicator) Connect(o provisioners.UIOutput) (err error) {
|
||||||
log.Printf("[DEBUG] Connection established. Handshaking for user %v", c.connInfo.User)
|
log.Printf("[DEBUG] Connection established. Handshaking for user %v", c.connInfo.User)
|
||||||
sshConn, sshChan, req, err := ssh.NewClientConn(c.conn, hostAndPort, c.config.config)
|
sshConn, sshChan, req, err := ssh.NewClientConn(c.conn, hostAndPort, c.config.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errwrap.Wrapf(fmt.Sprintf("SSH authentication failed (%s@%s): {{err}}", c.connInfo.User, hostAndPort), err)
|
err = fmt.Errorf("SSH authentication failed (%s@%s): %w", c.connInfo.User, hostAndPort, err)
|
||||||
|
|
||||||
// While in theory this should be a fatal error, some hosts may start
|
// While in theory this should be a fatal error, some hosts may start
|
||||||
// the ssh service before it is properly configured, or before user
|
// the ssh service before it is properly configured, or before user
|
||||||
|
|
|
@ -86,6 +86,7 @@ func decodeRequiredProvidersBlock(block *hcl.Block) (*RequiredProviders, hcl.Dia
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOOP:
|
||||||
for _, kv := range kvs {
|
for _, kv := range kvs {
|
||||||
key, keyDiags := kv.Key.Value(nil)
|
key, keyDiags := kv.Key.Value(nil)
|
||||||
if keyDiags.HasErrors() {
|
if keyDiags.HasErrors() {
|
||||||
|
@ -213,7 +214,7 @@ func decodeRequiredProvidersBlock(block *hcl.Block) (*RequiredProviders, hcl.Dia
|
||||||
Detail: `required_providers objects can only contain "version", "source" and "configuration_aliases" attributes. To configure a provider, use a "provider" block.`,
|
Detail: `required_providers objects can only contain "version", "source" and "configuration_aliases" attributes. To configure a provider, use a "provider" block.`,
|
||||||
Subject: kv.Key.Range().Ptr(),
|
Subject: kv.Key.Range().Ptr(),
|
||||||
})
|
})
|
||||||
break
|
break LOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,9 @@ func marshalVertexID(v Vertex) string {
|
||||||
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
|
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
|
||||||
return strconv.Itoa(int(val.Pointer()))
|
return strconv.Itoa(int(val.Pointer()))
|
||||||
case reflect.Interface:
|
case reflect.Interface:
|
||||||
return strconv.Itoa(int(val.InterfaceData()[1]))
|
// A vertex shouldn't contain another layer of interface, but handle
|
||||||
|
// this just in case.
|
||||||
|
return fmt.Sprintf("%#v", val.Interface())
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := v.(Hashable); ok {
|
if v, ok := v.(Hashable); ok {
|
||||||
|
|
|
@ -306,6 +306,7 @@ func (c *Context) prePlanFindAndApplyMoves(config *configs.Config, prevRunState
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//lint:ignore SA9003 TODO
|
||||||
if !matchesTarget {
|
if !matchesTarget {
|
||||||
// TODO: Return an error stating that a targeted plan is
|
// TODO: Return an error stating that a targeted plan is
|
||||||
// only valid if it includes this address that was moved.
|
// only valid if it includes this address that was moved.
|
||||||
|
|
|
@ -6,20 +6,6 @@ import (
|
||||||
"github.com/hashicorp/terraform/internal/dag"
|
"github.com/hashicorp/terraform/internal/dag"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testGraphContains is an assertion helper that tests that a node is
|
|
||||||
// contained in the graph.
|
|
||||||
func testGraphContains(t *testing.T, g *Graph, name string) {
|
|
||||||
for _, v := range g.Vertices() {
|
|
||||||
if dag.VertexName(v) == name {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Fatalf(
|
|
||||||
"Expected %q in:\n\n%s",
|
|
||||||
name, g.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
// testGraphnotContains is an assertion helper that tests that a node is
|
// testGraphnotContains is an assertion helper that tests that a node is
|
||||||
// NOT contained in the graph.
|
// NOT contained in the graph.
|
||||||
func testGraphNotContains(t *testing.T, g *Graph, name string) {
|
func testGraphNotContains(t *testing.T, g *Graph, name string) {
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package terraform
|
|
||||||
|
|
||||||
const errPluginInit = `
|
|
||||||
Plugins are external binaries that Terraform uses to access and manipulate
|
|
||||||
resources. The configuration provided requires plugins which can't be located,
|
|
||||||
don't satisfy the version constraints, or are otherwise incompatible.
|
|
||||||
|
|
||||||
Terraform automatically discovers provider requirements from your
|
|
||||||
configuration, including providers used in child modules. To see the
|
|
||||||
requirements and constraints, run "terraform providers".
|
|
||||||
|
|
||||||
%s
|
|
||||||
|
|
||||||
Plugin reinitialization required. Please address the above error(s) and run
|
|
||||||
"terraform init".
|
|
||||||
`
|
|
|
@ -46,33 +46,6 @@ func mockProviderWithResourceTypeSchema(name string, schema *configschema.Block)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mockProviderWithProviderSchema is a test helper to create a mock provider
|
|
||||||
// from an existing ProviderSchema.
|
|
||||||
func mockProviderWithProviderSchema(providerSchema ProviderSchema) *MockProvider {
|
|
||||||
p := &MockProvider{
|
|
||||||
GetProviderSchemaResponse: &providers.GetProviderSchemaResponse{
|
|
||||||
Provider: providers.Schema{
|
|
||||||
Block: providerSchema.Provider,
|
|
||||||
},
|
|
||||||
ResourceTypes: map[string]providers.Schema{},
|
|
||||||
DataSources: map[string]providers.Schema{},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, schema := range providerSchema.ResourceTypes {
|
|
||||||
p.GetProviderSchemaResponse.ResourceTypes[name] = providers.Schema{
|
|
||||||
Block: schema,
|
|
||||||
Version: int64(providerSchema.ResourceTypeSchemaVersions[name]),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, schema := range providerSchema.DataSources {
|
|
||||||
p.GetProviderSchemaResponse.DataSources[name] = providers.Schema{Block: schema}
|
|
||||||
}
|
|
||||||
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
// getProviderSchemaResponseFromProviderSchema is a test helper to convert a
|
// getProviderSchemaResponseFromProviderSchema is a test helper to convert a
|
||||||
// ProviderSchema to a GetProviderSchemaResponse for use when building a mock provider.
|
// ProviderSchema to a GetProviderSchemaResponse for use when building a mock provider.
|
||||||
func getProviderSchemaResponseFromProviderSchema(providerSchema *ProviderSchema) *providers.GetProviderSchemaResponse {
|
func getProviderSchemaResponseFromProviderSchema(providerSchema *ProviderSchema) *providers.GetProviderSchemaResponse {
|
||||||
|
|
|
@ -80,7 +80,7 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
protocGenGoGrpcExec, err := buildProtocGenGoGrpc(workDir)
|
_, err = buildProtocGenGoGrpc(workDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
protocGenGoGrpcExec, err = filepath.Abs(protocGenGoExec)
|
protocGenGoGrpcExec, err := filepath.Abs(protocGenGoExec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue