Help us shape the future of Go! Take the 2026 Go Developer Survey

datasource

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package datasource has the packages and logic that Waypoint uses for sourcing data for remote runs.

Index

Constants

This section is empty.

Variables

View Source
var (
	// FromString maps a string key to a source implementation.
	FromString = map[string]func() Sourcer{
		"git":   newGitSource,
		"local": newLocalSource,
	}

	// FromType maps a server DataSource type to a source implementation.
	FromType = map[reflect.Type]func() Sourcer{
		reflect.TypeOf((*pb.Job_DataSource_Git)(nil)):   newGitSource,
		reflect.TypeOf((*pb.Job_DataSource_Local)(nil)): newLocalSource,
	}
)

Functions

This section is empty.

Types

type GitSource

type GitSource struct{}

func (*GitSource) Changes added in v0.3.0

func (s *GitSource) Changes(
	ctx context.Context,
	log hclog.Logger,
	ui terminal.UI,
	raw *pb.Job_DataSource,
	current *pb.Job_DataSource_Ref,
	tempDir string,
) (*pb.Job_DataSource_Ref, bool, error)

func (*GitSource) Get

func (s *GitSource) Get(
	ctx context.Context,
	log hclog.Logger,
	ui terminal.UI,
	raw *pb.Job_DataSource,
	baseDir string,
) (string, *pb.Job_DataSource_Ref, func() error, error)

func (*GitSource) Override

func (s *GitSource) Override(raw *pb.Job_DataSource, m map[string]string) error

func (*GitSource) ProjectSource

func (s *GitSource) ProjectSource(body hcl.Body, ctx *hcl.EvalContext) (*pb.Job_DataSource, error)

func (*GitSource) RefToOverride added in v0.3.0

func (s *GitSource) RefToOverride(ref *pb.Job_DataSource_Ref) (map[string]string, error)

type LocalSource

type LocalSource struct{}

func (*LocalSource) Changes added in v0.3.0

func (s *LocalSource) Changes(
	ctx context.Context,
	log hclog.Logger,
	ui terminal.UI,
	source *pb.Job_DataSource,
	current *pb.Job_DataSource_Ref,
	tempDir string,
) (*pb.Job_DataSource_Ref, bool, error)

func (*LocalSource) Get

func (s *LocalSource) Get(
	ctx context.Context,
	log hclog.Logger,
	ui terminal.UI,
	raw *pb.Job_DataSource,
	baseDir string,
) (string, *pb.Job_DataSource_Ref, func() error, error)

func (*LocalSource) Override

func (s *LocalSource) Override(raw *pb.Job_DataSource, m map[string]string) error

func (*LocalSource) ProjectSource

func (s *LocalSource) ProjectSource(body hcl.Body, ctx *hcl.EvalContext) (*pb.Job_DataSource, error)

func (*LocalSource) RefToOverride added in v0.3.0

func (s *LocalSource) RefToOverride(*pb.Job_DataSource_Ref) (map[string]string, error)

type Sourcer

type Sourcer interface {
	// ProjectSource translates the configuration into a default data
	// source for the project. This should also perform any validation
	// on the configuration.
	ProjectSource(hcl.Body, *hcl.EvalContext) (*pb.Job_DataSource, error)

	// Override reconfigures the given data source with the given overrides.
	Override(*pb.Job_DataSource, map[string]string) error

	// RefToOverride converts a ref to the override settings necessary
	// to use this ref with a job.
	RefToOverride(*pb.Job_DataSource_Ref) (map[string]string, error)

	// Get downloads the sourced data and returns the directory where
	// the data is stored, a cleanup function, and any errors that occurred.
	// The cleanup function may be nil.
	Get(
		ctx context.Context,
		log hclog.Logger,
		ui terminal.UI,
		source *pb.Job_DataSource,
		baseDir string,
	) (string, *pb.Job_DataSource_Ref, func() error, error)

	// Changes is called to check a source for changes. The "current" argument
	// contains the current ref in use by the default workspace. The return
	// value should be non-nil only if there is a new ref to set.
	//
	// The boolean return value is the "ignore" boolean: if this is true,
	// there IS a change detected in the exact ref, but it should be ignored.
	// In this scenario, it means that the ref change doesn't result in a
	// triggerable-change (i.e. maybe the files didn't change at all).
	//
	// NOTE(mitchellh): I'm fairly sure that this will change when we
	// introduce per-workspace refs and stuff but given this is all internal
	// we're going with the crufty-but-works approach first.
	Changes(
		ctx context.Context,
		log hclog.Logger,
		ui terminal.UI,
		source *pb.Job_DataSource,
		current *pb.Job_DataSource_Ref,
		tempDir string,
	) (*pb.Job_DataSource_Ref, bool, error)
}

Sourcer is implemented by all data sourcers and is responsible for sourcing data, configuring projects, determining the default values for operations, and more.

Jump to

Keyboard shortcuts

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