project

package
v0.0.0-...-3b3e3cc Latest Latest
Warning

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

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

Documentation

Overview

Package project manages the project configuration

Index

Constants

View Source
const (
	ProjectFileName = "cneproject"

	WorkspaceDefaultName = "main"

	LayerNameOS = "os"

	LayerHandlerNone   = ""
	LayerHandlerImage  = "image"
	LayerHandlerUbuntu = "ubuntu"
	LayerHandlerDebian = "debian"
	LayerHandlerApt    = "apt"
	LayerHandlerDnf    = "dnf"
	LayerHandlerPip    = "pip"

	LayerNameTop = ""
)

Variables

Functions

func GetProjectPath

func GetProjectPath(path string) (string, error)

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 Header struct {
	Version string
}

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

func Create(name, path string) (*Project, error)

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

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

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

func (prj *Project) CreateWorkspace(name string, origin string, before string) (*Workspace, error)

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

func (prj *Project) CurrentWorkspace() (*Workspace, error)

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) Delete

func (prj *Project) Delete() error

Delete removes the CNE project file

func (*Project) DeleteWorkspace

func (prj *Project) DeleteWorkspace(name string) error

DeleteWorkspace removes the specified workspace. If it was the current workspace, the current workspace will become unset

func (*Project) SetCurrentWorkspace

func (prj *Project) SetCurrentWorkspace(name string) error

SetCurrentWorkspace sets the current workspace;

func (*Project) UpdateWorkspace

func (prj *Project) UpdateWorkspace(ws *Workspace, origin string)

func (*Project) Workspace

func (prj *Project) Workspace(name string) (*Workspace, error)

Workspace returns a pointer to the workspace in the project specified by the provided name or error if it doesn't exist in the project

func (*Project) Write

func (prj *Project) Write() error

Write writes the project to the project path

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) BaseHash

func (ws *Workspace) BaseHash() [16]byte

BaseHash returns a unique hash value for a build container

func (*Workspace) ConfigHash

func (ws *Workspace) ConfigHash() [16]byte

ConfigHash returns a unique hash over the Workspace Environment.

func (*Workspace) CreateLayer

func (ws *Workspace) CreateLayer(name string, at string) (int, *Layer, error)

CreateLayer inserts a new layer at the provided index, or at the end if 'at' is ""

func (*Workspace) DeleteLayer

func (ws *Workspace) DeleteLayer(name string) error

DeleteLayer removes the specified layer.

func (*Workspace) FindLayer

func (ws *Workspace) FindLayer(name string) (int, *Layer, error)

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

func (ws *Workspace) FindLayerByHandler(handler string, start int) (int, *Layer, error)

FindLayerByHandler looks up the layer by handler

func (*Workspace) ID

func (ws *Workspace) ID() [16]byte

ID returns an identification for the workspace

func (*Workspace) InsertCommands

func (ws *Workspace) InsertCommands(layer *Layer, at string, commands []Command) error

func (*Workspace) RemoveCommands

func (ws *Workspace) RemoveCommands(layer *Layer, at string) error

func (*Workspace) TopLayer

func (ws *Workspace) TopLayer() *Layer

TopLayer returns the pointer to the top layer.

func (*Workspace) UpdateCommands

func (ws *Workspace) UpdateCommands(layer *Layer, at string, commands Command) error

func (*Workspace) UpdateLayer

func (ws *Workspace) UpdateLayer(layer *Layer)

UpdateLayer ensures that any cached or reference data is updated

Jump to

Keyboard shortcuts

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