#Can I interact with a TUI or input on a dagger call?

1 messages ยท Page 1 of 1 (latest)

cyan stump
#

I can't recall if this is supported.
I have some things like terraform apply I'd like to have in dagger, but without opting to override and auto-apply, I want to run and then have the user still put something in, and then in CI I'd just pass the ci flag.

Is this possible, or is user input/prompt not supported? I couldn't remember ๐Ÿ™‚

dull urchin
cyan stump
#

@dull urchin if you have a simple example link, lets say just for "yes" or arrow up or anything for Go, I'd love to see it so I can jump start seeing what it looks like. No biggee though if it's self evident and I'll look further as soon as I can. ๐Ÿ™‡

dull urchin
#

Having said that, it's pretty straightforward. It's mostly calling the Terminal function and specifying which command you want to run there. That's pretty much it

quasi shoal
#

@dull urchin I saw @smoky stone mentioned tricks with the Terminal command, but how do you recover the result of the user input though?

dull urchin
#

Like terraform apply which only expects a Y/N input

quasi shoal
#

oh wow

#

like you only execute that one command. neat

#

technically you could compile a binary that is Dagger-aware, execute that binary in an interactive terminal, then have that binary make more dagger calls basedon the input. Like a continuation-style processing ๐Ÿ˜›

dull urchin
#

cc @sterile jolt and @quasi shoal

#

you can also get the output via cache volumes. It's not the best DX but it does the job

quasi shoal
#

oh nice! yeah that's super useful

cyan stump
#

k. i'm gonna play with this then. Thank you!

sterile jolt
# cyan stump k. i'm gonna play with this then. Thank you!

I played around a bit more myself, came up with this (feel free to copy/clone or use as a base)

https://daggerverse.dev/mod/github.com/pjmagee/dagger-prompt@6deb6b3cab9477c5bd2df8b2dc6a2f871d33537f

My thought for having a ci:true/false was so that 'somehow' someone can feed a user entered variable into the with-input(ValueFromCI) but locally, you would use with-ci(false) so that the Terminal() is used locally.

cyan stump
#

i didn't get there right now but i think perhaps it's an image issue, maybe it doesn't have a terminal, so right now just filewatch and rerunning to see where i get

quasi shoal
#

we could make the CLI prompt for missing required arguments

#

would make your code more portable

sterile jolt
#

@quasi shoal do you mean the module i wrote?

quasi shoal
#

I just meant in general

#

My thought for having a ci:true/false was so that 'somehow' someone can feed a user entered variable into the with-input(ValueFromCI) but locally, you would use with-ci(false) so that the Terminal() is used locally.

In response to this pattern (to avoid with-ci if possible)

sterile jolt
#

ah

#

that could be a neat CLI addition

quasi shoal
#

We used to have it a LONG time ago, with the original cue-based version. I think @green ember implemented it. It was quite neat!

cyan stump
#

If you use cobra for cli I found a library that integrates this with an interactive shell completion. Bit, kube-prompt use this. It's pretty neat.

cyan stump
#

So each image might have different shells (like chainguard dev vs another image with dev tools). So basically I use terminalsargs to override? I looked and didn't notice the default shell expected. Followed the code from terminal to buildkit session and maybe I missed it but didn't see what the default was.
Not priority, but to educate me where would that be defined?

dull urchin
#

So basically I use terminalsargs to override?
yes

cyan stump
#

So worst case if I did a. Dagger action with inline bash using gum or something like that I'd be able to use the same approach @dull urchin to allow interactivity as long as the image has the terminal (like not a locked down chainguard image)

dull urchin
cyan stump
#

My brain is confused. If it's a sidecar how can I respond to TUI info from the other container.

If it's "complicated" no need to provide detail then. Just interested. Point me to code and I can just look but never heard of this before. I know k8s debugging containers are a thing so maybe similar.

dull urchin
dull urchin
#

alpine is only use for Directory terminals. Which is when you call Terminal from a directory

cyan stump
#

sorry that's new to me, so are you saying:

  • can't interact with tui from main container, only sidecar?
  • it's focused on an interactive debugging terminal.

So I can I use this approach to prompt with say Charm's hey libraries from my actual dagger container or am I going to run into problems with that... so I don't waste time trying to make it work ;-p

dull urchin
#

When you call Terminal on a Directory, that's when the alpine container is used

dull urchin
quasi shoal
#

the terminal gets launched in a sidecar copy of the source container

I think the term "sidecar" is confusing in this context.

cyan stump
#

I'm thinking of sidecar containers like pods.
I was hoping I could start with a simple TUI from charm IN a dagger function and have user interact, but if not possible I get it. Just not groking if technically should or should not work, and sorry if answered somewhere and I missed it, been trying to pilot this stuff, but have other projects demanding attention ๐Ÿ‘‹