#variant (2019-02)

https://github.com/mumoshu/variant

Discuss variant (the “Universal CLI”) https://github.com/mumoshu/variant

Archive: https://archive.sweetops.com/variant/

2019-02-16

nutellinoit avatar
nutellinoit
08:52:16 AM

@nutellinoit has joined the channel

2019-02-14

Erik Osterman avatar
Erik Osterman
05:23:43 AM

@Erik Osterman set the channel purpose: Discuss variant (the “Universal CLI”) https://github.com/mumoshu/variant

Archive: https://archive.sweetops.com/variant/

2019-02-13

platinumnj avatar
platinumnj
04:31:20 AM

@platinumnj has joined the channel

2019-02-09

2019-02-08

mumoshu avatar
mumoshu

any contribution to docs is welcomed! (well, i’ll write more later :)

mumoshu avatar
mumoshu

FYI: Trigger your Variant tasks via GitHub Actions https://github.com/mumoshu/github-actions/tree/master/variant

mumoshu/github-actions

Contribute to mumoshu/github-actions development by creating an account on GitHub.

1
Erik Osterman avatar
Erik Osterman

this is exciting!

Erik Osterman avatar
Erik Osterman

github actions still don’t work on public projects, right?

antonbabenko avatar
antonbabenko

Seems so. Unfortunately.

Erik Osterman avatar
Erik Osterman

Erik Osterman avatar
Erik Osterman

variant will be so awesome when they add support for public repos

Erik Osterman avatar
Erik Osterman

run a pipeline locally as easily as remotely

zadkiel.aharonian avatar
zadkiel.aharonian

I can see the action button on one the projects i’m contributor in. Not sure if I can use them. Maybe the repo owner has to be subscribed to the beta

dennybaa avatar
dennybaa
12:19:19 PM

@dennybaa has joined the channel

richwine avatar
richwine
10:53:51 PM

@richwine has joined the channel

2019-02-07

mumoshu avatar
mumoshu

Wrote up an another issue that fills one of big missing pieces(to me): https://github.com/mumoshu/variant/issues/57

Experimental: Dependency Management(Packages) · Issue #57 · mumoshu/variant

