acorn-io / runtime

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

Not able to set the boolean arg flag to "false" when it has default value set to "true" in Acornfile. #2211

Open sangee2004 opened 1 year ago

sangee2004 commented 1 year ago

acorn version v0.8.0-80-g635ea0a6+635ea0a6

Steps to reproduce the problem:

  1. Deploy app using the following Acornfile by passing "false" to newApp - acorn run -n mytest . --newApp false --newtext nnupdate --oldtext ooupdate

Acornfile used:

args: {
    newApp:  true
    oldtext: "old"
    newtext: "new"
}
containers: {
    mywebnew: {
    image: "nginx"
    ports: publish: "80/http"
    files: {
        "/usr/share/nginx/html/index.html": std.ifelse(args.newApp, args.newtext, args.oldtext)
    }
}
}

This results in newApp being set to true

Spec for the app shows newApp set to true even when "false" was passed.

            "spec": {
                "image": "157b305f5477547cda05c29f2ff1758ac1029c9e786bcd2f16546dee15a278df",
                "deployArgs": {
                    "newApp": true,
                    "newtext": "nnupdate",
                    "oldtext": "ooupdate"
                }
            },

Possibly related to type not shown for boolean args in acorn help

acorn run . --help

Volumes:   <none>
Secrets:   <none>
Containers: mywebnew
Ports:     mywebnew:80/http

      --newApp            
      --newtext string    
      --oldtext string    
      --profile strings   Available profiles ()
cjellick commented 11 months ago

How is false pased? I feel like this is missing a step.

sangee2004 commented 11 months ago

@cjellick I am able to set boolean flag to "true" when it is passed with "=" like --newApp=false in the arg list. This issue is seen only when it is passed with out "=" like --newApp false in the arg list.

In the example provided in the above issue ,

acorn run -n mytest -f Acornfilebool -- --newApp=false --newtext nnupdate --oldtext ooupdate works as expected.

The issue is seen only when we launch the app as follows without "=" for the boolean args acorn run -n mytest -f Acornfilebool -- --newApp false --newtext nnupdate --oldtext ooupdate

cjellick commented 10 months ago

Not a blocker. Moving to low

cjellick commented 10 months ago

This is a limitation of the flag parsing lib we use. See: https://github.com/spf13/cobra/issues/613

Not super high priority, but im tempted to go as far a dropping use of the actual bool flag and have our own string-based bool-ish flag that behaves more predictably