[PATCH] Add terraform and terraform-provider-libvirt

  • Open
  • quality assurance status badge
Details
5 participants
  • Chris Marusich
  • Sarah Morgensen
  • Pierre Neidhardt
  • Christopher Baines
  • Sharlatan Hellseher
Owner
unassigned
Submitted by
Christopher Baines
Severity
normal
Merged with

Debbugs page

C
C
Christopher Baines wrote on 13 Mar 2018 13:25
(address . guix-patches@gnu.org)
87y3ivzps1.fsf@cbaines.net
Tags: moreinfo

I'll send some patches for adding a Terraform package and the Terraform
libvirt provider. Both of these work, at least in the way I've been
using them, but the packages need more work before they can be
included. I think both packages include quite a few copies of other
libraries which need packaging for Guix.


Christopher Baines (2):
gnu: Add terraform.
gnu: Add terraform-provider-libvirt.

gnu/local.mk | 1 +
gnu/packages/terraform.scm | 106 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 107 insertions(+)
create mode 100644 gnu/packages/terraform.scm
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlqoM75fFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9Xd30w//WWKK9xQ6TbalXF6UBsPPgQ1iRfGBFaObwfnAhtxviHxehGE2vXAQpLmK
oc0mcdwVe7A+Ln0TnhPv7hq+KZRJCqcRGRkoVspJB2kb+vUCGVsbPqU5bCoQP3WB
k4lVqf7TeMlseFY4lR66x3Jx5SxjeS5A9jJSBOsPXpmKI/5oVb3ZreRrpGtzrm8c
gKC84jN8xUYYsU9PZGSjmDcnOutf/YJzwD+rdgV4BCruFQg5WbzYdJw7gyBUqx3A
5gQek6l0AztPGXSy/+ytKC1kiD+V6DjDJkEhe0pkiH9EJnYeAR0f1AZ8pmq78Wnz
xPHKdvmFA6xULEE8TRyX5xppk6KFHZaC7mv4jIil5MSPZ3NIZtMUvoCoBi3hu6IW
VLalKWay5EvcKcJr3m/c7mdADLzsYrvrGK4mOFmR07ur3iQrchJ8IeVV3je7oNFl
vTN8JlHUjCdrN4HdBmQfLehDHU17erwSO7ZlT0DMsE0p1b9Nx4aCWn0CpaeY43Mc
xFuyt5jrdET41gageO39rHAybf9SKhTLmcGkdZzTQbi76lp2OT2FIB1bxnrrm7vm
e/8NrRhUKXsdDl4B2I/7Cop+RCtiqKRuFEblDsQbcxUwcEwnr4ekFoR0wTLIA4O8
iw5kw3D+zAw3FEvpD4vBDncaqsJlBG2MCCufqYyXH/KmYPG+6CU=
=4qAe
-----END PGP SIGNATURE-----

C
C
Christopher Baines wrote on 13 Mar 2018 13:30
[PATCH 2/2] gnu: Add terraform-provider-libvirt.
(address . 30806@debbugs.gnu.org)
20180313203008.3487-2-mail@cbaines.net
* gnu/packages/terraform.scm (terraform-provider-libvirt): New variable.
---
gnu/packages/terraform.scm | 48 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 47 insertions(+), 1 deletion(-)

Toggle diff (65 lines)
diff --git a/gnu/packages/terraform.scm b/gnu/packages/terraform.scm
index 277d19aed..e81ada45d 100644
--- a/gnu/packages/terraform.scm
+++ b/gnu/packages/terraform.scm
@@ -21,7 +21,11 @@
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix git-download)
- #:use-module (guix build-system go))
+ #:use-module (guix build-system go)
+ #:use-module (gnu packages golang)
+ #:use-module (gnu packages cdrom)
+ #:use-module (gnu packages pkg-config)
+ #:use-module (gnu packages virtualization))
(define-public terraform
(package
@@ -58,3 +62,45 @@ apply changes to the described resources.
Terraform uses plugins that provide intergrations to different providers.")
(home-page "https://www.terraform.io/")
(license license:mpl2.0)))
+
+(define-public terraform-provider-libvirt
+ (package
+ (name "terraform-provider-libvirt")
+ (version "0.3")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/dmacvicar/terraform-provider-libvirt")
+ (commit (string-append "v" version))))
+ (sha256
+ (base32
+ "004gxy55p5cf39f2zpah0i2zhvs4x6ixnxy8z9v7314604ggpkna"))))
+ (build-system go-build-system)
+ (native-inputs
+ `(("pkg-config" ,pkg-config)))
+ (inputs
+ `(("libvirt" ,libvirt)
+ ("cdrtools" ,cdrtools)))
+ (arguments
+ '(#:import-path "github.com/dmacvicar/terraform-provider-libvirt"
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-mkisofs
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute*
+ "src/github.com/dmacvicar/terraform-provider-libvirt/libvirt/cloudinit_def.go"
+ (("mkisofs")
+ (string-append (assoc-ref inputs "cdrtools")
+ "/bin/mkisofs")))))
+ ;; This should be redundant once the vendor directory is removed from
+ ;; this package
+ (add-before 'reset-gzip-timestamps 'remove-readonly-gzip-files
+ (lambda* (#:key outputs #:allow-other-keys)
+ (for-each delete-file
+ (find-files
+ (assoc-ref outputs "out")
+ ".*\\.gz")))))))
+ (synopsis "")
+ (description "")
+ (home-page "")
+ (license "")))
--
2.16.2
C
C
Christopher Baines wrote on 13 Mar 2018 13:30
[PATCH 1/2] gnu: Add terraform.
(address . 30806@debbugs.gnu.org)
20180313203008.3487-1-mail@cbaines.net
* gnu/packages/terraform.scm (New file).
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
gnu/local.mk | 1 +
gnu/packages/terraform.scm | 60 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
create mode 100644 gnu/packages/terraform.scm

