workspace

package
v1.105.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultDevConfigFile is the name of the default dev configuration file.
	DefaultDevConfigFile = "dev-config.yaml"
	// DefaultSpecPath is the default spec path for an app.
	DefaultSpecPath = ".do/app.yaml"
)

Variables

View Source
var ErrNoGitRepo = errors.New("no git repository found")

ErrNoGitRepo indicates that a .git worktree could not be found.

View Source
var (
	// SampleDevConfigFile represents a sample dev config file with all options and descriptions.
	SampleDevConfigFile = template.String(`
	timeout: {{muted "An optional timeout duration for the build. Valid time units are 's', 'm', 'h'. Example: 15m30s"}}
	app: {{muted "ID of an App Platform App to load the AppSpec from."}}
	spec: {{muted "Path to an AppSpec to load for builds."}}
	registry: {{muted "An optional registry name used to tag built container images."}}
	no_cache: {{muted "Boolean set to disable build caching."}}
	components:
	  {{muted "# Per-component configuration"}}
	  {{muted "component-name"}}: 
	    build_command: {{muted "Custom build command override for a given component."}}
	    env_file: {{muted "Path to an env file to override envs for a given component."}}
`, nil)
)

Functions

This section is empty.

Types

type AppDev

type AppDev struct {
	Config *AppDevConfig
	// contains filtered or unexported fields
}

func NewAppDev

func NewAppDev(opts NewAppDevOpts) (*AppDev, error)

NewAppDev creates a new AppDev workspace.

func (*AppDev) CacheDir

func (c *AppDev) CacheDir(component string) string

func (*AppDev) ClearCacheDir

func (c *AppDev) ClearCacheDir(ctx context.Context, component string) error

func (*AppDev) Context

func (ws *AppDev) Context(path ...string) string

Context returns a path relative to the workspace context. A call with no arguments returns the workspace context path. If an absolute path is given it is returned as-is.

func (*AppDev) EnsureCacheDir

func (c *AppDev) EnsureCacheDir(ctx context.Context, component string) error

type AppDevConfig

type AppDevConfig struct {

	// AppSpec is the app spec for the workspace.
	AppSpec *godo.AppSpec

	// App is the production app resource if AppID is set.
	App *godo.App

	Registry        string
	Timeout         time.Duration
	NoCache         bool
	CNBBuilderImage string

	// Components contains component-specific configuration keyed by component name.
	Components map[string]*AppDevConfigComponent
	// contains filtered or unexported fields
}

func NewAppDevConfig

func NewAppDevConfig(appDevConfig *config.AppDev, doctlConfig config.ConfigSource, appsService do.AppsService) (*AppDevConfig, error)

NewAppDevConfig populates an AppDevConfig instance with values sourced from *config.AppDev and doctl.Config.

func (*AppDevConfig) Load

func (c *AppDevConfig) Load() error

Load loads the config.

Note: the .Components config structure is only loaded for components that are present in the app spec. Configuration in dev-config.yaml for components that are not present in the app spec will be ignored.

func (*AppDevConfig) Set

func (c *AppDevConfig) Set(key string, value any) error

Set sets a value in dev-config.yaml. Note that the configuration must be reloaded for the new values to be populated in AppDevConfig.

func (*AppDevConfig) SetLinkedApp

func (c *AppDevConfig) SetLinkedApp(app *godo.App) error

func (*AppDevConfig) Write

func (c *AppDevConfig) Write() error

Write writes the current dev-config.yaml to disk. Note that modifying values in the AppDevConfig struct will not affect the contents of the dev-config.yaml file. Instead, use the Set(...) method and then call Write().

type AppDevConfigComponent

type AppDevConfigComponent struct {
	Spec         godo.AppComponentSpec
	EnvFile      string
	Envs         map[string]string
	BuildCommand string
}

func (*AppDevConfigComponent) LoadEnvFile

func (c *AppDevConfigComponent) LoadEnvFile(path string) error

LoadEnvFile loads the given file into the component config.

type NewAppDevOpts

type NewAppDevOpts struct {
	// DevConfigFilePath is an optional path to the config file. Defaults to <workspace context>/.do/<DefaultDevConfigFile>.
	DevConfigFilePath string
	// DoctlConfig is the doctl CLI config source. Use config.DoctlConfigSource(...) to create it.
	DoctlConfig config.ConfigSource
	// AppsService is the apps API service.
	AppsService do.AppsService
}

Jump to

Keyboard shortcuts

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