importsource

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BlockImportFile   = "import.file"
	BlockImportString = "import.string"
	BlockImportHTTP   = "import.http"
	BlockImportGit    = "import.git"
)

Variables

View Source
var DefaultFileArguments = FileArguments{
	Type:          filedetector.DetectorFSNotify,
	PollFrequency: time.Minute,
}
View Source
var DefaultGitArguments = GitArguments{
	Revision:      "HEAD",
	PullFrequency: time.Minute,
}
View Source
var DefaultHTTPArguments = HTTPArguments{
	PollFrequency: 1 * time.Minute,
	PollTimeout:   10 * time.Second,
	Client:        common_config.DefaultHTTPClientConfig,
	Method:        http.MethodGet,
}

DefaultHTTPArguments holds default settings for HTTPArguments.

Functions

This section is empty.

Types

type FileArguments

type FileArguments struct {
	// Filename indicates the file to watch.
	Filename string `alloy:"filename,attr"`
	// Type indicates how to detect changes to the file.
	Type filedetector.Detector `alloy:"detector,attr,optional"`
	// PollFrequency determines the frequency to check for changes when Type is Poll.
	PollFrequency time.Duration `alloy:"poll_frequency,attr,optional"`
}

func (*FileArguments) SetToDefault

func (a *FileArguments) SetToDefault()

SetToDefault implements syntax.Defaulter.

type GitArguments

type GitArguments struct {
	Repository    string            `alloy:"repository,attr"`
	Revision      string            `alloy:"revision,attr,optional"`
	Path          string            `alloy:"path,attr"`
	PullFrequency time.Duration     `alloy:"pull_frequency,attr,optional"`
	GitAuthConfig vcs.GitAuthConfig `alloy:",squash"`
}

func (*GitArguments) SetToDefault

func (args *GitArguments) SetToDefault()

SetToDefault implements syntax.Defaulter.

type HTTPArguments

type HTTPArguments struct {
	URL           string        `alloy:"url,attr"`
	PollFrequency time.Duration `alloy:"poll_frequency,attr,optional"`
	PollTimeout   time.Duration `alloy:"poll_timeout,attr,optional"`

	Method  string            `alloy:"method,attr,optional"`
	Headers map[string]string `alloy:"headers,attr,optional"`
	Body    string            `alloy:"body,attr,optional"`

	Client common_config.HTTPClientConfig `alloy:"client,block,optional"`
}

HTTPArguments holds values which are used to configure the remote.http component.

func (*HTTPArguments) SetToDefault

func (args *HTTPArguments) SetToDefault()

SetToDefault implements syntax.Defaulter.

type ImportFile

type ImportFile struct {
	// contains filtered or unexported fields
}

ImportFile imports a module from a file or a folder.

func NewImportFile

func NewImportFile(managedOpts component.Options, eval *vm.Evaluator, onContentChange func(map[string]string)) *ImportFile

func (*ImportFile) CurrentHealth

func (im *ImportFile) CurrentHealth() component.Health

func (*ImportFile) Evaluate

func (im *ImportFile) Evaluate(scope *vm.Scope) error

func (*ImportFile) Run

func (im *ImportFile) Run(ctx context.Context) error

func (*ImportFile) SetEval

func (im *ImportFile) SetEval(eval *vm.Evaluator)

Update the evaluator.

type ImportGit

type ImportGit struct {
	// contains filtered or unexported fields
}

ImportGit imports a module from a git repository. There are currently no remote.git component, the logic is implemented here.

func NewImportGit

func NewImportGit(managedOpts component.Options, eval *vm.Evaluator, onContentChange func(map[string]string)) *ImportGit

func (*ImportGit) CurrentHealth

func (im *ImportGit) CurrentHealth() component.Health

CurrentHealth implements component.HealthComponent.

func (*ImportGit) Evaluate

func (im *ImportGit) Evaluate(scope *vm.Scope) error

func (*ImportGit) Run

func (im *ImportGit) Run(ctx context.Context) error

func (*ImportGit) SetEval

func (im *ImportGit) SetEval(eval *vm.Evaluator)

Update the evaluator.

func (*ImportGit) Update

func (im *ImportGit) Update(args component.Arguments) (err error)

Update implements component.Component. Only acknowledge the error from Update if it's not a vcs.UpdateFailedError; vcs.UpdateFailedError means that the Git repo exists, but we were unable to update it. It makes sense to retry on the next poll and it may succeed.

type ImportHTTP

type ImportHTTP struct {
	// contains filtered or unexported fields
}

ImportHTTP imports a module from a HTTP server via the remote.http component.

func NewImportHTTP

func NewImportHTTP(managedOpts component.Options, eval *vm.Evaluator, onContentChange func(map[string]string)) *ImportHTTP

func (*ImportHTTP) CurrentHealth

func (im *ImportHTTP) CurrentHealth() component.Health

func (*ImportHTTP) Evaluate

func (im *ImportHTTP) Evaluate(scope *vm.Scope) error

func (*ImportHTTP) Run

func (im *ImportHTTP) Run(ctx context.Context) error

func (*ImportHTTP) SetEval

func (im *ImportHTTP) SetEval(eval *vm.Evaluator)

Update the evaluator.

type ImportSource

type ImportSource interface {
	// Evaluate updates the arguments provided via the Alloy block.
	Evaluate(scope *vm.Scope) error
	// Run the underlying source to be updated when the content changes.
	Run(ctx context.Context) error
	// CurrentHealth returns the current Health status of the running source.
	CurrentHealth() component.Health
	// Update evaluator
	SetEval(eval *vm.Evaluator)
}

ImportSource retrieves a module from a source.

func NewImportSource

func NewImportSource(sourceType SourceType, managedOpts component.Options, eval *vm.Evaluator, onContentChange func(map[string]string)) ImportSource

NewImportSource creates a new ImportSource depending on the type. onContentChange is used by the source when it receives new content.

type ImportString

type ImportString struct {
	// contains filtered or unexported fields
}

ImportString imports a module from a string.

func NewImportString

func NewImportString(eval *vm.Evaluator, onContentChange func(map[string]string)) *ImportString

func (*ImportString) CurrentHealth

func (im *ImportString) CurrentHealth() component.Health

ImportString is always healthy

func (*ImportString) Evaluate

func (im *ImportString) Evaluate(scope *vm.Scope) error

func (*ImportString) Run

func (im *ImportString) Run(ctx context.Context) error

func (*ImportString) SetEval

func (im *ImportString) SetEval(eval *vm.Evaluator)

Update the evaluator.

type SourceType

type SourceType int
const (
	File SourceType = iota
	String
	Git
	HTTP
)

func GetSourceType

func GetSourceType(fullName string) SourceType

GetSourceType returns a SourceType matching a source name.

Jump to

Keyboard shortcuts

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