devconfig

package
v0.0.0-...-b872246 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultName = "devbox.json"

Variables

This section is empty.

Functions

func Init

func Init(dir string, writer io.Writer) (created bool, err error)

func ValidateNixpkg

func ValidateNixpkg(cfg *Config) error

func WriteConfig

func WriteConfig(path string, cfg *Config) error

WriteConfig saves a devbox config file.

Types

type Config

type Config struct {
	// Packages is the slice of Nix packages that devbox makes available in
	// its environment. Deliberately do not omitempty.
	Packages Packages `json:"packages"`

	// Env allows specifying env variables
	Env map[string]string `json:"env,omitempty"`

	// Only allows "envsec" for now
	EnvFrom string `json:"env_from,omitempty"`

	// Shell configures the synopkg.github.io/devboxell environment.
	Shell *shellConfig `json:"shell,omitempty"`
	// Nixpkgs specifies the repository to pull packages from
	// Deprecated: Versioned packages don't need this
	Nixpkgs *NixpkgsConfig `json:"nixpkgs,omitempty"`

	// Reserved to allow including other config files. Proposed format is:
	// path: for local files
	// https:// for remote files
	// plugin: for built-in plugins
	// This is a similar format to nix inputs
	Include []string `json:"include,omitempty"`
}

Config defines a devbox environment as JSON.

func DefaultConfig

func DefaultConfig() *Config

func Load

func Load(path string) (*Config, error)

Load reads a devbox config file, and validates it.

func LoadConfigFromURL

func LoadConfigFromURL(url string) (*Config, error)

func (*Config) ComputedEnv

func (c *Config) ComputedEnv(
	ctx context.Context,
	projectDir string,
) (map[string]string, error)

func (*Config) Equals

func (c *Config) Equals(other *Config) bool

func (*Config) Hash

func (c *Config) Hash() (string, error)

func (*Config) InitHook

func (c *Config) InitHook() *shellcmd.Commands

func (*Config) IsEnvsecEnabled

func (c *Config) IsEnvsecEnabled() bool

func (*Config) NixPkgsCommitHash

func (c *Config) NixPkgsCommitHash() string

func (*Config) SaveTo

func (c *Config) SaveTo(path string) error

SaveTo writes the config to a file.

func (*Config) Scripts

func (c *Config) Scripts() map[string]*shellcmd.Commands

type NixpkgsConfig

type NixpkgsConfig struct {
	Commit string `json:"commit,omitempty"`
}

type Package

type Package struct {
	Version string `json:"version,omitempty"`

	Platforms         []string `json:"platforms,omitempty"`
	ExcludedPlatforms []string `json:"excluded_platforms,omitempty"`
	// contains filtered or unexported fields
}

func NewPackage

func NewPackage(name string, values map[string]any) Package

func NewVersionOnlyPackage

func NewVersionOnlyPackage(name, version string) Package

func (*Package) IsEnabledOnPlatform

func (p *Package) IsEnabledOnPlatform() bool

enabledOnPlatform returns whether the package is enabled on the given platform. If the package has a list of platforms, it is enabled only on those platforms. If the package has a list of excluded platforms, it is enabled on all platforms except those.

func (Package) MarshalJSON

func (p Package) MarshalJSON() ([]byte, error)

func (*Package) UnmarshalJSON

func (p *Package) UnmarshalJSON(data []byte) error

func (*Package) VersionedName

func (p *Package) VersionedName() string

type Packages

type Packages struct {

	// Collection contains the set of package definitions
	// We don't want this key to be serialized automatically, hence the "key" in json is "-"
	// NOTE: this is not a pointer to make debugging failure cases easier
	// (get dumps of the values, not memory addresses)
	Collection []Package `json:"-,omitempty"`
	// contains filtered or unexported fields
}

func (*Packages) Add

func (pkgs *Packages) Add(versionedName string)

Add adds a package to the list of packages

func (*Packages) AddPlatforms

func (pkgs *Packages) AddPlatforms(writer io.Writer, versionedname string, platforms []string) error

AddPlatforms adds a platform to the list of platforms for a given package

func (*Packages) ExcludePlatforms

func (pkgs *Packages) ExcludePlatforms(writer io.Writer, versionedName string, platforms []string) error

ExcludePlatforms adds a platform to the list of excluded platforms for a given package

func (*Packages) Get

func (pkgs *Packages) Get(versionedName string) (*Package, bool)

Get returns the package with the given versionedName

func (*Packages) MarshalJSON

func (pkgs *Packages) MarshalJSON() ([]byte, error)

func (*Packages) Remove

func (pkgs *Packages) Remove(versionedName string)

Remove removes a package from the list of packages

func (*Packages) UnmarshalJSON

func (pkgs *Packages) UnmarshalJSON(data []byte) error

func (*Packages) VersionedNames

func (pkgs *Packages) VersionedNames() []string

VersionedNames returns a list of package names with versions. NOTE: if the package is unversioned, the version will be omitted (doesn't default to @latest).

example: ["package1", "package2@latest", "[email protected]"]

type Stage

type Stage struct {
	Command string `json:"command"`
}

Stage contains a subset of fields from plansdk.Stage

Jump to

Keyboard shortcuts

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