Skip to content

Commit 081204d

Browse files
committed
resolved #5
Add a flag `no-ssh` that disables SSH. If the config repository or any of the target repositories use SSH, they will fail to pull.
1 parent 404c740 commit 081204d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ this repository has new commits, Wadsworth will automatically reconfigure.`,
6060
ArgsUsage: "target",
6161
Flags: []cli.Flag{
6262
cli.StringFlag{Name: "directory", EnvVar: "DIRECTORY", Value: "./cache/"},
63+
cli.BoolFlag{Name: "no-ssh", EnvVar: "NO_SSH"},
6364
cli.DurationFlag{Name: "check-interval", EnvVar: "CHECK_INTERVAL", Value: time.Second * 10},
6465
cli.StringFlag{Name: "vault-addr", EnvVar: "VAULT_ADDR"},
6566
cli.StringFlag{Name: "vault-token", EnvVar: "VAULT_TOKEN"},
@@ -76,6 +77,7 @@ this repository has new commits, Wadsworth will automatically reconfigure.`,
7677

7778
svc, err := service.Initialise(ctx, service.Config{
7879
Target: c.Args().First(),
80+
NoSSH: c.Bool("no-ssh"),
7981
Directory: c.String("directory"),
8082
CheckInterval: c.Duration("check-interval"),
8183
VaultAddress: c.String("vault-addr"),

service/service.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type App struct {
3333

3434
type Config struct {
3535
Target string
36+
NoSSH bool
3637
Directory string
3738
CheckInterval time.Duration
3839
VaultAddress string
@@ -47,9 +48,11 @@ func Initialise(ctx context.Context, c Config) (app *App, err error) {
4748
app.ctx, app.cancel = context.WithCancel(ctx)
4849
app.config = c
4950

50-
app.ssh, err = ssh.NewSSHAgentAuth("git")
51-
if err != nil {
52-
return nil, errors.Wrap(err, "failed to set up SSH authentication")
51+
if c.NoSSH {
52+
app.ssh, err = ssh.NewSSHAgentAuth("git")
53+
if err != nil {
54+
return nil, errors.Wrap(err, "failed to set up SSH authentication")
55+
}
5356
}
5457

5558
if c.VaultAddress != "" {

0 commit comments

Comments
 (0)