Skip to content

Commit

Permalink
up: consolidate usage of out and remove tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
mfojtik committed Apr 30, 2018
1 parent f3ca235 commit d570c0a
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 226 deletions.
39 changes: 39 additions & 0 deletions pkg/oc/bootstrap/docker/error_printer.go
@@ -0,0 +1,39 @@
package docker

import (
"fmt"
"io"

"github.com/openshift/origin/pkg/oc/util/prefixwriter"
)

type hasCause interface {
Cause() error
}

type hasDetails interface {
Details() string
}

type hasSolution interface {
Solution() string
}

func PrintError(err error, out io.Writer) {
fmt.Fprintf(out, "Error: %v\n", err)
if d, ok := err.(hasDetails); ok && len(d.Details()) > 0 {
fmt.Fprintln(out, "Details:")
w := prefixwriter.New(" ", out)
fmt.Fprintf(w, "%s\n", d.Details())
}
if s, ok := err.(hasSolution); ok && len(s.Solution()) > 0 {
fmt.Fprintln(out, "Solution:")
w := prefixwriter.New(" ", out)
fmt.Fprintf(w, "%s\n", s.Solution())
}
if c, ok := err.(hasCause); ok && c.Cause() != nil {
fmt.Fprintln(out, "Caused By:")
w := prefixwriter.New(" ", out)
PrintError(c.Cause(), w)
}
}
2 changes: 1 addition & 1 deletion pkg/oc/bootstrap/docker/openshift/project.go
Expand Up @@ -13,7 +13,7 @@ import (
projectclientinternal "github.com/openshift/origin/pkg/project/generated/internalclientset"
)

// CreateProject creates a project
// createProject creates a project
func CreateProject(f *clientcmd.Factory, name, display, desc, basecmd string, out io.Writer) error {
clientConfig, err := f.ClientConfig()
if err != nil {
Expand Down
119 changes: 0 additions & 119 deletions pkg/oc/bootstrap/docker/printer.go

This file was deleted.

0 comments on commit d570c0a

Please sign in to comment.