-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stacks): add CLI config in RPC API handshake (#35146)
Adds support for including fields typically found in the Terraform CLI configuration in the RPC API handshake. This allows us to include global configuration arguments that impact the RPC API session without requiring instrumentation for each RPC service. The new Config struct currently supports only service discovery credentials, but it can be expanded in the future.
- Loading branch information
Showing
7 changed files
with
2,398 additions
and
2,175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.