mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
feat(compose): handle image pull policy
This commit is contained in:
@@ -7,11 +7,24 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func ServiceSpecFromCompose(name string, service types.ServiceConfig) (api.ServiceSpec, error) {
|
func ServiceSpecFromCompose(name string, service types.ServiceConfig) (api.ServiceSpec, error) {
|
||||||
|
pullPolicy := ""
|
||||||
|
switch service.PullPolicy {
|
||||||
|
case types.PullPolicyAlways:
|
||||||
|
pullPolicy = api.PullPolicyAlways
|
||||||
|
case "", types.PullPolicyMissing, types.PullPolicyIfNotPresent:
|
||||||
|
pullPolicy = api.PullPolicyMissing
|
||||||
|
case types.PullPolicyNever:
|
||||||
|
pullPolicy = api.PullPolicyNever
|
||||||
|
default:
|
||||||
|
return api.ServiceSpec{}, fmt.Errorf("unsupported pull policy: '%s'", service.PullPolicy)
|
||||||
|
}
|
||||||
|
|
||||||
spec := api.ServiceSpec{
|
spec := api.ServiceSpec{
|
||||||
Container: api.ContainerSpec{
|
Container: api.ContainerSpec{
|
||||||
Command: service.Command,
|
Command: service.Command,
|
||||||
Image: service.Image,
|
Image: service.Image,
|
||||||
Init: service.Init,
|
Init: service.Init,
|
||||||
|
PullPolicy: pullPolicy,
|
||||||
// TODO: env
|
// TODO: env
|
||||||
// TODO: volumes
|
// TODO: volumes
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user