Fix problems caught by staticcheck v0.3.0

This will allow us to upgrade to this version in a later commit without
causing the our build checks to fail.
This commit is contained in:
Martin Atkins 2022-04-01 15:40:09 -07:00
parent 58b563e440
commit 49d7c879ac
4 changed files with 16 additions and 21 deletions

View File

@ -251,6 +251,6 @@ findTfVersion:
} }
if !hasVersion { if !hasVersion {
t.Skip(fmt.Sprintf("Skipping test because TFC/E does not have current Terraform version to test with (%s)", version)) t.Skipf("Skipping test because TFC/E does not have current Terraform version to test with (%s)", version)
} }
} }

View File

@ -78,18 +78,14 @@ func (c *LogoutCommand) Run(args []string) int {
return 1 return 1
} }
// credsCtx might not be set if we're using a mock credentials source switch credsCtx.Location {
// in a test, but it should always be set in normal use. case cliconfig.CredentialsNotAvailable:
if credsCtx != nil { c.Ui.Output(fmt.Sprintf("No credentials for %s are stored.\n", dispHostname))
switch credsCtx.Location { return 0
case cliconfig.CredentialsNotAvailable: case cliconfig.CredentialsViaHelper:
c.Ui.Output(fmt.Sprintf("No credentials for %s are stored.\n", dispHostname)) c.Ui.Output(fmt.Sprintf("Removing the stored credentials for %s from the configured\n%q credentials helper.\n", dispHostname, credsCtx.HelperType))
return 0 case cliconfig.CredentialsInPrimaryFile:
case cliconfig.CredentialsViaHelper: c.Ui.Output(fmt.Sprintf("Removing the stored credentials for %s from the following file:\n %s\n", dispHostname, credsCtx.LocalFilename))
c.Ui.Output(fmt.Sprintf("Removing the stored credentials for %s from the configured\n%q credentials helper.\n", dispHostname, credsCtx.HelperType))
case cliconfig.CredentialsInPrimaryFile:
c.Ui.Output(fmt.Sprintf("Removing the stored credentials for %s from the following file:\n %s\n", dispHostname, credsCtx.LocalFilename))
}
} }
err = creds.ForgetForHost(hostname) err = creds.ForgetForHost(hostname)

View File

@ -1,18 +1,16 @@
package marks package marks
import ( import (
"strings"
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
) )
// valueMarks allow creating strictly typed values for use as cty.Value marks. // valueMarks allow creating strictly typed values for use as cty.Value marks.
// The variable name for new values should be the title-cased format of the // Each distinct mark value must be a constant in this package whose value
// value to better match the GoString output for debugging. // is a valueMark whose underlying string matches the name of the variable.
type valueMark string type valueMark string
func (m valueMark) GoString() string { func (m valueMark) GoString() string {
return "marks." + strings.Title(string(m)) return "marks." + string(m)
} }
// Has returns true if and only if the cty.Value has the given mark. // Has returns true if and only if the cty.Value has the given mark.
@ -36,9 +34,9 @@ func Contains(val cty.Value, mark valueMark) bool {
// Sensitive indicates that this value is marked as sensitive in the context of // Sensitive indicates that this value is marked as sensitive in the context of
// Terraform. // Terraform.
var Sensitive = valueMark("sensitive") const Sensitive = valueMark("Sensitive")
// TypeType is used to indicate that the value contains a representation of // TypeType is used to indicate that the value contains a representation of
// another value's type. This is part of the implementation of the console-only // another value's type. This is part of the implementation of the console-only
// `type` function. // `type` function.
var TypeType = valueMark("typeType") const TypeType = valueMark("TypeType")

View File

@ -792,7 +792,8 @@ func (d *evaluationStateData) GetResource(addr addrs.Resource, rng tfdiags.Sourc
instances[key] = val instances[key] = val
} }
ret := cty.DynamicVal // ret should be populated with a valid value in all cases below
var ret cty.Value
switch { switch {
case config.Count != nil: case config.Count != nil: