MCPcopy Create free account
hub / github.com/bufbuild/buf / GetInputConfigForString

Function GetInputConfigForString

private/buf/buffetch/buffetch.go:540–577  ·  view source on GitHub ↗

GetInputConfigForString returns the input config for the input string.

(
	ctx context.Context,
	refParser RefParser,
	value string,
)

Source from the content-addressed store, hash-verified

538
539// GetInputConfigForString returns the input config for the input string.
540func GetInputConfigForString(
541 ctx context.Context,
542 refParser RefParser,
543 value string,
544) (bufconfig.InputConfig, error) {
545 ref, err := refParser.GetRef(ctx, value)
546 if err != nil {
547 return nil, err
548 }
549 switch t := ref.(type) {
550 case MessageRef:
551 switch t.MessageEncoding() {
552 case MessageEncodingBinpb:
553 return bufconfig.NewBinaryImageInputConfig(
554 t.Path(),
555 t.internalSingleRef().CompressionType().String(),
556 )
557 case MessageEncodingJSON:
558 return bufconfig.NewJSONImageInputConfig(
559 t.Path(),
560 t.internalSingleRef().CompressionType().String(),
561 )
562 case MessageEncodingTxtpb:
563 return bufconfig.NewTextImageInputConfig(
564 t.Path(),
565 t.internalSingleRef().CompressionType().String(),
566 )
567 case MessageEncodingYAML:
568 return bufconfig.NewYAMLImageInputConfig(
569 t.Path(),
570 t.internalSingleRef().CompressionType().String(),
571 )
572 default:
573 return nil, fmt.Errorf("unknown encoding: %v", t.MessageEncoding())
574 }
575 }
576 return internal.GetInputConfigForRef(ref.internalRef(), value)
577}
578
579type getReadBucketCloserOptions struct {
580 noSearch bool

Callers

nothing calls this directly

Calls 12

NewJSONImageInputConfigFunction · 0.92
NewTextImageInputConfigFunction · 0.92
NewYAMLImageInputConfigFunction · 0.92
GetInputConfigForRefFunction · 0.92
GetRefMethod · 0.65
MessageEncodingMethod · 0.65
PathMethod · 0.65
StringMethod · 0.65
CompressionTypeMethod · 0.65
internalSingleRefMethod · 0.65
internalRefMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…