drone-ecs
drone-ecs copied to clipboard
Comma in env variables causes panic
Hi,
Whenever I try to use commas in the environmental variables the plugin panics. I've tried wrapping the value with " but it does not help. I've noticed the same issue in two different code projects. If I put the value in a env secret then it works fine.
- name: deploy-production
image: josmo/drone-ecs:latest
...
settings:
environment_variables:
- DRONE_USER_CREATE=username:joakim,admin:true
Drone AWS ECS Plugin built
5 | panic: runtime error: index out of range [1] with length 1 6 | 7 | goroutine 1 [running]: 8 | main.(*Plugin).Exec(0xc0000aab00, 0xc0001b2180, 0xa2208b) 9 | /go/src/github.com/tallinger/drone-ecs/plugin.go:212 +0x4155 10 | main.run(0xc0000a8420, 0x0, 0xc0000d7190) 11 | /go/src/github.com/tallinger/drone-ecs/main.go:278 +0x1347 12 | github.com/urfave/cli.HandleAction(0x962780, 0xa44bb0, 0xc0000a8420, 0xc0000a8420, 0x0) 13 | /go/pkg/mod/github.com/urfave/[email protected]/app.go:514 +0xbe 14 | github.com/urfave/cli.(*App).Run(0xc0001c2000, 0xc0000761b0, 0x1, 0x1, 0x0, 0x0) 15 | /go/pkg/mod/github.com/urfave/[email protected]/app.go:274 +0x5f6 16 | main.main() 17 | /go/src/github.com/tallinger/drone-ecs/main.go:230 +0x1ef9
Any ideas what is wrong? I had a look at row 212 in plugin.go but I do not see anything obvious wrong?
Sorry @jtallinger I'm finally catching up on notifications and I definitely let this go. Did you find the issue? at first glance I'm wondering if something weird is going on it needing to be quoted or something.
Hi,
I was looking into this but did not find any solution. Issue relates to urfave/cli package (https://github.com/urfave/cli/issues/549), where comma is used as a separator. Seems not possible to escape it either.
I added a debug print in plugin.go and used this as a test:
steps:
- name: test
image: tallinger/drone-ecs:1.1
settings:
environment_variables:
- TEST=test,test
And output to console:
[test:0] Drone AWS ECS Plugin built
[test:1] ENV: TEST=test
[test:2] ENV: test
Tried various escape methods like TEST="test,test", TEST='test,test', "TEST=test,test" but none worked. For now I changed my application to use | as separator instead of comma. For those I could not change I use secrets manager, which works as a work around.
I'm using jsonnet and I'm having the same issue when using the "_" character as separator.
Hi, as a fix for me
steps:
- name: ssh commands
image: appleboy/drone-ssh
environment:
COMMA:
from_secret: comma
PLATFORM: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/386
settings:
host: localhost
username: user
port: 22
key:
from_secret: ssh_key
envs:
- COMMA
- PLATFORM
script:
- echo `pwd`
- echo $COMMA $PLATFORM
- echo
Output
latest: Pulling from appleboy/drone-ssh
--
2 | Digest: sha256:095ca4ceafcb751f1f22fe416057d3e2a6302f7b1f7011b17010973cb6bbdd9f
3 | Status: Image is up to date for appleboy/drone-ssh:latest
4 | ======CMD======
5 | echo `pwd`
6 | echo $COMMA $PLATFORM
7 | echo
8 | ======END======
9 | out: /home/user
10 | out: , linux/arm/v7,linux/arm64/v8,linux/amd64,linux/386
11 | ==============================================
12 | ✅ Successfully executed commands to all host.
13 | ==============================================