Toggle diff (80 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 5a3ae502f..2b5502e8e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -410,6 +410,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/tcl.scm \
%D%/packages/telephony.scm \
%D%/packages/terminals.scm \
+ %D%/packages/terraform.scm \
%D%/packages/texinfo.scm \
%D%/packages/tex.scm \
%D%/packages/textutils.scm \
diff --git a/gnu/packages/terraform.scm b/gnu/packages/terraform.scm
new file mode 100644
index 000000000..277d19aed
--- /dev/null
+++ b/gnu/packages/terraform.scm
@@ -0,0 +1,60 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2018 Christopher Baines <mail@cbaines.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages terraform)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix packages)
+ #:use-module (guix download)
+ #:use-module (guix git-download)
+ #:use-module (guix build-system go))
+
+(define-public terraform
+ (package
+ (name "terraform")
+ (version "0.11.3")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/hashicorp/terraform")
+ (commit (string-append "v" version))))
+ (sha256
+ (base32
+ "0637x7jcm62pdnivmh4rggly6dmlvdh3jpsd1z4vba15gbm203nz"))))
+ (build-system go-build-system)
+ (arguments
+ '(#:import-path "github.com/hashicorp/terraform"
+ #:phases
+ (modify-phases %standard-phases
+ ;; I'm not sure what purpose they serve, but they are readonly, so
+ ;; they break the reset-gzip-timestamps phase.
+ (add-after 'install 'delete-test-fixtures
+ (lambda* (#:key outputs #:allow-other-keys)
+ (delete-file-recursively
+ (string-append
+ (assoc-ref outputs "out")
+ "/src/github.com/hashicorp/terraform/config/module/test-fixtures")))))))
+ (synopsis "Tool for building and changing computing infrastructure")
+ (description
+ "Terraform uses descriptions of infrastructure written in @acronym{HCL,
+Hashicorp Configuration Language} which describe graphs of resources,
+including information about dependencies. From this, Terraform can plan and
+apply changes to the described resources.
+
+Terraform uses plugins that provide intergrations to different providers.")
+ (home-page "https://www.terraform.io/")
+ (license license:mpl2.0)))
--
2.16.2
C
C
Chris Marusich wrote on 20 Dec 2018 01:31
Re: Packaging Terraform, a Golang package
87bm5g4k8r.fsf@gmail.com
Hello Chris and Pierre!

Thank you for your tips regarding Golang and Terraform. I've built it -
both ad-hoc and using a slightly modified version of Chris' original
package definition. I'm still getting used to Golang's build system and
our own golang-build-system, so please bear with me!

I was able to run the official Terraform build steps on the latest
Terraform release by issuing the following commands - but I'm not sure
if this actually produced the terraform program:

mkdir terraform
cd terraform/
tar -xf v0.11.11.tar.gz
mkdir -p src/github.com/hashicorp
cp -r terraform-0.11.11 src/github.com/hashicorp/terraform
guix package -i go make git bash grep findutils which coreutils diffutils -p .guix-profile
mkdir gobin
eval "$(guix package --search-paths=exact --profile=$(realpath --no-symlinks .guix-profile))"
export GOPATH="$(pwd)"
export GOBIN="$GOPATH/bin"
export PATH="$PATH:$GOBIN"
cd src/github.com/hashicorp/terraform/
make tools
make

Those last two commands are the ones listed in Terraform's README.md.
It looks like the final command, "make" will execute the "fmtcheck",
"generate", and "test" recipes in that order. Here are the relevant
parts of the Makefile:

Toggle snippet (27 lines)
default: test

[...]

# test runs the unit tests
# we run this one package at a time here because running the entire suite in
# one command creates memory usage issues when running in Travis-CI.
test: fmtcheck generate
go list $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=2m -parallel=4

