Skip to content

chore: add installer options and version method to Software interface#141

Merged
brunodam merged 1 commit intomainfrom
00140-baseInstaller-with-options
Oct 17, 2025
Merged

chore: add installer options and version method to Software interface#141
brunodam merged 1 commit intomainfrom
00140-baseInstaller-with-options

Conversation

@brunodam
Copy link
Contributor

@brunodam brunodam commented Oct 15, 2025

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:

  • Replaces the exported BaseInstaller struct with an unexported baseInstaller type and introduces the InstallerOption functional options pattern, allowing for more flexible configuration (e.g., setting the version) when creating installers. (pkg/software/base_installer.go [1] [2]
  • Refactors all installer methods in baseInstaller to 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]
  • Adds new methods for configuration (Configure, IsConfigured) to the baseInstaller, providing default implementations for symlink creation and configuration checks. (pkg/software/base_installer.go pkg/software/base_installer.goR310-R333)

Workflow and Step Updates:

  • Updates all workflow step builder functions (e.g., 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:

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

image

Related Issues

@brunodam brunodam requested a review from a team as a code owner October 15, 2025 08:22
Copy link
Contributor

Copilot AI left a comment

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 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 InstallerOption functional pattern with WithVersion() helper for flexible installer configuration
  • Conversion of BaseInstaller to unexported baseInstaller with all methods made private
  • Addition of Version() method to the Software interface 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.

@brunodam brunodam force-pushed the 00140-baseInstaller-with-options branch from e693c50 to b662ff4 Compare October 15, 2025 08:26
Signed-off-by: Bruno De Assis Marques <bruno.marques@swirldslabs.com>
@brunodam brunodam force-pushed the 00140-baseInstaller-with-options branch from b662ff4 to 1e6dfc7 Compare October 15, 2025 08:26
Copy link
Member

@leninmehedy leninmehedy left a comment

Choose a reason for hiding this comment

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

Added a minor comment, which could be addressed in later PR.

@brunodam brunodam merged commit 8f0db74 into main Oct 17, 2025
7 checks passed
@brunodam brunodam deleted the 00140-baseInstaller-with-options branch October 17, 2025 21:04
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.

Use options pattern on BaseInstaller

3 participants