Skip to content

Commit

Permalink
Merge pull request #3 from dodevops/feature/dpr/fixes
Browse files Browse the repository at this point in the history
fix: Removes logs that were temporarily used for debugging and fixes …
  • Loading branch information
dploeger authored Oct 9, 2024
2 parents e21ef15 + 8a188ea commit 9acec4f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
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

0 comments on commit 9acec4f

Please sign in to comment.