@@ -19,6 +19,14 @@ import (
1919 "k8s.io/apimachinery/pkg/util/intstr"
2020)
2121
22+ const (
23+ hostPathName = "volume-hostpath"
24+ pvcName = "volume-pvc"
25+ emptyName = "volume-empty"
26+ secretName = "volume-secret"
27+ cmName = "volume-cm"
28+ )
29+
2230type VolumeBase struct {
2331 AddonBase
2432 readOnly bool
@@ -98,6 +106,8 @@ func (v *ConfigMapVolume) Validate() bool {
98106// Set custom options / attributes for the metric
99107func (v * ConfigMapVolume ) SetOptions (metric * api.MetricAddon ) {
100108
109+ v .Identifier = cmName
110+
101111 // Set an empty list of items
102112 v .items = map [string ]string {}
103113
@@ -190,6 +200,9 @@ func (v *PersistentVolumeClaim) Validate() bool {
190200
191201// Set custom options / attributes
192202func (v * PersistentVolumeClaim ) SetOptions (metric * api.MetricAddon ) {
203+
204+ v .Identifier = pvcName
205+
193206 claimName , ok := metric .Options ["claimName" ]
194207 if ok {
195208 v .claimName = claimName .StrVal
@@ -207,8 +220,6 @@ func (v *PersistentVolumeClaim) AssembleVolumes() []specs.VolumeSpec {
207220 },
208221 },
209222 }
210-
211- // ConfigMaps have to be read only!
212223 return []specs.VolumeSpec {{
213224 Volume : volume ,
214225 Path : filepath .Dir (v .path ),
@@ -236,6 +247,8 @@ func (v *SecretVolume) Validate() bool {
236247
237248// Set custom options / attributes
238249func (v * SecretVolume ) SetOptions (metric * api.MetricAddon ) {
250+
251+ v .Identifier = secretName
239252 secretName , ok := metric .Options ["secretName" ]
240253 if ok {
241254 v .secretName = secretName .StrVal
@@ -281,6 +294,8 @@ func (v *HostPathVolume) Validate() bool {
281294// Set custom options / attributes
282295func (v * HostPathVolume ) SetOptions (metric * api.MetricAddon ) {
283296
297+ v .Identifier = hostPathName
298+
284299 // Name is required!
285300 path , ok := metric .Options ["hostPath" ]
286301 if ok {
@@ -319,6 +334,7 @@ func (v *EmptyVolume) Validate() bool {
319334
320335// Set custom options / attributes
321336func (v * EmptyVolume ) SetOptions (metric * api.MetricAddon ) {
337+ v .Identifier = emptyName
322338 name , ok := metric .Options ["name" ]
323339 if ok {
324340 v .name = name .StrVal
@@ -347,7 +363,7 @@ func init() {
347363
348364 // Config map volume type
349365 base := AddonBase {
350- Identifier : "volume-cm" ,
366+ Identifier : cmName ,
351367 Summary : "config map volume type" ,
352368 }
353369 volBase := VolumeBase {AddonBase : base }
@@ -356,7 +372,7 @@ func init() {
356372
357373 // Secret volume type
358374 base = AddonBase {
359- Identifier : "volume-secret" ,
375+ Identifier : secretName ,
360376 Summary : "secret volume type" ,
361377 }
362378 volBase = VolumeBase {AddonBase : base }
@@ -365,7 +381,7 @@ func init() {
365381
366382 // Hostpath volume type
367383 base = AddonBase {
368- Identifier : "volume-hostpath" ,
384+ Identifier : hostPathName ,
369385 Summary : "host path volume type" ,
370386 }
371387 volBase = VolumeBase {AddonBase : base }
@@ -374,7 +390,7 @@ func init() {
374390
375391 // persistent volume claim volume type
376392 base = AddonBase {
377- Identifier : "volume-pvc" ,
393+ Identifier : pvcName ,
378394 Summary : "persistent volume claim volume type" ,
379395 }
380396 volBase = VolumeBase {AddonBase : base }
@@ -383,7 +399,7 @@ func init() {
383399
384400 // EmptyVolume
385401 base = AddonBase {
386- Identifier : "volume-empty" ,
402+ Identifier : emptyName ,
387403 Summary : "empty volume type" ,
388404 }
389405 volBase = VolumeBase {AddonBase : base }
0 commit comments