diff options
author | Michael Muré <batolettre@gmail.com> | 2020-02-15 02:55:19 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-02-15 02:55:19 +0100 |
commit | fe3d5c95e4be5874066402b5463ada34894c7f01 (patch) | |
tree | 29f04fae0dc3d5d4883d4989012c26109ba754dc /bridge/core/auth/options.go | |
parent | 2df72942f2b057956c7873f908b64880ab647331 (diff) | |
download | git-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.go | 11 |
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 } } |