Skip to content

Commit 4f2a8a1

Browse files
committed
firewall: Remove viper interactive check
filewall.UnblockBootpd() accepts now *run.CommandOptions and use it to check if we can interact with the user. Update callers to pass options.
1 parent b91345d commit 4f2a8a1

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

cmd/minikube/cmd/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
353353
klog.Infof("cluster config:\n%+v", cc)
354354

355355
if firewall.IsBootpdBlocked(cc) {
356-
if err := firewall.UnblockBootpd(); err != nil {
356+
if err := firewall.UnblockBootpd(options); err != nil {
357357
klog.Warningf("failed unblocking bootpd from firewall: %v", err)
358358
}
359359
}

pkg/drivers/krunkit/krunkit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func (d *Driver) setupIP(mac string) error {
305305
if !isBootpdError(err) {
306306
return errors.Wrap(err, "IP address never found in dhcp leases file")
307307
}
308-
if unblockErr := firewall.UnblockBootpd(); unblockErr != nil {
308+
if unblockErr := firewall.UnblockBootpd(&d.CommandOptions); unblockErr != nil {
309309
klog.Errorf("failed unblocking bootpd from firewall: %v", unblockErr)
310310
exit.Error(reason.IfBootpdFirewall, "ip not found", err)
311311
}

pkg/drivers/qemu/qemu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ func (d *Driver) Start() error {
541541
if !isBootpdError(err) {
542542
return errors.Wrap(err, "IP address never found in dhcp leases file")
543543
}
544-
if unblockErr := firewall.UnblockBootpd(); unblockErr != nil {
544+
if unblockErr := firewall.UnblockBootpd(&d.CommandOptions); unblockErr != nil {
545545
klog.Errorf("failed unblocking bootpd from firewall: %v", unblockErr)
546546
exit.Error(reason.IfBootpdFirewall, "ip not found", err)
547547
}

pkg/drivers/vfkit/vfkit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ func (d *Driver) setupIP(mac string) error {
380380
if !isBootpdError(err) {
381381
return errors.Wrap(err, "IP address never found in dhcp leases file")
382382
}
383-
if unblockErr := firewall.UnblockBootpd(); unblockErr != nil {
383+
if unblockErr := firewall.UnblockBootpd(&d.CommandOptions); unblockErr != nil {
384384
klog.Errorf("failed unblocking bootpd from firewall: %v", unblockErr)
385385
exit.Error(reason.IfBootpdFirewall, "ip not found", err)
386386
}

pkg/minikube/firewall/firewall.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ import (
2424
"slices"
2525
"strings"
2626

27-
"github.com/spf13/viper"
2827
"k8s.io/klog/v2"
2928
"k8s.io/minikube/pkg/minikube/config"
3029
"k8s.io/minikube/pkg/minikube/driver"
3130
"k8s.io/minikube/pkg/minikube/out"
31+
"k8s.io/minikube/pkg/minikube/run"
3232
"k8s.io/minikube/pkg/minikube/style"
3333
)
3434

@@ -63,7 +63,7 @@ func IsBootpdBlocked(cc config.ClusterConfig) bool {
6363
}
6464

6565
// UnblockBootpd adds bootpd to the built-in macOS firewall and then unblocks it
66-
func UnblockBootpd() error {
66+
func UnblockBootpd(options *run.CommandOptions) error {
6767
cmds := []*exec.Cmd{
6868
exec.Command("sudo", "/usr/libexec/ApplicationFirewall/socketfilterfw", "--add", "/usr/libexec/bootpd"),
6969
exec.Command("sudo", "/usr/libexec/ApplicationFirewall/socketfilterfw", "--unblock", "/usr/libexec/bootpd"),
@@ -82,7 +82,7 @@ func UnblockBootpd() error {
8282
klog.Infof("testing: %s", test.Args)
8383
if err := test.Run(); err != nil {
8484
klog.Infof("%v may require a password: %v", c.Args, err)
85-
if !viper.GetBool("interactive") {
85+
if !options.NonInteractive {
8686
klog.Warningf("%s requires a password, and --interactive=false", c.Args)
8787
c.Args = slices.Insert(c.Args, 1, "-n")
8888
}

0 commit comments

Comments
 (0)