aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/core/auth/options.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-15 02:55:19 +0100
committerMichael Muré <batolettre@gmail.com>2020-02-15 02:55:19 +0100
commitfe3d5c95e4be5874066402b5463ada34894c7f01 (patch)
tree29f04fae0dc3d5d4883d4989012c26109ba754dc /bridge/core/auth/options.go
parent2df72942f2b057956c7873f908b64880ab647331 (diff)
downloadgit-bug-fe3d5c95e4be5874066402b5463ada34894c7f01.tar.gz
bridges: massive refactor
- automatic flag validation and warning - generalized prompt - cleanups
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
}
}