Skip to content

Commit 4de1e4e

Browse files
Christian DoucetteChristian Doucette
authored andcommitted
Clean up and makes things that can be private
1 parent 617e2d2 commit 4de1e4e

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

internal/client/client.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func getTokenFromCreds(services *disco.Disco, hostname svchost.Hostname) string
7777
// TFE Client along with other necessary information for the provider to run it
7878
type ProviderClient struct {
7979
TfeClient *tfe.Client
80-
tokenSource TokenSource
80+
tokenSource tokenSource
8181
}
8282

8383
// Using presence of TFC_AGENT_VERSION to determine if this provider is running on HCP Terraform / enterprise
@@ -87,7 +87,7 @@ func providerRunningInCloud() bool {
8787
}
8888

8989
func (pc *ProviderClient) SendAuthenticationWarning() bool {
90-
return pc.tokenSource == CredentialFiles && providerRunningInCloud()
90+
return pc.tokenSource == credentialFiles && providerRunningInCloud()
9191

9292
}
9393

@@ -100,7 +100,6 @@ func (pc *ProviderClient) SendAuthenticationWarning() bool {
100100
// parameters
101101
func GetClient(tfeHost, token string, insecure bool) (*ProviderClient, error) {
102102
config, err := configure(tfeHost, token, insecure)
103-
104103
if err != nil {
105104
return nil, err
106105
}
@@ -111,7 +110,7 @@ func GetClient(tfeHost, token string, insecure bool) (*ProviderClient, error) {
111110
// Try to retrieve the client from cache
112111
cached := clientCache.GetByConfig(config)
113112
if cached != nil {
114-
return &ProviderClient{cached, config.TokenSource}, nil
113+
return &ProviderClient{cached, config.tokenSource}, nil
115114
}
116115

117116
// Discover the Terraform Enterprise address.
@@ -175,7 +174,7 @@ func GetClient(tfeHost, token string, insecure bool) (*ProviderClient, error) {
175174
client.RetryServerErrors(true)
176175
clientCache.Set(client, config)
177176

178-
return &ProviderClient{client, config.TokenSource}, nil
177+
return &ProviderClient{client, config.tokenSource}, nil
179178
}
180179

181180
// CheckConstraints checks service version constrains against our own

internal/client/config.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ type ConfigHost struct {
4141
Services map[string]interface{} `hcl:"services"`
4242
}
4343

44-
type TokenSource int
44+
type tokenSource int
4545

4646
const (
47-
ProviderArgument TokenSource = iota
48-
EnvironmentVariable
49-
CredentialFiles
47+
providerArgument tokenSource = iota
48+
environmentVariable
49+
credentialFiles
5050
)
5151

5252
// ClientConfiguration is the refined information needed to configureClient a tfe.Client
@@ -55,7 +55,7 @@ type ClientConfiguration struct {
5555
HTTPClient *http.Client
5656
TFEHost svchost.Hostname
5757
Token string
58-
TokenSource TokenSource
58+
tokenSource tokenSource
5959
Insecure bool
6060
}
6161

@@ -242,14 +242,14 @@ func configure(tfeHost, token string, insecure bool) (*ClientConfiguration, erro
242242
// If a token wasn't set in the provider configuration block, try and fetch it
243243
// from the environment or from Terraform's CLI configuration or configured credential helper.
244244

245-
tokenSource := ProviderArgument
245+
tokenSource := providerArgument
246246
if token == "" {
247247
if os.Getenv("TFE_TOKEN") != "" {
248248
token = getTokenFromEnv()
249-
tokenSource = EnvironmentVariable
249+
tokenSource = environmentVariable
250250
} else {
251251
token = getTokenFromCreds(services, hostname)
252-
tokenSource = CredentialFiles
252+
tokenSource = credentialFiles
253253
}
254254
}
255255

@@ -263,7 +263,7 @@ func configure(tfeHost, token string, insecure bool) (*ClientConfiguration, erro
263263
HTTPClient: httpClient,
264264
TFEHost: hostname,
265265
Token: token,
266-
TokenSource: tokenSource,
266+
tokenSource: tokenSource,
267267
Insecure: insecure,
268268
}, nil
269269
}

internal/provider/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func configure() schema.ConfigureContextFunc {
164164
diagnosticWarnings = diag.Diagnostics{
165165
diag.Diagnostic{
166166
Severity: diag.Warning,
167-
Summary: "Authentication with configuration file is invalid for TFE Provider running on HCP Terraform or Terraform Enterprise",
167+
Summary: "Authentication with configuration files is invalid for TFE Provider running on HCP Terraform or Terraform Enterprise",
168168
Detail: "Use a TFE_TOKEN variable in the workspace or the token argument for the provider. This authentication method will be deprecated in a future version.",
169169
},
170170
}

0 commit comments

Comments
 (0)