Skip to content

Commit

Permalink
always validate before returning client
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldwan committed Aug 13, 2021
1 parent c5fa194 commit 6c53a71
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/fly_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func runFlyAgentStart(cc *cmdctx.CmdContext) error {
c.Kill(ctx)
}

_, err = agent.Establish(ctx, api, true)
_, err = agent.Establish(ctx, api)
if err != nil {
fmt.Fprintf(os.Stderr, "can't start agent: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ssh_terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func runSSHConsole(cc *cmdctx.CmdContext) error {
return fmt.Errorf("get app: %w", err)
}

agentclient, err := agent.Establish(ctx, client, true)
agentclient, err := agent.Establish(ctx, client)
if err != nil {
return fmt.Errorf("can't establish agent: %s\n", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/build/imgsrc/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func newRemoteDockerClient(ctx context.Context, apiClient *api.Client, appName s
return errors.Wrap(err, "error fetching target app")
}

agentclient, err := agent.Establish(errCtx, apiClient, true)
agentclient, err := agent.Establish(errCtx, apiClient)
if err != nil {
return errors.Wrap(err, "error establishing agent")
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,9 @@ func captureWireguardConnErr(err error, org string) {
}

/// Establish starts the daemon if necessary and returns a client
func Establish(ctx context.Context, apiClient *api.Client, validate bool) (*Client, error) {
if validate {
if err := wireguard.PruneInvalidPeers(apiClient); err != nil {
return nil, err
}
func Establish(ctx context.Context, apiClient *api.Client) (*Client, error) {
if err := wireguard.PruneInvalidPeers(apiClient); err != nil {
return nil, err
}

c, err := DefaultClient(apiClient)
Expand Down

0 comments on commit 6c53a71

Please sign in to comment.