From c93a4ac982d2a3de8216f984baf2773cf529788b Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Wed, 18 Sep 2024 16:27:32 +0300 Subject: [PATCH] Simplify initialization of bool variables Signed-off-by: Oleksandr Redko --- cmd/limactl/copy.go | 5 +---- pkg/guestagent/iptables/iptables.go | 5 +---- pkg/instance/start.go | 7 +++---- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/cmd/limactl/copy.go b/cmd/limactl/copy.go index 3d4ec4a77e9..cbee6d21127 100644 --- a/cmd/limactl/copy.go +++ b/cmd/limactl/copy.go @@ -65,10 +65,7 @@ func copyAction(cmd *cobra.Command, args []string) error { if recursive { scpFlags = append(scpFlags, "-r") } - legacySSH := false - if sshutil.DetectOpenSSHVersion().LessThan(*semver.New("8.0.0")) { - legacySSH = true - } + legacySSH := sshutil.DetectOpenSSHVersion().LessThan(*semver.New("8.0.0")) for _, arg := range args { path := strings.Split(arg, ":") switch len(path) { diff --git a/pkg/guestagent/iptables/iptables.go b/pkg/guestagent/iptables/iptables.go index 12416c0446e..0f4fe1adb5e 100644 --- a/pkg/guestagent/iptables/iptables.go +++ b/pkg/guestagent/iptables/iptables.go @@ -72,10 +72,7 @@ func parsePortsFromRules(rules []string) ([]Entry, error) { return nil, err } - istcp := false - if found[2] == "tcp" { - istcp = true - } + istcp := found[2] == "tcp" // When no IP is present the rule applies to all interfaces. ip := found[1] diff --git a/pkg/instance/start.go b/pkg/instance/start.go index f3ec3064b4b..edd5168bb0b 100644 --- a/pkg/instance/start.go +++ b/pkg/instance/start.go @@ -97,11 +97,10 @@ func Prepare(ctx context.Context, inst *store.Instance) (*Prepared, error) { } // Check if the instance has been created (the base disk already exists) - created := false baseDisk := filepath.Join(inst.Dir, filenames.BaseDisk) - if _, err := os.Stat(baseDisk); err == nil { - created = true - } + _, err = os.Stat(baseDisk) + created := err == nil + if err := limaDriver.CreateDisk(ctx); err != nil { return nil, err }