lxd: github.com/lxc/lxd/lxd/project Index | Examples | Files

package project

import "github.com/lxc/lxd/lxd/project"



Package Files

permissions.go project.go


const Default = "default"

Default is the string used for a default project.


var AllRestrictions = []string{

AllRestrictions lists all available 'restrict.*' config keys.

func AllowInstanceCreation Uses

func AllowInstanceCreation(tx *db.ClusterTx, projectName string, req api.InstancesPost) error

AllowInstanceCreation returns an error if any project-specific limit or restriction is violated when creating a new instance.

func AllowInstanceUpdate Uses

func AllowInstanceUpdate(tx *db.ClusterTx, projectName, instanceName string, req api.InstancePut, currentConfig map[string]string) error

AllowInstanceUpdate returns an error if any project-specific limit or restriction is violated when updating an existing instance.

func AllowProfileUpdate Uses

func AllowProfileUpdate(tx *db.ClusterTx, projectName, profileName string, req api.ProfilePut) error

AllowProfileUpdate checks that project limits and restrictions are not violated when changing a profile.

func AllowProjectUpdate Uses

func AllowProjectUpdate(tx *db.ClusterTx, projectName string, config map[string]string, changed []string) error

AllowProjectUpdate checks the new config to be set on a project is valid.

func Instance Uses

func Instance(projectName string, instanceName string) string

Instance adds the "<project>_" prefix to instance name when the given project name is not "default".


prefixed := project.Instance(project.Default, "test")

prefixed = project.Instance("project_name", "test1")



func InstanceParts Uses

func InstanceParts(projectInstanceName string) (string, string)

InstanceParts takes a project prefixed Instance name string and returns the project and instance name. If a non-project prefixed Instance name is supplied, then the project is returned as "default" and the instance name is returned unmodified in the 2nd return value. This is suitable for passing back into Prefix(). Note: This should only be used with Instance names (because they cannot contain the project separator) and this function relies on this rule as project names can contain the project separator.


projectName, name := project.InstanceParts("unprefixed")
fmt.Println(projectName, name)

projectName, name = project.InstanceParts(project.Instance(project.Default, "test"))
fmt.Println(projectName, name)

projectName, name = project.InstanceParts("project_name_test")
fmt.Println(projectName, name)

projectName, name = project.InstanceParts(project.Instance("proj", "test1"))
fmt.Println(projectName, name)


default unprefixed
default test
project_name test
proj test1

func StorageVolume Uses

func StorageVolume(projectName string, storageVolumeName string) string

StorageVolume adds the "<project>_prefix" to the storage volume name. Even if the project name is "default".


prefixed := project.StorageVolume(project.Default, "test")

prefixed = project.StorageVolume("project_name", "test1")



func StorageVolumeParts Uses

func StorageVolumeParts(projectStorageVolumeName string) (string, string)

StorageVolumeParts takes a project prefixed storage volume name and returns the project and storage volume name as separate variables.

func StorageVolumeProject Uses

func StorageVolumeProject(c *db.Cluster, projectName string, volumeType int) (string, error)

StorageVolumeProject returns the project name to use to for the volume based on the requested project. For custom volume type, if the project specified has the "features.storage.volumes" flag enabled then the project name is returned, otherwise the default project name is returned. For all other volume types the supplied project name is returned.

Package project imports 10 packages (graph) and is imported by 22 packages. Updated 2020-03-30. Refresh now. Tools for package owners.