v1config

package
v0.6.3 Latest Latest
Warning

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

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

Documentation

Overview

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

This is the old version of the config file, which is now deprecated in favor of the new version (v2 at time of writing)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists() bool

Exists returns true if the config file exists.

func FileExists

func FileExists(path string) bool

FileExists returns true if a file/path exists.

func FolderExists

func FolderExists() bool

FolderExists returns true if the config folder exists.

func GetCurrentDirectory

func GetCurrentDirectory() string

GetCurrentDirectory returns the current folder's full path.

func GetDirNmHash

func GetDirNmHash() string

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

func GetPathHash

func GetPathHash(path string) string

GetPathHash returns a hash made using the provided path.

func SetDefaults

func SetDefaults(cfg *Struct)

SetDefaults sets the default values for the configuration

func SetName

func SetName(cfg *Struct)

SetName sets the name of the container

func Write

func Write(configs *Struct) error

Write writes 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"`

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

Binds is a list of bind mounts

type Container

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

	// Args is a list of arguments to pass to the container
	Args []string `default:"[\"--net=host\"]" json:"arguments"`

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

	// 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:"root-user"`

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

	// 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"`

	// Experiments contains experimental features
	Experiments Experiments `json:"experiments"`

	// 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 Experiments

type Experiments struct {
	// Socket decides if the socket server should be started
	Socket bool `default:"false" json:"sockets"`
}

Experiments contains settings for experimental features

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:"[\"apk update\"]" json:"on-creation"`

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

	// Installer contains the configuration for the package manager
	Installer Installer `json:"pkg-manager"`

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

Image contains the information for the image

type Installer

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

	// ArgModifier lets prefix or suffix packages with a string (see configs/nix/unstable.json)
	ArgModifier map[string]string `default:"{}" json:"args-modifier"`
}

Installer is the configuration for the package manager

type Operations

type Operations struct {
	// Add is the base string that the package manager uses to add a package
	Add string `default:"apk add {args}" 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:"apk del {args}" json:"del"`

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

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

	// Srch, short for search, is the base string that the package manager uses to search for a package
	Srch string `default:"apk search {args}" 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:"rm -rf /var/cache/apk/*" json:"clean"`
}

Operations contains all supported commands for managing packages

type Podman

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

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

	// BuildOnly tells develbox if it should delete the container after created
	BuildOnly bool `json:"create-deletion"`

	// Container is the container configuration
	Container Container `json:"container"`
}

Podman is the struct for the podman configuration

type Struct

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

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

	// 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 UserPkgs `json:"userpkgs"`
}

Struct is the main configuration struct

func Read

func Read() (Struct, error)

Read reads the config file and returns the Struct

func ReadBytes

func ReadBytes(data []byte) (Struct, error)

ReadBytes reads the config file from bytes and returns the Struct

func ReadFile

func ReadFile(path string) (Struct, error)

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

type UserPkgs

type UserPkgs struct {
	// Packages is a list of packages to install
	Packages []string `default:"[]" json:"packages"`

	// DevPackages is a list of packages to install for development
	DevPackages []string `default:"[]" json:"devpackages"`
}

UserPkgs is a list of packages to install user-side

Jump to

Keyboard shortcuts

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