guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Packaging Terraform, a Golang package


From: Chris Marusich
Subject: Packaging Terraform, a Golang package
Date: Tue, 18 Dec 2018 19:10:54 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hi,

I'm trying to package Terraform, which is available under the Mozilla
Public License 2.0:

https://github.com/hashicorp/terraform

I'm not very familiar with how Golang programs are packaged, so I might
be missing some obvious things.  Please let me know if I am!

To begin, I thought I would first try to build it without creating a
package definition just yet.  Should be easy, right?

Clone the repo:

git clone https://github.com/hashicorp/terraform.git

Create a profile for hacking around that contains some tools that the
project seems to need:

guix package -i go make git bash grep findutils which -p .guix-profile

Make sure we're only using those dependencies:

eval "$(guix package --search-paths=exact --profile=$(realpath --no-symlinks 
.guix-profile))"

Enter the project directory:

cd terraform

Following the docs, run "make tools" to "install some required tools".
This downloads some stuff using "go get" (I'll probably have to put
those dependencies into the package definition later...):

--8<---------------cut here---------------start------------->8---
$ make tools
GO111MODULE=off go get -u golang.org/x/tools/cmd/stringer
GO111MODULE=off go get -u golang.org/x/tools/cmd/cover
GO111MODULE=off go get -u github.com/golang/mock/mockgen
--8<---------------cut here---------------end--------------->8---

Nice! Now, per the docs, we run make:

--8<---------------cut here---------------start------------->8---
$ make
==> Checking that code complies with gofmt requirements...
which: no stringer in (/home/marusich/terraform/.guix-profile/bin)
# We turn off modules for "go generate" because our downstream generate
# commands are not all ready to deal with Go modules yet, and this
# avoids downloading all of the deps that are in the vendor dir anyway.
GO111MODULE=off go generate ./...
2018/12/18 19:06:13 Generated command/internal_plugin_list.go
addrs/resource.go:256: running "stringer": exec: "stringer": executable file 
not found in $PATH
backend/operation_type.go:3: running "stringer": exec: "stringer": executable 
file not found in $PATH
backend/local/hook_count_action.go:3: running "stringer": exec: "stringer": 
executable file not found in $PATH
config/resource_mode.go:3: running "stringer": exec: "stringer": executable 
file not found in $PATH
configs/provisioner.go:121: running "stringer": exec: "stringer": executable 
file not found in $PATH
configs/configschema/schema.go:86: running "stringer": exec: "stringer": 
executable file not found in $PATH
helper/schema/resource_data_get_source.go:3: running "stringer": exec: 
"stringer": executable file not found in $PATH
plans/action.go:15: running "stringer": exec: "stringer": executable file not 
found in $PATH
plugin/mock_proto/generate.go:1: running "mockgen": exec: "mockgen": executable 
file not found in $PATH
states/instance_object.go:43: running "stringer": exec: "stringer": executable 
file not found in $PATH
states/statemgr/migrate.go:132: running "stringer": exec: "stringer": 
executable file not found in $PATH
terraform/context_graph_type.go:3: running "stringer": exec: "stringer": 
executable file not found in $PATH
tfdiags/diagnostic.go:20: running "stringer": exec: "stringer": executable file 
not found in $PATH
make: *** [Makefile:80: generate] Error 1
[2] address@hidden:~/terraform/terraform
$ 
--8<---------------cut here---------------end--------------->8---

It seems like it failed to build because some tools were missing from
PATH, specifically "stringer" and mockgen".  I've tried various methods
of installing these things, but I can't seem to get it working.  How do
I get "stringer" and "mockgen"?

I ran these commands, but it didn't seem to work:

--8<---------------cut here---------------start------------->8---
[2] address@hidden:~/terraform/terraform
$ go get github.com/golang/mock/gomock
go: finding github.com/hashicorp/hcl2 v0.0.0-20181215005721-253da47fd604
go: finding github.com/terraform-providers/terraform-provider-aws v1.52.0
go: finding github.com/aws/aws-sdk-go v1.16.4
go: finding github.com/zclconf/go-cty v0.0.0-20181218225846-4fe1e489ee06
go: finding github.com/boombuler/barcode v1.0.0
go: finding github.com/pquerna/otp v1.0.0
go: finding github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
go: finding github.com/golang/mock/gomock latest
go: downloading github.com/golang/mock v1.2.0
[0] address@hidden:~/terraform/terraform
$ go install github.com/golang/mock/mockgen
[0] address@hidden:~/terraform/terraform
$ go get -u -a golang.org/x/tools/cmd/stringer
go: finding golang.org/x/tools/cmd/stringer latest
go: finding golang.org/x/tools/cmd latest
go: finding golang.org/x/tools latest
go: downloading golang.org/x/tools v0.0.0-20181218204010-d4971274fe38
[0] address@hidden:~/terraform/terraform
$ go install golang.org/x/tools/cmd/stringer
[0] address@hidden:~/terraform/terraform
$ type -P mockgen
[1] address@hidden:~/terraform/terraform
$ type -P stringer
[1] address@hidden:~/terraform/terraform
$ 
--8<---------------cut here---------------end--------------->8---

I found this information about mockgen and stringer:

https://github.com/golang/mock

https://github.com/golang/go/issues/13874

Any help would be appreciated!  I'm not sure how to proceed.

-- 
Chris

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]