-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into shorter-prefixes
- Loading branch information
Showing
20 changed files
with
727 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
<!-- Thank you for sharing your experience! If you are reporting a bug, please include: --> | ||
<!-- * The exact command-lines used so that we can replicate the issue --> | ||
<!-- * The full output of the command that failed --> | ||
<!-- * The output of the "minikube logs" command, if applicable --> | ||
<!-- * Which operating system version was used --> | ||
<!-- Please use this template while reporting an issue, providing as much information as possible. Failure to do so may result in a delayed response. Thank you! --> | ||
|
||
**The exact command to reproduce the issue**: | ||
|
||
**The full output of the command that failed**: | ||
|
||
**The output of the `minikube logs` command**: | ||
|
||
**The operating system version**: |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors All rights reserved. | ||
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 cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"runtime" | ||
"syscall" | ||
|
||
"github.com/golang/glog" | ||
"github.com/spf13/cobra" | ||
pkg_config "k8s.io/minikube/pkg/minikube/config" | ||
"k8s.io/minikube/pkg/minikube/console" | ||
"k8s.io/minikube/pkg/minikube/constants" | ||
"k8s.io/minikube/pkg/minikube/exit" | ||
"k8s.io/minikube/pkg/minikube/machine" | ||
) | ||
|
||
// kubectlCmd represents the kubectl command | ||
var kubectlCmd = &cobra.Command{ | ||
Use: "kubectl", | ||
Short: "Run kubectl", | ||
Long: `Run the kubernetes client, download it if necessary.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
api, err := machine.NewAPIClient() | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) | ||
os.Exit(1) | ||
} | ||
defer api.Close() | ||
|
||
cc, err := pkg_config.Load() | ||
if err != nil && !os.IsNotExist(err) { | ||
console.ErrLn("Error loading profile config: %v", err) | ||
} | ||
|
||
binary := "kubectl" | ||
if runtime.GOOS == "windows" { | ||
binary = "kubectl.exe" | ||
} | ||
|
||
version := constants.DefaultKubernetesVersion | ||
if cc != nil { | ||
version = cc.KubernetesConfig.KubernetesVersion | ||
} | ||
|
||
path, err := machine.CacheBinary(binary, version, runtime.GOOS, runtime.GOARCH) | ||
if err != nil { | ||
exit.WithError("Failed to download kubectl", err) | ||
} | ||
|
||
glog.Infof("Running %s %v", path, args) | ||
c := exec.Command(path, args...) | ||
c.Stdout = os.Stdout | ||
c.Stderr = os.Stderr | ||
if err := c.Run(); err != nil { | ||
var rc int | ||
if exitError, ok := err.(*exec.ExitError); ok { | ||
waitStatus := exitError.Sys().(syscall.WaitStatus) | ||
rc = waitStatus.ExitStatus() | ||
} else { | ||
fmt.Fprintf(os.Stderr, "Error running %s: %v\n", path, err) | ||
rc = 1 | ||
} | ||
os.Exit(rc) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(kubectlCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.