upgrade-agent: allow more than one KubernetesComponent

This commit is contained in:
Markus Rudy 2023-12-08 18:38:00 +01:00 committed by Markus Rudy
parent 4ba483ec0e
commit 6f1b6b532f
5 changed files with 126 additions and 43 deletions

View file

@ -132,13 +132,24 @@ func prepareUpdate(ctx context.Context, installer osInstaller, updateRequest *up
return err
}
// download & install the kubeadm binary
return installer.Install(ctx, &components.Component{
Url: updateRequest.KubeadmUrl,
Hash: updateRequest.KubeadmHash,
InstallPath: constants.KubeadmPath,
Extract: false,
})
var cs components.Components
if len(updateRequest.KubeadmUrl) > 0 {
cs = append(cs, &components.Component{
Url: updateRequest.KubeadmUrl,
Hash: updateRequest.KubeadmHash,
InstallPath: constants.KubeadmPath,
Extract: false,
})
}
cs = append(cs, updateRequest.KubernetesComponents...)
// Download & install the Kubernetes components.
for _, c := range cs {
if err := installer.Install(ctx, c); err != nil {
return fmt.Errorf("installing Kubernetes component %q: %w", c.Url, err)
}
}
return nil
}
// verifyVersion verifies the provided Kubernetes version.