GetInputConfigForString returns the input config for the input string.
( ctx context.Context, refParser RefParser, value string, )
| 538 | |
| 539 | // GetInputConfigForString returns the input config for the input string. |
| 540 | func 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 | |
| 579 | type getReadBucketCloserOptions struct { |
| 580 | noSearch bool |
nothing calls this directly
no test coverage detected
searching dependent graphs…