variant
Archived01,388
Discuss variant (the “Universal CLI”) https://github.com/mumoshu/variant
Archive: https://archive.sweetops.com/variant/
E
erik12 months ago
archived the channel
Robert Horroxabout 5 years ago
Not sure if this channel is best to discuss atmos (https://github.com/cloudposse/atmos) when using the config stack if a component hasn’t been defined at any level in the config files it will still return the full global config instead of error’ing out. Not sure if this is the intended behavior or a side effect of the multi layer import configs.
mumoshuover 5 years ago
You can now turn your Variant2 command into a Kubernetes controller 
See https://github.com/mumoshu/variant2/pull/35

See https://github.com/mumoshu/variant2/pull/35
mumoshuover 5 years ago
also - it may theoretically possible to export your variant-made command as a porter bundle by using https://porter.sh/custom-dockerfile/.
mumoshuover 5 years ago
variant is mostly a HCL-based DSL and the compiler to build CLI apps. So my guess is that porter should be used to package variant-made apps 🙂
Amit Karpeover 5 years ago
I found Porter a project which was accepted by the CNCF recently.
I am still trying to understand whether it is close to what variant dose!
I am still trying to understand whether it is close to what variant dose!
Package your application artifact, client tools, configuration and deployment logic together as a versioned bundle that you can distribute, and then install with a single commandmumoshuover 5 years ago
Turns out Waypoint is not make or variant at all. It's a pluggable PaaS powered by not cli only but also waypoint-entrypoint and waypoint-server 
Probably we may use variant to wrap waypoint-cli or call variant commands via waypoint's exec plugin

Probably we may use variant to wrap waypoint-cli or call variant commands via waypoint's exec plugin
mumoshuover 5 years ago(edited)
Apparently you can start from no server, and gradually move heavy processes to the waypoint server in the future
https://www.waypointproject.io/docs/roadmap#remote-runners
https://www.waypointproject.io/docs/roadmap#remote-runners
mumoshuover 5 years ago
The most impressive aspect of it for me was https://www.waypointproject.io/docs/internals/execution#most-common-cli-and-a-remote-server
mumoshuover 5 years ago
Probably variant could be handy when used from waypoint hooks(https://www.waypointproject.io/docs/lifecycle/hooks) and exec plugin(https://www.waypointproject.io/plugins/exec)
mumoshuover 5 years ago
@Erik Osterman (Cloud Posse) Just read the announcement. Looks nice!
E
erikover 5 years ago
Erik Osterman (Cloud Posse)over 5 years ago
@mumoshu see the new announcement today from HashiCorp on Waypoint?
https://www.waypointproject.io/
Example config:
https://github.com/hashicorp/waypoint-examples/blob/main/kubernetes/exec-kubectl-apply/waypoint.hcl
https://www.waypointproject.io/
Example config:
https://github.com/hashicorp/waypoint-examples/blob/main/kubernetes/exec-kubectl-apply/waypoint.hcl
johncblandiiover 5 years ago
@mumoshu any thoughts on this error? (see first comment)
This was working fine and is now failing with no changes to the variant files or the build approach.
This was working fine and is now failing with no changes to the variant files or the build approach.
Robert Horroxover 5 years ago
I’m hoping someone knows the answer to this, I’m working with variant2 and variantmod and I’m trying to pull an entire directory using variant. I can’t only figure out how to pull single files. I see in the code that Directories are supported in some fashion, I just can’t figure out the right config to pull them
johncblandiialmost 6 years ago
@Erik Osterman (Cloud Posse) @mumoshu here is an example of a CLI call not waiting for input.
I don’t have the exact code in play right here, but my guess it is the
I don’t have the exact code in play right here, but my guess it is the
workspace running then it immediately goes to a init which also skips waiting for the input.Initializing modules...
Initializing the backend...
Backend configuration changed!
Terraform has detected that the configuration specified for the backend
has changed. Terraform will now check for existing state in the backends.
Do you want to migrate all workspaces to "s3"?
Both the existing "s3" backend and the newly configured "s3" backend
support workspaces. When migrating between backends, Terraform will copy
all workspaces (with the same names). THIS WILL OVERWRITE any conflicting
states in the destination.
Terraform initialization doesn't currently migrate only select workspaces.
If you want to migrate a select number of workspaces, you must manually
pull and push those states.
If you answer "yes", Terraform will migrate all states. If you answer
"no", Terraform will abort.
Enter a value:
Do you want to migrate all workspaces to "s3"?
Both the existing "s3" backend and the newly configured "s3" backend
support workspaces. When migrating between backends, Terraform will copy
all workspaces (with the same names). THIS WILL OVERWRITE any conflicting
states in the destination.
Terraform initialization doesn't currently migrate only select workspaces.
If you want to migrate a select number of workspaces, you must manually
pull and push those states.
If you answer "yes", Terraform will migrate all states. If you answer
"no", Terraform will abort.
Enter a value:
Error: Migration aborted by user.johncblandiialmost 6 years ago
another interesting one, @mumoshu.
Parsing this YAML works fine:
Parsing this YAML seems to have a problem with:
It throws the following error, but the issue is a missing
Parsing this YAML works fine:
order:
- job: terraform plan eks
args: ""
- job: helmfile diff teleport
args: --selector chart=teleport-nodeParsing this YAML seems to have a problem with:
order:
- job: terraform plan eks
# args: ""
- job: helmfile diff teleport
args: --selector chart=teleport-nodeIt throws the following error, but the issue is a missing
args not a missing job:Error: Missing map element
on ../cli/trigger.variant line 36:
(source code not available)
This map does not have an element with the key "job".
Error: ../cli/trigger.variant:36,29-33: Missing map element; This map does not have an element with the key "job".johncblandiialmost 6 years ago
@mumoshu I’m getting weird results from simply reading my file.
contents:
error:
contents:
triggers:
smoke-test:
description: Smoke testing the CLI
order:
- job: terraform plan eks
args:
- -detailed-exitcodeerror:
panic: inconsistent map element types (cty.List(cty.String) then cty.String)
goroutine 1 [running]:
<http://github.com/zclconf/go-cty/cty.MapVal(0xc0009ea880|github.com/zclconf/go-cty/cty.MapVal(0xc0009ea880>, 0xc0009ea880, 0xc0009d20f8, 0x3, 0xc0009ea9b8)
/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/value_init.go:207 +0x4b3
<http://github.com/mumoshu/variant2/pkg/app.goToCty(0x1767100|github.com/mumoshu/variant2/pkg/app.goToCty(0x1767100>, 0xc0004d38f0, 0x0, 0x0, 0x1, 0xc0009bb8e0, 0x0, 0x1)
/home/runner/work/variant2/variant2/pkg/app/go_to_cty.go:28 +0x60e
<http://github.com/mumoshu/variant2/pkg/app.(*App).execMultiRun(0xc0000e3140|github.com/mumoshu/variant2/pkg/app.(*App).execMultiRun(0xc0000e3140>, 0xc000239580, 0xc000819280, 0xc0009eadf8, 0x16, 0xc0009d1160, 0x16)
/home/runner/work/variant2/variant2/pkg/app/app.go:1214 +0x13f
<http://github.com/mumoshu/variant2/pkg/app.(*App).execJob(0xc0000e3140|github.com/mumoshu/variant2/pkg/app.(*App).execJob(0xc0000e3140>, 0xc000239580, 0xc0000bd997, 0x7, 0x0, 0x205fbc0, 0xc0006fc540, 0xc0000c7610, 0xc000577ea0, 0x2, ...)
/home/runner/work/variant2/variant2/pkg/app/app.go:816 +0x246
<http://github.com/mumoshu/variant2/pkg/app.(*App).Job.func1(0x0|github.com/mumoshu/variant2/pkg/app.(*App).Job.func1(0x0>, 0x0, 0x0)
/home/runner/work/variant2/variant2/pkg/app/app.go:644 +0x939
<http://github.com/mumoshu/variant2/pkg/app.(*App).Run(0xc0000e3140|github.com/mumoshu/variant2/pkg/app.(*App).Run(0xc0000e3140>, 0xc0000bd997, 0x7, 0xc00080adb0, 0xc00080ade0, 0xc00020b9e0, 0x1, 0x1, 0x0, 0x0, ...)
/home/runner/work/variant2/variant2/pkg/app/app.go:513 +0xc3
<http://github.com/mumoshu/variant2.(*Runner).Cobra.func1(0xc00037d180|github.com/mumoshu/variant2.(*Runner).Cobra.func1(0xc00037d180>, 0xc00080acf0, 0x2, 0x3, 0x0, 0x0)
/home/runner/work/variant2/variant2/variant.go:661 +0x114
<http://github.com/spf13/cobra.(*Command).execute(0xc00037d180|github.com/spf13/cobra.(*Command).execute(0xc00037d180>, 0xc00080ac00, 0x3, 0x3, 0xc00037d180, 0xc00080ac00)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:826 +0x460
<http://github.com/spf13/cobra.(*Command).ExecuteC(0xc0000e9b80|github.com/spf13/cobra.(*Command).ExecuteC(0xc0000e9b80>, 0x2034ba0, 0xc0000be010, 0x2034ba0)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x2fb
<http://github.com/spf13/cobra.(*Command).Execute(...)|github.com/spf13/cobra.(*Command).Execute(...)>
/home/runner/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
<http://github.com/mumoshu/variant2.(*Runner).Run(0xc0007c3040|github.com/mumoshu/variant2.(*Runner).Run(0xc0007c3040>, 0xc0000f8c90, 0x4, 0x4, 0xc00020bd78, 0x1, 0x1, 0x0, 0x0)
/home/runner/work/variant2/variant2/variant.go:791 +0x2cc
<http://github.com/mumoshu/variant2.Main.Run(0x7ffe211094bb|github.com/mumoshu/variant2.Main.Run(0x7ffe211094bb>, 0x3, 0x0, 0x0, 0x0, 0x7ffe211094b4, 0xa, 0x2034ba0, 0xc0000be008, 0x2034ba0, ...)
/home/runner/work/variant2/variant2/variant.go:396 +0x12d
main.main()
/home/runner/work/variant2/variant2/pkg/cmd/main.go:13 +0xb8johncblandiialmost 6 years ago
0.28 seems to be pretty solid. tests are passing with no changes.
nianalmost 6 years ago
For variant … this tool appears to be running locally, as opposed to something in a cluster from the local terminal. Is that correct?
johncblandiialmost 6 years ago
@mumoshu can a
variable not reference a config?johncblandiialmost 6 years ago
@mumoshu it seems options are not available to a job when it is used as a
that works, but it does not recognize the
source of a config config "state" {
source job {
name = "state"
args = {
tenant = param.tenant
}
key = "key"
format = "text"
}
}that works, but it does not recognize the
opts.tenants-dir in the state job and it does recognize the opt when I call it directlyjohncblandiialmost 6 years ago
@mumoshu along the lines of the previous question, can you do a
source dynamically (only pull if param.x exists) or try/catch on a failed source load?johncblandiialmost 6 years ago
@mumoshu was talking with @Erik Osterman (Cloud Posse) about a new cli command and it’d be clean if I could use an
if statement on an internal depends_on. is that possible?johncblandiialmost 6 years ago
I think there is a regression in 0.24.2. the tests worked in 0.24.0 and now fail with:
26: aws --profile ${var.namespace}-${var.tenant}-helm eks update-kubeconfig --name=${var.namespace}-${var.tenant}-eks-cluster --region=${var.region} --kubeconfig=${var.kubeconfig-path}/kubecfg.${var.tenant}-helm
There is no variable named "var".johncblandiialmost 6 years ago(edited)
btw, @mumoshu, I was able to completely write full CLI coverage with 0 knowledge of the test approach within a day of work for about 15+ commands
johncblandiialmost 6 years ago
(sorry about the flood today; digging into a new area with variant2) 🙂
johncblandiialmost 6 years ago
I can’t pinpoint why this is failing. Any thoughts here, @mumoshu? I tried wrapping the
run.res.exitstatus in trimspace since case.exitstatus used it too. (string)--- FAIL: deploy (0.06s)
--- FAIL: deploy/ok (0.05s)
app.go:1040: case "ok": assertion "out" failed: this expression must be true, but was false: run.res.stdout == case.out
, where run.res.stdout=------------------------------------------------------------------------
[CLIENT] Deploying terraform project: project1
------------------------------------------------------------------------
terraform deploy project1
------------------------------------------------------------------------
[CLIENT] Deploying terraform project: project2
------------------------------------------------------------------------
terraform deploy project2
------------------------------------------------------------------------
[CLIENT] Deploying helmfile project: project1
------------------------------------------------------------------------
helmfile apply project1
------------------------------------------------------------------------
[CLIENT] Deploying helmfile project: project2
------------------------------------------------------------------------
helmfile apply project2
------------------------------------------------------------------------
[CLIENT] Deploying terraform project: project3
------------------------------------------------------------------------
terraform deploy project3
(string) case.out=------------------------------------------------------------------------
[CLIENT] Deploying terraform project: project1
------------------------------------------------------------------------
terraform deploy project1
------------------------------------------------------------------------
[CLIENT] Deploying terraform project: project2
------------------------------------------------------------------------
terraform deploy project2
------------------------------------------------------------------------
[CLIENT] Deploying helmfile project: project1
------------------------------------------------------------------------
helmfile apply project1
------------------------------------------------------------------------
[CLIENT] Deploying helmfile project: project2
------------------------------------------------------------------------
helmfile apply project2
------------------------------------------------------------------------
[CLIENT] Deploying terraform project: project3
------------------------------------------------------------------------
terraform deploy project3
(string)
FAIL
Error: test exited with code 1johncblandiialmost 6 years ago
@mumoshu i think something is up with global options again. this
deploy (dry-run = true) -> helmfile deploy (dry-run = false)
the
bool option I can echo at the top level and it is true. then in jobs run from that job it is false.deploy (dry-run = true) -> helmfile deploy (dry-run = false)
➜ ./nbo deploy acme --tenants-dir=../tenants --dry-run --kubeconfig-path=~/.kube
INTERNAL: dry? false. kc-path? /dev/shm
TOP-LEVEL: dry? true. kc-path? ~/.kubethe
kc opt is a string and dry is a bool. those should both internally be different values.johncblandiialmost 6 years ago
@mumoshu can we get some output clean-up on test failures? separating the runs + their failures and maybe some color coding would really help with readability.
https://github.com/mumoshu/variant2/issues/20
https://github.com/mumoshu/variant2/issues/20
johncblandiialmost 6 years ago(edited)
@mumoshu I’d like to dynamically run different parameters to
example from https://github.com/mumoshu/variant2/blob/9753895bdea9bd949596159aaf2f3f9f489575dc/examples/concurrency/concurrency_test.variant:
instead of having type type:
…which then requires me to change
run and reference them in my case without manually typing them again. case.* access seems only available in a run or assert and not within the case itself or in variable.example from https://github.com/mumoshu/variant2/blob/9753895bdea9bd949596159aaf2f3f9f489575dc/examples/concurrency/concurrency_test.variant:
case "ng1" {
concurrency = 0
err = "delay of ${case.delayone} is less than ${case.delaytwo}"
stdout = ""
delayone = 0
delaytwo = 1
}
run "test" {
concurrency = case.concurrency
delayone = case.delayone
delaytwo = case.delaytwo
}instead of having type type:
err = "delay of 0 is less than 1"…which then requires me to change
0 in multiple places if I change the value of delayone to anything else.johncblandiialmost 6 years ago
@mumoshu I’m working with tests and it seems
^ this works just fine.
take
set it to
null should be allowed for err as opposed to requiring an empty string. case "ok" {
tenant = "acme"
exitstatus = 0
err = ""
}^ this works just fine.
take
err out and you get an error: This object does not have an attribute named "err".set it to
err = null and you get:panic: handler for type dynamic not implemented yet [recovered]
panic: handler for type dynamic not implemented yet
goroutine 10 [running]:
testing.tRunner.func1(0xc0000cb500)
/opt/hostedtoolcache/go/1.13.10/x64/src/testing/testing.go:874 +0x3a3
panic(0x21ebee0, 0xc0000968e0)
/opt/hostedtoolcache/go/1.13.10/x64/src/runtime/panic.go:679 +0x1b2
<http://github.com/mumoshu/variant2/pkg/app.(*App).execAssert(0xc00020b080|github.com/mumoshu/variant2/pkg/app.(*App).execAssert(0xc00020b080>, 0xc0005cc980, 0xc0004dda0a, 0x5, 0x2840660, 0xc000598a80, 0x0, 0x0)
/home/runner/work/variant2/variant2/pkg/app/app.go:965 +0x9d0
<http://github.com/mumoshu/variant2/pkg/app.(*App).execTestCase(0xc00020b080|github.com/mumoshu/variant2/pkg/app.(*App).execTestCase(0xc00020b080>, 0xc000035740, 0x12, 0xc0005b5ec0, 0x1, 0x1, 0xc0005ab5e0, 0x1, 0x1, 0xc000035820, ...)
/home/runner/work/variant2/variant2/pkg/app/app.go:1091 +0x659
<http://github.com/mumoshu/variant2/pkg/app.(*App).execTest.func1(0xc0000cb500)|github.com/mumoshu/variant2/pkg/app.(*App).execTest.func1(0xc0000cb500)>
/home/runner/work/variant2/variant2/pkg/app/app.go:1037 +0xc2
testing.tRunner(0xc0000cb500, 0xc0005be790)
/opt/hostedtoolcache/go/1.13.10/x64/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
/opt/hostedtoolcache/go/1.13.10/x64/src/testing/testing.go:960 +0x350Zachary Loeberalmost 6 years ago
sorry 😞
Zachary Loeberalmost 6 years ago
I think they use buffalo framwork behind the scenes but, again, I'm barely scratching at this particular itch of mine yet
Zachary Loeberalmost 6 years ago
I've been seeking such a bullet myself. I was going to look towards some of the fairwinds projects for inspiration (https://github.com/FairwindsOps/polaris for instance) as they seem to use pure Go based solutions but I haven't gotten that far yet. Most solutions I've seen incorporate some java frameworks that instantly turn me off.
Z
Zachary Loeberalmost 6 years ago
@Zachary Loeber has joined the channel
Erik Osterman (Cloud Posse)almost 6 years ago
Where's/What's the silver bullet for building an enterprise-grade Web UI today?
Erik Osterman (Cloud Posse)almost 6 years ago
@Zachary Loeber you have a pulse on everything. Question for you: https://github.com/mumoshu/variant2/issues/17#issuecomment-617835218
mumoshualmost 6 years ago
thx!
johncblandiialmost 6 years ago
Issue created for building with a
. as the path: https://github.com/mumoshu/variant2/issues/19johncblandiialmost 6 years ago
Context:
deploy job:
order:
- terraform.account
- terraform.iam-tenant-roles
- terraform.cloudtrail
- terraform.vpcdeploy job:
depends_on "deploy switch" {
items = conf.file.order
args = {
item = item
tenant = param.tenant
}
}switch is the job that splits the left/right of the . and calls an internal jobjob "deploy switch" {
run {
job = "${var.subcommand} deploy"
with = {
project = var.project
tenant = param.tenant
}
}
}johncblandiialmost 6 years ago
this seems like building a dependency graph that each next job depends on its previous job?
i guess you could call it one, but that’s not the intent. it isn’t a dependency as in the cli depends on job 1 to run for 2. it is a dependency in how we’re managing our config file for looping
johncblandiialmost 6 years ago
yes, i saw different behavior. i’ll try to replicate
mumoshualmost 6 years ago
are you seeing different behavior?
mumoshualmost 6 years ago
and
depends_on items should be executed serially and stop on the first errormumoshualmost 6 years ago
exec jobs in a loop and stop when they fail
this seems like building a dependency graph that each next job depends on its previous job? 🤔
but anyways,
[10:35 AM] Is there a concept of looping outside of depends on?
no
johncblandiialmost 6 years ago
Is there a concept of looping outside of depends on?