project

package
v0.0.0-...-04e5504 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

View Source
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

func Instance(projectName string, instanceName string) string

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

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.

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

func ValidateLimitsUponProjectUpdate

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

ValidateLimitsUponProjectUpdate checks the new limits to be set on a project are valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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