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

[#439] Add --vars-inline that is capable of overwriting --vars #534

merged 5 commits into from Feb 12, 2020


Copy link

@pedroMMM pedroMMM commented Jan 2, 2020

  • make test-all (UNIX) passes. CI will also test this
  • unit and/or integration tests are included (if applicable)
  • documentation is changed or added (if applicable)

Description of change

Add --vars-inline to dynamically pass variables which can overwrite variables sourced from --vars, but with no deep merging.

Closes #439

Copy link

@aelsabbahy aelsabbahy commented Jan 2, 2020

I'll review this over the weekend. At first glance tests/results it looks great.

Copy link

@aelsabbahy aelsabbahy commented Feb 4, 2020

So, trying this out, and seems like there's either a bug in the code, or I'm misunderstanding it.

    installed: true
$ goss --vars-inline '{"package": "coreutils"}' render
panic: assignment to entry in nil map

goroutine 1 [running]:, 0x0, 0x7ffc125b2ee8, 0x18, 0x18)
        /home/aelsabbahy/sandbox/golang/src/ +0x1cf, 0xc0000b272f, 0x9de627)
        /home/aelsabbahy/sandbox/golang/src/ +0x162
main.main.func3(0xc0000d4dc0, 0xc0000b6800, 0xc0000d4d00)
        /home/aelsabbahy/sandbox/golang/src/ +0x2f, 0xa02330, 0xc0000d4dc0, 0xc0000b6800, 0x0)
        /home/aelsabbahy/sandbox/golang/pkg/mod/ +0xad, 0x6, 0x0, 0x0, 0xc000093f50, 0x1, 0x1, 0x9ea921, 0x1d, 0x0, ...)
        /home/aelsabbahy/sandbox/golang/pkg/mod/ +0x924*App).Run(0xc0000a1860, 0xc0000b8040, 0x4, 0x4, 0x0, 0x0)
        /home/aelsabbahy/sandbox/golang/pkg/mod/ +0x654
        /home/aelsabbahy/sandbox/golang/src/ +0x1e68

I tried:

--vars-inline '{"package": "coreutils"}'
--vars-inline '{package: coreutils}'
--vars-inline 'package: coreutils'

Copy link

@aelsabbahy aelsabbahy commented Feb 4, 2020

Oh, found the bug! seems --vars-inline doesn't work if --vars isn't provided

Copy link
Contributor Author

@pedroMMM pedroMMM commented Feb 4, 2020

Great catch! Thank you, I will address this bug as soon I have some time. I have been very busy with repairs at the new house...

Copy link

@aelsabbahy aelsabbahy commented Feb 4, 2020

Congrats on the new house. :)

Copy link
Contributor Author

@pedroMMM pedroMMM commented Feb 11, 2020

Thank you @aelsabbahy for the patience, it's ready to be reviewed again. I finally had some uninterrupted free time to wrap my head around Goss.

I abstracted the calls to load the variables and merge them and unit test it to ensure no other problems from now on.

I got problems on Code Climate so I tweaked the TemplateFilter in the template.go to satisfy Code Climate and simplify efforts like the one raised recently on #544.

Copy link

@aelsabbahy aelsabbahy left a comment

Looks great, small change to env var naming and then it's ready to go.

Thanks for the great contributions!

cmd/goss/goss.go Outdated Show resolved Hide resolved
docs/ Outdated Show resolved Hide resolved
… syntax

Co-Authored-By: Ahmed Elsabbahy <>
@pedroMMM pedroMMM requested a review from aelsabbahy Feb 12, 2020
@aelsabbahy aelsabbahy merged commit 6cb041d into aelsabbahy:master Feb 12, 2020
2 checks passed
BenjaminHerbert pushed a commit to BenjaminHerbert/goss that referenced this issue May 28, 2020
…ars (aelsabbahy#534)

* Add --vars-inline that is capable of overwriting --vars

* Reinforce the --vars-inline overwrite of --vars

* Clean up the TemplateFilter based on Code Climate feedback

* Fix the Travis testing by ensuring all the checks are ran

* Apply suggestions from code review for incorrect environment variable syntax

Co-Authored-By: Ahmed Elsabbahy <>

Co-authored-by: Ahmed Elsabbahy <>
Copy link

@EleanorRigby EleanorRigby commented Jul 22, 2020

If I want to inline mulltiple variables , will I have to add multiple arguments like,

--vars-inline {"containerd_version":"1.3.4"} --vars-inline {"k8s_version":"1.3.4"}

because, when I run

--vars-inline {"containerd_version":"1.3.4", "k8s_version":"1.3.4"}

goss throws an error with No help topic for k8s_version:1.3.4

Copy link

@EleanorRigby EleanorRigby commented Jul 22, 2020

Okay this is resolved. I had to put "" around json string. But how do we refer these variables .. is it like,

{{ .Vars.containerd_version }} ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

3 participants