#variant (2020-08)

https://github.com/mumoshu/variant

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

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

2020-08-13

johncblandii avatar
johncblandii

@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.

johncblandii avatar
johncblandii
Step 6/45 : RUN wget <https://github.com/mumoshu/variant2/releases/download/v${VARIANT_VERSION}/variant_${VARIANT_VERSION}_linux_amd64.tar.gz> &&     tar -zvxf variant*.tar.gz variant &&     mv variant /usr/local/bin/variant2 &&     rm -f variant*.tar.gz
 ---> Running in 39ac904d79b3
Connecting to github.com (140.82.114.4:443)
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (52.217.101.12:443)
saving to 'variant_0.28.0_linux_amd64.tar.gz'
variant_0.28.0_linux   5% |*                               |  662k  0:00:17 ETA
variant_0.28.0_linux  40% |*************                   | 5116k  0:00:02 ETA
variant_0.28.0_linux  99% |******************************* | 12.1M  0:00:00 ETA
variant_0.28.0_linux 100% |********************************| 12.2M  0:00:00 ETA
'variant_0.28.0_linux_amd64.tar.gz' saved
variant
Removing intermediate container 39ac904d79b3
 ---> e0541f921166
Step 7/45 : COPY cli .
 ---> bfb966dc9ef4
Step 8/45 : ARG CGO_ENABLED=1
 ---> Running in 47b7cdef1c39
Removing intermediate container 47b7cdef1c39
 ---> 09c2051f78b8
Step 9/45 : RUN make build
 ---> Running in bfddcfae3b86