This is even more experimental than other features :) variant should be able to manage package (direct) dependencies of your variant command, along with those of imported commands(=transitive depen…

joshmyers avatar
joshmyers
09:23:20 AM

@joshmyers has joined the channel

joshmyers avatar
joshmyers
mumoshu/variant

Write modern CLIs in YAML. Bash + Workflows + Dataflows + Dependency Injection, JSON Schema for inputs validation - mumoshu/variant

joshmyers avatar
joshmyers

Liking it so far but having to dig through all the tests

Erik Osterman avatar
Erik Osterman

Unfortunately the integration tests are the best documentation at this time. Fortunately there are a lot of examples there though!

2019-02-06

michal.matyjek avatar
michal.matyjek
05:14:47 PM

@michal.matyjek has joined the channel

mallen avatar
mallen
09:03:44 PM

@mallen has joined the channel

mumoshu avatar
mumoshu
Dependency Management(Versioned Directories) · Issue #56 · mumoshu/variant

variant should provide a generic way to manage dependencies of your variant command: dependent: directories: - path: ./helmfile-libs/stable # multiple library helmfile.yaml files should be maintain…

Erik Osterman avatar
Erik Osterman

Ahhh yes, ultimately this becomes an issue.

Erik Osterman avatar
Erik Osterman

I would like to discuss some idea that @Igor Rodionov had today

1
Erik Osterman avatar
Erik Osterman

I am afk, so will pick up later

1
mumoshu avatar
mumoshu

btw: https://github.com/mumoshu/variant/issues/51 and https://github.com/mumoshu/variant/issues/52 has been resolved and included in variant v0.20.0 (haven’t done much testing yet. briefly verified to work with github sources though

Import variant commands from various versioned sources · Issue #51 · mumoshu/variant

So that you can create a common/library variant commands to be versioned and reused. tasks: anothercmd: # Basically runs go-getter <http://github.com/foo/bar?ref=v0.1.0//dir|github.com/foo/bar?ref=v0.1.0//dir> /tmp/somewhere and then inclu…

Import config files from various versioned sources · Issue #52 · mumoshu/variant
So that you can create a common config file that is versioned and reused in various variant commands in divergent places. tasks: mytask: parameters: - name: config type: object script: cat <&l…

2019-02-05

mumoshu avatar
mumoshu

This feature will reduce repetitions in your scripts https://github.com/mumoshu/variant/issues/53

Reusing only part(s) of scripts · Issue #53 · mumoshu/variant
I tend to organize my variant scripts to the &quot;header&quot; and the &quot;body&quot; like seen in the following example: script: # header {{ $env := get &quot;environment&quot; }} {{ $state :…
Erik Osterman avatar
Erik Osterman

that’s awesome!

Erik Osterman avatar
Erik Osterman

also, like that you support a list under script

Erik Osterman avatar
Erik Osterman

are those ultimately joined as one script or each run in their own shell?

mumoshu avatar
mumoshu

the former, to cover reuses of both bash variable/func definitions, and template variables!

Erik Osterman avatar
Erik Osterman

yea, makes sense

Erik Osterman avatar
Erik Osterman
Import config files from various versioned sources · Issue #52 · mumoshu/variant
So that you can create a common config file that is versioned and reused in various variant commands in divergent places. tasks: mytask: parameters: - name: config type: object script: cat <&l…
Erik Osterman avatar
Erik Osterman

this!!

Erik Osterman avatar
Erik Osterman

I want.

Erik Osterman avatar
Erik Osterman

basically we can create a variant library, then create a cli that imports various capabiltiies

Erik Osterman avatar
Erik Osterman

for example, we can create a helm lib, and a helmfile lib and a kops lib and a terraform lib with useful tricks

Erik Osterman avatar
Erik Osterman

e.g. for terraform, automating force-unlock

Erik Osterman avatar
Erik Osterman

then in the final implementation, we can include the libs that we want into our cli. for example, one customer might not use kops, so we wouldn’t need to import that lib.

Erik Osterman avatar
Erik Osterman
Import variant commands from various versioned sources · Issue #51 · mumoshu/variant

So that you can create a common/library variant commands to be versioned and reused. tasks: anothercmd: # Basically runs go-getter <http://github.com/foo/bar?ref=v0.1.0//dir|github.com/foo/bar?ref=v0.1.0//dir> /tmp/somewhere and then inclu…

Erik Osterman avatar
Erik Osterman

so cool

Erik Osterman avatar
Erik Osterman

Erik Osterman avatar
Erik Osterman

@mumoshu I am trying to run an interactive SSH session inside of variant, should that work?

Erik Osterman avatar
Erik Osterman
+ ssh -A [[email protected]](mailto:[email protected])
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added '[bastion.us-west-2.staging.even.io](http://bastion.us-west-2.staging.even.io),35.163.154.194' (ECDSA) to the list of known hosts.

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

mumoshu avatar
mumoshu

interactive: true should work

tasks:
  foo:
    interactive: true
    script: |
      whatever
Erik Osterman avatar
Erik Osterman

Erik Osterman avatar
Erik Osterman
02:45:11 AM
Erik Osterman avatar
Erik Osterman

hah! that worked, but got this

Erik Osterman avatar
Erik Osterman

mumoshu avatar
mumoshu

whoa! let me check

mumoshu avatar
mumoshu

whats your variant’s version number?

Erik Osterman avatar
Erik Osterman

(variant version empty)

1
Erik Osterman avatar
Erik Osterman
cloudposse/packages

Cloud Posse installer and distribution of native apps, binaries and alpine packages - cloudposse/packages

Erik Osterman avatar
Erik Osterman

0.16.1

Erik Osterman avatar
Erik Osterman

i will try the latest

Erik Osterman avatar
Erik Osterman

reproducible in 0.18.0

Erik Osterman avatar
Erik Osterman

in 0.18.0 I see some debug output

Erik Osterman avatar
Erik Osterman
schema = map[type:object properties:map[] required:[]]
mumoshu avatar
mumoshu

thanks! please try v0.18.2 that fixes the logging and the hanging

Erik Osterman avatar
Erik Osterman

ALL FIXED!

1
Erik Osterman avatar
Erik Osterman
       tasks:
          # Connect to bastion instance
          bastion:
            description: "Connect to the bastion"
            script: |
              set -e
              source <(chamber exec kops -- sh -c 'export -p')
              eval $(ssh-agent -s)
              ssh-add - <<<${KOPS_SSH_PRIVATE_KEY}
              ssh -A [email protected]${KOPS_CLUSTER_NAME}
              eval $(ssh-agent -k) >/dev/null
Erik Osterman avatar
Erik Osterman

Erik Osterman avatar
Erik Osterman

I love it!!!

mixins:
  chamber: &chamber
    source <(chamber exec kops -- sh -c 'export -p' 2>/dev/null)
Erik Osterman avatar
Erik Osterman

Then anywhere I want chamber, I can just do this:

          bastion:
            description: "Connect to the bastion using ssh-agent forwarding"
            interactive: true
            script:
            - *chamber
            - |
              set -e
              eval $(ssh-agent -s)
              ssh-add - <<<${KOPS_SSH_PRIVATE_KEY}
              ssh -A [email protected]${KOPS_CLUSTER_NAME}
              eval $(ssh-agent -k) >/dev/null
Erik Osterman avatar
Erik Osterman

this is shell scripting on steroids

Erik Osterman avatar
Erik Osterman

Erik Osterman avatar
Erik Osterman

I tried to change the default runner by adding

Erik Osterman avatar
Erik Osterman
runner:
  command: "bash"
  args: ["-ex", "-c"]


Erik Osterman avatar
Erik Osterman

should that work?

Erik Osterman avatar
Erik Osterman

(in the global scope)

Erik Osterman avatar
Erik Osterman

my first advanced variant script:

1
Erik Osterman avatar
Erik Osterman
[kopsctl] add commands to facilitate management of cluster by osterman · Pull Request #378 · cloudposse/geodesic

what Add commands to easily rotate a kops cluster&#39;s ssh keys Add command to easily connect to a kops cluster Add command to see a kops plan why This are routine operations that are complicat…

:1000:1
daveyu avatar
daveyu
04:37:18 AM

@daveyu has joined the channel

    keyboard_arrow_up