provider

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package provider provides the interfaces for implementing providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProviders

func GetProviders() map[string]Provider

GetProviders will return the registered providers.

Types

type BunProvider

type BunProvider struct {
}

BunProvider is the provider implementation a generic Bun project.

func (*BunProvider) ConfigureDeploymentConfig

func (p *BunProvider) ConfigureDeploymentConfig(config *project.DeploymentConfig) error

func (*BunProvider) DeployPreflightCheck added in v0.0.5

func (p *BunProvider) DeployPreflightCheck(logger logger.Logger, data DeployPreflightCheckData) error

func (*BunProvider) Detect

func (p *BunProvider) Detect(logger logger.Logger, dir string, state map[string]any) (*Detection, error)

func (*BunProvider) Identifier

func (p *BunProvider) Identifier() string

func (*BunProvider) Name

func (p *BunProvider) Name() string

func (*BunProvider) NewProject

func (p *BunProvider) NewProject(logger logger.Logger, dir string, name string) error

func (*BunProvider) ProjectIgnoreRules

func (p *BunProvider) ProjectIgnoreRules() []string

func (*BunProvider) RunDev

func (p *BunProvider) RunDev(logger logger.Logger, dir string, env []string, args []string) (Runner, error)

type CrewAIProvider

type CrewAIProvider struct {
}

CrewAIProvider is the provider implementation for the CrewAI framework.

func (*CrewAIProvider) ConfigureDeploymentConfig

func (p *CrewAIProvider) ConfigureDeploymentConfig(config *project.DeploymentConfig) error

func (*CrewAIProvider) DeployPreflightCheck added in v0.0.5

func (p *CrewAIProvider) DeployPreflightCheck(logger logger.Logger, data DeployPreflightCheckData) error

func (*CrewAIProvider) Detect

func (p *CrewAIProvider) Detect(logger logger.Logger, dir string, state map[string]any) (*Detection, error)

func (*CrewAIProvider) Identifier

func (p *CrewAIProvider) Identifier() string

func (*CrewAIProvider) Name

func (p *CrewAIProvider) Name() string

func (*CrewAIProvider) NewProject

func (p *CrewAIProvider) NewProject(logger logger.Logger, dir string, name string) error

func (*CrewAIProvider) ProjectIgnoreRules

func (p *CrewAIProvider) ProjectIgnoreRules() []string

func (*CrewAIProvider) RunDev

func (p *CrewAIProvider) RunDev(logger logger.Logger, dir string, env []string, args []string) (Runner, error)

type DeployPreflightCheckData added in v0.0.5

type DeployPreflightCheckData struct {
	// Dir returns the full path to the project folder
	Dir string
	// APIClient is for communicating with the backend
	APIClient *util.APIClient
	// APIURL is the base url to the API
	APIURL string
	// APIKey is the projects api key
	APIKey string
	// Envfile if the project has a .env file and the parsed contents of that file
	Envfile *EnvFile
	// Project is the project data
	Project *project.Project
	// ProjectData is the project data loaded from the backend
	ProjectData *project.ProjectData
	// Config is the deployment configuration
	Config *project.DeploymentConfig
	// PromptHelpers are a set of funcs to assist in prompting the user on the command line
	PromptHelpers PromptHelpers
	// OS Environment as a map
	OSEnvironment map[string]string
}

type Detection

type Detection struct {
	Provider    string `json:"provider"`              // the name of the provider
	Name        string `json:"name,omitempty"`        // the optional name of the project
	Description string `json:"description,omitempty"` // the optional name of the description
	Version     string `json:"version,omitempty"`     // the optional version of the project
}

Detection is the structure that is returned by the Detect function.

func Detect

func Detect(logger logger.Logger, dir string) (*Detection, error)

Detect will detect the provider for the given directory. It will return the detection if it is found, otherwise it will return nil.

type EnvFile added in v0.0.5

type EnvFile struct {
	Filepath string
	Env      []env.EnvLine
}