variant2 export binary /usr/cli nbo
go: creating new go.mod: module cli
go: finding module for package github.com/mumoshu/variant2
go: downloading github.com/mumoshu/variant2 v0.33.0
go: found github.com/mumoshu/variant2 in github.com/mumoshu/variant2 v0.33.0
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/spf13/cobra v0.0.5
go: downloading github.com/nlopes/slack v0.6.0
go: downloading github.com/variantdev/mod v0.18.0
go: downloading github.com/google/go-cmp v0.4.0
go: downloading github.com/kr/text v0.1.0
go: downloading github.com/hashicorp/go-multierror v1.0.0
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/variantdev/vals v0.4.0
go: downloading github.com/AlecAivazis/survey/v2 v2.0.5
go: downloading github.com/zclconf/go-cty v1.2.1
go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
go: downloading github.com/rs/xid v1.2.1
go: downloading github.com/hashicorp/hcl/v2 v2.3.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/imdario/mergo v0.3.8
go: downloading github.com/heroku/docker-registry-client v0.0.0-20190909225348-afc9e1acc3d5
go: downloading github.com/hashicorp/terraform v0.12.18
go: downloading github.com/go-logr/logr v0.1.0
go: downloading k8s.io/klog v1.0.0
go: downloading github.com/twpayne/go-vfs v1.3.6
go: downloading github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
go: downloading golang.org/x/sys v0.0.0-20200331124033-c3d80250170d
go: downloading github.com/evanphx/json-patch v4.5.0+incompatible
go: downloading github.com/Masterminds/semver v1.5.0
go: downloading github.com/hashicorp/errwrap v1.0.0
go: downloading github.com/hashicorp/golang-lru v0.5.4
go: downloading github.com/aws/aws-sdk-go v1.29.34
go: downloading github.com/xeipuuv/gojsonschema v1.2.0
go: downloading github.com/gorilla/websocket v1.4.0
go: downloading github.com/docker/distribution v2.7.1+incompatible
go: downloading github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363
go: downloading google.golang.org/genproto v0.0.0-20200403120447-c50568487044
go: downloading github.com/hashicorp/go-getter v1.4.1
go: downloading github.com/apparentlymart/go-textseg v1.0.0
go: downloading cloud.google.com/go v0.56.0
go: downloading github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
go: downloading github.com/google/go-github v17.0.0+incompatible
go: downloading github.com/k-kinzal/aliases v0.5.1
go: downloading github.com/zclconf/go-cty-yaml v1.0.1
go: downloading github.com/opencontainers/image-spec v1.0.1
go: downloading github.com/google/go-github/v27 v27.0.6
go: downloading github.com/mattn/go-colorable v0.1.4
go: downloading golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
go: downloading github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7
go: downloading github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334
go: downloading github.com/opencontainers/go-digest v1.0.0-rc1
go: downloading github.com/sirupsen/logrus v1.4.2
go: downloading github.com/hashicorp/vault v1.2.3
go: downloading go.mozilla.org/sops v0.0.0-20190611200209-e9e1e87723c8
go: downloading github.com/Masterminds/sprig v2.22.0+incompatible
go: downloading github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
go: downloading gopkg.in/yaml.v2 v2.2.8
go: downloading github.com/fatih/color v1.9.0
go: downloading github.com/mitchellh/go-wordwrap v1.0.0
go: downloading github.com/google/uuid v1.1.1
go: downloading github.com/huandu/xstrings v1.3.0
go: downloading golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6
go: downloading github.com/ulikunitz/xz v0.5.6
go: downloading github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d
go: downloading gopkg.in/go-playground/validator.v9 v9.31.0
go: downloading github.com/mozilla-services/yaml v0.0.0-20180922153656-28ffe5d0cafb
go: downloading github.com/hashicorp/go-cleanhttp v0.5.1
go: downloading github.com/apparentlymart/go-cidr v1.0.1
go: downloading github.com/googleapis/gax-go v2.0.0+incompatible
go: downloading github.com/googleapis/gax-go/v2 v2.0.5
go: downloading google.golang.org/grpc v1.28.0
go: downloading github.com/creasty/defaults v1.3.0
go: downloading github.com/Masterminds/goutils v1.1.0
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/hashicorp/go-safetemp v1.0.0
go: downloading github.com/leodido/go-urn v1.2.0
go: downloading github.com/golang/protobuf v1.3.5
go: downloading github.com/hashicorp/vault/api v1.0.5-0.20190909201928-35325e2c3262
go: downloading cloud.google.com/go/storage v1.6.0
go: downloading google.golang.org/api v0.20.0
go: downloading github.com/hashicorp/go-uuid v1.0.1
go: downloading golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
go: downloading github.com/hashicorp/vault/sdk v0.1.14-0.20190909201848-e0fbf9b652e2
go: downloading github.com/go-playground/universal-translator v0.17.0
go: downloading golang.org/x/time v0.0.0-20191024005414-555d28b269f0
go: downloading github.com/hashicorp/go-version v1.2.0
go: downloading github.com/mitchellh/copystructure v1.0.0
go: downloading github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb
go: downloading github.com/PaesslerAG/jsonpath v0.1.1
go: downloading gopkg.in/square/go-jose.v2 v2.3.1
go: downloading github.com/Azure/azure-sdk-for-go v36.2.0+incompatible
go: downloading github.com/mitchellh/go-testing-interface v1.0.0
go: downloading github.com/mitchellh/mapstructure v1.1.2
go: downloading github.com/fujiwara/tfstate-lookup v0.0.4
go: downloading github.com/hashicorp/go-retryablehttp v0.5.4
go: downloading github.com/bmatcuk/doublestar v1.1.5
go: downloading golang.org/x/text v0.3.2
go: downloading github.com/go-playground/locales v0.13.0
go: downloading github.com/tidwall/gjson v1.3.5
go: downloading github.com/hashicorp/go-rootcerts v1.0.1
go: downloading go.opencensus.io v0.22.3
go: downloading github.com/hashicorp/go-sockaddr v1.0.2
go: downloading github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
go: downloading github.com/pierrec/lz4 v2.2.6+incompatible
go: downloading github.com/tidwall/match v1.0.1
go: downloading github.com/agext/levenshtein v1.2.2
go: downloading github.com/golang/snappy v0.0.1
go: downloading github.com/google/go-querystring v1.0.0
go: downloading github.com/itchyny/gojq v0.9.0
go: downloading github.com/mitchellh/reflectwalk v1.0.0
go: downloading github.com/PaesslerAG/gval v1.0.1
go: downloading github.com/goware/prefixer v0.0.0-20160118172347-395022866408
go: downloading github.com/alecthomas/participle v0.4.2-0.20191220090139-9fbceec1d131
go: downloading github.com/pbnjay/strptime v0.0.0-20140226051138-5c05b0d668c9
go: downloading github.com/tidwall/pretty v1.0.0
go: downloading github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c
go: downloading go.mozilla.org/gopgagent v0.0.0-20170926210634-4d7ea76ff71a
go: downloading github.com/lestrrat-go/strftime v1.0.1
go: downloading github.com/ryanuber/go-glob v1.0.0
go: downloading github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
go: downloading github.com/lib/pq v1.2.0
go: downloading github.com/Azure/go-autorest v13.2.0+incompatible
go: downloading github.com/Azure/go-autorest/autorest v0.9.2
go: downloading github.com/Azure/go-autorest/tracing v0.5.0
go: downloading github.com/Azure/go-autorest/autorest/azure/auth v0.4.0
go: downloading github.com/Azure/go-autorest/autorest/validation v0.2.0
go: downloading github.com/Azure/go-autorest/autorest/date v0.2.0
go: downloading github.com/Azure/go-autorest/autorest/to v0.3.0
go: downloading github.com/Azure/go-autorest/autorest/adal v0.8.1-0.20191028180845-3492b2aff503
go: downloading github.com/Azure/go-autorest/logger v0.1.0
go: downloading github.com/dimchansky/utfbom v1.1.0
go: downloading github.com/Azure/go-autorest/autorest/azure/cli v0.3.0
go: downloading github.com/dgrijalva/jwt-go v3.2.0+incompatible
# cli
./main.go:2536:9: undefined: variant.MustEval
Error: command "sh -c cd /tmp/variant-cli778896582; go mod init cli && go build -o /usr/cli/nbo /tmp/variant-cli778896582": exit status 2
make: *** [Makefile:4: build] Error 1
The command '/bin/sh -c make build' returned a non-zero code: 2
make[1]: *** [docker/build] Error 2
make: *** [build] Error 2
mumoshu avatar
mumoshu

