Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport: Prevent a panic in tsh kube login when logged out #4891

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions lib/client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ func readProfile(profileDir string, profileName string) (*ProfileStatus, error)
}

// Status returns the active profile as well as a list of available profiles.
// If no profile is active, Status returns a nil error and nil profile.
func Status(profileDir string, proxyHost string) (*ProfileStatus, []*ProfileStatus, error) {
var err error
var profile *ProfileStatus
Expand Down
9 changes: 5 additions & 4 deletions tool/tsh/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/gravitational/teleport/lib/client"
"github.com/gravitational/teleport/lib/kube/kubeconfig"
kubeutils "github.com/gravitational/teleport/lib/kube/utils"
"github.com/gravitational/teleport/lib/utils"
"github.com/gravitational/trace"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -226,10 +225,12 @@ func (c *kubeLoginCommand) run(cf *CLIConf) error {
profile, _, err := client.Status("", cf.Proxy)
if err != nil {
if trace.IsNotFound(err) {
fmt.Println("Not logged in.")
return nil
return trace.AccessDenied("not logged in")
}
utils.FatalError(err)
return trace.Wrap(err)
}
if profile == nil {
return trace.AccessDenied("not logged in")
}
kc, err := kubeconfig.Load("")
if err != nil {
Expand Down