From 1d3ebac2ca9bbdbc1cd1c97d9421f417c508a54c Mon Sep 17 00:00:00 2001 From: Michael Ruoss Date: Wed, 29 Nov 2023 13:35:27 +0100 Subject: [PATCH] chores: Upgrade xterm.js to 5.3.0 --- assets/kino_terminal/main.ts | 4 +- dev.livemd | 80 +++++++------------------------- lib/assets/kino_terminal/main.js | 2 +- 3 files changed, 20 insertions(+), 66 deletions(-) diff --git a/assets/kino_terminal/main.ts b/assets/kino_terminal/main.ts index cce059d..beba381 100644 --- a/assets/kino_terminal/main.ts +++ b/assets/kino_terminal/main.ts @@ -3,10 +3,10 @@ import { KinoTerminalAttrs } from './types' export async function init(ctx: KinoContext, attrs: KinoTerminalAttrs) { await ctx.importCSS( - 'https://cdn.jsdelivr.net/npm/xterm@5.0.0/css/xterm.min.css', + 'https://cdn.jsdelivr.net/npm/xterm@5.3.0/css/xterm.min.css', ) await ctx.importJS( - 'https://cdn.jsdelivr.net/npm/xterm@5.0.0/lib/xterm.min.js', + 'https://cdn.jsdelivr.net/npm/xterm@5.3.0/lib/xterm.min.js', ) ctx.root.innerHTML = ` diff --git a/dev.livemd b/dev.livemd index e6146b3..6136045 100644 --- a/dev.livemd +++ b/dev.livemd @@ -19,71 +19,38 @@ Mix.install([{:kino_k8s, path: "~/src/community/kino_k8s"}]) conn ``` - - -```elixir - -``` + ```elixir +connect_to_pod = fn terminal_kino_pid -> + {:ok, send_to_websocket} = + K8s.Client.connect("v1", "pods/exec", [namespace: "kino-k8s", name: "busybox"], + container: "busybox", + command: "/bin/sh", + tty: true + ) + |> K8s.Client.put_conn(conn) + |> K8s.Client.stream_to(terminal_kino_pid) -``` - -```elixir -{:ok, admin_token} = - K8s.Client.get("v1", "secrets", name: "ns-admin-token", namespace: "kino-k8s") - |> K8s.Client.put_conn(conn) - |> K8s.Client.run() - -{:ok, ca_cert} = K8s.Conn.PKI.cert_from_base64(admin_token["data"]["ca.crt"]) + send_to_websocket +end -admin_conn = - struct!(conn, - ca_cert: ca_cert, - auth: %K8s.Conn.Auth.Token{token: Base.decode64!(admin_token["data"]["token"])}, - namespace: Base.decode64!(admin_token["data"]["namespace"]) - ) +KinoK8s.KinoTerminal.open(connect_to_pod) ``` -```elixir -{:ok, cluster_admin_token} = - K8s.Client.get("v1", "secrets", name: "cluster-admin-token", namespace: "kino-k8s") - |> K8s.Client.put_conn(conn) - |> K8s.Client.run() - -{:ok, ca_cert} = K8s.Conn.PKI.cert_from_base64(cluster_admin_token["data"]["ca.crt"]) - -cluster_admin_conn = - struct!(conn, - ca_cert: ca_cert, - auth: %K8s.Conn.Auth.Token{token: Base.decode64!(cluster_admin_token["data"]["token"])}, - namespace: Base.decode64!(cluster_admin_token["data"]["namespace"]) - ) -``` + ```elixir -{:ok, cm_pod_reader_token} = - K8s.Client.get("v1", "secrets", name: "cm-pod-reader-token", namespace: "kino-k8s") - |> K8s.Client.put_conn(conn) - |> K8s.Client.run() - -{:ok, ca_cert} = K8s.Conn.PKI.cert_from_base64(cm_pod_reader_token["data"]["ca.crt"]) -cm_pod_reader_conn = - struct!(conn, - ca_cert: ca_cert, - auth: %K8s.Conn.Auth.Token{token: Base.decode64!(cm_pod_reader_token["data"]["token"])}, - namespace: Base.decode64!(cm_pod_reader_token["data"]["namespace"]) - ) ``` - + ```elixir ``` - + ````elixir import YamlElixir.Sigil @@ -117,23 +84,10 @@ Kino.Markdown.new("#### Applied Resource: ") ```` - + ```elixir -connect_to_pod = fn terminal_kino_pid -> - {:ok, send_to_websocket} = - K8s.Client.connect("v1", "pods/log", [namespace: "kino-k8s", name: "busybox"], - container: "busybox", - tailLines: 100, - follow: true - ) - |> K8s.Client.put_conn(cm_pod_reader_conn) - |> K8s.Client.stream_to(terminal_kino_pid) - send_to_websocket -end - -KinoK8s.KinoTerminal.open(connect_to_pod) ``` ```elixir diff --git a/lib/assets/kino_terminal/main.js b/lib/assets/kino_terminal/main.js index a2d3a89..915ae5a 100644 --- a/lib/assets/kino_terminal/main.js +++ b/lib/assets/kino_terminal/main.js @@ -1,4 +1,4 @@ -async function o(n,r){await n.importCSS("https://cdn.jsdelivr.net/npm/xterm@5.0.0/css/xterm.min.css"),await n.importJS("https://cdn.jsdelivr.net/npm/xterm@5.0.0/lib/xterm.min.js"),n.root.innerHTML=` +async function o(n,r){await n.importCSS("https://cdn.jsdelivr.net/npm/xterm@5.3.0/css/xterm.min.css"),await n.importJS("https://cdn.jsdelivr.net/npm/xterm@5.3.0/lib/xterm.min.js"),n.root.innerHTML=`