Skip to content

Commit 79ff34c

Browse files
committed
cleanup duration
Signed-off-by: Jess Frazelle <[email protected]>
1 parent 996b83e commit 79ff34c

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ $ sshb0t -h
4242
/ __/ __| '_ \| '_ \| | | | __|
4343
\__ \__ \ | | | |_) | |_| | |_
4444
|___/___/_| |_|_.__/ \___/ \__|
45+
4546
A bot for keeping your ssh authorized_keys up to date with user's GitHub keys
4647
Version: v0.3.2
47-
Build: 94b44ff
48+
Build: 996b83e
4849

4950
-d run in debug mode
50-
-interval string
51-
update interval (ex. 5ms, 10s, 1m, 3h) (default "30s")
51+
-interval duration
52+
update interval (ex. 5ms, 10s, 1m, 3h) (default 30s)
5253
-keyfile string
53-
file to update the authorized_keys (default "/home/jessie/.ssh/authorized_keys")
54+
file to update the authorized_keys (default "~/.ssh/authorized_keys")
5455
-once
5556
run once and exit, do not run as a daemon
5657
-url string

main.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
/ __/ __| '_ \| '_ \| | | | __|
2929
\__ \__ \ | | | |_) | |_| | |_
3030
|___/___/_| |_|_.__/ \___/ \__|
31+
3132
A bot for keeping your ssh authorized_keys up to date with user's GitHub keys
3233
Version: %s
3334
Build: %s
@@ -41,7 +42,7 @@ var (
4142
enturl string
4243
users stringSlice
4344

44-
interval string
45+
interval time.Duration
4546
once bool
4647

4748
debug bool
@@ -73,7 +74,7 @@ func init() {
7374
flag.StringVar(&enturl, "url", "https://github.com", "GitHub Enterprise URL")
7475
flag.Var(&users, "user", "GitHub usernames for which to fetch keys")
7576

76-
flag.StringVar(&interval, "interval", "30s", "update interval (ex. 5ms, 10s, 1m, 3h)")
77+
flag.DurationVar(&interval, "interval", 30*time.Second, "update interval (ex. 5ms, 10s, 1m, 3h)")
7778
flag.BoolVar(&once, "once", false, "run once and exit, do not run as a daemon")
7879

7980
flag.BoolVar(&vrsn, "version", false, "print version and exit")
@@ -121,7 +122,7 @@ func init() {
121122
}
122123

123124
func main() {
124-
var ticker *time.Ticker
125+
ticker := time.NewTicker(interval)
125126

126127
// On ^C, or SIGTERM handle exit.
127128
c := make(chan os.Signal, 1)
@@ -135,13 +136,6 @@ func main() {
135136
}
136137
}()
137138

138-
// parse the duration
139-
dur, err := time.ParseDuration(interval)
140-
if err != nil {
141-
logrus.Fatalf("parsing %s as duration failed: %v", interval, err)
142-
}
143-
ticker = time.NewTicker(dur)
144-
145139
// If the user passed the once flag, just do the run once and exit.
146140
if once {
147141
run()

0 commit comments

Comments
 (0)