mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-25 08:21:07 -06:00
Remove unnecessary type assertion checks
The type assertion checks on the credentials source are unnecessary, and the alternative code path they allow would panic.
This commit is contained in:
parent
325f8a84f8
commit
7ff58780d4
@ -105,21 +105,12 @@ func (c *LoginCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
creds := c.Services.CredentialsSource()
|
||||
|
||||
// In normal use (i.e. without test mocks/fakes) creds will be an instance
|
||||
// of the command/cliconfig.CredentialsSource type, which has some extra
|
||||
// methods we can use to give the user better feedback about what we're
|
||||
// going to do. credsCtx will be nil if it's any other implementation,
|
||||
// though.
|
||||
var credsCtx *loginCredentialsContext
|
||||
if c, ok := creds.(*cliconfig.CredentialsSource); ok {
|
||||
filename, _ := c.CredentialsFilePath()
|
||||
credsCtx = &loginCredentialsContext{
|
||||
Location: c.HostCredentialsLocation(hostname),
|
||||
LocalFilename: filename, // empty in the very unlikely event that we can't select a config directory for this user
|
||||
HelperType: c.CredentialsHelperType(),
|
||||
}
|
||||
creds := c.Services.CredentialsSource().(*cliconfig.CredentialsSource)
|
||||
filename, _ := creds.CredentialsFilePath()
|
||||
credsCtx := &loginCredentialsContext{
|
||||
Location: creds.HostCredentialsLocation(hostname),
|
||||
LocalFilename: filename, // empty in the very unlikely event that we can't select a config directory for this user
|
||||
HelperType: creds.CredentialsHelperType(),
|
||||
}
|
||||
|
||||
clientConfig, err := host.ServiceOAuthClient("login.v1")
|
||||
|
@ -61,21 +61,12 @@ func (c *LogoutCommand) Run(args []string) int {
|
||||
// working as expected. (Perhaps the normalization is part of the cause.)
|
||||
dispHostname := hostname.ForDisplay()
|
||||
|
||||
creds := c.Services.CredentialsSource()
|
||||
|
||||
// In normal use (i.e. without test mocks/fakes) creds will be an instance
|
||||
// of the command/cliconfig.CredentialsSource type, which has some extra
|
||||
// methods we can use to give the user better feedback about what we're
|
||||
// going to do. credsCtx will be nil if it's any other implementation,
|
||||
// though.
|
||||
var credsCtx *loginCredentialsContext
|
||||
if c, ok := creds.(*cliconfig.CredentialsSource); ok {
|
||||
filename, _ := c.CredentialsFilePath()
|
||||
credsCtx = &loginCredentialsContext{
|
||||
Location: c.HostCredentialsLocation(hostname),
|
||||
LocalFilename: filename, // empty in the very unlikely event that we can't select a config directory for this user
|
||||
HelperType: c.CredentialsHelperType(),
|
||||
}
|
||||
creds := c.Services.CredentialsSource().(*cliconfig.CredentialsSource)
|
||||
filename, _ := creds.CredentialsFilePath()
|
||||
credsCtx := &loginCredentialsContext{
|
||||
Location: creds.HostCredentialsLocation(hostname),
|
||||
LocalFilename: filename, // empty in the very unlikely event that we can't select a config directory for this user
|
||||
HelperType: creds.CredentialsHelperType(),
|
||||
}
|
||||
|
||||
if credsCtx.Location == cliconfig.CredentialsInOtherFile {
|
||||
|
Loading…
Reference in New Issue
Block a user