aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/core/auth/options.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-15 03:01:45 +0100
committerGitHub <noreply@github.com>2020-02-15 03:01:45 +0100
commit362c0c7e2e1ce9a8e2918376a340c76f46569d64 (patch)
tree29f04fae0dc3d5d4883d4989012c26109ba754dc /bridge/core/auth/options.go
parent2df72942f2b057956c7873f908b64880ab647331 (diff)
parentfe3d5c95e4be5874066402b5463ada34894c7f01 (diff)
downloadgit-bug-362c0c7e2e1ce9a8e2918376a340c76f46569d64.tar.gz
Merge pull request #325 from MichaelMure/bridge-refactor
bridges: massive refactor
Diffstat (limited to 'bridge/core/auth/options.go')
-rw-r--r--bridge/core/auth/options.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/bridge/core/auth/options.go b/bridge/core/auth/options.go
index 74189874..1d8c44d1 100644
--- a/bridge/core/auth/options.go
+++ b/bridge/core/auth/options.go
@@ -2,7 +2,7 @@ package auth
type options struct {
target string
- kind CredentialKind
+ kind map[CredentialKind]interface{}
meta map[string]string
}
@@ -21,7 +21,8 @@ func (opts *options) Match(cred Credential) bool {
return false
}
- if opts.kind != "" && cred.Kind() != opts.kind {
+ _, has := opts.kind[cred.Kind()]
+ if len(opts.kind) > 0 && !has {
return false
}
@@ -40,9 +41,13 @@ func WithTarget(target string) Option {
}
}
+// WithKind match credentials with the given kind. Can be specified multiple times.
func WithKind(kind CredentialKind) Option {
return func(opts *options) {
- opts.kind = kind
+ if opts.kind == nil {
+ opts.kind = make(map[CredentialKind]interface{})
+ }
+ opts.kind[kind] = nil
}
}