Skip to content

Commit 2075da4

Browse files
Merge pull request #19566 from mfojtik/up-32-printer
up: consolidate usage of out and remove tasks
2 parents a846d3d + d570c0a commit 2075da4

File tree

4 files changed

+113
-226
lines changed

4 files changed

+113
-226
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package docker
2+
3+
import (
4+
"fmt"
5+
"io"
6+
7+
"github.com/openshift/origin/pkg/oc/util/prefixwriter"
8+
)
9+
10+
type hasCause interface {
11+
Cause() error
12+
}
13+
14+
type hasDetails interface {
15+
Details() string
16+
}
17+
18+
type hasSolution interface {
19+
Solution() string
20+
}
21+
22+
func PrintError(err error, out io.Writer) {
23+
fmt.Fprintf(out, "Error: %v\n", err)
24+
if d, ok := err.(hasDetails); ok && len(d.Details()) > 0 {
25+
fmt.Fprintln(out, "Details:")
26+
w := prefixwriter.New(" ", out)
27+
fmt.Fprintf(w, "%s\n", d.Details())
28+
}
29+
if s, ok := err.(hasSolution); ok && len(s.Solution()) > 0 {
30+
fmt.Fprintln(out, "Solution:")
31+
w := prefixwriter.New(" ", out)
32+
fmt.Fprintf(w, "%s\n", s.Solution())
33+
}
34+
if c, ok := err.(hasCause); ok && c.Cause() != nil {
35+
fmt.Fprintln(out, "Caused By:")
36+
w := prefixwriter.New(" ", out)
37+
PrintError(c.Cause(), w)
38+
}
39+
}

pkg/oc/bootstrap/docker/openshift/project.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
projectclientinternal "github.com/openshift/origin/pkg/project/generated/internalclientset"
1414
)
1515

16-
// CreateProject creates a project
16+
// createProject creates a project
1717
func CreateProject(f *clientcmd.Factory, name, display, desc, basecmd string, out io.Writer) error {
1818
clientConfig, err := f.ClientConfig()
1919
if err != nil {

pkg/oc/bootstrap/docker/printer.go

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)