Enhancement Request: Control over Interactive Input Sequence in Custom Pipeline Command
Is your feature request related to a problem?
Problem Description
- I'm currently writing a custom pipeline command that involves user interaction for input.
- However, I'm encountering issues with the sequence of interactive prompts and controlling these prompts within the pipeline command.
Scenario and expectation
when I run the command devspace run-pipeline install , I would like to first ask the question where to install?
- if it is local, I will execute the respective logic, and the flow ends.
- if it is remote then only I want to get 3 more interactive inputs and then proceed with the flow.
Current Behavior and Need for Clarity
- The current behavior is that the order of the questions asked during interaction seems random.
- I'm uncertain if it's possible to declare the 'question' variable inside the pipeline itself. Attempts to use typical bash commands like 'read' did not function as expected, prompting me to explore a variable-based approach.
Additional Context
Example: (My devspace file)
version: v2beta1
name: install
# has bash functions for custom installation ( installOnKind, installOnRemoteNode )
imports:
- path: "./installScripts.yaml"
vars:
INSTALL:
question: Where do you want to install the k8s application?
options: ["local", "remote"]
default: "local"
noCache: true
HOST:
question: "Enter the hostname in which k8s is running?"
noCache: true
PASSWORD:
question: "Enter the password:"
password: true
noCache: true
USER_NAME:
question: "Enter the username for the host?"
default: "test"
noCache: true
pipelines:
install-application:
run: |-
if [ $INSTALL == "local" ]; then
# steps to install the local kind k8s cluster and app
installOnKind
echo "local kind k8s cluster installed successfully !!!"
else
# steps to install the setup on remote node
# here only I want to get user input for variables
installOnRemoteNode $HOST $PASSWORD $USER_NAME
fi
Which solution do you suggest?
- Sequential Prompting: Have control over the sequence of interactive prompts within the pipeline command.
- Clarification on Variable Declaration: Clarification on the possibility of declaring the 'question' variable inside the pipeline for better control over interactive prompts.
Which alternative solutions exist?
-
At present, exploring alternative methods to handle user interaction within the pipeline, considering different variable-based approaches and command sequencing.
-
I'd greatly appreciate any guidance, insights, or suggestions on how to achieve more structured control over the interactive input sequence within the pipeline command.
-
Thank you for your attention and support in addressing this matter.
@Naveen-oops Thanks for submitting this request!
I came up with an example using commands that may give you some ideas. If it doesn't suit your needs, then lets continue discussing, since I think there's room to improve the user experience with vars.
devspace.yaml:
version: v2beta1
name: test-var
pipelines:
dev: |
echo "${ONE}"
echo "${TWO}"
echo "${THREE}"
commands:
test-var: |-
read -p "Can you spell?" spell
if [ "$spell" = "yes" ]; then
read -p "Spell 1?" one
read -p "Spell 2?" two
read -p "Spell 3?" three
devspace dev --var ONE=$one --var TWO=$two --var THREE=$three
else
devspace dev --var ONE=one --var TWO=two --var THREE=three
fi
output
❯ devspace run test-var
Can you spell?yes
Spell 1?eins
Spell 2?zwei
Spell 3?drei
info Using namespace 'loft'
info Using kube context 'kind-kind'
eins
zwei
drei
❯ devspace run test-var
Can you spell?no
info Using namespace 'loft'
info Using kube context 'kind-kind'
one
two
three
Thanks @lizardruss for your reply.
Yeah, the example you gave is helping, I can implement my use case with the help of that.
My suggestion would be instead of read, if we have any utility POSIX function exposed outside for accessing VAR functionality of devspace, it would be even good. Because the color , theme , and options provided by VAR will increase user experience.