Skip to content

Commit b930e4c

Browse files
committed
cmd/rofl: Fix external service volumes check
Existing behavior didn't allow implicit volumes with default settings.
1 parent 552aff6 commit b930e4c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

cmd/rofl/build/validate.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,20 @@ func validateComposeFile(composeFile string, manifest *buildRofl.Manifest) error
116116
}
117117

118118
for _, vol := range service.Volumes {
119+
// Short compose syntax for volumes.
119120
if volumeSourceIsValid(vol.Source) {
120121
continue
121122
}
122123

123-
var ok bool
124-
for _, v := range proj.Volumes {
125-
if vol.Source == v.Name {
126-
ok = true
127-
break
124+
// Implicit declaration of volumes.
125+
if v, ok := proj.Volumes[vol.Source]; ok {
126+
// If the volume is external, it should be one of the valid locations.
127+
if bool(!v.External) || volumeSourceIsValid(v.Name) {
128+
continue
128129
}
129130
}
130-
if ok {
131-
continue
132-
}
133131

134-
return fmt.Errorf("volume '%s:%s' of service '%s' has an invalid source (should start with '/storage' or be equal to '/run/rofl-appd.sock')", vol.Source, vol.Target, serviceName)
132+
return fmt.Errorf("volume '%s:%s' of service '%s' has an invalid external source (should be '/run/rofl-appd.sock' or reside inside '/storage/')", vol.Source, vol.Target, serviceName)
135133
}
136134
}
137135

0 commit comments

Comments
 (0)