jetstack / tarmak

A toolkit for Kubernetes cluster provisioning and lifecycle management
Apache License 2.0
269 stars 49 forks source link

make build does not work out of the box #2

Closed leopoldodonnell closed 6 years ago

leopoldodonnell commented 6 years ago

OSX 10.12.6

> export GOPATH=$HOME/go
> rm -rf $GOPATH/*
> go version
go version go1.8 darwin/amd64

> git clone git@github.com:jetstack/tarmak.git && cd tarmak
Cloning into 'tarmak'...
remote: Counting objects: 38724, done.
remote: Compressing objects: 100% (176/176), done.
remote: Total 38724 (delta 133), reused 236 (delta 119), pack-reused 38415
Receiving objects: 100% (38724/38724), 43.18 MiB | 714.00 KiB/s, done.
Resolving deltas: 100% (15574/15574), done.
Checking out files: 100% (15365/15365), done.

> make build
go build -o .../tarmak/bin/go-bindata ./vendor/github.com/jteeuwen/go-bindata/go-bindata
vendor/github.com/jteeuwen/go-bindata/go-bindata/main.go:15:2: cannot find package "github.com/jteeuwen/go-bindata" in any of:
    /usr/local/go/src/github.com/jteeuwen/go-bindata (from $GOROOT)
    /Users/leo_odonnell/go/src/github.com/jteeuwen/go-bindata (from $GOPATH)
make: *** [.../tarmak/bin/go-bindata] Error 1

Started adding in missing packages with go get

make build now returns

make build
mkdir -p .../tarmak/bin
go build -o .../tarmak/bin/conversion-gen ./vendor/k8s.io/code-generator/cmd/conversion-gen
# _/.../tarmak/vendor/k8s.io/code-generator/cmd/conversion-gen
vendor/k8s.io/code-generator/cmd/conversion-gen/main.go:76: cannot use generators.NameSystems() (type "k8s.io/code-generator/vendor/k8s.io/gengo/namer".NameSystems) as type "k8s.io/gengo/namer".NameSystems in argument to arguments.Execute
vendor/k8s.io/code-generator/cmd/conversion-gen/main.go:77: cannot use generators.Packages (type func(*"k8s.io/code-generator/vendor/k8s.io/gengo/generator".Context, *"k8s.io/code-generator/vendor/k8s.io/gengo/args".GeneratorArgs) "k8s.io/code-generator/vendor/k8s.io/gengo/generator".Packages) as type func(*"k8s.io/gengo/generator".Context, *"k8s.io/gengo/args".GeneratorArgs) "k8s.io/gengo/generator".Packages in argument to arguments.Execute

I'm not certain if there are k8's version issues here. So while I'd love to dig deeper, I'm afraid it could possibly be a fools errand that might be easily fixed by the maintainers updating the dependencies to be more complete.

BradErz commented 6 years ago

You don't seem to be cloning into the right directory. If you clone to here: $GOPATH/src/github.com/jetstack

Then it should work.

simonswine commented 6 years ago

@leopoldodonnell Thanks for the report. I am not too sure what's going on in your environment. Basically what we are doing is we use the vendor/ folder to version our binary dependencies. (The ones you tried to install manually through go get).

First of all make sure your full path to the tarmak directory is like @BradErz suggest $GOPATH/src/github.com/jetstack/tarmak

Another thing to check is if the PWD is detected correctly. Your output suggest that your PWD is .../tarmak or something like that. This is strange maybe using $(CURDIR) works better:

diff --git a/Makefile b/Makefile
index 8156092..8341fd6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # Copyright Jetstack Ltd. See LICENSE for details.
 PACKAGE_NAME ?= github.com/jetstack/tarmak

-BINDIR ?= $(PWD)/bin
+BINDIR ?= $(CURDIR)/bin
 PATH   := $(BINDIR):$(PATH)

 CI_COMMIT_TAG ?= unknown
leopoldodonnell commented 6 years ago

BradErz - I think you're right - I'm so used to docker-based builds that I didn't think to clone into GOPATH. It is work adding a few lines to the developer doc for those of us with wood where we should have brains.

This gets me further:

cd jetstack/tarmak/
/Users/leo_odonnell/go/src/jetstack/tarmak
goldtop:tarmak leo_odonnell$ make build
mkdir -p /Users/leo_odonnell/go/src/jetstack/tarmak/bin
go build -o /Users/leo_odonnell/go/src/jetstack/tarmak/bin/go-bindata ./vendor/github.com/jteeuwen/go-bindata/go-bindata
mkdir -p /Users/leo_odonnell/go/src/jetstack/tarmak/bin
go build -o /Users/leo_odonnell/go/src/jetstack/tarmak/bin/mockgen ./vendor/github.com/golang/mock/mockgen
mkdir -p /Users/leo_odonnell/go/src/jetstack/tarmak/bin
go build -o /Users/leo_odonnell/go/src/jetstack/tarmak/bin/defaulter-gen ./vendor/k8s.io/code-generator/cmd/defaulter-gen
mkdir -p /Users/leo_odonnell/go/src/jetstack/tarmak/bin
go build -o /Users/leo_odonnell/go/src/jetstack/tarmak/bin/deepcopy-gen ./vendor/k8s.io/code-generator/cmd/deepcopy-gen
mkdir -p /Users/leo_odonnell/go/src/jetstack/tarmak/bin
go build -o /Users/leo_odonnell/go/src/jetstack/tarmak/bin/conversion-gen ./vendor/k8s.io/code-generator/cmd/conversion-gen
mkdir -p /Users/leo_odonnell/go/src/jetstack/tarmak/bin
go build -o /Users/leo_odonnell/go/src/jetstack/tarmak/bin/client-gen ./vendor/k8s.io/code-generator/cmd/client-gen
mkdir -p /Users/leo_odonnell/go/src/jetstack/tarmak/bin
go build -o /Users/leo_odonnell/go/src/jetstack/tarmak/bin/lister-gen ./vendor/k8s.io/code-generator/cmd/lister-gen
mkdir -p /Users/leo_odonnell/go/src/jetstack/tarmak/bin
go build -o /Users/leo_odonnell/go/src/jetstack/tarmak/bin/informer-gen ./vendor/k8s.io/code-generator/cmd/informer-gen
go generate $(go list ./pkg/... ./cmd/...)
CGO_ENABLED=0 GOOS=linux  GOARCH=amd64 go build -a -tags netgo -ldflags '-w -X main.version=unknown -X main.commit=unknown -X main.date=2017-10-17T12:56:16Z' -o tarmak_linux_amd64  ./cmd/tarmak
cmd/tarmak/main.go:5:2: cannot find package "github.com/jetstack/tarmak/cmd/tarmak/cmd" in any of:
    /Users/leo_odonnell/go/src/jetstack/tarmak/vendor/github.com/jetstack/tarmak/cmd/tarmak/cmd (vendor tree)
    /usr/local/go/src/github.com/jetstack/tarmak/cmd/tarmak/cmd (from $GOROOT)
    /Users/leo_odonnell/go/src/github.com/jetstack/tarmak/cmd/tarmak/cmd (from $GOPATH)
make: *** [go_build] Error 1
simonswine commented 6 years ago

I think it's still not the right directory: (there is no github.com)

go get -d github.com/jetstack/tarmak/...
cd $GOPATH/src/github.com/jetstack/tarmak
make build 
leopoldodonnell commented 6 years ago

I received a number of issues on the get, but they appear to be benign. The build works. I'm closing this now. Its up to you want to update the developer doc for dumb people like me.

Here's the output I saw from the get:

 rm -rf $GOPATH/*
goldtop:leo leo_odonnell$ go get -d github.com/jetstack/tarmak/...
package github.com/jetstack/tarmak/vendor/github.com/docker/docker/pkg/term/windows: case-insensitive import collision: "github.com/jetstack/tarmak/vendor/github.com/Sirupsen/logrus" and "github.com/jetstack/tarmak/vendor/github.com/sirupsen/logrus"
package github.com/jetstack/tarmak/vendor/github.com/docker/docker/api/server/router/image
    imports github.com/docker/distribution/digest: cannot find package "github.com/docker/distribution/digest" in any of:
    /usr/local/go/src/github.com/docker/distribution/digest (from $GOROOT)
    /Users/leo_odonnell/go/src/github.com/docker/distribution/digest (from $GOPATH)
package github.com/jetstack/tarmak/vendor/github.com/docker/docker/api/server/router/network
    imports github.com/docker/containerd/api/grpc/types: cannot find package "github.com/docker/containerd/api/grpc/types" in any of:
    /usr/local/go/src/github.com/docker/containerd/api/grpc/types (from $GOROOT)
    /Users/leo_odonnell/go/src/github.com/docker/containerd/api/grpc/types (from $GOPATH)
package github.com/jetstack/tarmak/vendor/github.com/docker/docker/daemon/logger/gcplogs
    imports google.golang.org/cloud/compute/metadata: code in directory /Users/leo_odonnell/go/src/google.golang.org/cloud/compute/metadata expects import "cloud.google.com/go/compute/metadata"
package github.com/jetstack/tarmak/vendor/github.com/docker/docker/daemon/logger/gcplogs
    imports google.golang.org/cloud/logging: code in directory /Users/leo_odonnell/go/src/google.golang.org/cloud/logging expects import "cloud.google.com/go/logging"
package github.com/jetstack/tarmak/vendor/github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/apis_guru
    imports github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/apis_guru/apis_guru: cannot find package "github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/apis_guru/apis_guru" in any of:
    /usr/local/go/src/github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/apis_guru/apis_guru (from $GOROOT)
    /Users/leo_odonnell/go/src/github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/apis_guru/apis_guru (from $GOPATH)
package github.com/jetstack/tarmak/vendor/github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/bookstore/service
    imports github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/bookstore/bookstore: cannot find package "github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/bookstore/bookstore" in any of:
    /usr/local/go/src/github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/bookstore/bookstore (from $GOROOT)
    /Users/leo_odonnell/go/src/github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/bookstore/bookstore (from $GOPATH)
package github.com/jetstack/tarmak/vendor/github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/xkcd
    imports github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/xkcd/xkcd: cannot find package "github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/xkcd/xkcd" in any of:
    /usr/local/go/src/github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/xkcd/xkcd (from $GOROOT)
    /Users/leo_odonnell/go/src/github.com/googleapis/gnostic/plugins/gnostic-go-generator/examples/v2.0/xkcd/xkcd (from $GOPATH)
bgeesaman commented 6 years ago

@simonswine I think a quick edit to the docs with your commands of how and where to "go get" this repo would be really helpful for users (like me) who are not go developers by trade get past step 1. Thanks!