Repository navigation
Finetune v2 naming conventions - #301
Conversation
There was a problem hiding this comment.
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
ServicetoProvider, and rename plumbing-backed repositories fromProvidertoRegistryacross sudo/os/initsystem/packagemanager. - Rename
ConnectionConfigurer/WithConnectionConfigurertoConnectionFactory/WithConnectionFactoryand update client wiring accordingly. - Rename
ErrAborttoErrNonRetryableacross 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 nowconnectionFactory. 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.
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>
There was a problem hiding this comment.
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.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
There was a problem hiding this comment.
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.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
There was a problem hiding this comment.
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.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
There was a problem hiding this comment.
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.Connectwrites toc.clientand starts keepalive without holdingc.mu, but other methods (e.g.IsConnected,Disconnect,StartProcess) now read/clearc.clientunderc.mu. This introduces a real data race (and can be triggered by the keepalive goroutine callingIsConnectedwhile a reconnect callsConnect). Consider takingc.muinConnect(andconnectViaBastion) around all reads/writes ofc.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:428connectViaBastionassigns toc.clientand callsstartKeepalive()without synchronization, which has the same race characteristics as the directConnectpath now that other methods guardc.clientwithc.mu. Apply the same locking strategy here as inConnectto keep client/done updates consistent.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
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
Connectassigns toc.clientand then starts keepalive without holdingc.mu, even though other methods (and the new reconnect logic inStartProcess) read/clearc.clientunder the mutex. This can cause data races (and inconsistentc.donehandling) whenConnect/Disconnect/IsConnectedrun concurrently. Consider lockingc.mufor 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.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
There was a problem hiding this comment.
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.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
There was a problem hiding this comment.
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.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
There was a problem hiding this comment.
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.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
There was a problem hiding this comment.
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.
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.