func (*EnvFile) Lookup added in v0.0.5

func (e *EnvFile) Lookup(key string) (string, bool)

type PromptHelpers added in v0.0.5

type PromptHelpers struct {
	// ShowSpinner will show a spinner with the title while the action is running
	ShowSpinner func(logger logger.Logger, title string, action func())
	// PrintSuccess will print a check mark and the message provided with optional formatting arguments
	PrintSuccess func(msg string, args ...any)
	// PrintLock will print a lock and the message provided with optional formatting arguments
	PrintLock func(msg string, args ...any)
	// PrintLock will print an X mark and the message provided with optional formatting arguments
	PrintWarning func(msg string, args ...any)
	// CommandString will format a CLI command
	CommandString func(cmd string, args ...string) string
	// LinkString will return a formatted URL string
	LinkString func(cmd string, args ...any) string
	// Ask will ask the user for input and return true (confirm) or false (no!)
	Ask func(logger logger.Logger, title string, defaultValue bool) bool
	// PromptForEnv is a helper for prompting the user to get a environment (or secret) value. You must do something with the result such as save it.
	PromptForEnv func(logger logger.Logger, key string, isSecret bool, localenv map[string]string, osenv map[string]string) string
}

type Provider

type Provider interface {
	// Name will return the name of the provider in a format that is easy to use in a CLI.
	Name() string

	// Identifier will return the identifier of the provider in a format that is easy to use in a CLI.
	Identifier() string

	// Detect will detect the provider for the given directory.
	// It will return the detection if it is found, otherwise it will return nil.
	Detect(logger logger.Logger, dir string, state map[string]any) (*Detection, error)

	// NewProject will create a new project for the given provider.
	NewProject(logger logger.Logger, dir string, name string) error

	// RunDev will run the development mode for the given provider.
	// It will return the runner if it is found, otherwise it will return nil.
	RunDev(logger logger.Logger, dir string, env []string, args []string) (Runner, error)

	// ProjectIgnoreRules should return any additional project specific deployment ignore rules.
	ProjectIgnoreRules() []string

	// DeployPreflightCheck is called before cloud deployment to allow the provider to perform any preflight checks.
	DeployPreflightCheck(logger logger.Logger, data DeployPreflightCheckData) error

	// ConfigureDeploymentConfig will configure the deployment config for the given provider.
	ConfigureDeploymentConfig(config *project.DeploymentConfig) error
}

Provider is the interface that is implemented by the provider to perform implementation specific logic.

func GetProviderForName

func GetProviderForName(name string) (Provider, error)

GetProviderForName returns a provider registered as name or returns an error

type PyProject

type PyProject struct {
	Name           string   `toml:"name"`
	Description    string   `toml:"description"`
	Version        string   `toml:"version"`
	RequiresPython string   `toml:"requires-python"`
	Dependencies   []string `toml:"dependencies"`
}

PyProject is the structure that is used to parse the pyproject.toml file.

type PythonRunner

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

PythonRunner is the runner implementation for python projects.

func (*PythonRunner) Done

func (p *PythonRunner) Done() chan struct{}

func (*PythonRunner) Restart

func (p *PythonRunner) Restart() chan struct{}

func (*PythonRunner) Start

func (p *PythonRunner) Start() error

func (*PythonRunner) Stop

func (p *PythonRunner) Stop() error

type Runner

type Runner interface {
	// Start will start the runner.
	Start() error
	// Stop will stop the runner.
	Stop() error
	// Restart will restart the runner.
	Restart() chan struct{}
	// Done will return a channel that is closed when the runner is done.
	Done() chan struct{}
}

Runner is the interface that is implemented by the provider for running the project.

func NewRunner

func NewRunner(logger logger.Logger, dir string, apiUrl string, eventLogFile string, args []string) (Runner, error)

NewRunner will create a new runner for the given provider. It will return the runner if it is found, otherwise it will return nil.

Jump to

Keyboard shortcuts

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