_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q177800
RestoreReader
test
func (c APIClient) RestoreReader(r io.Reader) (retErr error) { restoreClient, err := c.AdminAPIClient.Restore(c.Ctx()) if err != nil { return grpcutil.ScrubGRPC(err) } defer func() { if _, err := restoreClient.CloseAndRecv(); err != nil && retErr == nil { retErr = grpcutil.ScrubGRPC(err) } }() reader := ...
go
{ "resource": "" }
q177801
RestoreFrom
test
func (c APIClient) RestoreFrom(objects bool, otherC *APIClient) (retErr error) { restoreClient, err := c.AdminAPIClient.Restore(c.Ctx()) if err != nil { return grpcutil.ScrubGRPC(err) } defer func() { if _, err := restoreClient.CloseAndRecv(); err != nil && retErr == nil { retErr = grpcutil.ScrubGRPC(err) ...
go
{ "resource": "" }
q177802
RestoreURL
test
func (c APIClient) RestoreURL(url string) (retErr error) { restoreClient, err := c.AdminAPIClient.Restore(c.Ctx()) if err != nil { return grpcutil.ScrubGRPC(err) } defer func() { if _, err := restoreClient.CloseAndRecv(); err != nil && retErr == nil { retErr = grpcutil.ScrubGRPC(err) } }() return grpcuti...
go
{ "resource": "" }
q177803
IgnoreTypes
test
func IgnoreTypes(typs ...interface{}) cmp.Option { tf := newTypeFilter(typs...) return cmp.FilterPath(tf.filter, cmp.Ignore()) }
go
{ "resource": "" }
q177804
AppendEllipsis
test
func (s *textList) AppendEllipsis(ds diffStats) { hasStats := ds != diffStats{} if len(*s) == 0 || !(*s)[len(*s)-1].Value.Equal(textEllipsis) { if hasStats { *s = append(*s, textRecord{Value: textEllipsis, Comment: ds}) } else { *s = append(*s, textRecord{Value: textEllipsis}) } return } if hasStats {...
go
{ "resource": "" }
q177805
IsType
test
func IsType(t reflect.Type, ft funcType) bool { if t == nil || t.Kind() != reflect.Func || t.IsVariadic() { return false } ni, no := t.NumIn(), t.NumOut() switch ft { case tbFunc: // func(T) bool if ni == 1 && no == 1 && t.Out(0) == boolType { return true } case ttbFunc: // func(T, T) bool if ni == 2 &...
go
{ "resource": "" }
q177806
NameOf
test
func NameOf(v reflect.Value) string { fnc := runtime.FuncForPC(v.Pointer()) if fnc == nil { return "<unknown>" } fullName := fnc.Name() // e.g., "long/path/name/mypkg.(*MyType).(long/path/name/mypkg.myMethod)-fm" // Method closures have a "-fm" suffix. fullName = strings.TrimSuffix(fullName, "-fm") var name ...
go
{ "resource": "" }
q177807
PointerOf
test
func PointerOf(v reflect.Value) Pointer { // The proper representation of a pointer is unsafe.Pointer, // which is necessary if the GC ever uses a moving collector. return Pointer{unsafe.Pointer(v.Pointer()), v.Type()} }
go
{ "resource": "" }
q177808
String
test
func (es EditScript) String() string { b := make([]byte, len(es)) for i, e := range es { switch e { case Identity: b[i] = '.' case UniqueX: b[i] = 'X' case UniqueY: b[i] = 'Y' case Modified: b[i] = 'M' default: panic("invalid edit-type") } } return string(b) }
go
{ "resource": "" }
q177809
stats
test
func (es EditScript) stats() (s struct{ NI, NX, NY, NM int }) { for _, e := range es { switch e { case Identity: s.NI++ case UniqueX: s.NX++ case UniqueY: s.NY++ case Modified: s.NM++ default: panic("invalid edit-type") } } return }
go
{ "resource": "" }
q177810
connect
test
func (p *path) connect(dst point, f EqualFunc) { if p.dir > 0 { // Connect in forward direction. for dst.X > p.X && dst.Y > p.Y { switch r := f(p.X, p.Y); { case r.Equal(): p.append(Identity) case r.Similar(): p.append(Modified) case dst.X-p.X >= dst.Y-p.Y: p.append(UniqueX) default: ...
go
{ "resource": "" }
q177811
EquateNaNs
test
func EquateNaNs() cmp.Option { return cmp.Options{ cmp.FilterValues(areNaNsF64s, cmp.Comparer(equateAlways)), cmp.FilterValues(areNaNsF32s, cmp.Comparer(equateAlways)), } }
go
{ "resource": "" }
q177812
Index
test
func (pa Path) Index(i int) PathStep { if i < 0 { i = len(pa) + i } if i < 0 || i >= len(pa) { return pathStep{} } return pa[i] }
go
{ "resource": "" }
q177813
Key
test
func (si SliceIndex) Key() int { if si.xkey != si.ykey { return -1 } return si.xkey }
go
{ "resource": "" }
q177814
String
test
func (r *defaultReporter) String() string { assert(r.root != nil && r.curr == nil) if r.root.NumDiff == 0 { return "" } return formatOptions{}.FormatDiff(r.root).String() }
go
{ "resource": "" }
q177815
FormatType
test
func (opts formatOptions) FormatType(t reflect.Type, s textNode) textNode { // Check whether to emit the type or not. switch opts.TypeMode { case autoType: switch t.Kind() { case reflect.Struct, reflect.Slice, reflect.Array, reflect.Map: if s.Equal(textNil) { return s } default: return s } case...
go
{ "resource": "" }
q177816
formatMapKey
test
func formatMapKey(v reflect.Value) string { var opts formatOptions opts.TypeMode = elideType opts.AvoidStringer = true opts.ShallowPointers = true s := opts.FormatValue(v, visitedPointers{}).String() return strings.TrimSpace(s) }
go
{ "resource": "" }
q177817
formatString
test
func formatString(s string) string { // Use quoted string if it the same length as a raw string literal. // Otherwise, attempt to use the raw string form. qs := strconv.Quote(s) if len(qs) == 1+len(s)+1 { return qs } // Disallow newlines to ensure output is a single line. // Only allow printable runes for rea...
go
{ "resource": "" }
q177818
formatHex
test
func formatHex(u uint64) string { var f string switch { case u <= 0xff: f = "0x%02x" case u <= 0xffff: f = "0x%04x" case u <= 0xffffff: f = "0x%06x" case u <= 0xffffffff: f = "0x%08x" case u <= 0xffffffffff: f = "0x%010x" case u <= 0xffffffffffff: f = "0x%012x" case u <= 0xffffffffffffff: f = "0x...
go
{ "resource": "" }
q177819
formatPointer
test
func formatPointer(v reflect.Value) string { p := v.Pointer() if flags.Deterministic { p = 0xdeadf00f // Only used for stable testing purposes } return fmt.Sprintf("⟪0x%x⟫", p) }
go
{ "resource": "" }
q177820
Visit
test
func (m visitedPointers) Visit(v reflect.Value) bool { p := value.PointerOf(v) _, visited := m[p] m[p] = struct{}{} return visited }
go
{ "resource": "" }
q177821
retrieveUnexportedField
test
func retrieveUnexportedField(v reflect.Value, f reflect.StructField) reflect.Value { return reflect.NewAt(f.Type, unsafe.Pointer(v.UnsafeAddr()+f.Offset)).Elem() }
go
{ "resource": "" }
q177822
insert
test
func (ft *fieldTree) insert(cname []string) { if ft.sub == nil { ft.sub = make(map[string]fieldTree) } if len(cname) == 0 { ft.ok = true return } sub := ft.sub[cname[0]] sub.insert(cname[1:]) ft.sub[cname[0]] = sub }
go
{ "resource": "" }
q177823
matchPrefix
test
func (ft fieldTree) matchPrefix(p cmp.Path) bool { for _, ps := range p { switch ps := ps.(type) { case cmp.StructField: ft = ft.sub[ps.Name()] if ft.ok { return true } if len(ft.sub) == 0 { return false } case cmp.Indirect: default: return false } } return false }
go
{ "resource": "" }
q177824
canonicalName
test
func canonicalName(t reflect.Type, sel string) ([]string, error) { var name string sel = strings.TrimPrefix(sel, ".") if sel == "" { return nil, fmt.Errorf("name must not be empty") } if i := strings.IndexByte(sel, '.'); i < 0 { name, sel = sel, "" } else { name, sel = sel[:i], sel[i:] } // Type must be ...
go
{ "resource": "" }
q177825
FilterPath
test
func FilterPath(f func(Path) bool, opt Option) Option { if f == nil { panic("invalid path filter function") } if opt := normalizeOption(opt); opt != nil { return &pathFilter{fnc: f, opt: opt} } return nil }
go
{ "resource": "" }
q177826
normalizeOption
test
func normalizeOption(src Option) Option { switch opts := flattenOptions(nil, Options{src}); len(opts) { case 0: return nil case 1: return opts[0] default: return opts } }
go
{ "resource": "" }
q177827
flattenOptions
test
func flattenOptions(dst, src Options) Options { for _, opt := range src { switch opt := opt.(type) { case nil: continue case Options: dst = flattenOptions(dst, opt) case coreOption: dst = append(dst, opt) default: panic(fmt.Sprintf("invalid option type: %T", opt)) } } return dst }
go
{ "resource": "" }
q177828
CanFormatDiffSlice
test
func (opts formatOptions) CanFormatDiffSlice(v *valueNode) bool { switch { case opts.DiffMode != diffUnknown: return false // Must be formatting in diff mode case v.NumDiff == 0: return false // No differences detected case v.NumIgnored+v.NumCompared+v.NumTransformed > 0: // TODO: Handle the case where someon...
go
{ "resource": "" }
q177829
formatASCII
test
func formatASCII(s string) string { b := bytes.Repeat([]byte{'.'}, len(s)) for i := 0; i < len(s); i++ { if ' ' <= s[i] && s[i] <= '~' { b[i] = s[i] } } return string(b) }
go
{ "resource": "" }
q177830
coalesceAdjacentEdits
test
func coalesceAdjacentEdits(name string, es diff.EditScript) (groups []diffStats) { var prevCase int // Arbitrary index into which case last occurred lastStats := func(i int) *diffStats { if prevCase != i { groups = append(groups, diffStats{Name: name}) prevCase = i } return &groups[len(groups)-1] } for ...
go
{ "resource": "" }
q177831
SortKeys
test
func SortKeys(vs []reflect.Value) []reflect.Value { if len(vs) == 0 { return vs } // Sort the map keys. sort.Slice(vs, func(i, j int) bool { return isLess(vs[i], vs[j]) }) // Deduplicate keys (fails for NaNs). vs2 := vs[:1] for _, v := range vs[1:] { if isLess(vs2[len(vs2)-1], v) { vs2 = append(vs2, v) ...
go
{ "resource": "" }
q177832
FormatDiff
test
func (opts formatOptions) FormatDiff(v *valueNode) textNode { // Check whether we have specialized formatting for this node. // This is not necessary, but helpful for producing more readable outputs. if opts.CanFormatDiffSlice(v) { return opts.FormatDiffSlice(v) } // For leaf nodes, format the value based on th...
go
{ "resource": "" }
q177833
coalesceAdjacentRecords
test
func coalesceAdjacentRecords(name string, recs []reportRecord) (groups []diffStats) { var prevCase int // Arbitrary index into which case last occurred lastStats := func(i int) *diffStats { if prevCase != i { groups = append(groups, diffStats{Name: name}) prevCase = i } return &groups[len(groups)-1] } f...
go
{ "resource": "" }
q177834
Diff
test
func Diff(x, y interface{}, opts ...Option) string { r := new(defaultReporter) eq := Equal(x, y, Options(opts), Reporter(r)) d := r.String() if (d == "") != eq { panic("inconsistent difference and equality results") } return d }
go
{ "resource": "" }
q177835
statelessCompare
test
func (s *state) statelessCompare(step PathStep) diff.Result { // We do not save and restore the curPath because all of the compareX // methods should properly push and pop from the path. // It is an implementation bug if the contents of curPath differs from // when calling this function to when returning from it. ...
go
{ "resource": "" }
q177836
sanitizeValue
test
func sanitizeValue(v reflect.Value, t reflect.Type) reflect.Value { // TODO(dsnet): Workaround for reflect bug (https://golang.org/issue/22143). if !flags.AtLeastGo110 { if v.Kind() == reflect.Interface && v.IsNil() && v.Type() != t { return reflect.New(t).Elem() } } return v }
go
{ "resource": "" }
q177837
Check
test
func (rc *recChecker) Check(p Path) { const minLen = 1 << 16 if rc.next == 0 { rc.next = minLen } if len(p) < rc.next { return } rc.next <<= 1 // Check whether the same transformer has appeared at least twice. var ss []string m := map[Option]int{} for _, ps := range p { if t, ok := ps.(Transform); ok {...
go
{ "resource": "" }
q177838
makeAddressable
test
func makeAddressable(v reflect.Value) reflect.Value { if v.CanAddr() { return v } vc := reflect.New(v.Type()).Elem() vc.Set(v) return vc }
go
{ "resource": "" }
q177839
Marshal
test
func (lf Field) Marshal(visitor Encoder) { switch lf.fieldType { case stringType: visitor.EmitString(lf.key, lf.stringVal) case boolType: visitor.EmitBool(lf.key, lf.numericVal != 0) case intType: visitor.EmitInt(lf.key, int(lf.numericVal)) case int32Type: visitor.EmitInt32(lf.key, int32(lf.numericVal)) c...
go
{ "resource": "" }
q177840
String
test
func (lf Field) String() string { return fmt.Sprint(lf.key, ":", lf.Value()) }
go
{ "resource": "" }
q177841
Set
test
func (t Tag) Set(s Span) { s.SetTag(t.Key, t.Value) }
go
{ "resource": "" }
q177842
Inject
test
func (t *TextMapPropagator) Inject(spanContext MockSpanContext, carrier interface{}) error { writer, ok := carrier.(opentracing.TextMapWriter) if !ok { return opentracing.ErrInvalidCarrier } // Ids: writer.Set(mockTextMapIdsPrefix+"traceid", strconv.Itoa(spanContext.TraceID)) writer.Set(mockTextMapIdsPrefix+"sp...
go
{ "resource": "" }
q177843
Extract
test
func (t *TextMapPropagator) Extract(carrier interface{}) (MockSpanContext, error) { reader, ok := carrier.(opentracing.TextMapReader) if !ok { return emptyContext, opentracing.ErrInvalidCarrier } rval := MockSpanContext{0, 0, true, nil} err := reader.ForeachKey(func(key, val string) error { lowerKey := strings...
go
{ "resource": "" }
q177844
ToLogRecord
test
func (ld *LogData) ToLogRecord() LogRecord { var literalTimestamp time.Time if ld.Timestamp.IsZero() { literalTimestamp = time.Now() } else { literalTimestamp = ld.Timestamp } rval := LogRecord{ Timestamp: literalTimestamp, } if ld.Payload == nil { rval.Fields = []log.Field{ log.String("event", ld.Eve...
go
{ "resource": "" }
q177845
New
test
func New() *MockTracer { t := &MockTracer{ finishedSpans: []*MockSpan{}, injectors: make(map[interface{}]Injector), extractors: make(map[interface{}]Extractor), } // register default injectors/extractors textPropagator := new(TextMapPropagator) t.RegisterInjector(opentracing.TextMap, textPropagator) ...
go
{ "resource": "" }
q177846
StartSpan
test
func (t *MockTracer) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span { sso := opentracing.StartSpanOptions{} for _, o := range opts { o.Apply(&sso) } return newMockSpan(t, operationName, sso) }
go
{ "resource": "" }
q177847
RegisterInjector
test
func (t *MockTracer) RegisterInjector(format interface{}, injector Injector) { t.injectors[format] = injector }
go
{ "resource": "" }
q177848
RegisterExtractor
test
func (t *MockTracer) RegisterExtractor(format interface{}, extractor Extractor) { t.extractors[format] = extractor }
go
{ "resource": "" }
q177849
Inject
test
func (t *MockTracer) Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error { spanContext, ok := sm.(MockSpanContext) if !ok { return opentracing.ErrInvalidCarrier } injector, ok := t.injectors[format] if !ok { return opentracing.ErrUnsupportedFormat } return injector.Inject(spanCo...
go
{ "resource": "" }
q177850
Extract
test
func (t *MockTracer) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error) { extractor, ok := t.extractors[format] if !ok { return nil, opentracing.ErrUnsupportedFormat } return extractor.Extract(carrier) }
go
{ "resource": "" }
q177851
ContextWithSpan
test
func ContextWithSpan(ctx context.Context, span Span) context.Context { return context.WithValue(ctx, activeSpanKey, span) }
go
{ "resource": "" }
q177852
Set
test
func (tag uint32TagName) Set(span opentracing.Span, value uint32) { span.SetTag(string(tag), value) }
go
{ "resource": "" }
q177853
Set
test
func (tag uint16TagName) Set(span opentracing.Span, value uint16) { span.SetTag(string(tag), value) }
go
{ "resource": "" }
q177854
Set
test
func (tag boolTagName) Set(span opentracing.Span, value bool) { span.SetTag(string(tag), value) }
go
{ "resource": "" }
q177855
SetString
test
func (tag ipv4Tag) SetString(span opentracing.Span, value string) { span.SetTag(string(tag), value) }
go
{ "resource": "" }
q177856
EmitString
test
func (m *MockKeyValue) EmitString(key, value string) { m.Key = key m.ValueKind = reflect.TypeOf(value).Kind() m.ValueString = fmt.Sprint(value) }
go
{ "resource": "" }
q177857
EmitLazyLogger
test
func (m *MockKeyValue) EmitLazyLogger(value log.LazyLogger) { var meta MockKeyValue value(&meta) m.Key = meta.Key m.ValueKind = meta.ValueKind m.ValueString = meta.ValueString }
go
{ "resource": "" }
q177858
RunAPIChecks
test
func RunAPIChecks( t *testing.T, newTracer func() (tracer opentracing.Tracer, closer func()), opts ...APICheckOption, ) { s := &APICheckSuite{newTracer: newTracer} for _, opt := range opts { opt(s) } suite.Run(t, s) }
go
{ "resource": "" }
q177859
CheckBaggageValues
test
func CheckBaggageValues(val bool) APICheckOption { return func(s *APICheckSuite) { s.opts.CheckBaggageValues = val } }
go
{ "resource": "" }
q177860
CheckExtract
test
func CheckExtract(val bool) APICheckOption { return func(s *APICheckSuite) { s.opts.CheckExtract = val } }
go
{ "resource": "" }
q177861
CheckInject
test
func CheckInject(val bool) APICheckOption { return func(s *APICheckSuite) { s.opts.CheckInject = val } }
go
{ "resource": "" }
q177862
CheckEverything
test
func CheckEverything() APICheckOption { return func(s *APICheckSuite) { s.opts.CheckBaggageValues = true s.opts.CheckExtract = true s.opts.CheckInject = true } }
go
{ "resource": "" }
q177863
UseProbe
test
func UseProbe(probe APICheckProbe) APICheckOption { return func(s *APICheckSuite) { s.opts.Probe = probe } }
go
{ "resource": "" }
q177864
WithBaggageItem
test
func (c MockSpanContext) WithBaggageItem(key, value string) MockSpanContext { var newBaggage map[string]string if c.Baggage == nil { newBaggage = map[string]string{key: value} } else { newBaggage = make(map[string]string, len(c.Baggage)+1) for k, v := range c.Baggage { newBaggage[k] = v } newBaggage[key...
go
{ "resource": "" }
q177865
Tags
test
func (s *MockSpan) Tags() map[string]interface{} { s.RLock() defer s.RUnlock() tags := make(map[string]interface{}) for k, v := range s.tags { tags[k] = v } return tags }
go
{ "resource": "" }
q177866
Tag
test
func (s *MockSpan) Tag(k string) interface{} { s.RLock() defer s.RUnlock() return s.tags[k] }
go
{ "resource": "" }
q177867
Logs
test
func (s *MockSpan) Logs() []MockLogRecord { s.RLock() defer s.RUnlock() logs := make([]MockLogRecord, len(s.logs)) copy(logs, s.logs) return logs }
go
{ "resource": "" }
q177868
Context
test
func (s *MockSpan) Context() opentracing.SpanContext { s.Lock() defer s.Unlock() return s.SpanContext }
go
{ "resource": "" }
q177869
SetTag
test
func (s *MockSpan) SetTag(key string, value interface{}) opentracing.Span { s.Lock() defer s.Unlock() if key == string(ext.SamplingPriority) { if v, ok := value.(uint16); ok { s.SpanContext.Sampled = v > 0 return s } if v, ok := value.(int); ok { s.SpanContext.Sampled = v > 0 return s } } s.tag...
go
{ "resource": "" }
q177870
SetBaggageItem
test
func (s *MockSpan) SetBaggageItem(key, val string) opentracing.Span { s.Lock() defer s.Unlock() s.SpanContext = s.SpanContext.WithBaggageItem(key, val) return s }
go
{ "resource": "" }
q177871
BaggageItem
test
func (s *MockSpan) BaggageItem(key string) string { s.RLock() defer s.RUnlock() return s.SpanContext.Baggage[key] }
go
{ "resource": "" }
q177872
Finish
test
func (s *MockSpan) Finish() { s.Lock() s.FinishTime = time.Now() s.Unlock() s.tracer.recordSpan(s) }
go
{ "resource": "" }
q177873
FinishWithOptions
test
func (s *MockSpan) FinishWithOptions(opts opentracing.FinishOptions) { s.Lock() s.FinishTime = opts.FinishTime s.Unlock() // Handle any late-bound LogRecords. for _, lr := range opts.LogRecords { s.logFieldsWithTimestamp(lr.Timestamp, lr.Fields...) } // Handle (deprecated) BulkLogData. for _, ld := range opt...
go
{ "resource": "" }
q177874
String
test
func (s *MockSpan) String() string { return fmt.Sprintf( "traceId=%d, spanId=%d, parentId=%d, sampled=%t, name=%s", s.SpanContext.TraceID, s.SpanContext.SpanID, s.ParentID, s.SpanContext.Sampled, s.OperationName) }
go
{ "resource": "" }
q177875
LogFields
test
func (s *MockSpan) LogFields(fields ...log.Field) { s.logFieldsWithTimestamp(time.Now(), fields...) }
go
{ "resource": "" }
q177876
logFieldsWithTimestamp
test
func (s *MockSpan) logFieldsWithTimestamp(ts time.Time, fields ...log.Field) { lr := MockLogRecord{ Timestamp: ts, Fields: make([]MockKeyValue, len(fields)), } for i, f := range fields { outField := &(lr.Fields[i]) f.Marshal(outField) } s.Lock() defer s.Unlock() s.logs = append(s.logs, lr) }
go
{ "resource": "" }
q177877
LogKV
test
func (s *MockSpan) LogKV(keyValues ...interface{}) { if len(keyValues)%2 != 0 { s.LogFields(log.Error(fmt.Errorf("Non-even keyValues len: %v", len(keyValues)))) return } fields, err := log.InterleavedKVToFields(keyValues...) if err != nil { s.LogFields(log.Error(err), log.String("function", "LogKV")) return...
go
{ "resource": "" }
q177878
LogEvent
test
func (s *MockSpan) LogEvent(event string) { s.LogFields(log.String("event", event)) }
go
{ "resource": "" }
q177879
LogEventWithPayload
test
func (s *MockSpan) LogEventWithPayload(event string, payload interface{}) { s.LogFields(log.String("event", event), log.Object("payload", payload)) }
go
{ "resource": "" }
q177880
SetOperationName
test
func (s *MockSpan) SetOperationName(operationName string) opentracing.Span { s.Lock() defer s.Unlock() s.OperationName = operationName return s }
go
{ "resource": "" }
q177881
registriesDirPath
test
func registriesDirPath(sys *types.SystemContext) string { if sys != nil { if sys.RegistriesDirPath != "" { return sys.RegistriesDirPath } if sys.RootForImplicitAbsolutePaths != "" { return filepath.Join(sys.RootForImplicitAbsolutePaths, systemRegistriesDirPath) } } return systemRegistriesDirPath }
go
{ "resource": "" }
q177882
loadAndMergeConfig
test
func loadAndMergeConfig(dirPath string) (*registryConfiguration, error) { mergedConfig := registryConfiguration{Docker: map[string]registryNamespace{}} dockerDefaultMergedFrom := "" nsMergedFrom := map[string]string{} dir, err := os.Open(dirPath) if err != nil { if os.IsNotExist(err) { return &mergedConfig, ...
go
{ "resource": "" }
q177883
ParseReference
test
func ParseReference(ref string) (types.ImageReference, error) { r, err := reference.ParseNormalizedNamed(ref) if err != nil { return nil, errors.Wrapf(err, "failed to parse image reference %q", ref) } tagged, ok := r.(reference.NamedTagged) if !ok { return nil, errors.Errorf("invalid image reference %s, expect...
go
{ "resource": "" }
q177884
NewReference
test
func NewReference(dockerRef reference.NamedTagged) (types.ImageReference, error) { r := strings.SplitN(reference.Path(dockerRef), "/", 3) if len(r) != 2 { return nil, errors.Errorf("invalid image reference: %s, expected format: 'hostname/namespace/stream:tag'", reference.FamiliarString(dockerRef)) } return ope...
go
{ "resource": "" }
q177885
CheckAuth
test
func CheckAuth(ctx context.Context, sys *types.SystemContext, username, password, registry string) error { client, err := newDockerClient(sys, registry, registry) if err != nil { return errors.Wrapf(err, "error creating new docker client") } client.username = username client.password = password resp, err := cl...
go
{ "resource": "" }
q177886
doHTTP
test
func (c *dockerClient) doHTTP(req *http.Request) (*http.Response, error) { tr := tlsclientconfig.NewTransport() tr.TLSClientConfig = c.tlsClientConfig httpClient := &http.Client{Transport: tr} return httpClient.Do(req) }
go
{ "resource": "" }
q177887
detectPropertiesHelper
test
func (c *dockerClient) detectPropertiesHelper(ctx context.Context) error { if c.scheme != "" { return nil } // We overwrite the TLS clients `InsecureSkipVerify` only if explicitly // specified by the system context if c.sys != nil && c.sys.DockerInsecureSkipTLSVerify != types.OptionalBoolUndefined { c.tlsClie...
go
{ "resource": "" }
q177888
detectProperties
test
func (c *dockerClient) detectProperties(ctx context.Context) error { c.detectPropertiesOnce.Do(func() { c.detectPropertiesError = c.detectPropertiesHelper(ctx) }) return c.detectPropertiesError }
go
{ "resource": "" }
q177889
getExtensionsSignatures
test
func (c *dockerClient) getExtensionsSignatures(ctx context.Context, ref dockerReference, manifestDigest digest.Digest) (*extensionSignatureList, error) { path := fmt.Sprintf(extensionsSignaturePath, reference.Path(ref.ref), manifestDigest) res, err := c.makeRequest(ctx, "GET", path, nil, nil, v2Auth, nil) if err != ...
go
{ "resource": "" }
q177890
NewTransport
test
func NewTransport() *http.Transport { direct := &net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, DualStack: true, } tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: direct.Dial, TLSHandshakeTimeout: 10 * time.Second, // TODO(dmcgowan): Ca...
go
{ "resource": "" }
q177891
readRegistryConf
test
func readRegistryConf(sys *types.SystemContext) ([]byte, error) { return ioutil.ReadFile(RegistriesConfPath(sys)) }
go
{ "resource": "" }
q177892
GetRegistries
test
func GetRegistries(sys *types.SystemContext) ([]string, error) { config, err := loadRegistryConf(sys) if err != nil { return nil, err } return config.Registries.Search.Registries, nil }
go
{ "resource": "" }
q177893
GetInsecureRegistries
test
func GetInsecureRegistries(sys *types.SystemContext) ([]string, error) { config, err := loadRegistryConf(sys) if err != nil { return nil, err } return config.Registries.Insecure.Registries, nil }
go
{ "resource": "" }
q177894
RegistriesConfPath
test
func RegistriesConfPath(ctx *types.SystemContext) string { path := systemRegistriesConfPath if ctx != nil { if ctx.SystemRegistriesConfPath != "" { path = ctx.SystemRegistriesConfPath } else if ctx.RootForImplicitAbsolutePaths != "" { path = filepath.Join(ctx.RootForImplicitAbsolutePaths, systemRegistriesCo...
go
{ "resource": "" }
q177895
NewOptionalBool
test
func NewOptionalBool(b bool) OptionalBool { o := OptionalBoolFalse if b == true { o = OptionalBoolTrue } return o }
go
{ "resource": "" }
q177896
changeState
test
func (pc *PolicyContext) changeState(expected, new policyContextState) error { if pc.state != expected { return errors.Errorf(`"Invalid PolicyContext state, expected "%s", found "%s"`, expected, pc.state) } pc.state = new return nil }
go
{ "resource": "" }
q177897
Destroy
test
func (pc *PolicyContext) Destroy() error { if err := pc.changeState(pcReady, pcDestroying); err != nil { return err } // FIXME: destroy return pc.changeState(pcDestroying, pcDestroyed) }
go
{ "resource": "" }
q177898
policyIdentityLogName
test
func policyIdentityLogName(ref types.ImageReference) string { return ref.Transport().Name() + ":" + ref.PolicyConfigurationIdentity() }
go
{ "resource": "" }
q177899
requirementsForImageRef
test
func (pc *PolicyContext) requirementsForImageRef(ref types.ImageReference) PolicyRequirements { // Do we have a PolicyTransportScopes for this transport? transportName := ref.Transport().Name() if transportScopes, ok := pc.Policy.Transports[transportName]; ok { // Look for a full match. identity := ref.PolicyCon...
go
{ "resource": "" }