Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement Request: Control over Interactive Input Sequence in Custom Pipeline Command #2779

Open
Naveen-oops opened this issue Dec 29, 2023 · 2 comments
Labels
kind/enhancement Enhancement of an existing feature / improvement kind/feature New feature or feature request wait-on-user

Comments

@Naveen-oops
Copy link

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?

  1. Sequential Prompting: Have control over the sequence of interactive prompts within the pipeline command.
  2. 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 Naveen-oops added the kind/feature New feature or feature request label Dec 29, 2023
@lizardruss
Copy link
Collaborator

@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

@linear linear bot added the wait-on-user label Jan 11, 2024
@Naveen-oops
Copy link
Author

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.

@deniseschannon deniseschannon added the kind/enhancement Enhancement of an existing feature / improvement label May 8, 2024 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Enhancement of an existing feature / improvement kind/feature New feature or feature request wait-on-user
Projects
None yet
Development

No branches or pull requests

3 participants