[...]

# generate runs `go generate` to build the dynamically generated
# source files.
generate:
@which stringer > /dev/null; if [ $$? -ne 0 ]; then \
go get -u golang.org/x/tools/cmd/stringer; \
fi
go generate ./...
@go fmt command/internal_plugin_list.go > /dev/null

[...]

fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

So, in essence this runs "go generate", "go fmt", and "go test". The
script gofmtcheck.sh seems to be a read-only linter to assist the
Terraform maintainers in finding badly formatted Golang files.

This is slightly different from the installation procedure that our
go-build-system runs. When you build the attached package (which
packages an older version of terraform for now), our go-build-system
runs steps like the following (in order from top to bottom):

* Phase: unpack: Make a "src/github.com/hashicorp/terraform" directory.
* Phase: setup-environment: set GOPATH to (getcwd) and GOBIN to $out/bin.
* Phase: build: go install -v -x '-ldflags=-s -w' github.com/hashicorp/terraform
* Phase: check: go test github.com/hashicorp/terraform

All in all, this has raised some questions in my mind:

1) Is it bad that our package definition isn't running "go generate" or
"go fmt"? Do you know if "go install" does this for us somehow? I
don't think "stringer" or "mockgen" are present in the build
environment, but our "go install" invocation seems to build terraform
even without them. I wonder if the built terraform is broken in some
ways because we didn't run the code generation/formatting steps.

2) After I ran "make" ad-hoc, I couldn't find a built "terraform"
executable anywhere. Where is it? Am missing something obvious, or
could it be that the official documentation incomplete and I need to ask
upstream for advice?

3) The official instructions seem to arbitrarily choose to run the build
in parallel, using 4 threads, which means this package won't play nice
with build arguments like --cores. I suppose I might need to work with
upstream to fix that.

This feels so close, and yet so far. Hopefully we only have a little
more to do to get Terraform packaged well! Thank you again for your
help.

--
Chris
From 71d654e2738c6ef870441d4234632bd30e93c74a Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Thu, 20 Dec 2018 01:24:59 -0800
Subject: [PATCH] gnu: Add terraform.

This patch is slightly modified from Christopher Baines' original patch to
accommodate some changes that have taken place recently in the Guix source
tree. But it's essentially the same. It is still probably not suitable for
inclusion in Guix just yet.

* gnu/packages/terraform.scm (terraform): New variable.
---
gnu/packages/terraform.scm | 40 ++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)

Toggle diff (50 lines)
diff --git a/gnu/packages/terraform.scm b/gnu/packages/terraform.scm
index f14b152fd..de2288dda 100644
--- a/gnu/packages/terraform.scm
+++ b/gnu/packages/terraform.scm
@@ -47,3 +47,43 @@ the inputs and outputs for modules of the Terraform infrastructure management
tool. These can be shown, or written to a file in JSON or Markdown formats.")
(home-page "https://github.com/segmentio/terraform-docs")
(license license:expat)))
+
+(define-public terraform
+ (package
+ (name "terraform")
+ (version "0.11.3")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/hashicorp/terraform")
+ (commit (string-append "v" version))))
+ (sha256
+ (base32
+ "0637x7jcm62pdnivmh4rggly6dmlvdh3jpsd1z4vba15gbm203nz"))))
+ (build-system go-build-system)
+ (arguments
+ '(#:import-path "github.com/hashicorp/terraform"
+ #:phases
+ (modify-phases %standard-phases
+ ;; I'm not sure what purpose they serve, but they are readonly, so
+ ;; they break the reset-gzip-timestamps phase.
+ (add-after 'install 'delete-test-fixtures
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; If delete-file-recursively fails, it won't throw an exception.
+ ;; However, if it doesn't do its job, the build will fail, so
+ ;; we'll know one way or another.
+ (delete-file-recursively
+ (string-append
+ (assoc-ref outputs "out")
+ "/src/github.com/hashicorp/terraform/config/module/test-fixtures"))
+ #t)))))
+ (synopsis "Tool for building and changing computing infrastructure")
+ (description
+ "Terraform uses descriptions of infrastructure written in @acronym{HCL,
+Hashicorp Configuration Language} which describe graphs of resources,
+including information about dependencies. From this, Terraform can plan and
+apply changes to the described resources.
+
+Terraform uses plugins that provide intergrations to different providers.")
+ (home-page "https://www.terraform.io/")
+ (license license:mpl2.0)))
--
2.20.0
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEy/WXVcvn5+/vGD+x3UCaFdgiRp0FAlwbYYQACgkQ3UCaFdgi
Rp2pVRAAldIZ7HMppNLV19sT0R8pJuFL9MdlTAXrfus1PORIpXXsDyCSbJdkkCgU
0YBSCXMma91dPcABegKNbsN5WdztwMNd1/LailLSTnAQa7NFxAZTKOlrATtq+hY1
aqnUiaTkFSMQ+OKnCPrDJ8DLFqic1HOr72qeHlSu/dMYg5e14bDZQTlm2Z1MV28h
OhwevOozyVu7L3mJL/I839U8ysIyEnq3AB+q/+XHn7mwfY727uxM4GNVUzETvJAl
OiJTiqxES2Lyit14JHmKIol+lJGD4G2+659n3prodq4g1m0M9Ec0BV4urX1xEaHt
e9Aafe0Rx9D7nnRze8L/HNwI8IKS/XmUqBvPWHAAq5IIePAagq3Zvo2BDVYfZFe8
nDcdgB0ViM/mNUa0n7eU7zRAnwcun+Z5DFJCllpkiMNTDr4l57LNnJXuzCuCcSGT
3OHvnUvY7Rgrordhdgv/tSaEM+4L+8GCSptIImW2WNq9aWjURKlOemjitSQCF2kg
U8OVM1NoLY4xCFsCyXSA4TXKgKsUuo8bgbTclP7ofYBMKQuEm+aaI4XT2tOhGBAg
u4EjBxCR8vreJJob//+CxCr2YzlYvBWvkJPBGNlFgEQj+NOPRRR1ScKDUTxhwbar
xPFXrSfIjLUTKGOwEpecKV12WjQI1UL9XKe7J1hwJ4C8rC7ZRJY=
=qchI
-----END PGP SIGNATURE-----

P
P
Pierre Neidhardt wrote on 20 Dec 2018 01:47
(name . Chris Marusich)(address . cmmarusich@gmail.com)
87woo4zg0p.fsf@ambrevar.xyz
Toggle quote (4 lines)
> 1) Is it bad that our package definition isn't running "go generate" or
> "go fmt"? Do you know if "go install" does this for us somehow? I
> don't think "stringer" or "mockgen" are present in the build

