upgrade-agent: allow more than one KubernetesComponent

This commit is contained in:
Markus Rudy 2023-12-08 18:38:00 +01:00 committed by Leonard Cohnen
parent 034da67329
commit 4d714f2c02
4 changed files with 75 additions and 39 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.