Thanks for reporting. Seems like a regression introduced by recent change. I’ll investigate further and add regression test for that later!

johncblandii avatar
johncblandii

i’m curious why it’d be a problem since we’re downloading a specific version

mumoshu avatar
mumoshu

ah, im in doubt that go build is actually download the latest version of variant2

johncblandii avatar
johncblandii

gotcha

johncblandii avatar
johncblandii

this is the docker build, btw.

# Builder for the nbo CLI
ARG VARIANT_VERSION=0.28.0

FROM golang:alpine3.11 as cli

RUN apk add -u make

WORKDIR /usr/cli

# Install variant
ARG VARIANT_VERSION
RUN wget <https://github.com/mumoshu/variant2/releases/download/v${VARIANT_VERSION}/variant_${VARIANT_VERSION}_linux_amd64.tar.gz> && \
    tar -zvxf variant*.tar.gz variant && \
    mv variant /usr/local/bin/variant2 && \
    rm -f variant*.tar.gz

# Copy the cli directory
COPY cli .

ARG CGO_ENABLED=1
RUN make build
mumoshu avatar
mumoshu

ideally export binary should produce go.mod that locks the depended variant2 to the specific version

johncblandii avatar
johncblandii

make build is:

build:
	variant2 export binary $(CURDIR) nbo
johncblandii avatar
johncblandii

< yes

mumoshu avatar
mumoshu

a workaround is to do variant2 export go, update/add go.sum and then go build -o nbo $(CURDIR)

mumoshu avatar
mumoshu

and your go.sum should contain something like the below to work:

module ....
require (
	github.com/mumoshu/variant2 vx.y.z
)

where vx.y.z should be replaced with the exact version of variant2 you want

johncblandii avatar
johncblandii

doesn’t export go.sum

johncblandii avatar
johncblandii

just a main.go

mumoshu avatar
mumoshu

yes. i think i missed implementing it, which is why variant2 export binary broke due to recent api changes in variant2

johncblandii avatar
johncblandii

let me see if 0.33.0 works w/ the cli

johncblandii avatar
johncblandii

it definitely built just fine. let me run the unit tests to validate it

mumoshu avatar
mumoshu

thx for confirming!

anyway, i’ll enhance export binary to also write go.sum. i’ll also see if i can bring back the old API MustEval to future versions of variant2

johncblandii avatar
johncblandii

oddly the tests fail all the time now

johncblandii avatar
johncblandii

even went back to the original 0.28.0 and they fail there too. very odd

1
mumoshu avatar
mumoshu

how the test failures look like?

mumoshu avatar
mumoshu

how are you running tests?

johncblandii avatar
johncblandii

ahh…nm. this is likely due to this docker build

1
johncblandii avatar
johncblandii

ok…going back to testing versions real quick. tests run fine in this build now

johncblandii avatar
johncblandii

well…all tests pass in 0.33.0 so an upgrade may be enough to address this for now

johncblandii avatar
johncblandii
0.28.0 / `variant export binary` builds fail without changes to the CLI code · Issue #22 · mumoshu/variant2

@mumoshu thoughts on the cause and a solution: ideally export binary should produce go.mod that locks the depended variant2 to the specific version yes. i think i missed implementing it, which is w…

mumoshu avatar
mumoshu

thanks!

1
    keyboard_arrow_up