bufos

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2020 License: Apache-2.0 Imports: 31 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.
	//
	// Validated.
	Image *imagev1beta1.Image
	// Resolver is the resolver to apply before printing paths or FileAnnotations.
	// Can be nil.
	Resolver bufbuild.ProtoRealFilePathResolver
	// 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.
	//
	// FileAnnotations 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,
		getenv func(string) string,
		value string,
		configOverride string,
		specificFilePaths []string,
		specificFilePathsAllowNotExist bool,
		includeImports bool,
		includeSourceInfo bool,
	) (*Env, []*filev1beta1.FileAnnotation, 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,
		getenv func(string) string,
		value string,
		configOverride string,
		specificFilePaths []string,
		specificFilePathsAllowNotExist bool,
		includeImports bool,
		includeSourceInfo bool,
	) (*Env, []*filev1beta1.FileAnnotation, error)
	// ReadImageEnv reads an image environment.
	//
	// This is the same as ReadEnv but disallows source values and never builds.
	ReadImageEnv(
		ctx context.Context,
		stdin io.Reader,
		getenv func(string) string,
		value string,
		configOverride string,
		specificFilePaths []string,
		specificFilePathsAllowNotExist bool,
		includeImports bool,
	) (*Env, error)

	// ListFiles lists the files.
	ListFiles(
		ctx context.Context,
		stdin io.Reader,
		getenv func(string) string,
		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,
	httpClient *http.Client,
	configProvider bufconfig.Provider,
	buildHandler bufbuild.Handler,
	valueFlagName string,
	configOverrideFlagName string,
	httpsUsernameEnvKey string,
	httpsPasswordEnvKey string,
	sshKeyFileEnvKey string,
	sshKeyPassphraseEnvKey string,
	sshKnownHostsFilesEnvKey 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.
	//
	// Validates the image before writing.
	WriteImage(
		ctx context.Context,
		stdout io.Writer,
		value string,
		asFileDescriptorSet bool,
		image *imagev1beta1.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