id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c6400
unmarshal((*plain)(c)); err != nil { return err } return c.Validate() }
c6401
&http.Client{Transport: rt} }
c6402
err != nil { return nil, err } return newClient(rt), nil }
c6403
header correctly on each request. if len(cfg.BearerToken) > 0 { rt = NewBearerAuthRoundTripper(cfg.BearerToken, rt) } else if len(cfg.BearerTokenFile) > 0 { rt = NewBearerAuthFileRoundTripper(cfg.BearerTokenFile, rt) } if cfg.BasicAuth != nil { rt = NewBasicAuthRoundTripper(cfg.BasicAuth.Username, cf...
c6404
&bearerAuthFileRoundTripper{bearerFile, rt} }
c6405
tlsConfig.ServerName = cfg.ServerName } // If a client cert & key is provided then configure TLS config accordingly. if len(cfg.CertFile) > 0 && len(cfg.KeyFile) == 0 { return nil, fmt.Errorf("client cert file %q specified without client key file", cfg.CertFile) } else if len(cfg.KeyFile) > 0 && len(cfg.CertFil...
c6406
return nil, fmt.Errorf("unable to use specified client cert (%s) & key (%s): %s", c.CertFile, c.KeyFile, err) } return &cert, nil }
c6407
nil, fmt.Errorf("unable to load specified CA cert %s: %s", f, err) } return data, nil }
c6408
return false } cfg.RootCAs = caCertPool return true }
c6409
existing RoundTripper. return rt.RoundTrip(req) } // Create a new RoundTripper. tlsConfig := t.tlsConfig.Clone() if !updateRootCA(tlsConfig, b) { return nil, fmt.Errorf("unable to use specified CA cert %s", t.caFile) } rt, err = t.newRT(tlsConfig) if err != nil { return nil, err } t.CloseIdleConnection...
c6410
sum = hashAddByte(sum, SeparatorByte) sum = hashAdd(sum, string(labelValue)) result ^= sum } return Fingerprint(result) }
c6411
= file[slash+1:] } return l.entry.WithField("source", fmt.Sprintf("%s:%d", file, line)) }
c6412
return logger{entry: logrus.NewEntry(l)} }
c6413
return logger{entry: logrus.NewEntry(l)} }
c6414
LabelSet(m).Equal(LabelSet(o)) }
c6415
LabelSet(m).Before(LabelSet(o)) }
c6416
len(m)) for k, v := range m { clone[k] = v } return clone }
c6417
b == '_' || b == ':' || (b >= '0' && b <= '9' && i > 0)) { return false } } return true }
c6418
metric with a constant '1' value labeled by version, revision, branch, and goversion from which %s was built.", program, ), }, []string{"version", "revision", "branch", "goversion"}, ) buildInfo.WithLabelValues(Version, Revision, Branch, GoVersion).Set(1) return buildInfo }
c6419
"buildDate": BuildDate, "goVersion": GoVersion, } t := template.Must(template.New("version").Parse(versionInfoTmpl)) var buf bytes.Buffer if err := t.ExecuteTemplate(&buf, "version", m); err != nil { panic(err) } return strings.TrimSpace(buf.String()) }
c6420
case "warn": l.o = level.AllowWarn() case "error": l.o = level.AllowError() default: return errors.Errorf("unrecognized log level %q", s) } l.s = s return nil }
c6421
return errors.Errorf("unrecognized log format %q", s) } return nil }
c6422
} else { l = log.NewJSONLogger(log.NewSyncWriter(os.Stderr)) } l = level.NewFilter(l, config.Level.o) l = log.With(l, "ts", timestampFormat, "caller", log.DefaultCaller) return l }
c6423
if !lv.IsValid() { return fmt.Errorf("invalid value %q", lv) } } return nil }
c6424
lv := range ls { lsn[ln] = lv } return lsn }
c6425
for k, v := range other { result[k] = v } return result }
c6426
t + Time(d/minimumTick) }
c6427
{ return time.Duration(t-o) * minimumTick }
c6428
time.Unix(int64(t)/second, (int64(t)%second)*nanosPerTick) }
c6429
rconv.FormatFloat(float64(t)/float64(second), 'f', -1, 64) }
c6430
unit := matches[2]; unit { case "y": dur *= 1000 * 60 * 60 * 24 * 365 case "w": dur *= 1000 * 60 * 60 * 24 * 7 case "d": dur *= 1000 * 60 * 60 * 24 case "h": dur *= 1000 * 60 * 60 case "m": dur *= 1000 * 60 case "s": dur *= 1000 case "ms": // Value already correct default: return 0, fmt.Errorf(...
c6431
return math.IsNaN(float64(v)) && math.IsNaN(float64(o)) }
c6432
(s.Value.Equal(o.Value) && s.Timestamp.Equal(o.Timestamp)) }
c6433
!s.Timestamp.Equal(o.Timestamp) { return false } return s.Value.Equal(o.Value) }
c6434
{ p.err = ParseError{ Line: p.lineCount, Msg: msg, } }
c6435
switch p.currentByte { case '"': return case '\n': p.parseError(fmt.Sprintf("label value %q contains unescaped new-line", p.currentToken.String())) return case '\\': escaped = true default: p.currentToken.WriteByte(p.currentByte) } } }
c6436
if v := ctx.Value(param(p)); v != nil { return v.(string) } return "" }
c6437
context.WithValue(ctx, param(p), v) }
c6438
return &Router{rtr: r.rtr, prefix: r.prefix, instrh: instrh} }
c6439
r.rtr, prefix: r.prefix + prefix, instrh: r.instrh} }
c6440
:= context.WithCancel(req.Context()) defer cancel() for _, p := range params { ctx = context.WithValue(ctx, param(p.Key), p.Value) } h(w, req.WithContext(ctx)) } }
c6441
r.rtr.GET(r.prefix+path, r.handle(path, h)) }
c6442
r.rtr.OPTIONS(r.prefix+path, r.handle(path, h)) }
c6443
r.rtr.DELETE(r.prefix+path, r.handle(path, h)) }
c6444
r.rtr.PUT(r.prefix+path, r.handle(path, h)) }
c6445
r.rtr.POST(r.prefix+path, r.handle(path, h)) }
c6446
{ http.Redirect(w, req, r.prefix+path, code) }
c6447
return FmtUnknown } return FmtProtoDelim case textType: if v, ok := params["version"]; ok && v != TextVersion { return FmtUnknown } return FmtText } return FmtUnknown }
c6448
format { case FmtProtoDelim: return &protoDecoder{r: r} } return &textDecoder{r: r} }
c6449
err } *s, err = extractSamples(&sd.f, sd.Opts) return err }
c6450
if err != nil { lastErr = err continue } all = append(all, some...) } return all, lastErr }
c6451
type plain Secret return unmarshal((*plain)(s)) }
c6452
n, err = writeSample( w, name, "", metric, model.QuantileLabel, q.GetQuantile(), q.GetValue(), ) written += n if err != nil { return } } n, err = writeSample( w, name, "_sum", metric, "", 0, metric.Summary.GetSampleSum(), ) written += n if err != nil { ...
c6453
return w.WriteString("-Inf") default: bp := numBufPool.Get().(*[]byte) *bp = strconv.AppendFloat((*bp)[:0], f, 'g', -1, 64) written, err := w.Write(*bp) numBufPool.Put(bp) return written, err } }
c6454
*bp = strconv.AppendInt((*bp)[:0], i, 10) written, err := w.Write(*bp) numBufPool.Put(bp) return written, err }
c6455
} if err := a.Labels.Validate(); err != nil { return fmt.Errorf("invalid label set: %s", err) } if len(a.Labels) == 0 { return fmt.Errorf("at least one label pair required") } if err := a.Annotations.Validate(); err != nil { return fmt.Errorf("invalid annotations: %s", err) } return nil }
c6456
return true } } return false }
c6457
|| b == '_' || (b >= '0' && b <= '9' && i > 0)) { return false } } return true }
c6458
else if !LabelValue(m.Value).IsValid() || len(m.Value) == 0 { return fmt.Errorf("invalid value %q", m.Value) } return nil }
c6459
"" { return fmt.Errorf("creator information missing") } if s.Comment == "" { return fmt.Errorf("comment missing") } if s.CreatedAt.IsZero() { return fmt.Errorf("creation timestamp missing") } return nil }
c6460
!= nil { return nil, err } return &Conn{s, make([]byte, maxPktLen)}, nil }
c6461
rv, err := Receive(c.conn, c.buf) if err != nil { return nil, err } return &rv, nil }
c6462
false } n := len(pattern) if pattern[n-1] != '/' { return pattern == path } return len(path) >= n && path[0:n] == pattern }
c6463
h, _ = funcHandler(notFoundHandler), "" } // TODO: Rewrite path? return h.ServeCOAP(l, a, m) }
c6464
} if handler == nil { panic("http: nil handler") } mux.m[pattern] = muxEntry{h: handler, pattern: pattern} }
c6465
*Message) { mux.Handle(pattern, FuncHandler(f)) }
c6466
m *Message) *Message) Handler { return funcHandler(f) }
c6467
{ _, err = l.Write(d) } else { _, err = l.WriteTo(d, a) } return err }
c6468
net.ListenUDP(n, uaddr) if err != nil { return err } return Serve(l, rh) }
c6469
for _, v := range m.opts { if o == v.ID { rv = append(rv, v.Value) } } return rv }
c6470
o == v.ID { return v.Value } } return nil }
c6471
OptionID) { m.opts = m.opts.Minus(opID) }
c6472
m.opts = append(m.opts, option{opID, iv.Index(i).Interface()}) } return } m.opts = append(m.opts, option{opID, val}) }
c6473
interface{}) { m.RemoveOption(opID) m.AddOption(opID, val) }
c6474
\ / Option Value / 0 or more bytes \ \ / / \ \ +-------------------------------+ See parseExtOption(), extendOption() and writeOptionHeader() below for implementatio...
c6475
Message{} return rv, rv.UnmarshalBinary(data) }
c6476
if err != nil { return nil, err } m := TcpMessage{} err = m.UnmarshalBinary(packet) return &m, err }
c6477
_, err := time.Parse("2006-01-02", s) return err == nil }
c6478
err == nil { return true } if _, err := time.Parse("15:04:05.999999999Z07:00", s); err == nil { return true } return false }
c6479
n, err := strconv.Atoi(group) if err != nil { return false } if n < 0 || n > 255 { return false } } return true }
c6480
{ return false } return net.ParseIP(s) != nil }
c6481
u, err := url.Parse(s) return err == nil && u.IsAbs() }
c6482
if depth != 1 { return false } case '}': depth-- if depth != 0 { return false } } } if depth != 0 { return false } } return true }
c6483
} _, err := regexp.Compile(s) return err == nil }
c6484
decoder.Token(); t != nil { return nil, fmt.Errorf("invalid character %v after top-level value", t) } return doc, nil }
c6485
return "array" case map[string]interface{}: return "object" } panic(InvalidJSONTypeError(fmt.Sprintf("%T", v))) }
c6486
obj1, obj2 := v1.(map[string]interface{}), v2.(map[string]interface{}) if len(obj1) != len(obj2) { return false } for k, v1 := range obj1 { if v2, ok := obj2[k]; ok { if !equals(v1, v2) { return false } } else { return false } } return true case "number": num1, _ := new(big....
c6487
token = strings.Replace(token, "/", "~1", -1) return url.PathEscape(token) }
c6488
{ return err } c.resources[res.url] = res return nil }
c6489
case "http://json-schema.org/draft-07/schema#": r.draft = Draft7 case "http://json-schema.org/draft-06/schema#": r.draft = Draft6 case "http://json-schema.org/draft-04/schema#": r.draft = Draft4 default: return nil, fmt.Errorf("unknown $schema %q", url) } } } if r.draft == n...
c6490
self //return //} // TODO(bgentry): logger isn't on Windows. Replace w/ proper error reports. if err := u.update(); err != nil { return err } } return nil }
c6491
return nil, fmt.Errorf("bad http status from %s: %v", url, resp.Status) } return resp.Body, nil }
c6492
if !validOptions[con[0]] { return "", "", fmt.Errorf("Bad label option %q, valid options 'disable, user, role, level, type'", con[0]) } pcon[con[0]] = con[1] if con[0] == "level" || con[0] == "user" { mcon[con[0]] = con[1] } } _ = ReleaseLabel(processLabel) processLabel = pcon.Get() mou...
c6493
&& fileLabel != "" { return selinux.SetFileLabel(path, fileLabel) } return nil }
c6494
selinux.SetFSCreateLabel(fileLabel) } return nil }
c6495
true, "/var/log": true, } if home := os.Getenv("HOME"); home != "" { exclude_paths[home] = true } if sudoUser := os.Getenv("SUDO_USER"); sudoUser != "" { if usr, err := user.Lookup(sudoUser); err == nil { exclude_paths[usr.HomeDir] = true } } if path != "/" { path = strings.TrimSuffix(path, "...
c6496
"z") && strings.Contains(label, "Z") { return ErrIncompatibleLabel } return nil }
c6497
|| strings.Contains(label, "Z") }
c6498
if !strings.Contains(txt, " - selinuxfs ") { continue } const mPos = 5 // mount point is 5th field fields := strings.SplitN(txt, " ", mPos+1) if len(fields) < mPos+1 { continue } return fields[mPos-1] } return "" }
c6499
return lsetxattr(fpath, xattrNameSelinux, []byte(label), 0) }