Skip to content

Finetune v2 naming conventions - #301

Merged
kke merged 30 commits into
mainfrom
naming-conventions
Mar 24, 2026
Merged

kke merged 30 commits into
mainfrom
naming-conventions

Conversation

@kke

@kke kke commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor
  • Rename the lazy init wrappers from Service to Provider to avoid confusion with system services
  • Rename connectionConfigurer to connectionFactory to avoid confusion with OS configurers
  • Some other renames and fixes

The v2 API is not being used by anything yet (it's still 2.0.0-alpha.1) so breaking the API is a non-issue.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates naming across the rig v2 API to reduce ambiguity between “services” (OS/init system services) and internal lazy-init wrappers, and to clarify “configurer” vs “factory” responsibilities. It also renames the “abort” sentinel error to better communicate retry semantics.

Changes:

  • Rename lazy-init wrappers from Service to Provider, and rename plumbing-backed repositories from Provider to Registry across sudo/os/initsystem/packagemanager.
  • Rename ConnectionConfigurer/WithConnectionConfigurer to ConnectionFactory/WithConnectionFactory and update client wiring accordingly.
  • Rename ErrAbort to ErrNonRetryable across protocol/retry layers and update call sites/tests.

Reviewed changes

Copilot reviewed 47 out of 47 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
sudo/windows.go Update registration function signature to accept *Registry.
sudo/sudo.go Update registration function signature to accept *Registry.
sudo/service.go Rename lazy-init wrapper Service → Provider; adjust constructor and method naming.
sudo/noop.go Update registration function signature to accept *Registry.
sudo/doas.go Update registration function signature to accept *Registry.
sudo/defaultprovider.go Rename default repo DefaultProvider → DefaultRegistry; rename SudoProvider → SudoFactory; alias repo type to Registry.
retry/retry.go Rename sentinel ErrAbort → ErrNonRetryable and update retry predicate default.
retry/retry_test.go Update tests to use ErrNonRetryable.
remotefs/service.go Rename lazy-init wrapper Service → Provider; remove error-swallowing accessor, keep error-returning API.
remotefs/defaultprovider.go Rename default provider symbol/type to DefaultRegistry/Registry; rename RemoteFSProvider → RemoteFSFactory.
protocol/winrm/connection.go Replace protocol.ErrAbort usage with protocol.ErrNonRetryable in non-retryable error paths.
protocol/ssh/connection.go Replace protocol.ErrAbort usage with protocol.ErrNonRetryable in non-retryable error paths.
protocol/connection.go Rename ErrAbort → ErrNonRetryable in protocol package.
packagemanager/zypper.go Update registration function signature to accept *Registry.
packagemanager/yum.go Update registration function signature to accept *Registry.
packagemanager/winget.go Update registration function signature to accept *Registry.
packagemanager/windowsmulti.go Use NewRegistry() for Windows multi-manager repo and update registration signature.
packagemanager/service.go Rename lazy-init wrapper Service → Provider; move to error-returning accessor naming.
packagemanager/service_test.go Update tests to new provider API and default registry usage.
packagemanager/scoop.go Update registration function signature to accept *Registry.
packagemanager/pacman.go Update registration function signature to accept *Registry.
packagemanager/macports.go Update registration function signature to accept *Registry.
packagemanager/homebrew.go Update registration function signature to accept *Registry.
packagemanager/dnf.go Update registration function signature to accept *Registry.
packagemanager/defaultprovider.go Rename PackageManagerProvider → PackageManagerFactory; rename default repo to DefaultRegistry; alias repo type to Registry.
packagemanager/chocolatey.go Update registration function signature to accept *Registry.
packagemanager/apt.go Update registration function signature to accept *Registry.
packagemanager/apk.go Update registration function signature to accept *Registry.
os/windows.go Update resolver registration signature to accept *Registry.
os/service.go Rename lazy-init wrapper Service → Provider; rename getter and constructor to factory terminology.
os/linux.go Update resolver registration signature to accept *Registry.
os/defaultprovider.go Rename default repo DefaultProvider → DefaultRegistry; rename OSReleaseProvider → OSReleaseFactory; alias repo type to Registry.
os/darwin.go Update resolver registration signature to accept *Registry.
initsystem/winscm.go Update registration function signature to accept *Registry.
initsystem/upstart.go Update registration function signature to accept *Registry.
initsystem/sysvinit.go Update registration function signature to accept *Registry.
initsystem/systemd.go Update registration function signature to accept *Registry.
initsystem/service.go Rename lazy-init wrapper Service → Provider; change to error-returning accessor and new constructor naming.
initsystem/runit.go Update registration function signature to accept *Registry.
initsystem/openrc.go Update registration function signature to accept *Registry.
initsystem/launchd.go Update registration function signature to accept *Registry.
initsystem/defaultprovider.go Rename default repo DefaultProvider → DefaultRegistry; rename InitSystemProvider → InitSystemFactory; alias repo type to Registry.
compositeconfig.go Update compile-time assertion and internal selection to return ConnectionFactory.
clientoptions.go Rename connection configurer concepts to ConnectionFactory; update provider/factory config plumbing and defaults.
client.go Update client wiring to new factory/provider APIs; update retry sentinel; adjust sudo/fs/pm/os accessors accordingly.
client_test.go Update tests to use WithConnectionFactory.
aliases.go Rename exported alias ErrAbort → ErrNonRetryable and update type aliases to new Provider names; update default registry usage.
Comments suppressed due to low confidence (1)

clientoptions.go:141

  • Debug log messages in GetConnection() still refer to a "client configurer" even though the field is now connectionFactory. Update these messages to match the new terminology.
	} else {
		if o.connectionFactory == nil {
			return nil, fmt.Errorf("%w: no connection or connection configurer provided", protocol.ErrNonRetryable)
		}
		o.Log().Debug("using client configurer to setup a connection", log.HostAttr(o.connectionFactory), log.KeyComponent, "clientoptions")
		c, err := o.connectionFactory.Connection()
		if err != nil {
			return nil, fmt.Errorf("create connection: %w", err)
		}
		o.Log().Debug("using connection received from client configurer", log.HostAttr(c), log.KeyComponent, "clientoptions")
		conn = c

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread client.go Resolved
Comment thread client.go Resolved
Comment thread client.go Resolved
Comment thread clientoptions.go Resolved
Comment thread clientoptions.go Resolved
Comment thread protocol/connection.go Resolved
Comment thread retry/retry.go Resolved
Comment thread remotefs/defaultprovider.go Resolved
Comment thread sudo/windows.go Resolved
Comment thread clientoptions.go Resolved
kke added 11 commits March 22, 2026 19:39
Also rename the plumbing.Provider type aliases from Provider to Registry
in each sub-package to avoid name collisions with the new Provider struct.

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Consolidate the two-method pattern (GetXxx + null-object Xxx) into a
single error-returning method. The null-object fallback is now handled
inline in Client convenience methods.

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Rename in both protocol and retry packages for consistency.

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Rename interfaces to avoid revive stutter warnings:
- initsystem.InitSystemFactory -> ServiceManagerFactory
- os.OSReleaseFactory -> ReleaseFactory
- packagemanager.PackageManagerFactory -> ManagerFactory
- remotefs.RemoteFSFactory -> Factory
- sudo.SudoFactory -> RunnerFactory

Rename remotefs.Registry to DefaultFactory since it is a simple
factory that switches on OS, not a real registry wrapping
plumbing.Provider with multiple registered factories.

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
- Remove unused connectionFactory field from Client struct; use
  c.options.connectionFactory in String() instead
- Fix field alignment in ClientOptions to satisfy gci formatter
- Simplify embedded field selectors (staticcheck QF1008):
  c.InitSystemProvider.ServiceManager() -> c.ServiceManager()
  c.SudoProvider.SudoRunner() -> c.SudoRunner()
  c.OSReleaseProvider.OSRelease() -> c.OSRelease()

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
- Replace "configurer" with "factory" in comments, log messages,
  and error strings following the ConnectionConfigurer rename
- Fix "intialized" typo in client.go error message
- Fix "managament" spelling in initsystem/service.go comment
- Change "can not" to "cannot" in ErrNonRetryable error messages
  in both protocol/connection.go and retry/retry.go

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Align local variable naming with the ConnectionConfigurer to
ConnectionFactory rename done in an earlier commit.

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
All XxxFactory interfaces in subpackages are replaced with named
function types (e.g. ServiceManagerProvider, FSProvider) following
Go idiom: single-method interfaces become named func types.

plumbing.LazyService now holds a plain func field instead of an
internal provider interface, removing unnecessary abstraction.

Callers pass registry.Get as a method value where a provider func
is expected, e.g. initsystem.DefaultRegistry().Get.

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 49 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread client.go Resolved
Comment thread plumbing/lazyservice.go Resolved
kke added 2 commits March 23, 2026 10:49
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 49 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread clientoptions.go Resolved
Comment thread packagemanager/yum.go Resolved
kke added 2 commits March 23, 2026 11:16
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 49 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread aliases.go Resolved
Comment thread aliases.go Resolved
Comment thread client.go Resolved
Comment thread client_test.go Resolved
Comment thread aliases.go Resolved
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
@kke
kke requested a review from Copilot March 23, 2026 09:39
kke added 2 commits March 23, 2026 14:21
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 49 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

protocol/ssh/connection.go:479

  • Connection.Connect writes to c.client and starts keepalive without holding c.mu, but other methods (e.g. IsConnected, Disconnect, StartProcess) now read/clear c.client under c.mu. This introduces a real data race (and can be triggered by the keepalive goroutine calling IsConnected while a reconnect calls Connect). Consider taking c.mu in Connect (and connectViaBastion) around all reads/writes of c.client, c.done, and any other shared fields touched during connection setup/teardown, or switch to an RWMutex/atomic pattern consistently.
    protocol/ssh/connection.go:428
  • connectViaBastion assigns to c.client and calls startKeepalive() without synchronization, which has the same race characteristics as the direct Connect path now that other methods guard c.client with c.mu. Apply the same locking strategy here as in Connect to keep client/done updates consistent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread protocol/ssh/connection.go Resolved
Comment thread protocol/ssh/connection.go Resolved
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 49 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

protocol/ssh/connection.go:479

  • Connect assigns to c.client and then starts keepalive without holding c.mu, even though other methods (and the new reconnect logic in StartProcess) read/clear c.client under the mutex. This can cause data races (and inconsistent c.done handling) when Connect/Disconnect/IsConnected run concurrently. Consider locking c.mu for the entire connection establishment + c.client/keepalive state update, and ensure any previous keepalive channel is cleaned up before overwriting it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread protocol/ssh/connection.go Resolved
Comment thread protocol/ssh/connection.go Resolved
Comment thread aliases.go Resolved
Comment thread protocol/connection.go Resolved
kke added 2 commits March 23, 2026 15:00
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 49 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread protocol/ssh/connection.go Resolved
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 49 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plumbing/lazyservice.go Resolved
Comment thread protocol/ssh/connection.go Resolved
kke added 2 commits March 24, 2026 14:12
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 49 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sudo/windows.go Resolved
Comment thread protocol/ssh/connection.go Resolved
Comment thread protocol/ssh/connection.go Resolved
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 49 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kke
kke marked this pull request as ready for review March 24, 2026 13:11
@kke
kke merged commit 3ce15ab into main Mar 24, 2026
15 checks passed
@kke
kke deleted the naming-conventions branch March 24, 2026 13:12
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