bufos

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2019 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package bufos provides abstractions to read and write images from an OS context.

This is primarily meant for the CLI tool, and isn't used in a service context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllFormatsToString

func AllFormatsToString() string

AllFormatsToString returns all format strings.

func ImageFormatsToString

func ImageFormatsToString() string

ImageFormatsToString returns image format strings.

func SourceFormatsToString

func SourceFormatsToString() string

SourceFormatsToString returns source format strings.

Types

type Env

type Env struct {
	// Image is the image to use.
	Image bufpb.Image
	// Resolver is the resolver to apply before printing paths or annotations.
	// Can be nil.
	Resolver bufbuild.ProtoFilePathResolver
	// Config is the config to use.
	Config *bufconfig.Config
}

Env is an environment.

type EnvReader

type EnvReader interface {
	// ReadEnv reads an environment.
	//
	// If specificFilePaths is empty, this builds all the files under Buf control.
	//
	// Note that includeImports will only be respected for Images if the image was
	// built with buf - if it was built with protoc, we have no way of detecting
	// what is and isn't an import.
	//
	// Note that includeSourceInfo will only be respected for Sources. We make
	// no modifications for Images.
	//
	// Annotations will be fixed per the resolver before returning.
	// If stdin is nil and this tries to read from stdin, returns user error.
	ReadEnv(
		ctx context.Context,
		stdin io.Reader,
		value string,
		configOverride string,
		specificFilePaths []string,
		specificFilePathsAllowNotExist bool,
		includeImports bool,
		includeSourceInfo bool,
	) (*Env, []*analysis.Annotation, error)
	// ReadSourceEnv reads an source environment.
	//
	// This is the same as ReadEnv but disallows image values and always builds.
	ReadSourceEnv(
		ctx context.Context,
		stdin io.Reader,
		value string,
		configOverride string,
		specificFilePaths []string,
		specificFilePathsAllowNotExist bool,
		includeImports bool,
		includeSourceInfo bool,
	) (*Env, []*analysis.Annotation, error)
	// ReadImageEnv reads an source environment.
	//
	// This is the same as ReadEnv but disallows source values and never builds.
	// specificFilePaths are always allowed to not exist.
	// TODO: add filter?
	ReadImageEnv(
		ctx context.Context,
		stdin io.Reader,
		value string,
		configOverride string,
		specificFilePaths []string,
		specificFilePathsAllowNotExist bool,
		includeImports bool,
	) (*Env, error)

	// ListFiles lists the files.
	ListFiles(
		ctx context.Context,
		stdin io.Reader,
		value string,
		configOverride string,
	) ([]string, error)

	// GetConfig gets the config.
	GetConfig(
		ctx context.Context,
		configOverride string,
	) (*bufconfig.Config, error)
}

EnvReader is an env reader.

func NewEnvReader

func NewEnvReader(
	logger *zap.Logger,
	segList *bytepool.SegList,
	httpClient *http.Client,
	configProvider bufconfig.Provider,
	buildHandler bufbuild.Handler,
	valueFlagName string,
	configOverrideFlagName string,
) EnvReader

NewEnvReader returns a new EnvReader.

type ImageWriter

type ImageWriter interface {
	// WriteImage writes the image to the value.
	//
	// The file must be an image format.
	// This is a no-np if value is the equivalent of /dev/null.
	WriteImage(
		ctx context.Context,
		stdout io.Writer,
		value string,
		asFileDescriptorSet bool,
		image bufpb.Image,
	) error
}

ImageWriter is an image writer.

func NewImageWriter

func NewImageWriter(
	logger *zap.Logger,
	valueFlagName string,
) ImageWriter

NewImageWriter returns a new ImageWriter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL