vmware-archive / cliaas

an iaas agnostic cli to perform blue green ops manager rotations
Apache License 2.0
5 stars 7 forks source link

Compilation fails with Azure-related errors #1

Closed RamXX closed 7 years ago

RamXX commented 7 years ago

Build command:

go get github.com/pivotal-cf/cliaas && \
cd $GOPATH/src/github.com/pivotal-cf/cliaas &&\
glide install &&\
go install github.com/pivotal-cf/cliaas/cmd/cliaas

Errors out with:

# github.com/Azure/azure-sdk-for-go/arm/examples/helpers
/opt/go/src/github.com/Azure/azure-sdk-for-go/arm/examples/helpers/helpers.go:23: undefined: azure.ServicePrincipalToken
/opt/go/src/github.com/Azure/azure-sdk-for-go/arm/examples/helpers/helpers.go:24: azure.PublicCloud.OAuthConfigForTenant undefined (type azure.Environment has no field or method OAuthConfigForTenant)
/opt/go/src/github.com/Azure/azure-sdk-for-go/arm/examples/helpers/helpers.go:28: undefined: azure.NewServicePrincipalToken

returned a non-zero code: 2.

This happened during the build of cfjump which has been working with the same build process for some time.

cf-gitbot commented 7 years ago

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

krishicks commented 7 years ago

I'm unable to reproduce this as of 2c130d5:

$ cd $GOPATH/src/github.com/pivotal-cf/cliaas &&\
> glide install &&\
> go install github.com/pivotal-cf/cliaas/cmd/cliaas
[INFO]  Downloading dependencies. Please wait...
[INFO]  --> Found desired version locally cloud.google.com/go 675fad27ef35e552d3708858ff337d54b3b6f4d3!
[INFO]  --> Found desired version locally code.cloudfoundry.org/clock 2269160ae1757f96bbb8c6475e6fa36c805e73e0!
[INFO]  --> Found desired version locally github.com/aws/aws-sdk-go 00fb2125993965df739fa3398b03bef3eb2e198f!
[INFO]  --> Found desired version locally github.com/Azure/azure-sdk-for-go 088007b3b08cc02b27f2eadfdcd870958460ce7e!
[INFO]  --> Found desired version locally github.com/Azure/azure-storage-go 7c36d244fc8bf27bcf9785b0b37d6beef2949296!
[INFO]  --> Found desired version locally github.com/Azure/go-autorest ec5f4903f77ed9927ac95b19ab8e44ada64c1356!
[INFO]  --> Found desired version locally github.com/dgrijalva/jwt-go 2268707a8f0843315e2004ee4f1d021dc08baedf!
[INFO]  --> Found desired version locally github.com/go-ini/ini e7fea39b01aea8d5671f6858f0532f56e8bff3a5!
[INFO]  --> Found desired version locally github.com/golang/protobuf 2bba0603135d7d7f5cb73b2125beeda19c09f4ef!
[INFO]  --> Found desired version locally github.com/google/go-genproto 411e09b969b1170a9f0c467558eb4c4c110d9c77!
[INFO]  --> Found desired version locally github.com/googleapis/gax-go 9af46dd5a1713e8b5cd71106287eba3cefdde50b!
[INFO]  --> Found desired version locally github.com/jessevdk/go-flags 48cf8722c3375517aba351d1f7577c40663a4407!
[INFO]  --> Found desired version locally github.com/jmespath/go-jmespath bd40a432e4c76585ef6b72d3fd96fb9b6dc7b68d!
[INFO]  --> Found desired version locally github.com/pkg/errors ff09b135c25aae272398c51a07235b90a75aa4f0!
[INFO]  --> Found desired version locally golang.org/x/net ffcf1bedda3b04ebb15a168a59800a73d6dc0f4d!
[INFO]  --> Found desired version locally golang.org/x/oauth2 7fdf09982454086d5570c7db3e11f360194830ca!
[INFO]  --> Found desired version locally golang.org/x/text f4b4367115ec2de254587813edaa901bc1c723a8!
[INFO]  --> Found desired version locally google.golang.org/api 48e49d1645e228d1c50c3d54fb476b2224477303!
[INFO]  --> Found desired version locally google.golang.org/appengine 56d253d1dd14aa01937e12c73a0971bcfd797ff2!
[INFO]  --> Found desired version locally google.golang.org/grpc b5071124392bfd416c713e6595ac149b387f7186!
[INFO]  --> Found desired version locally gopkg.in/yaml.v2 a3f3340b5840cee44f372bddb5880fcbc419b46a!
[INFO]  --> Found desired version locally github.com/google/uuid 6a5e28554805e78ea6141142aba763936c4761c0!
[INFO]  --> Found desired version locally github.com/onsi/ginkgo 77a8c1e5c40d6bb6c5eb4dd4bdce9763564f6298!
[INFO]  --> Found desired version locally github.com/onsi/gomega 334b8f472b3af5d541c5642701c1e29e2126f486!
[INFO]  --> Found desired version locally golang.org/x/sys 7de4796419dc3b554e6dab3a119a62469569d299!
[INFO]  Setting references.
[INFO]  --> Setting version for github.com/Azure/go-autorest to ec5f4903f77ed9927ac95b19ab8e44ada64c1356.
[INFO]  --> Setting version for github.com/dgrijalva/jwt-go to 2268707a8f0843315e2004ee4f1d021dc08baedf.
[INFO]  --> Setting version for github.com/go-ini/ini to e7fea39b01aea8d5671f6858f0532f56e8bff3a5.
[INFO]  --> Setting version for github.com/googleapis/gax-go to 9af46dd5a1713e8b5cd71106287eba3cefdde50b.
[INFO]  --> Setting version for github.com/jmespath/go-jmespath to bd40a432e4c76585ef6b72d3fd96fb9b6dc7b68d.
[INFO]  --> Setting version for github.com/google/go-genproto to 411e09b969b1170a9f0c467558eb4c4c110d9c77.
[INFO]  --> Setting version for github.com/pkg/errors to ff09b135c25aae272398c51a07235b90a75aa4f0.
[INFO]  --> Setting version for github.com/Azure/azure-sdk-for-go to 088007b3b08cc02b27f2eadfdcd870958460ce7e.
[INFO]  --> Setting version for github.com/jessevdk/go-flags to 48cf8722c3375517aba351d1f7577c40663a4407.
[INFO]  --> Setting version for github.com/aws/aws-sdk-go to 00fb2125993965df739fa3398b03bef3eb2e198f.
[INFO]  --> Setting version for github.com/golang/protobuf to 2bba0603135d7d7f5cb73b2125beeda19c09f4ef.
[INFO]  --> Setting version for github.com/Azure/azure-storage-go to 7c36d244fc8bf27bcf9785b0b37d6beef2949296.
[INFO]  --> Setting version for golang.org/x/text to f4b4367115ec2de254587813edaa901bc1c723a8.
[INFO]  --> Setting version for github.com/google/uuid to 6a5e28554805e78ea6141142aba763936c4761c0.
[INFO]  --> Setting version for github.com/onsi/gomega to 334b8f472b3af5d541c5642701c1e29e2126f486.
[INFO]  --> Setting version for github.com/onsi/ginkgo to 77a8c1e5c40d6bb6c5eb4dd4bdce9763564f6298.
[INFO]  --> Setting version for golang.org/x/oauth2 to 7fdf09982454086d5570c7db3e11f360194830ca.
[INFO]  --> Setting version for gopkg.in/yaml.v2 to a3f3340b5840cee44f372bddb5880fcbc419b46a.
[INFO]  --> Setting version for code.cloudfoundry.org/clock to 2269160ae1757f96bbb8c6475e6fa36c805e73e0.
[INFO]  --> Setting version for golang.org/x/sys to 7de4796419dc3b554e6dab3a119a62469569d299.
[INFO]  --> Setting version for golang.org/x/net to ffcf1bedda3b04ebb15a168a59800a73d6dc0f4d.
[INFO]  --> Setting version for google.golang.org/appengine to 56d253d1dd14aa01937e12c73a0971bcfd797ff2.
[INFO]  --> Setting version for google.golang.org/grpc to b5071124392bfd416c713e6595ac149b387f7186.
[INFO]  --> Setting version for google.golang.org/api to 48e49d1645e228d1c50c3d54fb476b2224477303.
[INFO]  --> Setting version for cloud.google.com/go to 675fad27ef35e552d3708858ff337d54b3b6f4d3.
[INFO]  Exporting resolved dependencies...
[INFO]  --> Exporting github.com/Azure/go-autorest
[INFO]  --> Exporting github.com/dgrijalva/jwt-go
[INFO]  --> Exporting github.com/googleapis/gax-go
[INFO]  --> Exporting github.com/aws/aws-sdk-go
[INFO]  --> Exporting github.com/go-ini/ini
[INFO]  --> Exporting github.com/Azure/azure-sdk-for-go
[INFO]  --> Exporting github.com/Azure/azure-storage-go
[INFO]  --> Exporting golang.org/x/text
[INFO]  --> Exporting github.com/pkg/errors
[INFO]  --> Exporting github.com/google/go-genproto
[INFO]  --> Exporting github.com/google/uuid
[INFO]  --> Exporting github.com/golang/protobuf
[INFO]  --> Exporting github.com/onsi/gomega
[INFO]  --> Exporting github.com/onsi/ginkgo
[INFO]  --> Exporting github.com/jmespath/go-jmespath
[INFO]  --> Exporting github.com/jessevdk/go-flags
[INFO]  --> Exporting golang.org/x/net
[INFO]  --> Exporting google.golang.org/grpc
[INFO]  --> Exporting gopkg.in/yaml.v2
[INFO]  --> Exporting google.golang.org/appengine
[INFO]  --> Exporting golang.org/x/sys
[INFO]  --> Exporting code.cloudfoundry.org/clock
[INFO]  --> Exporting golang.org/x/oauth2
[INFO]  --> Exporting google.golang.org/api
[INFO]  --> Exporting cloud.google.com/go
[INFO]  Replacing existing vendor dependencies
$ echo $?
0
ryanpei commented 7 years ago

