Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
open
kubernetes-ghost
Commits
b1dbc609
Commit
b1dbc609
authored
Sep 23, 2020
by
Arie Peterson
🐚
Browse files
Shorten DiskImage name if necessary
parent
c8ec464c
Changes
1
Hide whitespace changes
Inline
Side-by-side
provisioner/cmd/provisioner/main.go
View file @
b1dbc609
...
...
@@ -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
:
len
(
fullName
)]
}
}
// 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"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment