github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/caas/kubernetes/provider/constants/storage.go (about) 1 // Copyright 2020 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package constants 5 6 import ( 7 "regexp" 8 9 "github.com/juju/juju/core/paths" 10 "github.com/juju/juju/storage" 11 ) 12 13 const ( 14 // StorageProviderType defines the Juju storage type which can be used 15 // to provision storage on k8s models. 16 StorageProviderType = storage.ProviderType("kubernetes") 17 18 // K8s storage pool attributes. 19 20 // StorageClass is the name of a storage class resource. 21 StorageClass = "storage-class" 22 StorageProvisioner = "storage-provisioner" 23 StorageMedium = "storage-medium" 24 StorageMode = "storage-mode" 25 ) 26 27 const ( 28 // WorkloadStorageKey is the model config attribute used to specify 29 // the storage class for provisioning workload storage. 30 WorkloadStorageKey = "workload-storage" 31 32 // OperatorStorageKey is the model config attribute used to specify 33 // the storage class for provisioning operator storage. 34 OperatorStorageKey = "operator-storage" 35 ) 36 37 // QualifiedStorageClassName returns a qualified storage class name. 38 func QualifiedStorageClassName(namespace, storageClass string) string { 39 if namespace == "" { 40 return storageClass 41 } 42 return namespace + "-" + storageClass 43 } 44 45 var ( 46 // StorageBaseDir is the base storage dir for the k8s series. 47 StorageBaseDir = getK8sStorageBaseDir() 48 49 // LegacyPVNameRegexp matches how Juju labels persistent volumes. 50 // The pattern is: juju-<storagename>-<digit> 51 LegacyPVNameRegexp = regexp.MustCompile(`^juju-(?P<storageName>\D+)-\d+$`) 52 53 // PVNameRegexp matches how Juju labels persistent volumes. 54 // The pattern is: <storagename>-<digit> 55 PVNameRegexp = regexp.MustCompile(`^(?P<storageName>\D+)-\w+$`) 56 ) 57 58 func getK8sStorageBaseDir() string { 59 return paths.StorageDir(paths.OSUnixLike) 60 }