config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package config auto detects the version of the config file and returns the Struct in the latest version

It converts the v1 config file to the v2 config file if it detects a v1 config file

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists added in v0.4.1

func Exists() bool

Exists checks if the config file exists

func FileExists

func FileExists(path string) bool

FileExists checks if a file exists

func GetCurrentDirectory

func GetCurrentDirectory() string

GetCurrentDirectory returns the current directory

func GetDirNmHash

func GetDirNmHash() string

GetDirNmHash returns a hash made using the current directory's name.

func GetPathHash added in v0.4.0

func GetPathHash(path string) string

GetPathHash returns a hash made using the provided path.

func SetDefaults

func SetDefaults(cfg *Structure)

SetDefaults sets the default values for the configuration

func SetName

func SetName(cfg *Structure)

SetName sets the name of the container

func Write

func Write(configs *Structure) error

Write writes the config file

func WriteNewVersion added in v0.5.0

func WriteNewVersion(configs *Structure) error

WriteNewVersion writes the new version of the config file

Types

type Binds

type Binds struct {
	// XOrg decides if the X11 socket should be bind mounted
	XOrg bool `default:"true" json:"xorg"`

	// Dev decides if the /dev directory should be bind mounted
	Dev bool `default:"true" json:"dev"`

	// Variables is a list of environment variables to copy to the container
	Variables []string `default:"[]" json:"variables"`
}

Binds is a list of bind mounts

type Container

type Container struct {
	// Name of the container
	Name string `json:"name"`

	// WorkDir is the directory where the code will be mounted
	WorkDir string `default:"/code" json:"workdir"`

	// Shell is the shell to use in the container
	Shell string `default:"/bin/sh" json:"shell"`

	// RootUser decides if the user inside the container is root or not
	RootUser bool `json:"rootuser"`

	// Binds contains settings related to the binds (for example, /dev)
	Binds Binds `json:"binds"`

	// Ports is a map of host:container ports
	Ports []string `default:"[]" json:"ports"`

	// Mounts is a list of mounts to be added to the container
	Mounts []string `default:"[]" json:"mounts"`

	// SharedFolders is a list of folders that are shared between containers
	SharedFolders map[string]interface{} `default:"{}" json:"shared_folders"`
}

Container is the struct for the container configuration

type Image

type Image struct {
	// URI is the location of the image
	URI string `default:"alpine:latest" json:"uri"`

	// OnCreation is a list of commands to run on creation
	OnCreation []string `default:"[]" json:"on_creation"`

	// OnFinish is a list of commands to run on finish
	OnFinish []string `default:"[]" json:"on_finish"`

	// PkgManager contains the configuration for the package manager
	PkgManager PackageManager `json:"pkgmanager"`

	// Variables is a list of environment variables to set
	Variables map[string]string `default:"{}" json:"variables"`
}

Image contains the information for the image

type Operations

type Operations struct {
	// Add is the base string that the package manager uses to add a package
	Add string `default:"" json:"add"` // add "{-y}" to auto install on creation on debian

	// Del, short for delete, is the base string that the package manager uses to delete a package
	Del string `default:"" json:"del"`

	// Upd, short for update, is the base string that the package manager uses to update the database
	Upd string `default:"" json:"update"`

	// Upg, short for upgrade, is the base string that the package manager uses to upgrade all packages
	Upg string `default:"" json:"upgrade"`

	// Srch, short for search, is the base string that the package manager uses to search for a package
	Srch string `default:"" json:"search"`

	// Clean is the command to clean the cache, necessary if we want to reduce the image size (using the build command)
	Clean string `default:"" json:"clean"`
}

Operations is a list of pkgm that can be performed on a container

type PackageManager added in v0.5.0

type PackageManager struct {
	// Operations contains the commands for the package manager
	Operations Operations `json:"operations"`

	// Modifiers enable prefixs or suffixs on packages names with a string (see configs/nix/unstable.json)
	Modifiers map[string]string `default:"{}" json:"modifiers"`
}

PackageManager is the configuration for the package manager

type Podman

type Podman struct {
	// Path is the path to the podman executable
	Path string `default:"podman" json:"path"`

	// Args is a list of arguments to pass to the podman executable
	Args []string `default:"[]" json:"args"`

	// Rootless tells develbox if podman is running as rootless
	Rootless bool `default:"true" json:"rootless"`

	// AutoDelete tells develbox if it should delete the container after created
	AutoDelete bool `default:"false" json:"auto_delete"`

	// AutoCommit tells develbox if it should commit the container after created
	AutoCommit bool `default:"false" json:"auto_commit"`

	// Privileged is a boolean that determines if the container should be run in privileged mode.
	Privileged bool `default:"true" json:"privileged"`
}

Podman is the struct for the podman configuration

type Structure added in v0.5.0

type Structure struct {
	// Image contains the information for the image
	Image Image `json:"image"`

	// Podman contains the configuration for podman
	Podman Podman `json:"podman"`

	// Container contains the configuration for the container
	Container Container `json:"container"`

	// Using interface so we can support string and []string
	Commands map[string]interface{} `default:"{}" json:"commands"`

	// Packages is a list of packages to install (that are required for your code to work)
	Packages []string `default:"[]" json:"packages"`

	// DevPackages is a list of packages to install for development (like compilers, linters, etc)
	DevPackages []string `default:"[]" json:"devpackages"`

	// UserPkgs is a list of packages to install user-side (Image has to support it)
	UserPkgs v1config.UserPkgs `json:"userpkgs"`

	// Experiments is a list of experimental features to enable
	Experiments v1config.Experiments `json:"experiments"`
}

Structure is the main configuration struct

func ConvertFromV1 added in v0.5.0

func ConvertFromV1(cfg *v1config.Struct) Structure

ConvertFromV1 converts a v1 config file to a v2 config file

func Read

func Read() (cfg Structure, err error)

Read reads the config file and returns the Struct

func ReadBytes

func ReadBytes(data []byte) (parsed Structure, wasV1Conf bool, err error)

ReadBytes parses bytes and returns the Struct

It converts the v1 config file to the v2 config file if it detects a v1 config file

func ReadFile added in v0.4.0

func ReadFile(path string) (Structure, bool, error)

ReadFile reads the config file from a path and returns the Struct

It converts the v1 config file to the v2 config file if it detects a v1 config file

Directories

Path Synopsis
Package v1config defines the configuration file and provides functions to read and write it
Package v1config defines the configuration file and provides functions to read and write it

Jump to

Keyboard shortcuts

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