Skip to content

Commit 7cb1f8b

Browse files
committed
introduce RuntimeVersion for code to check container runtime supports required features
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent cb01186 commit 7cb1f8b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/compose/compose.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,5 +295,22 @@ func (s *composeService) isSWarmEnabled(ctx context.Context) (bool, error) {
295295
}
296296
})
297297
return swarmEnabled.val, swarmEnabled.err
298+
}
299+
300+
var runtimeVersion = struct {
301+
once sync.Once
302+
val string
303+
err error
304+
}{}
305+
306+
func (s *composeService) RuntimeVersion(ctx context.Context) (string, error) {
307+
runtimeVersion.once.Do(func() {
308+
version, err := s.dockerCli.Client().ServerVersion(ctx)
309+
if err != nil {
310+
runtimeVersion.err = err
311+
}
312+
runtimeVersion.val = version.APIVersion
313+
})
314+
return runtimeVersion.val, runtimeVersion.err
298315

299316
}

0 commit comments

Comments
 (0)