@RamXX we'll close this issue, unless you tell us you still see this happening with the latest cliaas

RamXX commented 7 years ago

As of today with latest release, the error is still happening:

go get github.com/pivotal-cf/cliaas && cd $GOPATH/src/github.com/pivotal-cf/cliaas && glide install && go install github.com/pivotal-cf/cliaas/cmd/cliaas
# github.com/Azure/azure-sdk-for-go/arm/examples/helpers
/opt/go/src/github.com/Azure/azure-sdk-for-go/arm/examples/helpers/helpers.go:23: undefined: azure.ServicePrincipalToken
/opt/go/src/github.com/Azure/azure-sdk-for-go/arm/examples/helpers/helpers.go:24: azure.PublicCloud.OAuthConfigForTenant undefined (type azure.Environment has no field or method OAuthConfigForTenant)
/opt/go/src/github.com/Azure/azure-sdk-for-go/arm/examples/helpers/helpers.go:28: undefined: azure.NewServicePrincipalToken

I'll opt for downloading a pre-built binary for cfjump instead of building from source. You are welcome to git clone https://github.com/RamXX/cfjump.git and attempt to reproduce it that way. Maybe I'm missing some package that doesn't get downloaded by go get, or maybe the azure client I already have installed somehow produces conflict. I'll just use the binary going forward.

krishicks commented 7 years ago

