Commit 4b4c05e7 authored by Remon Huijts's avatar Remon Huijts
Browse files

Merge branch '17-shorten-labels-of-provisioned-disks-if-too-long' into 'master'

Resolve "Shorten labels of provisioned disks if too long"

Closes #17

See merge request !10
parents c8ec464c bdeecaed
Pipeline #11102 passed with stages
in 1 minute and 19 seconds
......@@ -54,10 +54,24 @@ func NewGreenhostProvisioner() controller.Provisioner {
}
}
// Create a name for the cosmos DiskImage based on the name of the persistent
// volume. We add a "ghost:" prefix, and shorten the name if necessary.
func deriveDiskImageName(pvName string) string {
fullName := "ghost:" + pvName
// The maximum length of a disk name allowed by cosmos2 is 64.
if len(fullName) <= 64 {
return fullName
} else {
// Take the beginning and end of the string to attempt to
// preserve the most important information.
return fullName[0:31] + "*" + fullName[len(fullName)-32:]
}
}
// Provision creates a storage asset and returns a pv object representing it.
func (p *GreenhostProvisioner) Provision(ctx context.Context, options controller.ProvisionOptions) (*v1.PersistentVolume, controller.ProvisioningState, error) {
pvName := options.PVC.ObjectMeta.Name
name := "kubernetes-ghost:" + pvName
name := deriveDiskImageName(pvName)
region := os.Getenv("GHOST_CLOUD_REGION")
backup := os.Getenv("GHOST_IMAGE_BACKUP")
backupBool := backup == "true"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment