diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 0a07aa01..e3da3d26 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -23,44 +23,48 @@ }, { "ImportPath": "github.com/coreos/go-oidc/http", - "Rev": "e6174c764e906bd60c76fdfc33faf5e0bdc875d6" + "Rev": "dedb650fb29c39c2f21aa88c1e4cec66da8754d1" }, { "ImportPath": "github.com/coreos/go-oidc/jose", - "Rev": "e6174c764e906bd60c76fdfc33faf5e0bdc875d6" + "Rev": "dedb650fb29c39c2f21aa88c1e4cec66da8754d1" }, { "ImportPath": "github.com/coreos/go-oidc/key", - "Rev": "e6174c764e906bd60c76fdfc33faf5e0bdc875d6" + "Rev": "dedb650fb29c39c2f21aa88c1e4cec66da8754d1" }, { "ImportPath": "github.com/coreos/go-oidc/oauth2", - "Rev": "e6174c764e906bd60c76fdfc33faf5e0bdc875d6" + "Rev": "dedb650fb29c39c2f21aa88c1e4cec66da8754d1" }, { "ImportPath": "github.com/coreos/go-oidc/oidc", - "Rev": "e6174c764e906bd60c76fdfc33faf5e0bdc875d6" + "Rev": "dedb650fb29c39c2f21aa88c1e4cec66da8754d1" }, { "ImportPath": "github.com/coreos/go-systemd/journal", - "Comment": "v5", - "Rev": "7b2428fec40033549c68f54e26e89e7ca9a9ce31" + "Comment": "v14-2-gefa0506", + "Rev": "efa0506b99d3d9cfade280f5c7a1c1980d8c6c48" }, { "ImportPath": "github.com/coreos/pkg/capnslog", - "Rev": "1914e367e85eaf0c25d495b48e060dfe6190f8d0" + "Comment": "v3-2-g447b7ec", + "Rev": "447b7ec906e523386d9c53be15b55a8ae86ea944" }, { "ImportPath": "github.com/coreos/pkg/health", - "Rev": "1914e367e85eaf0c25d495b48e060dfe6190f8d0" + "Comment": "v3-2-g447b7ec", + "Rev": "447b7ec906e523386d9c53be15b55a8ae86ea944" }, { "ImportPath": "github.com/coreos/pkg/httputil", - "Rev": "1914e367e85eaf0c25d495b48e060dfe6190f8d0" + "Comment": "v3-2-g447b7ec", + "Rev": "447b7ec906e523386d9c53be15b55a8ae86ea944" }, { "ImportPath": "github.com/coreos/pkg/timeutil", - "Rev": "1914e367e85eaf0c25d495b48e060dfe6190f8d0" + "Comment": "v3-2-g447b7ec", + "Rev": "447b7ec906e523386d9c53be15b55a8ae86ea944" }, { "ImportPath": "github.com/davecgh/go-spew/spew", diff --git a/vendor/github.com/coreos/go-oidc/http/doc.go b/vendor/github.com/coreos/go-oidc/http/doc.go new file mode 100644 index 00000000..5687e8b8 --- /dev/null +++ b/vendor/github.com/coreos/go-oidc/http/doc.go @@ -0,0 +1,2 @@ +// Package http is DEPRECATED. Use net/http instead. +package http diff --git a/vendor/github.com/coreos/go-oidc/http/http.go b/vendor/github.com/coreos/go-oidc/http/http.go index f0d051b5..c3f51215 100644 --- a/vendor/github.com/coreos/go-oidc/http/http.go +++ b/vendor/github.com/coreos/go-oidc/http/http.go @@ -4,18 +4,13 @@ import ( "encoding/base64" "encoding/json" "errors" + "log" "net/http" "net/url" "path" "strconv" "strings" "time" - - "github.com/coreos/pkg/capnslog" -) - -var ( - log = capnslog.NewPackageLogger("github.com/coreos/go-oidc", "http") ) func WriteError(w http.ResponseWriter, code int, msg string) { @@ -26,7 +21,9 @@ func WriteError(w http.ResponseWriter, code int, msg string) { } b, err := json.Marshal(e) if err != nil { - log.Errorf("Failed marshaling %#v to JSON: %v", e, err) + log.Printf("go-oidc: failed to marshal %#v: %v", e, err) + code = http.StatusInternalServerError + b = []byte(`{"error":"server_error"}`) } w.Header().Set("Content-Type", "application/json") w.WriteHeader(code) diff --git a/vendor/github.com/coreos/go-oidc/http/middleware.go b/vendor/github.com/coreos/go-oidc/http/middleware.go deleted file mode 100644 index 270b3bc0..00000000 --- a/vendor/github.com/coreos/go-oidc/http/middleware.go +++ /dev/null @@ -1,14 +0,0 @@ -package http - -import ( - "net/http" -) - -type LoggingMiddleware struct { - Next http.Handler -} - -func (l *LoggingMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) { - log.Infof("HTTP %s %v", r.Method, r.URL) - l.Next.ServeHTTP(w, r) -} diff --git a/vendor/github.com/coreos/go-oidc/jose/doc.go b/vendor/github.com/coreos/go-oidc/jose/doc.go new file mode 100644 index 00000000..b5e13217 --- /dev/null +++ b/vendor/github.com/coreos/go-oidc/jose/doc.go @@ -0,0 +1,2 @@ +// Package jose is DEPRECATED. Use gopkg.in/square/go-jose.v2 instead. +package jose diff --git a/vendor/github.com/coreos/go-oidc/jose/jwk.go b/vendor/github.com/coreos/go-oidc/jose/jwk.go index b7a8e235..119f073f 100644 --- a/vendor/github.com/coreos/go-oidc/jose/jwk.go +++ b/vendor/github.com/coreos/go-oidc/jose/jwk.go @@ -104,7 +104,7 @@ func encodeExponent(e int) string { break } } - return base64.URLEncoding.EncodeToString(b[idx:]) + return base64.RawURLEncoding.EncodeToString(b[idx:]) } // Turns a URL encoded modulus of a key into a big int. @@ -119,7 +119,7 @@ func decodeModulus(n string) (*big.Int, error) { } func encodeModulus(n *big.Int) string { - return base64.URLEncoding.EncodeToString(n.Bytes()) + return base64.RawURLEncoding.EncodeToString(n.Bytes()) } // decodeBase64URLPaddingOptional decodes Base64 whether there is padding or not. diff --git a/vendor/github.com/coreos/go-oidc/jose/sig.go b/vendor/github.com/coreos/go-oidc/jose/sig.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/coreos/go-oidc/jose/sig_hmac.go b/vendor/github.com/coreos/go-oidc/jose/sig_hmac.go deleted file mode 100644 index b3ca3ef3..00000000 --- a/vendor/github.com/coreos/go-oidc/jose/sig_hmac.go +++ /dev/null @@ -1,67 +0,0 @@ -package jose - -import ( - "bytes" - "crypto" - "crypto/hmac" - _ "crypto/sha256" - "errors" - "fmt" -) - -type VerifierHMAC struct { - KeyID string - Hash crypto.Hash - Secret []byte -} - -type SignerHMAC struct { - VerifierHMAC -} - -func NewVerifierHMAC(jwk JWK) (*VerifierHMAC, error) { - if jwk.Alg != "" && jwk.Alg != "HS256" { - return nil, fmt.Errorf("unsupported key algorithm %q", jwk.Alg) - } - - v := VerifierHMAC{ - KeyID: jwk.ID, - Secret: jwk.Secret, - Hash: crypto.SHA256, - } - - return &v, nil -} - -func (v *VerifierHMAC) ID() string { - return v.KeyID -} - -func (v *VerifierHMAC) Alg() string { - return "HS256" -} - -func (v *VerifierHMAC) Verify(sig []byte, data []byte) error { - h := hmac.New(v.Hash.New, v.Secret) - h.Write(data) - if !bytes.Equal(sig, h.Sum(nil)) { - return errors.New("invalid hmac signature") - } - return nil -} - -func NewSignerHMAC(kid string, secret []byte) *SignerHMAC { - return &SignerHMAC{ - VerifierHMAC: VerifierHMAC{ - KeyID: kid, - Secret: secret, - Hash: crypto.SHA256, - }, - } -} - -func (s *SignerHMAC) Sign(data []byte) ([]byte, error) { - h := hmac.New(s.Hash.New, s.Secret) - h.Write(data) - return h.Sum(nil), nil -} diff --git a/vendor/github.com/coreos/go-oidc/jose/sig_rsa.go b/vendor/github.com/coreos/go-oidc/jose/sig_rsa.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/coreos/go-oidc/key/doc.go b/vendor/github.com/coreos/go-oidc/key/doc.go new file mode 100644 index 00000000..936eec74 --- /dev/null +++ b/vendor/github.com/coreos/go-oidc/key/doc.go @@ -0,0 +1,2 @@ +// Package key is DEPRECATED. Use github.com/coreos/go-oidc instead. +package key diff --git a/vendor/github.com/coreos/go-oidc/key/key.go b/vendor/github.com/coreos/go-oidc/key/key.go index d0142a9e..208c1fc1 100644 --- a/vendor/github.com/coreos/go-oidc/key/key.go +++ b/vendor/github.com/coreos/go-oidc/key/key.go @@ -3,9 +3,9 @@ package key import ( "crypto/rand" "crypto/rsa" - "encoding/base64" + "encoding/hex" "encoding/json" - "math/big" + "io" "time" "github.com/coreos/go-oidc/jose" @@ -139,15 +139,15 @@ func GeneratePrivateKey() (*PrivateKey, error) { if err != nil { return nil, err } + keyID := make([]byte, 20) + if _, err := io.ReadFull(rand.Reader, keyID); err != nil { + return nil, err + } k := PrivateKey{ - KeyID: base64BigInt(pk.PublicKey.N), + KeyID: hex.EncodeToString(keyID), PrivateKey: pk, } return &k, nil } - -func base64BigInt(b *big.Int) string { - return base64.URLEncoding.EncodeToString(b.Bytes()) -} diff --git a/vendor/github.com/coreos/go-oidc/key/rotate.go b/vendor/github.com/coreos/go-oidc/key/rotate.go index 9c5508bc..bc6cdfb1 100644 --- a/vendor/github.com/coreos/go-oidc/key/rotate.go +++ b/vendor/github.com/coreos/go-oidc/key/rotate.go @@ -2,16 +2,14 @@ package key import ( "errors" + "log" "time" - "github.com/coreos/pkg/capnslog" ptime "github.com/coreos/pkg/timeutil" "github.com/jonboulle/clockwork" ) var ( - log = capnslog.NewPackageLogger("github.com/coreos/go-oidc", "key") - ErrorPrivateKeysExpired = errors.New("private keys have expired") ) @@ -67,7 +65,6 @@ func (r *PrivateKeyRotator) privateKeySet() (*PrivateKeySet, error) { func (r *PrivateKeyRotator) nextRotation() (time.Duration, error) { pks, err := r.privateKeySet() if err == ErrorNoKeys { - log.Infof("No keys in private key set; must rotate immediately") return 0, nil } if err != nil { @@ -94,17 +91,15 @@ func (r *PrivateKeyRotator) Run() chan struct{} { attempt := func() { k, err := r.generateKey() if err != nil { - log.Errorf("Failed generating signing key: %v", err) + log.Printf("go-oidc: failed generating signing key: %v", err) return } exp := r.expiresAt() if err := rotatePrivateKeys(r.repo, k, r.keep, exp); err != nil { - log.Errorf("Failed key rotation: %v", err) + log.Printf("go-oidc: key rotation failed: %v", err) return } - - log.Infof("Rotated signing keys: id=%s expiresAt=%s", k.ID(), exp) } stop := make(chan struct{}) @@ -118,11 +113,10 @@ func (r *PrivateKeyRotator) Run() chan struct{} { break } sleep = ptime.ExpBackoff(sleep, time.Minute) - log.Errorf("error getting nextRotation, retrying in %v: %v", sleep, err) + log.Printf("go-oidc: error getting nextRotation, retrying in %v: %v", sleep, err) time.Sleep(sleep) } - log.Infof("will rotate keys in %v", nextRotation) select { case <-r.clock.After(nextRotation): attempt() diff --git a/vendor/github.com/coreos/go-oidc/key/sync.go b/vendor/github.com/coreos/go-oidc/key/sync.go index e8d5d03d..b887f7b5 100644 --- a/vendor/github.com/coreos/go-oidc/key/sync.go +++ b/vendor/github.com/coreos/go-oidc/key/sync.go @@ -2,6 +2,7 @@ package key import ( "errors" + "log" "time" "github.com/jonboulle/clockwork" @@ -38,15 +39,14 @@ func (s *KeySetSyncer) Run() chan struct{} { next = timeutil.ExpBackoff(next, time.Minute) } if exp == 0 { - log.Errorf("Synced to already expired key set, retrying in %v: %v", next, err) + log.Printf("Synced to already expired key set, retrying in %v: %v", next, err) } else { - log.Errorf("Failed syncing key set, retrying in %v: %v", next, err) + log.Printf("Failed syncing key set, retrying in %v: %v", next, err) } } else { failing = false next = exp / 2 - log.Infof("Synced key set, checking again in %v", next) } select { diff --git a/vendor/github.com/coreos/go-oidc/oauth2/doc.go b/vendor/github.com/coreos/go-oidc/oauth2/doc.go new file mode 100644 index 00000000..52eb3085 --- /dev/null +++ b/vendor/github.com/coreos/go-oidc/oauth2/doc.go @@ -0,0 +1,2 @@ +// Package oauth2 is DEPRECATED. Use golang.org/x/oauth instead. +package oauth2 diff --git a/vendor/github.com/coreos/go-oidc/oauth2/oauth2.go b/vendor/github.com/coreos/go-oidc/oauth2/oauth2.go index 1c68293a..72d1d671 100644 --- a/vendor/github.com/coreos/go-oidc/oauth2/oauth2.go +++ b/vendor/github.com/coreos/go-oidc/oauth2/oauth2.go @@ -332,16 +332,16 @@ func parseTokenResponse(resp *http.Response) (result TokenResponse, err error) { result.Scope = vals.Get("scope") } else { var r struct { - AccessToken string `json:"access_token"` - TokenType string `json:"token_type"` - IDToken string `json:"id_token"` - RefreshToken string `json:"refresh_token"` - Scope string `json:"scope"` - State string `json:"state"` - ExpiresIn int `json:"expires_in"` - Expires int `json:"expires"` - Error string `json:"error"` - Desc string `json:"error_description"` + AccessToken string `json:"access_token"` + TokenType string `json:"token_type"` + IDToken string `json:"id_token"` + RefreshToken string `json:"refresh_token"` + Scope string `json:"scope"` + State string `json:"state"` + ExpiresIn json.Number `json:"expires_in"` // Azure AD returns string + Expires int `json:"expires"` + Error string `json:"error"` + Desc string `json:"error_description"` } if err = json.Unmarshal(body, &r); err != nil { return @@ -355,10 +355,10 @@ func parseTokenResponse(resp *http.Response) (result TokenResponse, err error) { result.IDToken = r.IDToken result.RefreshToken = r.RefreshToken result.Scope = r.Scope - if r.ExpiresIn == 0 { + if expiresIn, err := r.ExpiresIn.Int64(); err != nil { result.Expires = r.Expires } else { - result.Expires = r.ExpiresIn + result.Expires = int(expiresIn) } } return diff --git a/vendor/github.com/coreos/go-oidc/oidc/doc.go b/vendor/github.com/coreos/go-oidc/oidc/doc.go new file mode 100644 index 00000000..196611ec --- /dev/null +++ b/vendor/github.com/coreos/go-oidc/oidc/doc.go @@ -0,0 +1,2 @@ +// Package oidc is DEPRECATED. Use github.com/coreos/go-oidc instead. +package oidc diff --git a/vendor/github.com/coreos/go-oidc/oidc/key.go b/vendor/github.com/coreos/go-oidc/oidc/key.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/coreos/go-oidc/oidc/provider.go b/vendor/github.com/coreos/go-oidc/oidc/provider.go index dcae4c92..42197ff1 100644 --- a/vendor/github.com/coreos/go-oidc/oidc/provider.go +++ b/vendor/github.com/coreos/go-oidc/oidc/provider.go @@ -4,13 +4,13 @@ import ( "encoding/json" "errors" "fmt" + "log" "net/http" "net/url" "strings" "sync" "time" - "github.com/coreos/pkg/capnslog" "github.com/coreos/pkg/timeutil" "github.com/jonboulle/clockwork" @@ -18,10 +18,6 @@ import ( "github.com/coreos/go-oidc/oauth2" ) -var ( - log = capnslog.NewPackageLogger("github.com/coreos/go-oidc", "http") -) - const ( // Subject Identifier types defined by the OIDC spec. Specifies if the provider // should provide the same sub claim value to all clients (public) or a unique @@ -69,6 +65,8 @@ type ProviderConfig struct { UserInfoEndpoint *url.URL KeysEndpoint *url.URL // Required RegistrationEndpoint *url.URL + EndSessionEndpoint *url.URL + CheckSessionIFrame *url.URL // Servers MAY choose not to advertise some supported scope values even when this // parameter is used, although those defined in OpenID Core SHOULD be listed, if supported. @@ -170,6 +168,8 @@ type encodableProviderConfig struct { UserInfoEndpoint string `json:"userinfo_endpoint,omitempty"` KeysEndpoint string `json:"jwks_uri"` RegistrationEndpoint string `json:"registration_endpoint,omitempty"` + EndSessionEndpoint string `json:"end_session_endpoint,omitempty"` + CheckSessionIFrame string `json:"check_session_iframe,omitempty"` // Use 'omitempty' for all slices as per OIDC spec: // "Claims that return multiple values are represented as JSON arrays. @@ -219,6 +219,8 @@ func (cfg ProviderConfig) toEncodableStruct() encodableProviderConfig { UserInfoEndpoint: uriToString(cfg.UserInfoEndpoint), KeysEndpoint: uriToString(cfg.KeysEndpoint), RegistrationEndpoint: uriToString(cfg.RegistrationEndpoint), + EndSessionEndpoint: uriToString(cfg.EndSessionEndpoint), + CheckSessionIFrame: uriToString(cfg.CheckSessionIFrame), ScopesSupported: cfg.ScopesSupported, ResponseTypesSupported: cfg.ResponseTypesSupported, ResponseModesSupported: cfg.ResponseModesSupported, @@ -260,6 +262,8 @@ func (e encodableProviderConfig) toStruct() (ProviderConfig, error) { UserInfoEndpoint: p.parseURI(e.UserInfoEndpoint, "userinfo_endpoint"), KeysEndpoint: p.parseURI(e.KeysEndpoint, "jwks_uri"), RegistrationEndpoint: p.parseURI(e.RegistrationEndpoint, "registration_endpoint"), + EndSessionEndpoint: p.parseURI(e.EndSessionEndpoint, "end_session_endpoint"), + CheckSessionIFrame: p.parseURI(e.CheckSessionIFrame, "check_session_iframe"), ScopesSupported: e.ScopesSupported, ResponseTypesSupported: e.ResponseTypesSupported, ResponseModesSupported: e.ResponseModesSupported, @@ -364,6 +368,8 @@ func (p ProviderConfig) Valid() error { {p.UserInfoEndpoint, "userinfo_endpoint", false}, {p.KeysEndpoint, "jwks_uri", true}, {p.RegistrationEndpoint, "registration_endpoint", false}, + {p.EndSessionEndpoint, "end_session_endpoint", false}, + {p.CheckSessionIFrame, "check_session_iframe", false}, {p.ServiceDocs, "service_documentation", false}, {p.Policy, "op_policy_uri", false}, {p.TermsOfService, "op_tos_uri", false}, @@ -537,8 +543,6 @@ func (s *ProviderConfigSyncer) sync() (time.Duration, error) { s.initialSyncDone = true } - log.Debugf("Updating provider config: config=%#v", cfg) - return nextSyncAfter(cfg.ExpiresAt, s.clock), nil } @@ -561,10 +565,9 @@ func (n *pcsStepNext) step(fn pcsStepFunc) (next pcsStepper) { ttl, err := fn() if err == nil { next = &pcsStepNext{aft: ttl} - log.Debugf("Synced provider config, next attempt in %v", next.after()) } else { next = &pcsStepRetry{aft: time.Second} - log.Errorf("Provider config sync failed, retrying in %v: %v", next.after(), err) + log.Printf("go-oidc: provider config sync failed, retrying in %v: %v", next.after(), err) } return } @@ -581,10 +584,9 @@ func (r *pcsStepRetry) step(fn pcsStepFunc) (next pcsStepper) { ttl, err := fn() if err == nil { next = &pcsStepNext{aft: ttl} - log.Infof("Provider config sync no longer failing") } else { next = &pcsStepRetry{aft: timeutil.ExpBackoff(r.aft, time.Minute)} - log.Errorf("Provider config sync still failing, retrying in %v: %v", next.after(), err) + log.Printf("go-oidc: provider config sync failed, retrying in %v: %v", next.after(), err) } return } diff --git a/vendor/github.com/coreos/go-oidc/oidc/verification.go b/vendor/github.com/coreos/go-oidc/oidc/verification.go index 00241304..d9c6afa6 100644 --- a/vendor/github.com/coreos/go-oidc/oidc/verification.go +++ b/vendor/github.com/coreos/go-oidc/oidc/verification.go @@ -161,11 +161,18 @@ func NewJWTVerifier(issuer, clientID string, syncFunc func() error, keysFunc fun } func (v *JWTVerifier) Verify(jwt jose.JWT) error { + // Verify claims before verifying the signature. This is an optimization to throw out + // tokens we know are invalid without undergoing an expensive signature check and + // possibly a re-sync event. + if err := VerifyClaims(jwt, v.issuer, v.clientID); err != nil { + return fmt.Errorf("oidc: JWT claims invalid: %v", err) + } + ok, err := VerifySignature(jwt, v.keysFunc()) - if ok { - goto SignatureVerified - } else if err != nil { + if err != nil { return fmt.Errorf("oidc: JWT signature verification failed: %v", err) + } else if ok { + return nil } if err = v.syncFunc(); err != nil { @@ -179,10 +186,5 @@ func (v *JWTVerifier) Verify(jwt jose.JWT) error { return errors.New("oidc: unable to verify JWT signature: no matching keys") } -SignatureVerified: - if err := VerifyClaims(jwt, v.issuer, v.clientID); err != nil { - return fmt.Errorf("oidc: JWT claims invalid: %v", err) - } - return nil } diff --git a/vendor/github.com/coreos/pkg/capnslog/formatters.go b/vendor/github.com/coreos/pkg/capnslog/formatters.go index 99ec6f82..b305a845 100644 --- a/vendor/github.com/coreos/pkg/capnslog/formatters.go +++ b/vendor/github.com/coreos/pkg/capnslog/formatters.go @@ -18,6 +18,7 @@ import ( "bufio" "fmt" "io" + "log" "runtime" "strings" "time" @@ -28,7 +29,7 @@ type Formatter interface { Flush() } -func NewStringFormatter(w io.Writer) *StringFormatter { +func NewStringFormatter(w io.Writer) Formatter { return &StringFormatter{ w: bufio.NewWriter(w), } @@ -104,3 +105,53 @@ func (c *PrettyFormatter) Format(pkg string, l LogLevel, depth int, entries ...i func (c *PrettyFormatter) Flush() { c.w.Flush() } + +// LogFormatter emulates the form of the traditional built-in logger. +type LogFormatter struct { + logger *log.Logger + prefix string +} + +// NewLogFormatter is a helper to produce a new LogFormatter struct. It uses the +// golang log package to actually do the logging work so that logs look similar. +func NewLogFormatter(w io.Writer, prefix string, flag int) Formatter { + return &LogFormatter{ + logger: log.New(w, "", flag), // don't use prefix here + prefix: prefix, // save it instead + } +} + +// Format builds a log message for the LogFormatter. The LogLevel is ignored. +func (lf *LogFormatter) Format(pkg string, _ LogLevel, _ int, entries ...interface{}) { + str := fmt.Sprint(entries...) + prefix := lf.prefix + if pkg != "" { + prefix = fmt.Sprintf("%s%s: ", prefix, pkg) + } + lf.logger.Output(5, fmt.Sprintf("%s%v", prefix, str)) // call depth is 5 +} + +// Flush is included so that the interface is complete, but is a no-op. +func (lf *LogFormatter) Flush() { + // noop +} + +// NilFormatter is a no-op log formatter that does nothing. +type NilFormatter struct { +} + +// NewNilFormatter is a helper to produce a new LogFormatter struct. It logs no +// messages so that you can cause part of your logging to be silent. +func NewNilFormatter() Formatter { + return &NilFormatter{} +} + +// Format does nothing. +func (_ *NilFormatter) Format(_ string, _ LogLevel, _ int, _ ...interface{}) { + // noop +} + +// Flush is included so that the interface is complete, but is a no-op. +func (_ *NilFormatter) Flush() { + // noop +} diff --git a/vendor/github.com/coreos/pkg/capnslog/logmap.go b/vendor/github.com/coreos/pkg/capnslog/logmap.go index 84954488..226b60c2 100644 --- a/vendor/github.com/coreos/pkg/capnslog/logmap.go +++ b/vendor/github.com/coreos/pkg/capnslog/logmap.go @@ -95,6 +95,11 @@ func (l *LogLevel) Set(s string) error { return nil } +// Returns an empty string, only here to fulfill the pflag.Value interface. +func (l *LogLevel) Type() string { + return "" +} + // ParseLevel translates some potential loglevel strings into their corresponding levels. func ParseLevel(s string) (LogLevel, error) { switch s { diff --git a/vendor/github.com/coreos/pkg/capnslog/pkg_logger.go b/vendor/github.com/coreos/pkg/capnslog/pkg_logger.go index e2c46688..612d55c6 100644 --- a/vendor/github.com/coreos/pkg/capnslog/pkg_logger.go +++ b/vendor/github.com/coreos/pkg/capnslog/pkg_logger.go @@ -92,6 +92,12 @@ func (p *PackageLogger) Fatal(args ...interface{}) { os.Exit(1) } +func (p *PackageLogger) Fatalln(args ...interface{}) { + s := fmt.Sprintln(args...) + p.internalLog(calldepth, CRITICAL, s) + os.Exit(1) +} + // Error Functions func (p *PackageLogger) Errorf(format string, args ...interface{}) {