mirror of
https://github.com/rancher/os.git
synced 2025-09-01 14:48:55 +00:00
Sync with libcompose
This commit is contained in:
@@ -9,13 +9,15 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
yaml "github.com/cloudfoundry-incubator/candiedyaml"
|
||||
|
||||
dockerClient "github.com/fsouza/go-dockerclient"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/docker/libcompose/project"
|
||||
dockerClient "github.com/docker/engine-api/client"
|
||||
composeConfig "github.com/docker/libcompose/config"
|
||||
"github.com/docker/libcompose/project/options"
|
||||
"github.com/rancher/os/cmd/power"
|
||||
"github.com/rancher/os/compose"
|
||||
"github.com/rancher/os/config"
|
||||
@@ -127,8 +129,8 @@ func osMetaDataGet(c *cli.Context) {
|
||||
}
|
||||
|
||||
for _, image := range images.Available {
|
||||
_, err := client.InspectImage(image)
|
||||
if err == dockerClient.ErrNoSuchImage {
|
||||
_, _, err := client.ImageInspectWithRaw(context.Background(), image, false)
|
||||
if dockerClient.IsErrImageNotFound(err) {
|
||||
fmt.Println(image, "remote")
|
||||
} else {
|
||||
fmt.Println(image, "local")
|
||||
@@ -209,16 +211,16 @@ func startUpgradeContainer(image string, stage, force, reboot, kexec bool, upgra
|
||||
}
|
||||
}
|
||||
|
||||
container, err := compose.CreateService(nil, "os-upgrade", &project.ServiceConfig{
|
||||
container, err := compose.CreateService(nil, "os-upgrade", &composeConfig.ServiceConfigV1{
|
||||
LogDriver: "json-file",
|
||||
Privileged: true,
|
||||
Net: "host",
|
||||
Pid: "host",
|
||||
Image: image,
|
||||
Labels: project.NewSliceorMap(map[string]string{
|
||||
Labels: map[string]string{
|
||||
config.SCOPE: config.SYSTEM,
|
||||
}),
|
||||
Command: project.NewCommand(command...),
|
||||
},
|
||||
Command: command,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -230,8 +232,8 @@ func startUpgradeContainer(image string, stage, force, reboot, kexec bool, upgra
|
||||
}
|
||||
|
||||
// Only pull image if not found locally
|
||||
if _, err := client.InspectImage(image); err != nil {
|
||||
if err := container.Pull(); err != nil {
|
||||
if _, _, err := client.ImageInspectWithRaw(context.Background(), image, false); err != nil {
|
||||
if err := container.Pull(context.Background()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -252,19 +254,19 @@ func startUpgradeContainer(image string, stage, force, reboot, kexec bool, upgra
|
||||
|
||||
// If there is already an upgrade container, delete it
|
||||
// Up() should to this, but currently does not due to a bug
|
||||
if err := container.Delete(); err != nil {
|
||||
if err := container.Delete(context.Background(), options.Delete{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := container.Up(); err != nil {
|
||||
if err := container.Up(context.Background(), options.Up{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := container.Log(); err != nil {
|
||||
if err := container.Log(context.Background(), true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := container.Delete(); err != nil {
|
||||
if err := container.Delete(context.Background(), options.Delete{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user