@@ -20,39 +20,42 @@ import (
20
20
"fmt"
21
21
"io/ioutil"
22
22
"os"
23
+ "path/filepath"
23
24
24
25
"github.com/Sirupsen/logrus"
25
26
"github.com/bitnami-labs/kubewatch/config"
26
27
"github.com/bitnami-labs/kubewatch/pkg/client"
27
28
"github.com/spf13/cobra"
28
29
)
29
30
31
+ const kubewatchConfigFile = ".kubewatch.yaml"
32
+
30
33
// configCmd represents the config command
31
34
var configCmd = & cobra.Command {
32
35
Use : "config" ,
33
36
Short : "modify kubewatch configuration" ,
34
37
Long : `
35
- config command allows configuration of .kubewatch.yaml for running kubewatch` ,
38
+ config command allows configuration of ~/ .kubewatch.yaml for running kubewatch` ,
36
39
Run : func (cmd * cobra.Command , args []string ) {
37
40
cmd .Help ()
38
41
},
39
42
}
40
43
41
44
var configAddCmd = & cobra.Command {
42
45
Use : "add" ,
43
- Short : "add webhook config to .kubewatch.yaml" ,
46
+ Short : "add webhook config to ~/ .kubewatch.yaml" ,
44
47
Long : `
45
- Adds webhook config to .kubewatch.yaml` ,
48
+ Adds webhook config to ~/ .kubewatch.yaml` ,
46
49
Run : func (cmd * cobra.Command , args []string ) {
47
50
cmd .Help ()
48
51
},
49
52
}
50
53
51
54
var configTestCmd = & cobra.Command {
52
55
Use : "test" ,
53
- Short : "test handler config present in .kubewatch.yaml" ,
56
+ Short : "test handler config present in ~/ .kubewatch.yaml" ,
54
57
Long : `
55
- Tests handler configs present in .kubewatch.yaml by sending test messages` ,
58
+ Tests handler configs present in ~/ .kubewatch.yaml by sending test messages` ,
56
59
Run : func (cmd * cobra.Command , args []string ) {
57
60
fmt .Println ("Testing Handler configs from .kubewatch.yaml" )
58
61
conf , err := config .New ()
@@ -66,16 +69,17 @@ Tests handler configs present in .kubewatch.yaml by sending test messages`,
66
69
67
70
var configViewCmd = & cobra.Command {
68
71
Use : "view" ,
69
- Short : "view .kubewatch.yaml" ,
72
+ Short : "view ~/ .kubewatch.yaml" ,
70
73
Long : `
71
- Display the contents of the contents of .kubewatch.yaml` ,
74
+ Display the contents of the contents of ~/ .kubewatch.yaml` ,
72
75
Run : func (cmd * cobra.Command , args []string ) {
73
- fmt .Println ( "Contents of .kubewatch.yaml" )
74
- configFile , err := ioutil .ReadFile (os .Getenv ("HOME" ) + "/" + ".kubewatch.yaml" )
76
+ fmt .Fprintln ( os . Stderr , "Contents of ~/ .kubewatch.yaml" )
77
+ configFile , err := ioutil .ReadFile (filepath . Join ( os .Getenv ("HOME" ), kubewatchConfigFile ) )
75
78
if err != nil {
76
- fmt .Printf ("yamlFile.Get err #%v " , err )
79
+ fmt .Fprintf (os .Stderr , "%v\n " , err )
80
+ os .Exit (1 )
77
81
}
78
- fmt .Println (string (configFile ))
82
+ fmt .Print (string (configFile ))
79
83
},
80
84
}
81
85
0 commit comments