mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-17 17:45:03 +02:00
add additional opt to set v.auth
This commit is contained in:
parent
db698f9ef4
commit
187d1d65bb
@ -179,7 +179,7 @@ var flags = []cli.Flag{
|
|||||||
EnvVar: "DRONE_VAULT_AUTH_TYPE",
|
EnvVar: "DRONE_VAULT_AUTH_TYPE",
|
||||||
Name: "drone-vault-auth-type",
|
Name: "drone-vault-auth-type",
|
||||||
Usage: "auth backend type used for connecting to vault",
|
Usage: "auth backend type used for connecting to vault",
|
||||||
Value: "token",
|
Value: "",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
EnvVar: "DRONE_VAULT_AUTH_MOUNT_POINT",
|
EnvVar: "DRONE_VAULT_AUTH_MOUNT_POINT",
|
||||||
|
@ -25,9 +25,17 @@ func WithRenewal(d time.Duration) Opts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithAuth returns an options that sets the vault
|
||||||
|
// method to use for authentication
|
||||||
|
func WithAuth(method string) Opts {
|
||||||
|
return func(v *vault) {
|
||||||
|
v.auth = method
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithKubernetes returns an options that sets
|
// WithKubernetes returns an options that sets
|
||||||
// kubernetes-auth parameters required to retrieve
|
// kubernetes-auth parameters required to retrieve
|
||||||
// an initial Vault token
|
// an initial vault token
|
||||||
func WithKubernetesAuth(addr, role, mount string) Opts {
|
func WithKubernetesAuth(addr, role, mount string) Opts {
|
||||||
return func(v *vault) {
|
return func(v *vault) {
|
||||||
v.kubeAuth.addr = addr
|
v.kubeAuth.addr = addr
|
||||||
|
@ -27,6 +27,16 @@ func TestWithRenewal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWithAuth(t *testing.T) {
|
||||||
|
v := new(vault)
|
||||||
|
method := "kubernetes"
|
||||||
|
opt := WithAuth(method)
|
||||||
|
opt(v)
|
||||||
|
if got, want := v.auth, method; got != want {
|
||||||
|
t.Errorf("Want auth %v, got %v", want, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestWithKubernetesAuth(t *testing.T) {
|
func TestWithKubernetesAuth(t *testing.T) {
|
||||||
v := new(vault)
|
v := new(vault)
|
||||||
addr := "https://address.fake"
|
addr := "https://address.fake"
|
||||||
|
Loading…
Reference in New Issue
Block a user