这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,25 @@ func NewDefaultOcCommand(in io.Reader, out, errout io.Writer) *cobra.Command {
// only look for suitable extension executables if
// the specified command does not already exist
if _, _, err := cmd.Find(cmdPathPieces); err != nil {
if err := kubecmd.HandlePluginCommand(pluginHandler, cmdPathPieces); err != nil {
fmt.Fprintf(errout, "%v\n", err)
os.Exit(1)
// Also check the commands that will be added by Cobra.
// These commands are only added once rootCmd.Execute() is called, so we
// need to check them explicitly here.
var cmdName string // first "non-flag" arguments
for _, arg := range cmdPathPieces {
if !strings.HasPrefix(arg, "-") {
cmdName = arg
break
}
}

switch cmdName {
case "help", cobra.ShellCompRequestCmd, cobra.ShellCompNoDescRequestCmd:
// Don't search for a plugin
default:
if err := kubecmd.HandlePluginCommand(pluginHandler, cmdPathPieces); err != nil {
fmt.Fprintf(errout, "%v\n", err)
os.Exit(1)
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/login/loginoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@ func (o *LoginOptions) gatherProjectInfo() error {

projectsList, err := projectClient.Projects().List(context.TODO(), metav1.ListOptions{})
// if we're running on kube (or likely kube), just set it to "default"
if kerrors.IsNotFound(err) || kerrors.IsForbidden(err) {
if err != nil {
if !kerrors.IsNotFound(err) && !kerrors.IsForbidden(err) {
fmt.Fprintf(o.Out, "WARNING: Failed to list projects: %v\n", err)
}
fmt.Fprintf(o.Out, "Using \"default\" namespace. You can switch namespaces with:\n\n %s project <projectname>\n", o.CommandName)
o.Project = "default"
return nil
}
if err != nil {
return err
}

projectsItems := projectsList.Items
projects := sets.String{}
Expand Down
11 changes: 5 additions & 6 deletions pkg/helpers/newapp/app/sourcelookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ func (r *SourceRepository) LocalPath() (string, error) {
// DetectAuth returns an error if the source repository cannot be cloned
// without the current user's environment. The following changes are made to the
// environment:
// 1) The HOME directory is set to a temporary dir to avoid loading any settings in .gitconfig
// 2) The GIT_SSH variable is set to /dev/null so the regular SSH keys are not used
// (changing the HOME directory is not enough).
// 3) GIT_CONFIG_NOSYSTEM prevents git from loading system-wide config
// 4) GIT_ASKPASS to prevent git from prompting for a user/password
// 1. The HOME directory is set to a temporary dir to avoid loading any settings in .gitconfig
// 2. The GIT_SSH variable is set to /dev/null so the regular SSH keys are not used
// (changing the HOME directory is not enough).
// 3. GIT_CONFIG_NOSYSTEM prevents git from loading system-wide config
// 4. GIT_ASKPASS to prevent git from prompting for a user/password
func (r *SourceRepository) DetectAuth() error {

url, ok, err := r.RemoteURL()
Expand All @@ -301,7 +301,6 @@ func (r *SourceRepository) DetectAuth() error {
defer os.RemoveAll(tempSrc)
env := []string{
fmt.Sprintf("HOME=%s", tempHome),
"GIT_SSH=/dev/null",
"GIT_CONFIG_NOSYSTEM=true",
"GIT_ASKPASS=true",
}
Expand Down