Get initial namespace from k8s context in the k8s runtime settings (#2838)

This commit is contained in:
Michael Ruoss 2024-10-25 07:32:50 +02:00 committed by GitHub
parent 9a2bcfd751
commit ce1b56ee37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -536,6 +536,7 @@ defmodule LivebookWeb.SessionLive.K8sRuntimeComponent do
def handle_async(:cluster_check, {:ok, results}, socket) do
[access_review_result, namespaces_result] = results
context_namespace = socket.assigns.kubeconfig.current_namespace
access_review_result =
case access_review_result do
@ -548,7 +549,7 @@ defmodule LivebookWeb.SessionLive.K8sRuntimeComponent do
case namespaces_result do
{:ok, namespaces} ->
namespace_options = Enum.map(namespaces, & &1.name)
{:ok, namespace_options, List.first(namespace_options)}
{:ok, namespace_options, context_namespace || List.first(namespace_options)}
{:error, %{status: 403}} ->
# No access to list namespaces, we will show an input instead