@@ -29,6 +29,7 @@ type Store struct {
29
29
Author string
30
30
Email string
31
31
Msg string
32
+ DryRun bool
32
33
stopch chan struct {}
33
34
donech chan struct {}
34
35
}
@@ -42,6 +43,7 @@ func New(config *config.KfConfig) *Store {
42
43
Author : "Katafygio" , // XXX maybe this could be a cli option
43
44
Email : "katafygio@localhost" ,
44
45
Msg : "Kubernetes cluster change" ,
46
+ DryRun : config .DryRun ,
45
47
}
46
48
}
47
49
@@ -83,6 +85,10 @@ func (s *Store) Stop() {
83
85
84
86
// Git wraps the git command
85
87
func (s * Store ) Git (args ... string ) error {
88
+ if s .DryRun {
89
+ return nil
90
+ }
91
+
86
92
ctx , cancel := context .WithTimeout (context .Background (), timeoutCommands )
87
93
defer cancel ()
88
94
@@ -99,6 +105,10 @@ func (s *Store) Git(args ...string) error {
99
105
100
106
// Status tests the git status of a repository
101
107
func (s * Store ) Status () (changed bool , err error ) {
108
+ if s .DryRun {
109
+ return false , nil
110
+ }
111
+
102
112
ctx , cancel := context .WithTimeout (context .Background (), timeoutCommands )
103
113
defer cancel ()
104
114
@@ -119,6 +129,10 @@ func (s *Store) Status() (changed bool, err error) {
119
129
120
130
// Clone does git clone, or git init (when there's no GiURL to clone from)
121
131
func (s * Store ) Clone () error {
132
+ if s .DryRun {
133
+ return nil
134
+ }
135
+
122
136
err := os .MkdirAll (s .LocalDir , 0700 )
123
137
if err != nil {
124
138
return fmt .Errorf ("failed to created %s: %v" , s .LocalDir , err )
0 commit comments