chore: add installer options and version method to Software interface#141
Merged
chore: add installer options and version method to Software interface#141
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the software installer infrastructure to introduce a functional options pattern for installer configuration, making the codebase more maintainable and extensible. The primary change converts the exported BaseInstaller to an unexported baseInstaller with InstallerOption functional options, particularly enabling flexible version configuration during installer creation.
Key changes:
- Introduction of
InstallerOptionfunctional pattern withWithVersion()helper for flexible installer configuration - Conversion of
BaseInstallerto unexportedbaseInstallerwith all methods made private - Addition of
Version()method to theSoftwareinterface for version retrieval
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/software/base_installer.go | Implements core refactoring with unexported baseInstaller, functional options pattern, and new Configure/IsConfigured methods |
| pkg/software/interface.go | Adds Version() method to Software interface |
| pkg/software/crio_installer.go | Simplifies to single constructor using functional options |
| pkg/software/kubelet_installer.go | Updates to use unexported baseInstaller and functional options |
| pkg/software/kubeadm_installer.go | Updates to use unexported baseInstaller and functional options |
| pkg/software/kubectl_installer.go | Simplifies to direct baseInstaller usage |
| pkg/software/k9s_installer.go | Simplifies to single constructor using functional options |
| pkg/software/helm_installer.go | Simplifies to single constructor using functional options |
| pkg/software/cilium_installer.go | Simplifies to single constructor using functional options |
| pkg/software/base_installer_test.go | Updates test to use unexported baseInstaller type |
| pkg/software/config_test.go | Updates test to use unexported baseInstaller type |
| pkg/software/crio_installer_it_test.go | Updates integration tests to use functional options pattern |
| internal/workflows/steps/step_crio.go | Updates function signatures to accept InstallerOption variadic parameters |
| internal/workflows/steps/step_kubeadm.go | Updates function signatures to accept InstallerOption variadic parameters |
| internal/workflows/steps/step_kubectl.go | Updates function signatures to accept InstallerOption variadic parameters |
| internal/workflows/steps/step_kubelet.go | Updates function signatures to accept InstallerOption variadic parameters |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
e693c50 to
b662ff4
Compare
Signed-off-by: Bruno De Assis Marques <bruno.marques@swirldslabs.com>
b662ff4 to
1e6dfc7
Compare
leninmehedy
approved these changes
Oct 17, 2025
Member
leninmehedy
left a comment
There was a problem hiding this comment.
Added a minor comment, which could be addressed in later PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request refactors the software installer infrastructure to provide a more flexible and extensible base installer implementation. It introduces a new pattern for passing installer options, refines the base installer struct and methods, and updates related workflow steps and installers to use the new approach. The changes improve code maintainability and make it easier to customize software installation processes.
Core Refactoring of Installer Infrastructure:
BaseInstallerstruct with an unexportedbaseInstallertype and introduces theInstallerOptionfunctional options pattern, allowing for more flexible configuration (e.g., setting the version) when creating installers. (pkg/software/base_installer.go[1] [2]baseInstallerto be unexported (lowercase), and updates method signatures and internal logic for better encapsulation and separation of concerns. (pkg/software/base_installer.go[1] [2] [3] [4] [5] [6] [7] [8] [9]Configure,IsConfigured) to thebaseInstaller, providing default implementations for symlink creation and configuration checks. (pkg/software/base_installer.gopkg/software/base_installer.goR310-R333)Workflow and Step Updates:
installKubeadm,configureCrio, etc.) to accept the new provider function signature with installer options, enabling more flexible installer creation in workflows. (internal/workflows/steps/step_crio.go[1] [2] [3];internal/workflows/steps/step_kubeadm.go[4] [5];internal/workflows/steps/step_kubectl.go[6] [7];internal/workflows/steps/step_kubelet.go[8] [9]Installer Implementations and Tests:
baseInstallerby implementing aNewCiliumnstallerfunction that returns aSoftwareusing the new pattern. (pkg/software/cilium_installer.gopkg/software/cilium_installer.goL3-R4)baseInstallertype instead of the oldBaseInstaller. (pkg/software/base_installer_test.gopkg/software/base_installer_test.goL18-R18)These changes modernize the installer codebase, making it easier to extend and maintain as new software components and installation requirements arise.
References: [1] [2] [3] [4] [5]
Manual Test Results
Related Issues