gitlab.com/jfprevost/gitlab-runner-notlscheck@v11.11.4+incompatible/executors/docker/internal/volumes/parser/volume.go (about) 1 package parser 2 3 import ( 4 "strings" 5 ) 6 7 type Volume struct { 8 Source string 9 Destination string 10 Mode string 11 } 12 13 func newVolume(source string, destination string, mode string) *Volume { 14 return &Volume{ 15 Source: source, 16 Destination: destination, 17 Mode: mode, 18 } 19 } 20 21 func (v *Volume) Definition() string { 22 parts := make([]string, 0) 23 24 if v.Source != "" { 25 parts = append(parts, v.Source) 26 } 27 28 parts = append(parts, v.Destination) 29 30 if v.Mode != "" { 31 parts = append(parts, v.Mode) 32 } 33 34 return strings.Join(parts, ":") 35 } 36 37 func (v *Volume) Len() int { 38 len := 0 39 40 if v.Source != "" { 41 len++ 42 } 43 44 if v.Destination != "" { 45 len++ 46 } 47 48 return len 49 }