acorn-io / runtime

A simple application deployment framework built on Kubernetes
https://docs.acorn.io/
Apache License 2.0
1.14k stars 101 forks source link

Default values set for credential data fields are not usable. #2411

Closed sangee2004 closed 6 months ago

sangee2004 commented 6 months ago

acorn version - v0.10.0-rc2-9-g43dbcbf4+43dbcbf4

Steps to reproduce the problem:

  1. Deploy app with credentials that have default values set for data fields

    secrets: config: {
    type: "credential.acorn.io/mytestcred"
    params: {
        promptOrder: ["username", "password"]
    }
    data: {
        username:      "abc"
        password:      "ppp"
    }
    }
    containers: {
    mytest: {
        image: "nginx"
    }
    }
  2. When user chooses to create a new credential , the default values are not presented when user is prompted to enter values for the fields (it is empty)

? Choose an existing credential or enter a new one Enter a new credential
? password 
? username 
  1. Choosing to enter no values for these fields , does not result in credentials being created with the default values.

Expected Behavior:

  1. Default values should be presented when user is prompted to enter values for the fields .
  2. When user does not do any changes to the existing value, credential should get created with default values set for the data.
g-linville commented 6 months ago

Just merged the fix.

sangee2004 commented 6 months ago

Tested with acorn version - v0.10.0-rc2-23-g70b569f8+70b569f8

Default values are now presented as follows when user is prompted to create a new credential:

For this secret:

secrets: config: {
    type: "credential.acorn.io/mytestcred"
    params: {
        promptOrder: ["username", "password"]
    }
    data: {
        username:      "abcd"
        password:      "ppp"
        testnodef:      ""
    }

User is prompted as:

? Choose an existing credential or enter a new one Enter a new credential
? password (default: ppp) 
? testnodef (default: ) ***
? username (default: abcd) ******

When there are no defaults provided for a field , we still get an entry with default: . Can this be improved?

g-linville commented 6 months ago

Merged the fix. There is now no default displayed if the value is set to "".

sangee2004 commented 6 months ago

Tested with acorn version - v0.10.0-rc2-35-g3cf6c107+3cf6c107

Default label is not presented for fields that do not have default values when prompted to enter credentials.