versions: consolidate various types of Components

There used to be three definitions of a Component type, and conversion
routines between the three. Since the use case is always the same, and
the Component semantics are defined by versions.go and the installer, it
seems appropriate to define the Component type there and import it in
the necessary places.
This commit is contained in:
Markus Rudy 2023-12-11 08:08:55 +01:00 committed by Markus Rudy
parent a8fb6c5af0
commit a1dbd13f95
25 changed files with 454 additions and 379 deletions

View file

@ -55,8 +55,8 @@ func NewOSInstaller() *OsInstaller {
// Install downloads a resource from a URL, applies any given text transformations and extracts the resulting file if required.
// The resulting file(s) are copied to the destination. It also verifies the sha256 hash of the downloaded file.
func (i *OsInstaller) Install(ctx context.Context, kubernetesComponent components.Component) error {
tempPath, err := i.retryDownloadToTempDir(ctx, kubernetesComponent.URL)
func (i *OsInstaller) Install(ctx context.Context, kubernetesComponent *components.Component) error {
tempPath, err := i.retryDownloadToTempDir(ctx, kubernetesComponent.Url)
if err != nil {
return err
}
@ -83,7 +83,7 @@ func (i *OsInstaller) Install(ctx context.Context, kubernetesComponent component
err = i.copy(tempPath, kubernetesComponent.InstallPath, executablePerm)
}
if err != nil {
return fmt.Errorf("installing from %q: copying to destination %q: %w", kubernetesComponent.URL, kubernetesComponent.InstallPath, err)
return fmt.Errorf("installing from %q: copying to destination %q: %w", kubernetesComponent.Url, kubernetesComponent.InstallPath, err)
}
return nil