module_loader

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DownloadModulesDirectoryName = "modules"
)

Variables

View Source
var Pattern = regexp.MustCompile("^[A-Za-z_-]?[\\w\\-_@.]+$")

Functions

func IsYamlFile

func IsYamlFile(entry os.DirEntry) bool

Types

type GitHubRegistryModuleLoader

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

GitHubRegistryModuleLoader Load the module from GitHub's Registry

func (*GitHubRegistryModuleLoader) Load

func (*GitHubRegistryModuleLoader) Name

func (*GitHubRegistryModuleLoader) Options

type GitHubRegistryModuleLoaderOptions

type GitHubRegistryModuleLoaderOptions struct {
	*ModuleLoaderOptions

	// The full name of the Registry's repository
	RegistryRepoFullName string `json:"registry-repo-full-name" yaml:"registry-repo-full-name"`
}

GitHubRegistryModuleLoaderOptions Options when creating the GitHub Registry

type LocalDirectoryModuleLoader

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

LocalDirectoryModuleLoader Load the module from the local directory

func (*LocalDirectoryModuleLoader) Load

func (*LocalDirectoryModuleLoader) Name

func (*LocalDirectoryModuleLoader) Options

type LocalDirectoryModuleLoaderOptions

type LocalDirectoryModuleLoaderOptions struct {
	*ModuleLoaderOptions

	// Directory where the module resides Directory
	ModuleDirectory string `json:"module-directory" yaml:"module-directory"`
}

LocalDirectoryModuleLoaderOptions Option when loading modules from a local directory

func (*LocalDirectoryModuleLoaderOptions) BuildFullName

func (x *LocalDirectoryModuleLoaderOptions) BuildFullName() string

BuildFullName Gets the globally unique identity of the module

type ModuleLoader

type ModuleLoader[Options any] interface {

	// Name The name of the loader
	Name() ModuleLoaderType

	// Load Use this loader to load the module
	Load(ctx context.Context) (*module.Module, bool)

	Options() Options
}

ModuleLoader Module loader

type ModuleLoaderOptions

type ModuleLoaderOptions struct {

	// Where can I download the module
	Source string `json:"source" yaml:"source"`

	// Which version of which module to download
	Version string `json:"version" yaml:"version"`

	// What is the download path configured in the current system
	DownloadDirectory string `json:"download-directory" yaml:"download-directory"`

	// TODO Can be used to track download progress
	ProgressTracker getter.ProgressTracker

	// It's used to send information back in real time
	MessageChannel *message.Channel[*schema.Diagnostics] `json:"message-channel"`

	// How do I go from the root module to the current module
	DependenciesTree []string `json:"dependencies-tree" yaml:"dependencies-tree"`
}

ModuleLoaderOptions Options when loading the module

func (*ModuleLoaderOptions) DeepDependenciesTree

func (x *ModuleLoaderOptions) DeepDependenciesTree(source string) []string

DeepDependenciesTree The dependence goes deeper

type ModuleLoaderType

type ModuleLoaderType string
const (

	// ModuleLoaderTypeInvalid Default value if not set
	ModuleLoaderTypeInvalid ModuleLoaderType = ""

	// ModuleLoaderTypeS3Bucket Load modules from S3 bucket.s
	ModuleLoaderTypeS3Bucket ModuleLoaderType = "s3-bucket-module-loader"

	// ModuleLoaderTypeGitHubRegistry Load the module from GitHub's Registry
	ModuleLoaderTypeGitHubRegistry ModuleLoaderType = "github-registry-module-loader"

	// ModuleLoaderTypeLocalDirectory Load the module from the local directory
	ModuleLoaderTypeLocalDirectory ModuleLoaderType = "local-directory-module-loader"

	ModuleLoaderTypeURL ModuleLoaderType = "url-module-loader"
)

func NewModuleLoaderBySource

func NewModuleLoaderBySource(source string) ModuleLoaderType

NewModuleLoaderBySource Distributed to different module loaders based on load options

type S3BucketModuleLoader

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

func NewS3BucketModuleLoader

func NewS3BucketModuleLoader(options *S3BucketModuleLoaderOptions) (*S3BucketModuleLoader, error)

func (*S3BucketModuleLoader) Load

func (*S3BucketModuleLoader) Name

func (*S3BucketModuleLoader) Options

type S3BucketModuleLoaderOptions

type S3BucketModuleLoaderOptions struct {
	*ModuleLoaderOptions

	S3BucketURL string
}

type URLModuleLoader

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

URLModuleLoader Load the module from a URL, which should be a zipped package that happens to be the module's directory

func NewURLModuleLoader

func NewURLModuleLoader(options *URLModuleLoaderOptions) (*URLModuleLoader, error)

func (*URLModuleLoader) Load

func (x *URLModuleLoader) Load(ctx context.Context) (*module.Module, bool)

func (*URLModuleLoader) Name

func (*URLModuleLoader) Options

type URLModuleLoaderOptions

type URLModuleLoaderOptions struct {
	*ModuleLoaderOptions

	// Module URL, It's a zip package
	ModuleURL string `json:"module-url" yaml:"module-url"`
}

URLModuleLoaderOptions Parameter options when creating the URL module loader

Jump to

Keyboard shortcuts

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