mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 19:31:05 +00:00
add additional opt to set v.auth
This commit is contained in:
parent
db698f9ef4
commit
187d1d65bb
3 changed files with 20 additions and 2 deletions
|
@ -179,7 +179,7 @@ var flags = []cli.Flag{
|
|||
EnvVar: "DRONE_VAULT_AUTH_TYPE",
|
||||
Name: "drone-vault-auth-type",
|
||||
Usage: "auth backend type used for connecting to vault",
|
||||
Value: "token",
|
||||
Value: "",
|
||||
},
|
||||
cli.StringFlag{
|
||||
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
|
||||
// kubernetes-auth parameters required to retrieve
|
||||
// an initial Vault token
|
||||
// an initial vault token
|
||||
func WithKubernetesAuth(addr, role, mount string) Opts {
|
||||
return func(v *vault) {
|
||||
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) {
|
||||
v := new(vault)
|
||||
addr := "https://address.fake"
|
||||
|
|
Loading…
Reference in a new issue