Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine package installs into one exec #94

Merged
merged 2 commits into from
Feb 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions phase/prepare_hosts.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package phase

import (
"strings"

"github.com/k0sproject/k0sctl/config/cluster"
log "github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -28,16 +30,19 @@ func (p *PrepareHosts) prepareHost(h *cluster.Host) error {
}
}

var pkgs []string

if h.NeedCurl() {
log.Infof("%s: installing curl", h)
if err := h.Configurer.InstallPackage(h, "curl"); err != nil {
return err
}
pkgs = append(pkgs, "curl")
}

// TODO: combine with above using a slice of packages as each InstallPackage call triggers an apt/zypper/etc update.
if h.NeedIPTables() {
if err := h.Configurer.InstallPackage(h, "iptables"); err != nil {
pkgs = append(pkgs, "iptables")
}

if len(pkgs) > 0 {
log.Infof("%s: installing packages (%s)", h, strings.Join(pkgs, ", "))
if err := h.Configurer.InstallPackage(h, pkgs...); err != nil {
return err
}
}
Expand Down