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

fix: Removes logs that were temporarily used for debugging and fixes … #3

Merged
merged 1 commit into from
Oct 9, 2024
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
6 changes: 0 additions & 6 deletions pkg/api/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
"log"
"slices"
)

Expand Down Expand Up @@ -55,7 +54,6 @@ func (r *KubeConfig) GetCurrentNamespace() string {
}

func (r *KubeConfig) GetNamespacesInContext(context string) ([]string, error) {
log.Printf("Getting namespaces in context %s", context)
var namespaces []string
oldContext := r.config.CurrentContext

Expand All @@ -75,10 +73,7 @@ func (r *KubeConfig) GetNamespacesInContext(context string) ([]string, error) {
namespaces = ns
}

log.Printf("Found %d namespaces", len(namespaces))

if oldContext != context {
log.Printf("Switching back to old context")
if err := r.SwitchContext(context); err != nil {
return namespaces, err
}
Expand All @@ -88,7 +83,6 @@ func (r *KubeConfig) GetNamespacesInContext(context string) ([]string, error) {
}

func (r *KubeConfig) SwitchContext(context string) error {
log.Printf("Switching to context %s", context)
r.config.CurrentContext = context
return r.updateConfig(r.config)
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/cmd/cs.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func (o *ContextSwitcherOptions) Complete(args []string) error {

func (o *ContextSwitcherOptions) interpretTask(value string) {
components := strings.Split(value, ":")
if len(components) != 2 {
return
}
if components[0] != "" {
o.context = components[0]
o.task = TaskSwitchContext
Expand All @@ -132,7 +135,7 @@ func (o *ContextSwitcherOptions) Validate() error {
return fmt.Errorf("wrong argument specified")
}

if o.task == TaskSwitchBoth || o.task == TaskSwitchContext &&
if (o.task == TaskSwitchBoth || o.task == TaskSwitchContext) &&
!funk.ContainsString(funk.Keys(o.rawConfig.Contexts).([]string), o.context) {
return fmt.Errorf("selected context does not exist")
}
Expand Down
1 change: 0 additions & 1 deletion pkg/ui/selection_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type SelectionList struct {
var _ tea.Model = SelectionList{}

func NewSelectionList(title string, kubeConfigAPI api.KubeConfig, onlyCurrentContext bool) SelectionList {
_, _ = tea.LogToFile("/tmp/cslog", "debug")
d := list.NewDefaultDelegate()
d.SetSpacing(0)
d.ShowDescription = false
Expand Down
Loading