Documentation ¶
Index ¶
- func CheckRestrictedDevicesDiskPaths(projectConfig map[string]string, sourcePath string) (bool, string)
- func DNS(projectName string, instanceName string) string
- func FilterUsedBy(authorizer auth.Authorizer, r *http.Request, entries []string) []string
- func ImageProject(ctx context.Context, tx *sql.Tx, requestProjectName string) (string, error)
- func Instance(projectName string, instanceName string) string
- func InstanceParts(projectInstanceName string) (projectName string, instanceName string)
- func NetworkAllowed(reqProjectConfig map[string]string, networkName string, isManaged bool) bool
- func NetworkProject(c *db.Cluster, projectName string) (string, *api.Project, error)
- func NetworkProjectFromRecord(p *api.Project) string
- func NetworkZoneProject(c *db.Cluster, projectName string) (string, *api.Project, error)
- func NetworkZoneProjectFromRecord(p *api.Project) string
- func ProfileProject(c *db.Cluster, projectName string) (*api.Project, error)
- func ProfileProjectFromRecord(p *api.Project) string
- func StorageBucketProject(ctx context.Context, c *db.Cluster, projectName string) (string, error)
- func StorageBucketProjectFromRecord(p *api.Project) string
- func StorageVolume(projectName string, storageVolumeName string) string
- func StorageVolumeParts(projectStorageVolumeName string) (projectName string, storageVolumeName string)
- func StorageVolumeProject(c *db.Cluster, projectName string, volumeType int) (string, error)
- func StorageVolumeProjectFromRecord(p *api.Project, volumeType int) string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRestrictedDevicesDiskPaths ¶
func CheckRestrictedDevicesDiskPaths(projectConfig map[string]string, sourcePath string) (bool, string)
CheckRestrictedDevicesDiskPaths checks whether the disk's source path is within the allowed paths specified in the project's restricted.devices.disk.paths config setting. If no allowed paths are specified in project, then it allows all paths, and returns true and empty string. If allowed paths are specified, and one matches, returns true and the matching allowed parent source path. Otherwise if sourcePath not allowed returns false and empty string.
func DNS ¶
DNS adds ".<project>" as a suffix to instance name when the given project name is not "default".
func FilterUsedBy ¶
FilterUsedBy filters a UsedBy list based on the entities that the requestor is able to view.
func ImageProject ¶
ImageProject returns the effective project for images based on the value of `features.images` in the given project.
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/canonical/lxd/lxd/project" "github.com/canonical/lxd/shared/api" ) func main() { prefixed := project.Instance(api.ProjectDefaultName, "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 Instance(). 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/canonical/lxd/lxd/project" "github.com/canonical/lxd/shared/api" ) func main() { projectName, name := project.InstanceParts("unprefixed") fmt.Println(projectName, name) projectName, name = project.InstanceParts(project.Instance(api.ProjectDefaultName, "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 NetworkAllowed ¶
NetworkAllowed returns whether access is allowed to a particular network based on projectConfig.
func NetworkProject ¶
NetworkProject returns the effective project name to use for the network based on the requested project. If the requested project has the "features.networks" flag enabled then the requested project's name is returned, otherwise the default project name is returned. The second return value is always the requested project's info.
func NetworkProjectFromRecord ¶
NetworkProjectFromRecord returns the project name to use for the network based on the supplied project. If the project supplied has the "features.networks" flag enabled then the project name is returned, otherwise the default project name is returned.
func NetworkZoneProject ¶
NetworkZoneProject returns the effective project name to use for network zone based on the requested project. If the requested project has the "features.networks.zones" flag enabled then the requested project's name is returned, otherwise the default project name is returned. The second return value is always the requested project's info.
func NetworkZoneProjectFromRecord ¶
NetworkZoneProjectFromRecord returns the project name to use for the network zone based on the supplied project. If the project supplied has the "features.networks.zones" flag enabled then the project name is returned, otherwise the default project name is returned.
func ProfileProject ¶
ProfileProject returns the effective project to use for the profile based on the requested project. If the requested project has the "features.profiles" flag enabled then the requested project's info is returned, otherwise the default project's info is returned.
func ProfileProjectFromRecord ¶
ProfileProjectFromRecord returns the project name to use for the profile based on the supplied project. If the project supplied has the "features.profiles" flag enabled then the project name is returned, otherwise the default project name is returned.
func StorageBucketProject ¶
StorageBucketProject returns the effective project name to use to for the bucket based on the requested project. If the project specified has the "features.storage.buckets" flag enabled then the project name is returned, otherwise the default project name is returned.
func StorageBucketProjectFromRecord ¶
StorageBucketProjectFromRecord returns the project name to use to for the bucket based on the supplied project. If the project supplied has the "features.storage.buckets" flag enabled then the project name is returned, otherwise the default project name is returned.
func StorageVolume ¶
StorageVolume adds the "<project>_prefix" to the storage volume name. Even if the project name is "default".
Example ¶
package main import ( "fmt" "github.com/canonical/lxd/lxd/project" "github.com/canonical/lxd/shared/api" ) func main() { prefixed := project.StorageVolume(api.ProjectDefaultName, "test") fmt.Println(prefixed) prefixed = project.StorageVolume("project_name", "test1") fmt.Println(prefixed) }
Output: default_test project_name_test1
func StorageVolumeParts ¶
func StorageVolumeParts(projectStorageVolumeName string) (projectName string, storageVolumeName string)
StorageVolumeParts takes a project prefixed storage volume name and returns the project and storage volume name as separate variables.
func StorageVolumeProject ¶
StorageVolumeProject returns the project name to use to for the volume based on the requested project. For image volume types the default project is always returned. 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.
func StorageVolumeProjectFromRecord ¶
StorageVolumeProjectFromRecord returns the project name to use to for the volume based on the supplied project. For image volume types the default project is always returned. For custom volume type, if the project supplied 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's name is returned.
Types ¶
This section is empty.