Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit bea890d

Browse files
committed
[integration-test] merge master
2 parents 4597235 + 5ec8817 commit bea890d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+8555
-634
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![Build Status](https://travis-ci.org/hyperhq/hypercli.svg?branch=master)](https://travis-ci.org/hyperhq/hypercli)
22

3-
Hyper_ client for Mac/Linux
3+
Hyper.sh client for Mac/Linux
44

55
How to build
66
```

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.10.2
1+
1.10.12

api/client/cli.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ func (cli *DockerCli) ImagesFormat() string {
8383
return cli.configFile.ImagesFormat
8484
}
8585

86+
// VolumesFormat returns the format string specified in the configuration.
87+
// String contains columns and format specification, for example {{ID}}\t{{Name}}.
88+
func (cli *DockerCli) VolumesFormat() string {
89+
return cli.configFile.VolumesFormat
90+
}
91+
8692
func (cli *DockerCli) setRawTerminal() error {
8793
if cli.isTerminalIn && os.Getenv("NORAW") == "" {
8894
state, err := term.SetRawTerminal(cli.inFd)
@@ -153,6 +159,9 @@ func NewDockerCli(in io.ReadCloser, out, err io.Writer, clientFlags *cli.ClientF
153159
if ok {
154160
cloudConfig.AccessKey = cc.AccessKey
155161
cloudConfig.SecretKey = cc.SecretKey
162+
} else {
163+
cloudConfig.AccessKey = os.Getenv("HYPER_ACCESS")
164+
cloudConfig.SecretKey = os.Getenv("HYPER_SECRET")
156165
}
157166
if cloudConfig.AccessKey == "" || cloudConfig.SecretKey == "" {
158167
fmt.Fprintf(cli.err, "WARNING: null cloud config\n")

api/client/commit.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,26 @@ import (
44
"encoding/json"
55
"fmt"
66

7-
"golang.org/x/net/context"
8-
97
"github.com/docker/engine-api/types"
108
"github.com/docker/engine-api/types/container"
119
Cli "github.com/hyperhq/hypercli/cli"
1210
"github.com/hyperhq/hypercli/opts"
1311
flag "github.com/hyperhq/hypercli/pkg/mflag"
12+
"golang.org/x/net/context"
1413
)
1514

1615
// CmdCommit creates a new image from a container's changes.
1716
//
18-
// Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
19-
func (cli *DockerCli) Commit(args ...string) error {
17+
// Usage: hyper commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
18+
func (cli *DockerCli) CmdCommit(args ...string) error {
2019
cmd := Cli.Subcmd("commit", []string{"CONTAINER [REPOSITORY[:TAG]]"}, Cli.DockerCommands["commit"].Description, true)
21-
flPause := cmd.Bool([]string{"p", "-pause"}, true, "Pause container during commit")
20+
flPause := cmd.Bool([]string{}, true, "Pause container during commit")
2221
flComment := cmd.String([]string{"m", "-message"}, "", "Commit message")
2322
flAuthor := cmd.String([]string{"a", "-author"}, "", "Author (e.g., \"John Hannibal Smith <hannibal@a-team.com>\")")
2423
flChanges := opts.NewListOpts(nil)
2524
cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image")
2625
// FIXME: --run is deprecated, it will be replaced with inline Dockerfile commands.
27-
flConfig := cmd.String([]string{"#-run"}, "", "This option is deprecated and will be removed in a future version in favor of inline Dockerfile-compatible commands")
26+
flConfig := cmd.String([]string{}, "", "This option is deprecated and will be removed in a future version in favor of inline Dockerfile-compatible commands")
2827
cmd.Require(flag.Max, 2)
2928
cmd.Require(flag.Min, 1)
3029

api/client/compose.go

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111

1212
"github.com/Sirupsen/logrus"
1313
"github.com/docker/engine-api/client"
14+
"github.com/docker/engine-api/types"
15+
"github.com/docker/engine-api/types/filters"
1416
Cli "github.com/hyperhq/hypercli/cli"
1517
"github.com/hyperhq/hypercli/pkg/jsonmessage"
1618
flag "github.com/hyperhq/hypercli/pkg/mflag"
@@ -21,6 +23,8 @@ import (
2123
"golang.org/x/net/context"
2224
)
2325

26+
const ComposeFipAuto = "auto"
27+
2428
// CmdCompose is the parent subcommand for all compose commands
2529
//
2630
// Usage: hyper compose <COMMAND> [OPTIONS]
@@ -53,6 +57,7 @@ func (cli *DockerCli) CmdComposeRun(args ...string) error {
5357
Context: project.Context{
5458
ComposeFiles: []string{*composeFile},
5559
ProjectName: *projectName,
60+
Autoremove: *rm,
5661
},
5762
ClientFactory: cli,
5863
})
@@ -65,15 +70,15 @@ func (cli *DockerCli) CmdComposeRun(args ...string) error {
6570
if err != nil {
6671
return err
6772
}
68-
if status != 0 {
69-
return Cli.StatusError{StatusCode: status}
70-
}
7173
if *rm {
7274
opts := options.Delete{RemoveVolume: true}
7375
if err = project.Delete(opts, service); err != nil {
7476
return err
7577
}
7678
}
79+
if status != 0 {
80+
return Cli.StatusError{StatusCode: status}
81+
}
7782

7883
return nil
7984
}
@@ -152,6 +157,45 @@ func (cli *DockerCli) CmdComposeUp(args ...string) error {
152157
if *projectName == "" {
153158
*projectName = getBaseDir()
154159
}
160+
var fips = []string{}
161+
var newFipNum = 0
162+
for _, svconfig := range c.M {
163+
if svconfig.Fip == ComposeFipAuto {
164+
newFipNum++
165+
}
166+
}
167+
fipFilterArgs, _ := filters.FromParam("dangling=true")
168+
options := types.NetworkListOptions{
169+
Filters: fipFilterArgs,
170+
}
171+
fipList, err := cli.client.FipList(context.Background(), options)
172+
if err == nil {
173+
for _, fip := range fipList {
174+
if fip["container"] == "" && fip["service"] == "" {
175+
fips = append(fips, fip["fip"])
176+
}
177+
}
178+
}
179+
if newFipNum > len(fips) {
180+
if askForConfirmation(warnMessage) == true {
181+
newFips, err := cli.client.FipAllocate(context.Background(), fmt.Sprintf("%d", newFipNum-len(fips)))
182+
if err != nil {
183+
return err
184+
}
185+
fips = append(fips, newFips...)
186+
}
187+
}
188+
i := 0
189+
for _, svconfig := range c.M {
190+
if svconfig.Fip == ComposeFipAuto {
191+
if i >= newFipNum {
192+
svconfig.Fip = ""
193+
} else {
194+
svconfig.Fip = fips[i]
195+
i++
196+
}
197+
}
198+
}
155199
body, err := cli.client.ComposeUp(*projectName, services, c, vc, nc, cli.configFile.AuthConfigs, *forcerecreate, *norecreate)
156200
if err != nil {
157201
return err
@@ -409,12 +453,41 @@ func (cli *DockerCli) CmdComposeScale(args ...string) error {
409453
return nil
410454
}
411455

456+
// CmdComposePull
457+
//
458+
// Usage: hyper compose pull [OPTIONS]
459+
func (cli *DockerCli) CmdComposePull(args ...string) error {
460+
cmd := Cli.Subcmd("compose pull", []string{"[SERVICE...]"}, "Pull images of services.", false)
461+
composeFile := cmd.String([]string{"f", "-file"}, "docker-compose.yml", "Specify an alternate compose file")
462+
cmd.Require(flag.Min, 0)
463+
err := cmd.ParseFlags(args, true)
464+
if err != nil {
465+
return err
466+
}
467+
project, err := docker.NewProject(&docker.Context{
468+
Context: project.Context{
469+
ComposeFiles: []string{*composeFile},
470+
},
471+
ClientFactory: cli,
472+
})
473+
474+
if err != nil {
475+
return err
476+
}
477+
err = project.Pull(cmd.Args()...)
478+
if err != nil {
479+
return err
480+
}
481+
return nil
482+
}
483+
412484
func composeUsage() string {
413485
composeCommands := [][]string{
414486
{"create", "Creates containers for a service"},
415487
{"down", "Stop and remove containers, images, and volumes"},
416488
{"kill", "Force stop service containers"},
417489
{"ps", "List containers"},
490+
{"pull", "Pull images of services"},
418491
{"rm", "Remove stopped service containers"},
419492
{"run", "Run a one-off command"},
420493
{"scale", "Set number of containers for a service"},

api/client/create.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io"
66
"os"
7+
"path/filepath"
78
"strings"
89

910
"golang.org/x/net/context"
@@ -87,6 +88,8 @@ func parseProtoAndLocalBind(bind string) (string, string, bool) {
8788
if strings.Count(bind, ":") < 1 {
8889
return "", "", false
8990
}
91+
case filepath.VolumeName(bind) != "":
92+
// Windows local path
9093
default:
9194
return "", "", false
9295
}
@@ -165,7 +168,7 @@ func (cli *DockerCli) createContainer(ctx context.Context, config *container.Con
165168
//if image not found try to pull it
166169
if err != nil {
167170
if client.IsErrImageNotFound(err) {
168-
fmt.Fprintf(cli.err, "Unable to find image '%s' locally\n", ref.String())
171+
fmt.Fprintf(cli.err, "Unable to find image '%s' in the current region\n", ref.String())
169172

170173
// we don't want to write to stdout anything apart from container.ID
171174
if err = cli.pullImageCustomOut(ctx, config.Image, cli.err); err != nil {

0 commit comments

Comments
 (0)