buftarget

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketTargeting

type BucketTargeting interface {
	// ControllingWorkpsace returns the information for the controlling workspace, if one was
	// found. If not found, then this will be nil.
	ControllingWorkspace() ControllingWorkspace
	// SubDirPath returns the input directory relative to the controlling workspace, if one
	// was found, otherwise it is relative to the root of the bucket
	SubDirPath() string
	// TargetPaths returns the target paths relative to the controlling workpsace, if one was
	// found, otherwise it is relative to the root of the bucket.
	TargetPaths() []string
	// TargetExcludePaths returns the target exclude paths relative to the controlling
	// workspace, if one is found, otherwise it is relative to the root of the bucket.
	TargetExcludePaths() []string
	// contains filtered or unexported methods
}

BucketTargeting provides targeting information for the bucket based on any controlling workspaces that have been found.

func NewBucketTargeting

func NewBucketTargeting(
	ctx context.Context,
	logger *zap.Logger,
	bucket storage.ReadBucket,
	subDirPath string,
	targetPaths []string,
	targetExcludePaths []string,
	terminateFunc TerminateFunc,
) (BucketTargeting, error)

NewBucketTargeting returns new targeting information for the given bucket, input dir, target paths, and target exclude paths.

The subDirPath, targetPaths, and targetExcludePaths are expected to be relative to the root of the bucket.

If a controlling workspace is found, the input dir, target paths, and target exclude paths are mapped as relative paths to the controlling workspace path. Otherwise, the input dir, target paths, and target exclude paths are returned as-is.

type ControllingWorkspace

type ControllingWorkspace interface {
	// Path of the controlling workspace. This is a normalized path, relative to the root of
	// the bucket the controlling workspace was found in. Semantically, this is where the v1
	// buf.work.yaml or v2 buf.yaml workspace configuration is located.
	Path() string
	// Returns a buf.work.yaml file that was found for the controlling workspace.
	// This is empty if we are retruning a buf.yaml.
	BufWorkYAMLFile() bufconfig.BufWorkYAMLFile
	// Returns a buf.yaml that was found for the controlling workspace.
	// This is empty if we are returning a buf.work.yaml.
	BufYAMLFile() bufconfig.BufYAMLFile
	// contains filtered or unexported methods
}

ControllingWorkspace is the information for the ControllingWorkspace.

func NewControllingWorkspace

func NewControllingWorkspace(
	path string,
	bufWorkYAMLFile bufconfig.BufWorkYAMLFile,
	bufYAMLFile bufconfig.BufYAMLFile,
) ControllingWorkspace

NewControllingWorkspace takes a path where the controlling workspace configuration is located and a workspace configuration file for the controlling workspace.

func TerminateAtControllingWorkspace

func TerminateAtControllingWorkspace(
	ctx context.Context,
	bucket storage.ReadBucket,
	prefix string,
	originalInputPath string,
) (ControllingWorkspace, error)

TerminateAtControllingWorkspace implements a TerminateFunc and returns controlling workspace if one is found at the given prefix.

func TerminateAtV1Module

func TerminateAtV1Module(
	ctx context.Context,
	bucket storage.ReadBucket,
	prefix string,
	originalInputPath string,
) (ControllingWorkspace, error)

TerminateAtV1Module is a special terminate func that returns a controlling workspace with a v1 module confiugration if found at the given prefix.

type TerminateFunc

type TerminateFunc func(
	ctx context.Context,
	bucket storage.ReadBucket,
	prefix string,
	originalInputPath string,
) (ControllingWorkspace, error)

TerminateFunc is a termination function.

Jump to

Keyboard shortcuts

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