Documentation
¶
Overview ¶
Package project manages the project configuration
Index ¶
- Constants
- Variables
- func GetProjectPath(path string) (string, error)
- type Command
- type Environment
- type Header
- type Layer
- type Project
- func (prj *Project) CreateWorkspace(name string, origin string, before string) (*Workspace, error)
- func (prj *Project) CurrentWorkspace() (*Workspace, error)
- func (prj *Project) Delete() error
- func (prj *Project) DeleteWorkspace(name string) error
- func (prj *Project) SetCurrentWorkspace(name string) error
- func (prj *Project) UpdateWorkspace(ws *Workspace, origin string)
- func (prj *Project) Workspace(name string) (*Workspace, error)
- func (prj *Project) Write() error
- type Workspace
- func (ws *Workspace) BaseHash() [16]byte
- func (ws *Workspace) ConfigHash() [16]byte
- func (ws *Workspace) CreateLayer(name string, at string) (int, *Layer, error)
- func (ws *Workspace) DeleteLayer(name string) error
- func (ws *Workspace) FindLayer(name string) (int, *Layer, error)
- func (ws *Workspace) FindLayerByHandler(handler string, start int) (int, *Layer, error)
- func (ws *Workspace) ID() [16]byte
- func (ws *Workspace) InsertCommands(layer *Layer, at string, commands []Command) error
- func (ws *Workspace) RemoveCommands(layer *Layer, at string) error
- func (ws *Workspace) TopLayer() *Layer
- func (ws *Workspace) UpdateCommands(layer *Layer, at string, commands Command) error
- func (ws *Workspace) UpdateLayer(layer *Layer)
Constants ¶
const ( ProjectFileName = "cneproject" WorkspaceDefaultName = "main" LayerNameOS = "os" LayerHandlerNone = "" LayerHandlerImage = "image" LayerHandlerUbuntu = "ubuntu" LayerHandlerDebian = "debian" LayerHandlerApt = "apt" LayerHandlerDnf = "dnf" LayerHandlerPip = "pip" LayerNameTop = "" )
Variables ¶
var LayerHandlers = [...]string{ LayerHandlerImage, LayerHandlerUbuntu, LayerHandlerDebian, LayerHandlerApt, LayerHandlerDnf, LayerHandlerPip, }
Functions ¶
func GetProjectPath ¶
GetProjectPath returns the path to the project, which could be in an upper directory. If no project cannot be found, the path for the current path is returned
Types ¶
type Command ¶
type Command struct { Name string Envs []string `output:"flat" yaml:",flow"` Args []string `output:"flat" yaml:",flow"` }
Command describes the command and its argument(s). The Name is optional and used by support functions to manage the command list.
type Environment ¶
type Environment struct { Origin string // Name or link of the base image Update string // Update package strategy: One of "never", "manual", "auto" Layers []Layer }
Environment describes the container-native environment The options for the update strategy are as follows:
- "never" - packages are never updated
- "manual" - manually (re-)building the image will update the packages
- "auto" - packages will be updated whenever the package layer(s) are rebuild
Note that the image needs to be pulled manually to cause an update (using 'pull')
type Layer ¶
type Layer struct { Name string // Unique name for the layer in the workspace; must not contain '/' Handler string // one of the layer handlers Digest string `output:"-"` // Images/Snaps for faster rebuilds Commands []Command }
Layer describes an 'overlay' layer. This can be virtual or explicit using an overlay FS Note that ideally we could use compositions for apt and other handlers
type Project ¶
type Project struct { Name string UUID string // Universal Unique id for the project CurrentWorkspaceName string Workspaces []Workspace Path string `yaml:"-"` // path to the project file // contains filtered or unexported fields }
Project is the current persistent project definition.
func Create ¶
Create creates the project in the provide path The path can be empty to use the current working directory. Callers can provide a directory or a filename. If a filename is provided, it must not exist. In general, using a different configuration file than the standard "cneproject" is discouraged.
func Load ¶
Load loads the project from the provided path. It also scans all parent paths for the project file if path is a directory.
func (*Project) CreateWorkspace ¶
CreateWorkspace creates a new workspace in the project before the provided workspace or at the end if 'before' is an empty string. It returns the pointer to the workspace in the current project.
func (*Project) CurrentWorkspace ¶
CurrentWorkspace retuns a pointer to the current workspace or nil if unset or no workspaces. Returns an error if the workspace wasn't found.
func (*Project) DeleteWorkspace ¶
DeleteWorkspace removes the specified workspace. If it was the current workspace, the current workspace will become unset
func (*Project) SetCurrentWorkspace ¶
SetCurrentWorkspace sets the current workspace;
func (*Project) UpdateWorkspace ¶
type Workspace ¶
type Workspace struct { Name string // Name of the workspace (must be unique) ProjectUUID string `yaml:"-" output:"-"` Environment Environment }
Workspace is a specific environment of the project. They allow for building a development pipeline by propagating results to the following workspace. Note that Image cannot be changed and requires to create a new workspace
func (*Workspace) ConfigHash ¶
ConfigHash returns a unique hash over the Workspace Environment.
func (*Workspace) CreateLayer ¶
CreateLayer inserts a new layer at the provided index, or at the end if 'at' is ""
func (*Workspace) DeleteLayer ¶
DeleteLayer removes the specified layer.
func (*Workspace) FindLayer ¶
FindLayer looks up the layer by name and returns the layer index starting with 0 for the first layer in the list and a pointer to the Layer structure. If the layer cannot be found, it returns an index value of -1 and nil for the layer.
func (*Workspace) FindLayerByHandler ¶
FindLayerByHandler looks up the layer by handler
func (*Workspace) InsertCommands ¶
func (*Workspace) RemoveCommands ¶
func (*Workspace) UpdateCommands ¶
func (*Workspace) UpdateLayer ¶
UpdateLayer ensures that any cached or reference data is updated