Skip to content

Commit dcf2066

Browse files
authored
Warn the user if an env token is set (#684)
1 parent 035d4fc commit dcf2066

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

internal/config/config.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import (
2525
"github.com/spf13/afero"
2626
)
2727

28-
var legacyTokenWarningOnce sync.Once
28+
var (
29+
legacyTokenWarningOnce sync.Once
30+
envTokenWarningOnce sync.Once
31+
)
2932

3033
const (
3134
DefaultGraphQLEndpoint = "https://graphql.buildkite.com/v1"
@@ -126,6 +129,9 @@ func (conf *Config) APIToken() string {
126129
// Precedence: environment variable > keyring > config file (legacy, read-only with warning)
127130
func (conf *Config) APITokenForOrg(org string) string {
128131
if token := os.Getenv("BUILDKITE_API_TOKEN"); token != "" {
132+
envTokenWarningOnce.Do(func() {
133+
fmt.Fprintln(os.Stderr, "Warning: using BUILDKITE_API_TOKEN environment variable for authentication.")
134+
})
129135
return token
130136
}
131137

0 commit comments

Comments
 (0)