Open lcrockett opened 2 years ago
Thanks for posting the code.
Given that it invokes talosctl
on every command, I cannot add it to powerlevel10k proper (it would be too slow). The usual way powerelvel10k solves this problem is either by caching or invoking the tool asynchronously. Caching is easier and gives better UX but it requires knowing the set of env vars and files on which the output of the command depends.
I clicked on https://www.talos.dev/ and then on Try it now. The latter gave me 404. I gave up there.
Don't mind my example above, that was just a personal workaround for illustrative purposes. I agree asynchronous invocation and / or caching is more UX friendly as derived from the current Kubernetes implementation in powerlevel10k
. It's a shame the documentation link doesn't work, it's a recent change it seems and i'm guessing it's due to them preparing for their upcoming v1.0.0 release. The correct link to the quick start guide is (https://www.talos.dev/v1.0/introduction/quickstart/).
If you'd like to give it a go, loosely following the Kubernetes example in powerlevel10k
, I can assist in providing the required implementation details. As I wrote before, I got it somewhat working by re-using the existing Kubernetes context prompt segments and stripping / modifying it to work with talosctl
, so i'd assume that should make things a tad easier.
Regarding some implied questions you had:
talosctl
depends on the environment variable $TALOSCONFIG
that points to a Talos configuration file, usually located at $HOME/.talos/config
. See below for an example of the Talos configuration filetalosctl config context <context-name>
. This changes the context
value in the $TALOSCONFIG
filetalosctl config info
can be used to find out the currently set context, but parsing the Talos configuration file will work just as well. See below for an exmaple of the talosctl config info
outputExample Talos configuration file:
context: orange-spoon
contexts:
orange-spoon:
endpoints:
- talos-control-plane.subnetwork.domain.tld
nodes:
- talos-control-plane-a2c.subnetwork.domain.tld
- talos-control-plane-b8d.subnetwork.domain.tld
- talos-control-plane-c6b.subnetwork.domain.tld
- talos-control-plane-d9f.subnetwork.domain.tld
- talos-control-plane-e1a.subnetwork.domain.tld
- talos-worker-a3d.subnetwork.domain.tld
- talos-worker-b4c.subnetwork.domain.tld
- talos-worker-c8f.subnetwork.domain.tld
- talos-worker-d1a.subnetwork.domain.tld
- talos-worker-e7b.subnetwork.domain.tld
ca: <certificate-contents>
crt: <certificate-contents>
key: <key-contents>
Output talosctl config info
:
$ talosctl config info
Current context: orange-spoon
Nodes: talos-control-plane-a2c.subnetwork.domain.tld, talos-control-plane-b8d.subnetwork.domain.tld, talos-control-plane-c6b.subnetwork.domain.tld, talos-control-plane-d9f.subnetwork.domain.tld, talos-control-plane-e1a.subnetwork.domain.tld, talos-worker-a3d.subnetwork.domain.tld, talos-worker-b4c.subnetwork.domain.tld, talos-worker-c8f.subnetwork.domain.tld, talos-worker-d1a.subnetwork.domain.tld, talos-worker-e7b.subnetwork.domain.tld
Endpoints: talos-control-plane.subnetwork.domain.tld
Roles: os:admin
Certificate expires: 10 years from now (2032-03-04)
Thanks for the info. This should in theory allow me to add talosctl
segment but in practice I'm unlikely to do that given my time constraints. If you send a clean PR, I'll merge it.
Thank you for the great Z shell theme, i'm using it daily with great pleasure.
I was wondering if you could consider including suport for Talos context support. As the CLI tool
talosctl
shares similarities withkubectl
, i've skimmed the p10k source for Kubernetes prompt segments and took a stab at it. It kinda worked except for the caching that seemed to give inconsistent results and even show the prompt when there was no Talos configuration set. So instead I made a simple custom section that is less then ideal (see snippet below) to get it working for now.The Talos CLI tool
talosctl
shares similarities withkubectl
in the sense that they can both set contexts (talosctl config context <context-name>
) and can use an environment variable to determine it's current configuration (file)$TALOSCONFIG
. Info regarding the currently set context can be retrieved from the set Talos configuration file or using the CLItalosctl config info
.Currently used snippet (yes, i'm aware of the suboptimal delay due to the recurring
talosctl config info
command that is ran at every new prompt line):Example of a Talos configuration file:
If you'd like more information or some testing to be done, let me know. Cheers