From 248c03b576ea920ddd0ab6b8ef909f2dff42aecf Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Sun, 15 Nov 2026 00:20:38 -0500 Subject: [PATCH 1/4] Use the selected Minikube profile in tunnel instructions Signed-off-by: Dave Protasowski --- README.md | 5 ++++- pkg/minikube/minikube.go | 14 ++++++++----- pkg/minikube/minikube_test.go | 38 +++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 pkg/minikube/minikube_test.go diff --git a/README.md b/README.md index 97aad2b6..2a023412 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,12 @@ kn quickstart minikube Note: for Windows/Mac users, after the above command completes, you will need to run the following in a separate terminal window: ``` bash -minikube tunnel --profile minikube-knative +minikube tunnel --profile knative ``` +If you selected a custom cluster name with `--name` or passed a Minikube +`--profile` after `--`, use that profile name instead of `knative`. + ## Building from Source You must [set up your development environment](https://github.com/knative/client/blob/main/DEVELOPMENT.md#prerequisites) before you build `kn-plugin-quickstart`. diff --git a/pkg/minikube/minikube.go b/pkg/minikube/minikube.go index 0411b2a0..0d0a30e9 100644 --- a/pkg/minikube/minikube.go +++ b/pkg/minikube/minikube.go @@ -16,6 +16,7 @@ package minikube import ( "fmt" + "io" "os" "os/exec" "regexp" @@ -91,11 +92,7 @@ func SetUp(name, kVersion string, installServing, installEventing bool, minikube if err := createMinikubeCluster(); err != nil { return fmt.Errorf("failed to create minikube cluster: %w", err) } - fmt.Print("\n") - fmt.Println("To finish setting up networking for minikube, run the following command in a separate terminal window:") - fmt.Println(" minikube tunnel --profile knative") - fmt.Println("The tunnel command must be running in a terminal window any time when using the knative quickstart environment.") - fmt.Println("\nPress the Enter key to continue") + printTunnelInstructions(os.Stdout, clusterName) fmt.Scanln() if installKnative { if installServing { @@ -123,6 +120,13 @@ func SetUp(name, kVersion string, installServing, installEventing bool, minikube return nil } +func printTunnelInstructions(out io.Writer, profile string) { + fmt.Fprintln(out, "\nTo finish setting up networking for minikube, run the following command in a separate terminal window:") + fmt.Fprintf(out, " minikube tunnel --profile %s\n", profile) + fmt.Fprintln(out, "The tunnel command must be running in a terminal window any time when using the knative quickstart environment.") + fmt.Fprintln(out, "\nPress the Enter key to continue") +} + func createMinikubeCluster() error { if err := checkMinikubeVersion(); err != nil { return fmt.Errorf("unable to get minikube version: %w", err) diff --git a/pkg/minikube/minikube_test.go b/pkg/minikube/minikube_test.go new file mode 100644 index 00000000..99aaa5a2 --- /dev/null +++ b/pkg/minikube/minikube_test.go @@ -0,0 +1,38 @@ +// Copyright © 2026 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package minikube + +import ( + "bytes" + "fmt" + "strings" + "testing" +) + +func TestPrintTunnelInstructions(t *testing.T) { + for _, profile := range []string{"knative", "my-cluster", "custom-profile"} { + t.Run(profile, func(t *testing.T) { + var out bytes.Buffer + printTunnelInstructions(&out, profile) + want := fmt.Sprintf(" minikube tunnel --profile %s\n", profile) + if !strings.Contains(out.String(), want) { + t.Errorf("instructions = %q, want command %q", out.String(), want) + } + if profile != "knative" && strings.Contains(out.String(), "--profile knative") { + t.Error("instructions still refer to the default profile") + } + }) + } +} From 8f4fc45b61268d0f8aab557f936dc17799050aad Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Sun, 15 Nov 2026 00:37:06 -0500 Subject: [PATCH 2/4] Simplify tunnel output and test profile resolution directly Signed-off-by: Dave Protasowski --- pkg/minikube/minikube.go | 51 +++++++++++++++++------------------ pkg/minikube/minikube_test.go | 38 -------------------------- pkg/minikube/profile_test.go | 37 +++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 64 deletions(-) delete mode 100644 pkg/minikube/minikube_test.go create mode 100644 pkg/minikube/profile_test.go diff --git a/pkg/minikube/minikube.go b/pkg/minikube/minikube.go index 0d0a30e9..49a8cefe 100644 --- a/pkg/minikube/minikube.go +++ b/pkg/minikube/minikube.go @@ -16,7 +16,6 @@ package minikube import ( "fmt" - "io" "os" "os/exec" "regexp" @@ -63,25 +62,9 @@ func SetUp(name, kVersion string, installServing, installEventing bool, minikube os.Exit(1) } - clusterName = name + clusterName = profileName(name, minikubeArgs) if len(minikubeArgs) > 0 { customMinikubeArgs = minikubeArgs - // check custom flags for name, as that takes precedent and affects functionality the most (most recent) - for i, arg := range slices.Backward(minikubeArgs) { - customArg, value := parseArg(arg) - if customArg == "-p" || customArg == "--profile" { - // use value from equal sign if it is there - if value != "" { - clusterName = value - } else if i+1 >= len(customMinikubeArgs) { - // edge case, but continue if not filled in and let minikube throw an error for empty arg - continue - } else { - clusterName = customMinikubeArgs[i+1] - } - break - } - } } if kVersion != "" { @@ -92,7 +75,11 @@ func SetUp(name, kVersion string, installServing, installEventing bool, minikube if err := createMinikubeCluster(); err != nil { return fmt.Errorf("failed to create minikube cluster: %w", err) } - printTunnelInstructions(os.Stdout, clusterName) + fmt.Print("\n") + fmt.Println("To finish setting up networking for minikube, run the following command in a separate terminal window:") + fmt.Printf(" minikube tunnel --profile %s\n", clusterName) + fmt.Println("The tunnel command must be running in a terminal window any time when using the knative quickstart environment.") + fmt.Println("\nPress the Enter key to continue") fmt.Scanln() if installKnative { if installServing { @@ -120,13 +107,6 @@ func SetUp(name, kVersion string, installServing, installEventing bool, minikube return nil } -func printTunnelInstructions(out io.Writer, profile string) { - fmt.Fprintln(out, "\nTo finish setting up networking for minikube, run the following command in a separate terminal window:") - fmt.Fprintf(out, " minikube tunnel --profile %s\n", profile) - fmt.Fprintln(out, "The tunnel command must be running in a terminal window any time when using the knative quickstart environment.") - fmt.Fprintln(out, "\nPress the Enter key to continue") -} - func createMinikubeCluster() error { if err := checkMinikubeVersion(); err != nil { return fmt.Errorf("unable to get minikube version: %w", err) @@ -314,6 +294,25 @@ func recreateCluster() error { return nil } +// profileName resolves the name used by both cluster setup and tunnel instructions. +// The last passthrough profile flag takes precedence over quickstart's --name. +func profileName(name string, args []string) string { + for index, arg := range slices.Backward(args) { + flag, value := parseArg(arg) + if flag != "-p" && flag != "--profile" { + continue + } + if value != "" { + return value + } + if index+1 < len(args) { + return args[index+1] + } + // Leave a missing value for minikube to report as an error. + } + return name +} + func parseArg(arg string) (string, string) { if strings.Contains(arg, "=") { parts := strings.Split(arg, "=") diff --git a/pkg/minikube/minikube_test.go b/pkg/minikube/minikube_test.go deleted file mode 100644 index 99aaa5a2..00000000 --- a/pkg/minikube/minikube_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright © 2026 The Knative Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package minikube - -import ( - "bytes" - "fmt" - "strings" - "testing" -) - -func TestPrintTunnelInstructions(t *testing.T) { - for _, profile := range []string{"knative", "my-cluster", "custom-profile"} { - t.Run(profile, func(t *testing.T) { - var out bytes.Buffer - printTunnelInstructions(&out, profile) - want := fmt.Sprintf(" minikube tunnel --profile %s\n", profile) - if !strings.Contains(out.String(), want) { - t.Errorf("instructions = %q, want command %q", out.String(), want) - } - if profile != "knative" && strings.Contains(out.String(), "--profile knative") { - t.Error("instructions still refer to the default profile") - } - }) - } -} diff --git a/pkg/minikube/profile_test.go b/pkg/minikube/profile_test.go new file mode 100644 index 00000000..c1feb5e2 --- /dev/null +++ b/pkg/minikube/profile_test.go @@ -0,0 +1,37 @@ +// Copyright © 2026 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package minikube + +import "testing" + +func TestProfileName(t *testing.T) { + for _, tt := range []struct { + name string + args []string + want string + }{ + {name: "knative", want: "knative"}, + {name: "custom-name", want: "custom-name"}, + {name: "knative", args: []string{"--profile=custom"}, want: "custom"}, + {name: "knative", args: []string{"--profile", "custom"}, want: "custom"}, + {name: "knative", args: []string{"-p", "custom"}, want: "custom"}, + {name: "knative", args: []string{"--profile=first", "--profile=last"}, want: "last"}, + {name: "knative", args: []string{"--keep-context"}, want: "knative"}, + } { + if got := profileName(tt.name, tt.args); got != tt.want { + t.Errorf("profileName(%q, %v) = %q, want %q", tt.name, tt.args, got, tt.want) + } + } +} From 705d8ecdc8c0aaad2e562c16d3545aa38342908f Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Sun, 15 Nov 2026 00:44:27 -0500 Subject: [PATCH 3/4] Keep the tunnel fix focused on its output and documentation Signed-off-by: Dave Protasowski --- pkg/minikube/minikube.go | 37 +++++++++++++++++------------------- pkg/minikube/profile_test.go | 37 ------------------------------------ 2 files changed, 17 insertions(+), 57 deletions(-) delete mode 100644 pkg/minikube/profile_test.go diff --git a/pkg/minikube/minikube.go b/pkg/minikube/minikube.go index 49a8cefe..a3865b56 100644 --- a/pkg/minikube/minikube.go +++ b/pkg/minikube/minikube.go @@ -62,9 +62,25 @@ func SetUp(name, kVersion string, installServing, installEventing bool, minikube os.Exit(1) } - clusterName = profileName(name, minikubeArgs) + clusterName = name if len(minikubeArgs) > 0 { customMinikubeArgs = minikubeArgs + // check custom flags for name, as that takes precedent and affects functionality the most (most recent) + for i, arg := range slices.Backward(minikubeArgs) { + customArg, value := parseArg(arg) + if customArg == "-p" || customArg == "--profile" { + // use value from equal sign if it is there + if value != "" { + clusterName = value + } else if i+1 >= len(customMinikubeArgs) { + // edge case, but continue if not filled in and let minikube throw an error for empty arg + continue + } else { + clusterName = customMinikubeArgs[i+1] + } + break + } + } } if kVersion != "" { @@ -294,25 +310,6 @@ func recreateCluster() error { return nil } -// profileName resolves the name used by both cluster setup and tunnel instructions. -// The last passthrough profile flag takes precedence over quickstart's --name. -func profileName(name string, args []string) string { - for index, arg := range slices.Backward(args) { - flag, value := parseArg(arg) - if flag != "-p" && flag != "--profile" { - continue - } - if value != "" { - return value - } - if index+1 < len(args) { - return args[index+1] - } - // Leave a missing value for minikube to report as an error. - } - return name -} - func parseArg(arg string) (string, string) { if strings.Contains(arg, "=") { parts := strings.Split(arg, "=") diff --git a/pkg/minikube/profile_test.go b/pkg/minikube/profile_test.go deleted file mode 100644 index c1feb5e2..00000000 --- a/pkg/minikube/profile_test.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright © 2026 The Knative Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package minikube - -import "testing" - -func TestProfileName(t *testing.T) { - for _, tt := range []struct { - name string - args []string - want string - }{ - {name: "knative", want: "knative"}, - {name: "custom-name", want: "custom-name"}, - {name: "knative", args: []string{"--profile=custom"}, want: "custom"}, - {name: "knative", args: []string{"--profile", "custom"}, want: "custom"}, - {name: "knative", args: []string{"-p", "custom"}, want: "custom"}, - {name: "knative", args: []string{"--profile=first", "--profile=last"}, want: "last"}, - {name: "knative", args: []string{"--keep-context"}, want: "knative"}, - } { - if got := profileName(tt.name, tt.args); got != tt.want { - t.Errorf("profileName(%q, %v) = %q, want %q", tt.name, tt.args, got, tt.want) - } - } -} From a1c418cfbeaeef8162d2468337bb51de3bfb2d81 Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Sun, 15 Nov 2026 00:46:17 -0500 Subject: [PATCH 4/4] Keep profile name resolution in an internal helper Signed-off-by: Dave Protasowski --- pkg/minikube/minikube.go | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/pkg/minikube/minikube.go b/pkg/minikube/minikube.go index a3865b56..49a8cefe 100644 --- a/pkg/minikube/minikube.go +++ b/pkg/minikube/minikube.go @@ -62,25 +62,9 @@ func SetUp(name, kVersion string, installServing, installEventing bool, minikube os.Exit(1) } - clusterName = name + clusterName = profileName(name, minikubeArgs) if len(minikubeArgs) > 0 { customMinikubeArgs = minikubeArgs - // check custom flags for name, as that takes precedent and affects functionality the most (most recent) - for i, arg := range slices.Backward(minikubeArgs) { - customArg, value := parseArg(arg) - if customArg == "-p" || customArg == "--profile" { - // use value from equal sign if it is there - if value != "" { - clusterName = value - } else if i+1 >= len(customMinikubeArgs) { - // edge case, but continue if not filled in and let minikube throw an error for empty arg - continue - } else { - clusterName = customMinikubeArgs[i+1] - } - break - } - } } if kVersion != "" { @@ -310,6 +294,25 @@ func recreateCluster() error { return nil } +// profileName resolves the name used by both cluster setup and tunnel instructions. +// The last passthrough profile flag takes precedence over quickstart's --name. +func profileName(name string, args []string) string { + for index, arg := range slices.Backward(args) { + flag, value := parseArg(arg) + if flag != "-p" && flag != "--profile" { + continue + } + if value != "" { + return value + } + if index+1 < len(args) { + return args[index+1] + } + // Leave a missing value for minikube to report as an error. + } + return name +} + func parseArg(arg string) (string, string) { if strings.Contains(arg, "=") { parts := strings.Split(arg, "=")