Skip to content

Commit

Permalink
Implement Hubert suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasMahe committed Dec 4, 2018
1 parent ff6ac3c commit e15ffb2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

var (
errSwarmNotInit = errors.New(`docker swarm is not initialized. run "docker swarm init" to setup swarm and try again`)
errSwarmNotInit = errors.New(`docker swarm is not initialized. run "docker swarm init" and try again`)
)

// Container describes the API of container package.
Expand Down Expand Up @@ -71,7 +71,7 @@ func New(options ...Option) (*DockerContainer, error) {
}
}
c.negotiateAPIVersion()
if err := c.checkSwarm(); err != nil {
if err := c.checkSwarmInit(); err != nil {
return c, err
}
return c, c.createSharedNetworkIfNeeded()
Expand All @@ -97,7 +97,7 @@ func (c *DockerContainer) negotiateAPIVersion() {
c.client.NegotiateAPIVersion(ctx)
}

func (c *DockerContainer) checkSwarm() error {
func (c *DockerContainer) checkSwarmInit() error {
ctx, cancel := context.WithTimeout(context.Background(), c.callTimeout)
defer cancel()
info, err := c.client.Info(ctx)
Expand Down
2 changes: 1 addition & 1 deletion container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestNewSwarmError(t *testing.T) {
dt.ProvideInfo(types.Info{Swarm: swarm.Info{NodeID: ""}}, nil)

_, err := New(ClientOption(dt.Client()))
require.Error(t, err, errSwarmNotInit)
require.Equal(t, err, errSwarmNotInit)
}

func TestFindContainerNonExistent(t *testing.T) {
Expand Down

0 comments on commit e15ffb2

Please sign in to comment.