( ctx context.Context, imageOutput string, image bufimage.Image, options ...FunctionOption, )
| 667 | } |
| 668 | |
| 669 | func (c *controller) PutImage( |
| 670 | ctx context.Context, |
| 671 | imageOutput string, |
| 672 | image bufimage.Image, |
| 673 | options ...FunctionOption, |
| 674 | ) (retErr error) { |
| 675 | defer c.handleFileAnnotationSetRetError(&retErr) |
| 676 | functionOptions := newFunctionOptions(c) |
| 677 | for _, option := range options { |
| 678 | option(functionOptions) |
| 679 | } |
| 680 | // Must be messageRefParser NOT c.buffetchRefParser as a NewMessageRefParser |
| 681 | // defaults to a defaultMessageEncoding and not dir. |
| 682 | messageRefParser := buffetch.NewMessageRefParser(c.logger) |
| 683 | messageRef, err := messageRefParser.GetMessageRef(ctx, imageOutput) |
| 684 | if err != nil { |
| 685 | return err |
| 686 | } |
| 687 | // Stop short for performance. |
| 688 | if messageRef.IsNull() { |
| 689 | return nil |
| 690 | } |
| 691 | marshaler, err := newProtoencodingMarshaler(image, messageRef) |
| 692 | if err != nil { |
| 693 | return err |
| 694 | } |
| 695 | putImage, err := filterImage(image, functionOptions, false) |
| 696 | if err != nil { |
| 697 | return err |
| 698 | } |
| 699 | var putMessage proto.Message |
| 700 | if functionOptions.imageAsFileDescriptorSet { |
| 701 | putMessage = bufimage.ImageToFileDescriptorSet(putImage) |
| 702 | } else { |
| 703 | putMessage, err = bufimage.ImageToProtoImage(putImage) |
| 704 | if err != nil { |
| 705 | return err |
| 706 | } |
| 707 | } |
| 708 | data, err := marshaler.Marshal(putMessage) |
| 709 | if err != nil { |
| 710 | return err |
| 711 | } |
| 712 | writeCloser, err := c.buffetchWriter.PutMessageFile(ctx, c.container, messageRef) |
| 713 | if err != nil { |
| 714 | return err |
| 715 | } |
| 716 | defer func() { |
| 717 | retErr = errors.Join(retErr, writeCloser.Close()) |
| 718 | }() |
| 719 | _, err = writeCloser.Write(data) |
| 720 | return err |
| 721 | } |
| 722 | |
| 723 | func (c *controller) GetMessage( |
| 724 | ctx context.Context, |
nothing calls this directly
no test coverage detected