mirror of https://github.com/hashicorp/terraform
stacks: load credentials from config file on startup (#35952)
* stacks: load credentials from config file on startup * delete unneeded filepull/35951/head^2
parent
f0b00c45f7
commit
7c4aeac5f3
@ -1,27 +1,25 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package main
|
||||
package cliconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/hashicorp/terraform/internal/command/cliconfig"
|
||||
)
|
||||
|
||||
// globalPluginDirs returns directories that should be searched for
|
||||
// GlobalPluginDirs returns directories that should be searched for
|
||||
// globally-installed plugins (not specific to the current configuration).
|
||||
//
|
||||
// Earlier entries in this slice get priority over later when multiple copies
|
||||
// of the same plugin version are found, but newer versions always override
|
||||
// older versions where both satisfy the provider version constraints.
|
||||
func globalPluginDirs() []string {
|
||||
func GlobalPluginDirs() []string {
|
||||
var ret []string
|
||||
// Look in ~/.terraform.d/plugins/ , or its equivalent on non-UNIX
|
||||
dir, err := cliconfig.ConfigDir()
|
||||
dir, err := ConfigDir()
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Error finding global config directory: %s", err)
|
||||
} else {
|
||||
@ -1,40 +0,0 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package rpcapi
|
||||
|
||||
import (
|
||||
svchost "github.com/hashicorp/terraform-svchost"
|
||||
"github.com/hashicorp/terraform-svchost/auth"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
var _ auth.CredentialsSource = &credentialsSource{}
|
||||
|
||||
type credentialsSource struct {
|
||||
configured map[svchost.Hostname]cty.Value
|
||||
}
|
||||
|
||||
func newCredentialsSource() *credentialsSource {
|
||||
return &credentialsSource{
|
||||
configured: map[svchost.Hostname]cty.Value{},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *credentialsSource) ForHost(host svchost.Hostname) (auth.HostCredentials, error) {
|
||||
v, ok := c.configured[host]
|
||||
if ok {
|
||||
return auth.HostCredentialsFromObject(v), nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *credentialsSource) StoreForHost(host svchost.Hostname, credentials auth.HostCredentialsWritable) error {
|
||||
c.configured[host] = credentials.ToStore()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *credentialsSource) ForgetForHost(host svchost.Hostname) error {
|
||||
delete(c.configured, host)
|
||||
return nil
|
||||
}
|
||||
Loading…
Reference in new issue