glide install only installs dependencies to vendor/ of the directory they're for. That compilation error is coming from a dependency in your GOPATH. What version of Go are you using? And what do you have in vendor/?

RamXX commented 7 years ago

I'm using Go 1.8.1. Bear in mind this is the first go app that gets built in the workflow after the installation of the Golang environment and the setting up of $GOPATH and $GOBIN. Indeed the error occurs in go get github.com/pivotal-cf/cliaas. Glide doesn't get involved yet. Since I'm now downloading the final release binary, this is no longer an issue for me, so you may decide to close the issue or explore further. Happy to collaborate either way.

krishicks commented 7 years ago

This problem is occurring for you because of two things:

One solution is to add -d to your go get:

go get -d github.com/pivotal-cf/cliaas

This will inform go get not to install the dependent packages.

However, you probably don't want the rest of the dependencies there anyway because the project uses glide, which means go get will likely break at some point in the exact way it has broken for you here, which is that the version of azure-sdk-for-go that we use is different from HEAD of the repo.

A better thing for you to do would be to do a shallow clone of just cliaas:

curl https://glide.sh/get | sh
mkdir -p $GOPATH/src/github.com/pivotal-cf
git clone --depth 1 https://github.com/pivotal-cf/cliaas $GOPATH/src/github.com/pivotal-cf/cliaas
cd $GOPATH/src/github.com/pivotal-cf/cliaas
glide install
go install github.com/pivotal-cf/cliaas/cmd/cliaas

This workflow works, as the following demonstrates:

$ docker run -ti golang bash
root@c15e6f7cfd7d:/go# curl https://glide.sh/get | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3242  100  3242    0     0  28661      0 --:--:-- --:--:-- --:--:-- 28946
Downloading https://github.com/Masterminds/glide/releases/download/v0.12.3/glide-v0.12.3-linux-amd64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   608    0   608    0     0   2208      0 --:--:-- --:--:-- --:--:--  2210
100 3344k  100 3344k    0     0  1701k      0  0:00:01  0:00:01 --:--:-- 2301k
glide version v0.12.3 installed successfully
root@c15e6f7cfd7d:/go# mkdir -p $GOPATH/src/github.com/pivotal-cf
root@c15e6f7cfd7d:/go# git clone https://github.com/pivotal-cf/cliaas $GOPATH/src/github.com/pivotal-cf/cliaas
Cloning into '/go/src/github.com/pivotal-cf/cliaas'...
remote: Counting objects: 1160, done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 1160 (delta 8), reused 0 (delta 0), pack-reused 1114
Receiving objects: 100% (1160/1160), 206.82 KiB | 0 bytes/s, done.
Resolving deltas: 100% (616/616), done.
Checking connectivity... done.
root@c15e6f7cfd7d:/go# cd $GOPATH/src/github.com/pivotal-cf/cliaas
root@c15e6f7cfd7d:/go/src/github.com/pivotal-cf/cliaas# glide install
[INFO]  Downloading dependencies. Please wait...
[INFO]  --> Fetching cloud.google.com/go.
[INFO]  --> Fetching code.cloudfoundry.org/clock.
[INFO]  --> Fetching golang.org/x/text.
...snip...
[INFO]  --> Exporting golang.org/x/sys
[INFO]  --> Exporting cloud.google.com/go
[INFO]  Replacing existing vendor dependencies
root@c15e6f7cfd7d:/go/src/github.com/pivotal-cf/cliaas# go install github.com/pivotal-cf/cliaas/cmd/cliaas
root@c15e6f7cfd7d:/go/src/github.com/pivotal-cf/cliaas# which cliaas
/go/bin/cliaas

This would avoid downloading useless dependencies that you don't need and avoid the compilation error.

krishicks commented 7 years ago

I've changed the README to suit: https://github.com/pivotal-cf/cliaas/commit/2eb8287265ef49f3057eec45210f7bf8145e08a6