Skip to content

Commit

Permalink
Suggest how to disable weave errors and warnings
Browse files Browse the repository at this point in the history
This applies when running scope deployments without Weave Net.
  • Loading branch information
Roberto Bruggemann committed Dec 15, 2017
1 parent dacf284 commit c098d56
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions common/weave/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import (
"github.com/weaveworks/common/exec"
)

const dockerAPIVersion = "1.22" // Support Docker Engine >= 1.10
const (
dockerAPIVersion = "1.22" // Support Docker Engine >= 1.10

noWeaveTip = "If you are not running Weave Net, you may wish to suppress this warning by launching scope with the `--weave=false` option."
)

// Client for Weave Net API
type Client interface {
Expand Down Expand Up @@ -136,7 +140,7 @@ func (c *client) Status() (Status, error) {
req.Header.Add("Accept", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return Status{}, err
return Status{}, errorf("%v", err)
}
defer resp.Body.Close()

Expand Down Expand Up @@ -165,7 +169,7 @@ func (c *client) AddDNSEntry(fqdn, containerID string, ip net.IP) error {
req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
return errorf("%v", err)
}
if err := resp.Body.Close(); err != nil {
return err
Expand Down Expand Up @@ -212,7 +216,7 @@ func (c *client) PS() (map[string]PSEntry, error) {
slurp, _ := ioutil.ReadAll(stdErr)
cmdErr := cmd.Wait()
if cmdErr != nil {
return nil, fmt.Errorf("%s: %q", cmdErr, slurp)
return nil, errorf("%s: %q", cmdErr, slurp)
}
if scannerErr != nil {
return nil, scannerErr
Expand All @@ -228,7 +232,7 @@ func (c *client) Expose() error {
if exitErr, ok := err.(*realexec.ExitError); ok {
stdErr = exitErr.Stderr
}
return fmt.Errorf("Error running weave ps: %s: %q", err, stdErr)
return errorf("Error running weave ps: %s: %q", err, stdErr)
}
ips := ipMatch.FindAllSubmatch(output, -1)
if ips != nil {
Expand All @@ -241,7 +245,7 @@ func (c *client) Expose() error {
if exitErr, ok := err.(*realexec.ExitError); ok {
stdErr = exitErr.Stderr
}
return fmt.Errorf("Error running weave expose: %s: %q", err, stdErr)
return errorf("Error running weave expose: %s: %q", err, stdErr)
}
return nil
}
Expand All @@ -251,3 +255,7 @@ func weaveCommand(arg ...string) exec.Cmd {
cmd.SetEnv(append(os.Environ(), "DOCKER_API_VERSION="+dockerAPIVersion))
return cmd
}

func errorf(format string, a...interface{}) error {
return fmt.Errorf(format + ". %v", append(a, noWeaveTip)...)
}

0 comments on commit c098d56

Please sign in to comment.