Documentation ¶
Index ¶
- Constants
- func CheckLimitsUponInstanceCreation(tx *db.ClusterTx, projectName string, req api.InstancesPost) error
- func CheckLimitsUponInstanceUpdate(tx *db.ClusterTx, projectName, instanceName string, req api.InstancePut) error
- func CheckLimitsUponProfileUpdate(tx *db.ClusterTx, projectName, profileName string, req api.ProfilePut) error
- func Instance(projectName string, instanceName string) string
- func InstanceParts(projectInstanceName string) (string, string)
- func ValidateLimitsUponProjectUpdate(tx *db.ClusterTx, projectName string, config map[string]string, ...) error
Examples ¶
Constants ¶
const Default = "default"
Default is the string used for a default project.
Variables ¶
This section is empty.
Functions ¶
func CheckLimitsUponInstanceCreation ¶
func CheckLimitsUponInstanceCreation(tx *db.ClusterTx, projectName string, req api.InstancesPost) error
CheckLimitsUponInstanceCreation returns an error if any project-specific limit is violated when creating a new instance.
func CheckLimitsUponInstanceUpdate ¶
func CheckLimitsUponInstanceUpdate(tx *db.ClusterTx, projectName, instanceName string, req api.InstancePut) error
CheckLimitsUponInstanceUpdate returns an error if any project-specific limit is violated when updating an existing instance.
func CheckLimitsUponProfileUpdate ¶
func CheckLimitsUponProfileUpdate(tx *db.ClusterTx, projectName, profileName string, req api.ProfilePut) error
CheckLimitsUponProfileUpdate checks that project limits are not violated when changing a profile.
func Instance ¶
Instance Adds the "<project>_" prefix to instance name when the given project name is not "default".
Example ¶
package main import ( "fmt" "github.com/lxc/lxd/lxd/project" ) func main() { prefixed := project.Instance(project.Default, "test") fmt.Println(prefixed) prefixed = project.Instance("project_name", "test1") fmt.Println(prefixed) }
Output: test project_name_test1
func InstanceParts ¶
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.
Example ¶
package main import ( "fmt" "github.com/lxc/lxd/lxd/project" ) func main() { 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) }
Output: default unprefixed default test project_name test proj test1
Types ¶
This section is empty.