Skip to content

Commit f22826a

Browse files
committed
Rename bearer and method fields for consistency
1 parent 9043812 commit f22826a

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

cmd/consul-dataplane/main.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ var (
3636
namespace string
3737
partition string
3838

39-
credentialType string
40-
token string
41-
loginMethod string
42-
loginNamespace string
43-
loginPartition string
44-
loginDatacenter string
45-
loginBearer string
46-
loginBearerPath string
47-
loginMeta map[string]string
39+
credentialType string
40+
token string
41+
loginAuthMethod string
42+
loginNamespace string
43+
loginPartition string
44+
loginDatacenter string
45+
loginBearerToken string
46+
loginBearerTokenPath string
47+
loginMeta map[string]string
4848

4949
useCentralTelemetryConfig bool
5050

@@ -84,12 +84,12 @@ func init() {
8484

8585
flag.StringVar(&credentialType, "credential-type", "", "The type of credentials that will be used to authenticate with Consul servers (static or login).")
8686
flag.StringVar(&token, "static-token", "", "The ACL token used to authenticate requests to Consul servers (when -credential-type is set to static).")
87-
flag.StringVar(&loginMethod, "login-method", "", "The auth method that will be used to log in.")
87+
flag.StringVar(&loginAuthMethod, "login-auth-method", "", "The auth method that will be used to log in.")
8888
flag.StringVar(&loginNamespace, "login-namespace", "", "The Consul Enterprise namespace containing the auth method.")
8989
flag.StringVar(&loginPartition, "login-partition", "", "The Consul Enterprise partition containing the auth method.")
9090
flag.StringVar(&loginDatacenter, "login-datacenter", "", "The datacenter containing the auth method.")
91-
flag.StringVar(&loginBearer, "login-bearer", "", "The bearer token that will be presented to the auth method.")
92-
flag.StringVar(&loginBearerPath, "login-bearer-path", "", "The path to a file containing the bearer token that will be presented to the auth method.")
91+
flag.StringVar(&loginBearerToken, "login-bearer-token", "", "The bearer token that will be presented to the auth method.")
92+
flag.StringVar(&loginBearerTokenPath, "login-bearer-token-path", "", "The path to a file containing the bearer token that will be presented to the auth method.")
9393
flag.Var((*FlagMapValue)(&loginMeta), "login-meta", "An arbitrary set of key/value pairs that will be attached to the ACL token (formatted as key=value, may be given multiple times).")
9494

9595
flag.BoolVar(&useCentralTelemetryConfig, "telemetry-use-central-config", true, "Controls whether the proxy will apply the central telemetry configuration.")
@@ -140,13 +140,13 @@ func main() {
140140
Token: token,
141141
},
142142
Login: consuldp.LoginCredentialsConfig{
143-
Method: loginMethod,
144-
Namespace: loginNamespace,
145-
Partition: loginPartition,
146-
Datacenter: loginDatacenter,
147-
Bearer: loginBearer,
148-
BearerPath: loginBearerPath,
149-
Meta: loginMeta,
143+
AuthMethod: loginAuthMethod,
144+
Namespace: loginNamespace,
145+
Partition: loginPartition,
146+
Datacenter: loginDatacenter,
147+
BearerToken: loginBearerToken,
148+
BearerTokenPath: loginBearerTokenPath,
149+
Meta: loginMeta,
150150
},
151151
},
152152
ServerWatchDisabled: serverWatchDisabled,

pkg/consuldp/config.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,18 @@ type StaticCredentialsConfig struct {
132132

133133
// LoginCredentialsConfig contains credentials for logging in with an auth method.
134134
type LoginCredentialsConfig struct {
135-
// Method is the name of the Consul auth method.
136-
Method string
135+
// AuthMethod is the name of the Consul auth method.
136+
AuthMethod string
137137
// Namespace is the namespace containing the auth method.
138138
Namespace string
139139
// Partition is the partition containing the auth method.
140140
Partition string
141141
// Datacenter is the datacenter containing the auth method.
142142
Datacenter string
143-
// Bearer is the bearer token presented to the auth method.
144-
Bearer string
145-
// BearerPath is the path to a file containing a bearer token.
146-
BearerPath string
143+
// BearerToken is the bearer token presented to the auth method.
144+
BearerToken string
145+
// BearerTokenPath is the path to a file containing a bearer token.
146+
BearerTokenPath string
147147
// Meta is the arbitrary set of key-value pairs to attach to the
148148
// token. These are included in the Description field of the token.
149149
Meta map[string]string
@@ -165,16 +165,16 @@ func (cc *CredentialsConfig) ToDiscoveryCredentials() (discovery.Credentials, er
165165
case CredentialsTypeLogin:
166166
creds.Type = discovery.CredentialsTypeLogin
167167
creds.Login = discovery.LoginCredential{
168-
AuthMethod: cc.Login.Method,
168+
AuthMethod: cc.Login.AuthMethod,
169169
Namespace: cc.Login.Namespace,
170170
Partition: cc.Login.Partition,
171171
Datacenter: cc.Login.Datacenter,
172-
BearerToken: cc.Login.Bearer,
172+
BearerToken: cc.Login.BearerToken,
173173
Meta: cc.Login.Meta,
174174
}
175175

176-
if creds.Login.BearerToken == "" && cc.Login.BearerPath != "" {
177-
bearer, err := os.ReadFile(cc.Login.BearerPath)
176+
if creds.Login.BearerToken == "" && cc.Login.BearerTokenPath != "" {
177+
bearer, err := os.ReadFile(cc.Login.BearerTokenPath)
178178
if err != nil {
179179
return creds, fmt.Errorf("failed to read bearer token from file: %w", err)
180180
}

pkg/consuldp/config_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ func TestConfig_Credentials(t *testing.T) {
105105
in: CredentialsConfig{
106106
Type: CredentialsTypeLogin,
107107
Login: LoginCredentialsConfig{
108-
Method: "jwt",
109-
Namespace: "namespace-1",
110-
Partition: "partition-a",
111-
Datacenter: "primary-dc",
112-
Bearer: "bearer-token",
113-
Meta: map[string]string{"foo": "bar"},
108+
AuthMethod: "jwt",
109+
Namespace: "namespace-1",
110+
Partition: "partition-a",
111+
Datacenter: "primary-dc",
112+
BearerToken: "bearer-token",
113+
Meta: map[string]string{"foo": "bar"},
114114
},
115115
},
116116
out: discovery.Credentials{
@@ -129,12 +129,12 @@ func TestConfig_Credentials(t *testing.T) {
129129
in: CredentialsConfig{
130130
Type: CredentialsTypeLogin,
131131
Login: LoginCredentialsConfig{
132-
Method: "jwt",
133-
Namespace: "namespace-1",
134-
Partition: "partition-a",
135-
Datacenter: "primary-dc",
136-
BearerPath: tokFile.Name(),
137-
Meta: map[string]string{"foo": "bar"},
132+
AuthMethod: "jwt",
133+
Namespace: "namespace-1",
134+
Partition: "partition-a",
135+
Datacenter: "primary-dc",
136+
BearerTokenPath: tokFile.Name(),
137+
Meta: map[string]string{"foo": "bar"},
138138
},
139139
},
140140
out: discovery.Credentials{

pkg/consuldp/consul_dataplane.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func validateConfig(cfg *Config) error {
8282
}
8383

8484
creds := cfg.Consul.Credentials
85-
if creds.Type == CredentialsTypeLogin && creds.Login.Bearer == "" && creds.Login.BearerPath == "" {
85+
if creds.Type == CredentialsTypeLogin && creds.Login.BearerToken == "" && creds.Login.BearerTokenPath == "" {
8686
return errors.New("bearer token (or path to a file containing a bearer token) is required for login")
8787
}
8888

0 commit comments

Comments
 (0)