Skip to content

refactor: use descriptive verbs for SSH config construction - #420

Open
th3james wants to merge 4 commits into
mainfrom
target-env-refactor
Open

refactor: use descriptive verbs for SSH config construction#420
th3james wants to merge 4 commits into
mainfrom
target-env-refactor

Conversation

@th3james

@th3james th3james commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Changes

I noticed that ssh.NewConfig has a stateful side effect (exec'ing ssh) and discarded its errors. Because stateful calls are so critical for performance and reliability, I prefer it when function names make it clear that they are stateful, which, IMHO NewConfig does not. I recognise this may go slightly against the conventions for the use of New for constructors in this repo, so happy to debate this.

  • Renames: ssh.NewConfig -> ssh.LoadConfig
  • Renames: ssh.NewConfigFromBytes -> ssh.ParseConfig
  • Repurposes the previously unused ResolveHostName function, and then uses it
  • Makes ssh.LoadConfig return an error, forcing callers to handle it

Checklist

  • 🤖 This change is covered by tests as required.
  • 🤹 All required manual testing has been performed.
  • 📖 All documentation updates are complete.

@th3james
th3james marked this pull request as ready for review August 20, 2026 15:00
@th3james
th3james requested a review from a team as a code owner August 20, 2026 15:00
@th3james
th3james force-pushed the target-env-refactor branch from 07140a7 to f2a951a Compare August 20, 2026 15:04
err := env.SetTargetEnv("localhost")

require.NoError(t, err)
assert.Equal(t, "ssh://localhost", os.Getenv(env.TargetVariable))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This codifies the existing behaviour, but does call into question whether or not this is desirable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's undesirable? The prepending of ssh://? If yes I've got no strong opinions but an argument in favour of leaving it is you want to write something like:

# compose.yaml
x-topo:
  deployment_success_message: "Check out your new deployed application on the target with `ssh ${TOPO_TARGET} 'cat /my/cool/thing'`"

This wouldn't work anymore if we removed the prepending since Topo happily accepts things like --target localhost:2222, an invalid ssh destination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants