Cloud-builders: Troubles replicating local go install with cloud builder

Created on 3 Apr 2017  ·  3Comments  ·  Source: GoogleCloudPlatform/cloud-builders

For our go projects we are moving to locating all of our go src within a base go folder which in turn is what GOPATH is set to:

~/go

With this in mind for our github organization an example-project the path would look like:

~/go/src/github.com/vendasta/example-project

This example-project has a structure that looks like

./example-project
├── gke
└── exampleProject
    ├── package1
    ├── package2
    └── package3
    ├── main.go
    ├── channel_handlers.go
    ├── api_handlers.go

From within the terminal I can run go install ./exampleProject from the base project folder. I've as of yet been able to replicate this go install command with the cloud builder.

gcloud container builds submit exampleProject --config cloudbuild.yaml

cloudbuild.yaml

steps:
- name: 'gcr.io/cloud-builders/go'
  args: ['install', '.']
  env: ['PROJECT_ROOT=exampleProject']

I keep getting errors stating that the sub packages cannot be found? Am I doing something wrong here?

Step #0: Creating shadow workspace and symlinking source into "./gopath/src/exampleProject".
Step #0: Documentation at https://github.com/GoogleCloudPlatform/cloud-builders/blob/master/go/README.md
Step #0: Binaries built using 'go install' will go to "/workspace/gopath/bin".
Step #0: Running: go install .
Step #0: api_handlers.go:12:2: cannot find package "github.com/vendasta/example-project/exampleProject/package1" in any of:
Step #0:  /workspace/gopath/src/exampleProject/vendor/github.com/vendasta/example-project/exampleProject/package1 (vendor tree)
Step #0:  /usr/local/go/src/github.com/vendasta/example-project/exampleProject/package1 (from $GOROOT)
Step #0:  /workspace/gopath/src/github.com/vendasta/example-project/exampleProject/package1 (from $GOPATH)
Step #0: channel_handlers.go:6:2: cannot find package "github.com/vendasta/example-project/exampleProject/package2" in any of:
Step #0:  /workspace/gopath/src/exampleProject/vendor/github.com/vendasta/example-project/exampleProject/package2 (vendor tree)
Step #0:  /usr/local/go/src/github.com/vendasta/example-project/exampleProject/package2 (from $GOROOT)
Step #0:  /workspace/gopath/src/github.com/vendasta/example-project/exampleProject/package2 (from $GOPATH)
Step #0: api_handlers.go:13:2: cannot find package "github.com/vendasta/example-project/exampleProject/package3" in any of:
Step #0:  /workspace/gopath/src/exampleProject/vendor/github.com/vendasta/example-project/exampleProject/package3 (vendor tree)
Step #0:  /usr/local/go/src/github.com/vendasta/example-project/exampleProject/package3 (from $GOROOT)
Step #0:  /workspace/gopath/src/github.com/vendasta/example-project/exampleProject/package3 (from $GOPATH)
Finished Step #0
ERROR

Most helpful comment

Set 'PROJECT_ROOT=github.com/vendasta/example-project' and I believe it should work.

All 3 comments

Set 'PROJECT_ROOT=github.com/vendasta/example-project' and I believe it should work.

Thanks for the reply, that did indeed work!

steps:
- name: 'gcr.io/cloud-builders/go'
  args: ['install', './exampleProject']
  env: ['PROJECT_ROOT=github.com/vendasta/example-project']

Thanks for the reply, that did indeed work!

steps:
- name: 'gcr.io/cloud-builders/go'
  args: ['install', './exampleProject']
  env: ['PROJECT_ROOT=github.com/vendasta/example-project']

could you please tell me what command line did you make and where?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cove picture cove  ·  7Comments

mbana picture mbana  ·  6Comments

govindrai picture govindrai  ·  5Comments

evanj picture evanj  ·  4Comments

leighmcculloch picture leighmcculloch  ·  5Comments