Skip to content

Commit

Permalink
fix: properly work if listing ns is denied (redhat-developer#717)
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish committed Mar 15, 2024
1 parent eff7074 commit 0fcfa81
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
package com.redhat.devtools.intellij.kubernetes.tree

import com.intellij.ide.util.treeView.NodeDescriptor
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.IconLoader
import com.redhat.devtools.intellij.kubernetes.model.IResourceModel
import com.redhat.devtools.intellij.kubernetes.model.context.KubernetesContext
import com.redhat.devtools.intellij.kubernetes.model.resource.ResourceKind
import com.redhat.devtools.intellij.kubernetes.model.util.getHighestPriorityVersion
import com.redhat.devtools.intellij.kubernetes.model.util.toMessage
import com.redhat.devtools.intellij.kubernetes.model.util.trimWithEllipsis
import com.redhat.devtools.intellij.kubernetes.tree.AbstractTreeStructureContribution.DescriptorFactory
import com.redhat.devtools.intellij.kubernetes.tree.KubernetesStructure.NamespacesFolder
import com.redhat.devtools.intellij.kubernetes.tree.TreeStructure.ContextDescriptor
Expand Down Expand Up @@ -123,14 +126,19 @@ object KubernetesDescriptors {
project
) {
override fun getSubLabel(element: Folder): String {
val current = model.getCurrentNamespace()
return "current: ${
if (current.isNullOrEmpty()) {
"<none>"
} else {
current
val current = try {
model.getCurrentNamespace()
} catch (e: Exception) {
logger<KubernetesDescriptors>().warn("Could not get current namespace", e)
"<none> (error retrieving all namespaces)"
}
}"
return "current: ${
if (current.isNullOrEmpty()) {
"<none>"
} else {
current
}
}"
}
}

Expand Down

0 comments on commit 0fcfa81

Please sign in to comment.