aml icon indicating copy to clipboard operation
aml copied to clipboard

Not able to set the boolean arg flag to "false".

Open sangee2004 opened this issue 1 year ago • 2 comments

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 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 ()

sangee2004 avatar Oct 04 '23 16:10 sangee2004

This issue is seen even when the default value defined in Acornfile for the boolean arg is "false"

acorn run -n yy . --newApp false

args: {
	newApp:  false
	oldtext: "old"
	newtext: "new"
        number: 1
        decimal: 4.5
}
containers: {
	mywebnew: {
	image: "nginx"
	ports: publish: "80/http"
	files: {
		"/usr/share/nginx/html/index.html": std.ifelse(args.newApp, args.newtext, args.oldtext)
		"/usr/share/nginx/html/test.html": std.ifelse( args.number == 1, "default", "\(args.number)")
		"/usr/share/nginx/html/test1.html": std.ifelse(args.decimal > 5, "default", "\(args.decimal)")
	}
}
}

This results is newApp getting set to true

sangee2004 avatar Oct 06 '23 00:10 sangee2004

The syntax for setting bools to false is --newApp=false. What is happening here is that it's being interpreted as one flag --newApp, which means set to true, and then an arg false which is silently ignored.

I can change the parser to not silently ignore the extra argument.

ibuildthecloud avatar Oct 09 '23 04:10 ibuildthecloud