"go generate" is used to generate code, it's like a preprocessor. Most Go
programs don't use it, but if they do, then it's needed.

"go fmt" should not be part of the build process in my opinion. A code
formatter fits better into a Git hook or something.

Toggle quote (5 lines)
> 2) After I ran "make" ad-hoc, I couldn't find a built "terraform"
> executable anywhere. Where is it? Am missing something obvious, or
> could it be that the official documentation incomplete and I need to ask
> upstream for advice?

I haven't looked into it, but it should be either in ~/go/bin or in the package
source folder, something like ~/go/src/.../terraform/.

Toggle quote (5 lines)
> 3) The official instructions seem to arbitrarily choose to run the build
> in parallel, using 4 threads, which means this package won't play nice
> with build arguments like --cores. I suppose I might need to work with
> upstream to fix that.

I think Go decides this on its own. Off the top of my head, there is an
environment variable to control the number of CPU threads used globally,
GO_xxx_CORES or something like that.

--
Pierre Neidhardt
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEUPM+LlsMPZAEJKvom9z0l6S7zH8FAlwbZSYACgkQm9z0l6S7
zH+4+wgAqodcAcZ28ZHf8W9KaeUXwsffaoqr19e1Gixwc8enb2X61YyG/TZYUp/j
ICfXe7xzjm8n4uKmSjYa8Te17bVR+tfEEDEq8wJoBBlCFS60kIXSFfGPw4qFPmm4
+0q4BB/CKmh75nmL6K2UYPwOViHHuSezd5mXk1CYbvA00KqFNw/+hz7DcNhK4XsB
LkSxYSux5CwGaZdWYi8lRStBChkeIW52N4BurAj5CpGzG9KxJ70plF00bhq4paKM
t8db2G+YR0cvE3STdf4GbZ+TYVBgat9BfnY7iOBh7Ju7nyjdJ+rvcaOj2LBLHccz
7IyAvZizAscQCJ2w6oWyksKSs2YUfQ==
=ddux
-----END PGP SIGNATURE-----

S
S
Sarah Morgensen wrote on 12 Sep 2021 18:18
control message for bug #30806
(address . control@debbugs.gnu.org)
E1mPac2-0003HB-B8@debbugs.gnu.org
merge 30806 44721
quit
S
S
Sharlatan Hellseher wrote on 28 Sep 2021 12:57
(address . 30806@debbugs.gnu.org)
CAO+9K5p1ext8TmxTVrrT3omQLbCnmsWesaG=4oTfVp3=OqcpgQ@mail.gmail.com
Hi all,
Terraform is reached stable version 1.0.0+ is it still in review to
have it in Guix or it will be regected due to any licensing reason?
--
… наш разум - превосходная объяснительная машина которая способна
найти смысл почти в чем угодно, истолковать любой феномен, но
совершенно не в состоянии принять мысль о непредсказуемости.
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 30806@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 30806
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch