From fe3d5c95e4be5874066402b5463ada34894c7f01 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 15 Feb 2020 02:55:19 +0100 Subject: bridges: massive refactor - automatic flag validation and warning - generalized prompt - cleanups --- bridge/core/auth/options.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bridge/core/auth') 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 } } -- cgit