Skip to content

Commit fa0bca2

Browse files
run make fmt
1 parent 0e4cbf2 commit fa0bca2

File tree

8 files changed

+60
-63
lines changed

8 files changed

+60
-63
lines changed

cmd/minikube/cmd/config/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type ViewTemplate struct {
4040
var configViewCmd = &cobra.Command{
4141
Use: "view",
4242
Short: "Display values currently set in the minikube config file",
43-
Long: `Display values currently set in the minikube config file.
43+
Long: `Display values currently set in the minikube config file.
4444
The output format can be customized using the --format flag, which accepts a Go template.
4545
The config file is typically located at "~/.minikube/config/config.json".`,
4646
Run: func(_ *cobra.Command, _ []string) {

pkg/addons/addons.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -450,20 +450,18 @@ func enableOrDisableAddonInternal(cc *config.ClusterConfig, addon *assets.Addon,
450450
}
451451
}
452452

453-
if addon.HelmChart != nil {
454-
err := helmInstallBinary(addon,runner)
455-
if err != nil {
456-
return err
457-
}
458-
459-
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
460-
defer cancel()
461-
cmd := helmUninstallOrInstall(ctx, addon.HelmChart, enable)
462-
_, err = runner.RunCmd(cmd)
463-
return err
453+
if addon.HelmChart != nil {
454+
err := helmInstallBinary(addon, runner)
455+
if err != nil {
456+
return err
464457
}
465-
466458

459+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
460+
defer cancel()
461+
cmd := helmUninstallOrInstall(ctx, addon.HelmChart, enable)
462+
_, err = runner.RunCmd(cmd)
463+
return err
464+
}
467465

468466
// on the first attempt try without force, but on subsequent attempts use force
469467
force := false

pkg/addons/helm.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,41 @@ import (
2929
)
3030

3131
// runs a helm install within the minikube vm or container based on the contents of chart *assets.HelmChart
32-
func installHelmChart (ctx context.Context, chart *assets.HelmChart) *exec.Cmd {
32+
func installHelmChart(ctx context.Context, chart *assets.HelmChart) *exec.Cmd {
3333
args := []string{
3434
fmt.Sprintf("KUBECONFIG=%s", path.Join(vmpath.GuestPersistentDir, "kubeconfig")),
3535
"helm", "upgrade", "--install", chart.Name, chart.Repo, "--create-namespace",
3636
}
37-
if chart.Namespace != "" {
38-
args = append(args, "--namespace", chart.Namespace)
39-
}
37+
if chart.Namespace != "" {
38+
args = append(args, "--namespace", chart.Namespace)
39+
}
4040

41-
if chart.Values != nil {
42-
for _, value := range chart.Values {
43-
args = append(args, "--set", value)
44-
}
45-
}
41+
if chart.Values != nil {
42+
for _, value := range chart.Values {
43+
args = append(args, "--set", value)
44+
}
45+
}
4646

47-
if chart.ValueFiles != nil {
48-
for _, value := range chart.ValueFiles {
49-
args = append(args, "--values", value)
50-
}
51-
}
52-
53-
return exec.CommandContext(ctx, "sudo", args...)
47+
if chart.ValueFiles != nil {
48+
for _, value := range chart.ValueFiles {
49+
args = append(args, "--values", value)
50+
}
5451
}
5552

53+
return exec.CommandContext(ctx, "sudo", args...)
54+
}
55+
5656
// runs a helm uninstall based on the contents of chart *assets.HelmChart
57-
func uninstalllHelmChart (ctx context.Context, chart *assets.HelmChart) *exec.Cmd {
57+
func uninstalllHelmChart(ctx context.Context, chart *assets.HelmChart) *exec.Cmd {
5858
args := []string{
5959
fmt.Sprintf("KUBECONFIG=%s", path.Join(vmpath.GuestPersistentDir, "kubeconfig")),
6060
"helm", "uninstall", chart.Name,
61-
}
62-
if chart.Namespace != "" {
63-
args = append(args, "--namespace", chart.Namespace)
64-
}
65-
return exec.CommandContext(ctx, "sudo", args...)
6661
}
62+
if chart.Namespace != "" {
63+
args = append(args, "--namespace", chart.Namespace)
64+
}
65+
return exec.CommandContext(ctx, "sudo", args...)
66+
}
6767

6868
// based on enable will execute installHelmChart or uninstallHelmChart
6969
func helmUninstallOrInstall(ctx context.Context, chart *assets.HelmChart, enable bool) *exec.Cmd {
@@ -86,8 +86,8 @@ func helmInstallBinary(addon *assets.Addon, runner command.Runner) error {
8686
// we copy the binary from /usr/local/bin to /usr/bin because /usr/local/bin is not in PATH in both iso and kicbase
8787
_, err = runner.RunCmd(exec.Command("sudo", "mv", "/usr/local/bin/helm", "/usr/bin/helm"))
8888
if err != nil {
89-
return errors.Wrap(err, "installing helm")
89+
return errors.Wrap(err, "installing helm")
9090
}
9191
}
9292
return err
93-
}
93+
}

pkg/addons/helm_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ func TestHelmCommand(t *testing.T) {
3030
chart *assets.HelmChart
3131
enable bool
3232
expected string
33-
mode string
33+
mode string
3434
}{
3535
{
3636
description: "enable an addon",
3737
chart: &assets.HelmChart{
38-
Name: "addon-name",
39-
Repo: "addon-repo/addon-chart",
40-
Namespace: "addon-namespace",
41-
Values: []string{"key=value"},
38+
Name: "addon-name",
39+
Repo: "addon-repo/addon-chart",
40+
Namespace: "addon-namespace",
41+
Values: []string{"key=value"},
4242
ValueFiles: []string{"/etc/kubernetes/addons/values.yaml"},
4343
},
4444
enable: true,
@@ -47,13 +47,13 @@ func TestHelmCommand(t *testing.T) {
4747
{
4848
description: "enable an addon without namespace",
4949
chart: &assets.HelmChart{
50-
Name: "addon-name",
51-
Repo: "addon-repo/addon-chart",
52-
Values: []string{"key=value"},
50+
Name: "addon-name",
51+
Repo: "addon-repo/addon-chart",
52+
Values: []string{"key=value"},
5353
ValueFiles: []string{"/etc/kubernetes/addons/values.yaml"},
5454
},
5555
enable: true,
56-
expected: "sudo KUBECONFIG=/var/lib/minikube/kubeconfig helm upgrade --install addon-name addon-repo/addon-chart --create-namespace --set key=value --values /etc/kubernetes/addons/values.yaml" ,
56+
expected: "sudo KUBECONFIG=/var/lib/minikube/kubeconfig helm upgrade --install addon-name addon-repo/addon-chart --create-namespace --set key=value --values /etc/kubernetes/addons/values.yaml",
5757
},
5858
{
5959
description: "disable an addon",
@@ -63,13 +63,13 @@ func TestHelmCommand(t *testing.T) {
6363
},
6464
enable: false,
6565
expected: "sudo KUBECONFIG=/var/lib/minikube/kubeconfig helm uninstall addon-name --namespace addon-namespace",
66-
mode: "cpu",
66+
mode: "cpu",
6767
},
6868
}
6969

7070
for _, test := range tests {
7171
t.Run(test.description, func(t *testing.T) {
72-
command := helmUninstallOrInstall(context.Background(), test.chart, test.enable )
72+
command := helmUninstallOrInstall(context.Background(), test.chart, test.enable)
7373
actual := strings.Join(command.Args, " ")
7474
if actual != test.expected {
7575
t.Errorf("helm command mismatch:\nexpected: %s\nactual: %s", test.expected, actual)

pkg/minikube/assets/addons.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ import (
3636

3737
// HelmChart holds information about a helm chart.
3838
type HelmChart struct {
39-
Name string
40-
Repo string
41-
Namespace string
42-
Values []string
39+
Name string
40+
Repo string
41+
Namespace string
42+
Values []string
4343
ValueFiles []string
44-
4544
}
4645

4746
// Addon is a named list of assets, that can be enabled

pkg/minikube/assets/addons_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func mapsEqual(a, b map[string]string) bool {
4545

4646
func TestParseMapString(t *testing.T) {
4747
cases := map[string]map[string]string{
48-
"Aardvark=1,B=2,Cantaloupe=3": {"Aardvark": "1", "B": "2", "Cantaloupe": "3"},
48+
"Aardvark=1,B=2,Cantaloupe=3": {"Aardvark": "1", "B": "2", "Cantaloupe": "3"},
4949
"A=,B=2,C=": {"A": "", "B": "2", "C": ""},
5050
"": {},
5151
"malformed,good=howdy,manyequals==,": {"good": "howdy"},

pkg/minikube/assets/vm_assets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import (
2020
"bytes"
2121
"embed"
2222
"fmt"
23-
"text/template"
2423
"io"
2524
"os"
2625
"path"
2726
"path/filepath"
2827
"strconv"
2928
"strings"
29+
"text/template"
3030
"time"
3131

3232
"github.com/pkg/errors"

pkg/minikube/download/licenses.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ func Licenses(dir string) error {
6767
return fmt.Errorf("failed to create temporary file: %v", err)
6868
}
6969
defer func() {
70-
if err := os.Remove(tempFile.Name()); err != nil {
71-
klog.Warningf("Failed to remove temp file %s: %v", tempFile.Name(), err)
72-
}
73-
}()
70+
if err := os.Remove(tempFile.Name()); err != nil {
71+
klog.Warningf("Failed to remove temp file %s: %v", tempFile.Name(), err)
72+
}
73+
}()
7474
defer func() {
75-
if err := tempFile.Close(); err != nil {
76-
klog.Warningf("Failed to close temp file %s: %v", tempFile.Name(), err)
77-
}
78-
}()
75+
if err := tempFile.Close(); err != nil {
76+
klog.Warningf("Failed to close temp file %s: %v", tempFile.Name(), err)
77+
}
78+
}()
7979

8080
if _, err := io.Copy(tempFile, resp.Body); err != nil {
8181
return fmt.Errorf("failed to copy downloaded content from %s: %v", url, err)

0 commit comments

Comments
 (0)