Skip to content

Commit d327f19

Browse files
authored
Merge pull request #4335 from MPLew-is/get-profile
Get current profile if no arguments given
2 parents faf9496 + 7dac217 commit d327f19

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Diff for: cmd/minikube/cmd/config/profile.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,29 @@ limitations under the License.
1717
package config
1818

1919
import (
20+
"os"
21+
2022
"github.com/spf13/cobra"
23+
"github.com/spf13/viper"
2124
pkgConfig "k8s.io/minikube/pkg/minikube/config"
2225
"k8s.io/minikube/pkg/minikube/console"
2326
"k8s.io/minikube/pkg/minikube/exit"
2427
)
2528

2629
// ProfileCmd represents the profile command
2730
var ProfileCmd = &cobra.Command{
28-
Use: "profile MINIKUBE_PROFILE_NAME. You can return to the default minikube profile by running `minikube profile default`",
29-
Short: "Profile sets the current minikube profile",
30-
Long: "profile sets the current minikube profile. This is used to run and manage multiple minikube instance. You can return to the default minikube profile by running `minikube profile default`",
31+
Use: "profile [MINIKUBE_PROFILE_NAME]. You can return to the default minikube profile by running `minikube profile default`",
32+
Short: "Profile gets or sets the current minikube profile",
33+
Long: "profile sets the current minikube profile, or gets the current profile if no arguments are provided. This is used to run and manage multiple minikube instance. You can return to the default minikube profile by running `minikube profile default`",
3134
Run: func(cmd *cobra.Command, args []string) {
32-
if len(args) != 1 {
33-
exit.Usage("usage: minikube profile MINIKUBE_PROFILE_NAME")
35+
if len(args) == 0 {
36+
profile := viper.GetString(pkgConfig.MachineProfile)
37+
console.OutLn("%s", profile)
38+
os.Exit(0)
39+
}
40+
41+
if len(args) > 1 {
42+
exit.Usage("usage: minikube profile [MINIKUBE_PROFILE_NAME]")
3443
}
3544

3645
profile := args[0]

0 commit comments

Comments
 (0)