Skip to content

Commit 7fcf5a2

Browse files
committed
Export the git config settings
Other users of this package may want to override those settings, so exporting and documenting them make this just easier. While at it, improve the inline doc.
1 parent a295e74 commit 7fcf5a2

File tree

4 files changed

+31
-24
lines changed

4 files changed

+31
-24
lines changed

cmd/execute.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var (
4646
return fmt.Errorf("Failed to initialize the configuration: %v", err)
4747
}
4848

49-
run.Run(conf) // <- this is where things happens
49+
run.Run(conf) // <- this is where things happen
5050
return nil
5151
},
5252
}

pkg/recorder/recorder.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package recorder listen for events notification from controllers,
1+
// Package recorder listen for event notifications from controllers,
22
// and persists those events' content as files on disk.
33
package recorder
44

@@ -38,7 +38,7 @@ type Listener struct {
3838
donech chan struct{}
3939
}
4040

41-
// New creates a new Listener
41+
// New creates a new event Listener
4242
func New(config *config.KfConfig, events event.Notifier) *Listener {
4343
return &Listener{
4444
config: config,
@@ -47,7 +47,7 @@ func New(config *config.KfConfig, events event.Notifier) *Listener {
4747
}
4848
}
4949

50-
// Start receive events and saves them to disk as files
50+
// Start continuously receive events and saves them to disk as files
5151
func (w *Listener) Start() *Listener {
5252
w.config.Logger.Info("Starting event recorder")
5353
err := appFs.MkdirAll(filepath.Clean(w.config.LocalDir), 0700)

pkg/store/git/doc.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Package git makes a git repository out of a local directory, keeps the
2+
// content committed when the directory content changes, and optionaly (if
3+
// a remote repos url is provided), keep it in sync with a remote repository.
4+
//
5+
// It requires the git command in $PATH, since the pure Go git implementations
6+
// aren't up to the task (see go-git issues #793 and #785 for instance).
7+
package git

pkg/store/git/git.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
// We'd love a working pure Go implementation. But so far we didn't find any
2-
// that would work for us. src-d/go-git is innapropriate due to
3-
// https://github.com/src-d/go-git/issues/793 and
4-
// https://github.com/src-d/go-git/issues/785 . And binding to the libgit C lib
5-
// aren't pure Go either. So we need the git binary for now.
6-
7-
// Package git makes a git repository out of a local directory, keeps the
8-
// content committed when the directory content changes, and optionaly (if
9-
// a remote repos url is provided), keep it in sync with a remote repository.
101
package git
112

123
import (
@@ -23,11 +14,20 @@ import (
2314
)
2415

2516
var (
26-
timeoutCommands = 60 * time.Second
27-
checkInterval = 10 * time.Second
28-
gitAuthor = "Katafygio"
29-
gitEmail = "katafygio@localhost"
30-
gitMsg = "Kubernetes cluster change"
17+
// TimeoutCommands defines the max execution time for git commands
18+
TimeoutCommands = 60 * time.Second
19+
20+
// CheckInterval defines the interval between local directory checks
21+
CheckInterval = 10 * time.Second
22+
23+
// GitAuthor is the name of the commiter
24+
GitAuthor = "Katafygio"
25+
26+
// GitEmail is the email of the commiter
27+
GitEmail = "katafygio@localhost"
28+
29+
// GitMsg is the commit message we'll use
30+
GitMsg = "Kubernetes cluster change"
3131
)
3232

3333
var appFs = afero.NewOsFs()
@@ -51,9 +51,9 @@ func New(config *config.KfConfig) *Store {
5151
Logger: config.Logger,
5252
URL: config.GitURL,
5353
LocalDir: config.LocalDir,
54-
Author: gitAuthor,
55-
Email: gitEmail,
56-
Msg: gitMsg,
54+
Author: GitAuthor,
55+
Email: GitEmail,
56+
Msg: GitMsg,
5757
DryRun: config.DryRun,
5858
}
5959
}
@@ -70,7 +70,7 @@ func (s *Store) Start() (*Store, error) {
7070
}
7171

7272
go func() {
73-
checkTick := time.NewTicker(checkInterval)
73+
checkTick := time.NewTicker(CheckInterval)
7474
defer checkTick.Stop()
7575
defer close(s.donech)
7676

@@ -100,7 +100,7 @@ func (s *Store) Git(args ...string) error {
100100
return nil
101101
}
102102

103-
ctx, cancel := context.WithTimeout(context.Background(), timeoutCommands)
103+
ctx, cancel := context.WithTimeout(context.Background(), TimeoutCommands)
104104
defer cancel()
105105

106106
cmd := exec.CommandContext(ctx, "git", args...) // #nosec
@@ -121,7 +121,7 @@ func (s *Store) Status() (changed bool, err error) {
121121
return false, nil
122122
}
123123

124-
ctx, cancel := context.WithTimeout(context.Background(), timeoutCommands)
124+
ctx, cancel := context.WithTimeout(context.Background(), TimeoutCommands)
125125
defer cancel()
126126

127127
cmd := exec.CommandContext(ctx, "git", "status", "--porcelain") // #nosec

0 commit comments

Comments
 (0)