Skip to content

Commit ce0970d

Browse files
authored
Create standard Terraform packages using alternatives (#397)
1 parent f6e2389 commit ce0970d

40 files changed

+352
-64
lines changed

.github/auto-label.yml

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ vendor/terraform-0.12: vendor/terraform-0.12/**
113113
vendor/terraform-0.13: vendor/terraform-0.13/**
114114
vendor/terraform-docs: vendor/terraform-docs/**
115115
vendor/terraform: vendor/terraform/**
116+
vendor/terraform_0.11: vendor/terraform_0.11/**
117+
vendor/terraform_0.12: vendor/terraform_0.12/**
118+
vendor/terraform_0.13: vendor/terraform_0.13/**
116119
vendor/terragrunt: vendor/terragrunt/**
117120
vendor/terrahelp: vendor/terrahelp/**
118121
vendor/tfenv: vendor/tfenv/**

README.md

+43-56
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
<!--
2-
3-
4-
5-
6-
7-
8-
1+
# Packages [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/cloudposse%2Fpackages%2Fapk?branch=master&key=eyJhbGciOiJIUzI1NiJ9.NWEwMTJmNWM3Yjg3YTQwMDAxYTlkMjU0.UwxTSXZGXq3wPQjj3O1k71kQsGuWGlzgkp9V2-llce8&type=cf-1)](https://g.codefresh.io/pipelines/apk/builds?repoOwner=cloudposse&repoName=packages&serviceName=cloudposse%2Fpackages&filter=trigger:build~Build;branch:master;pipeline:5baae099b35f251ecadf1fa0~apk) [![Auto Update Status](https://github.com/cloudposse/packages/workflows/auto-update/badge.svg)](https://github.com/cloudposse/packages/actions?query=workflow%3Aauto-update) [![Latest Release](https://img.shields.io/github/release/cloudposse/packages.svg)](https://github.com/cloudposse/packages/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
92

3+
[![README Header][readme_header_img]][readme_header_link]
104

5+
[![Cloud Posse][logo]](https://cpco.io/homepage)
116

7+
<!--
128
139
1410
1511
1612
** DO NOT EDIT THIS FILE
17-
**
18-
** This file was automatically generated by the `build-harness`.
19-
** 1) Make all changes to `README.yaml`
13+
**
14+
** This file was automatically generated by the `build-harness`.
15+
** 1) Make all changes to `README.yaml`
2016
** 2) Run `make init` (you only need to do this once)
21-
** 3) Run`make readme` to rebuild this file.
17+
** 3) Run`make readme` to rebuild this file.
2218
**
2319
** (We maintain HUNDREDS of open source projects. This is how we maintain our sanity.)
2420
**
@@ -27,30 +23,14 @@
2723
2824
2925
30-
31-
32-
33-
34-
35-
36-
37-
38-
39-
40-
-->
41-
[![README Header][readme_header_img]][readme_header_link]
42-
43-
[![Cloud Posse][logo]](https://cpco.io/homepage)
44-
45-
# Packages [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/cloudposse%2Fpackages%2Fapk?branch=master&key=eyJhbGciOiJIUzI1NiJ9.NWEwMTJmNWM3Yjg3YTQwMDAxYTlkMjU0.UwxTSXZGXq3wPQjj3O1k71kQsGuWGlzgkp9V2-llce8&type=cf-1)](https://g.codefresh.io/pipelines/apk/builds?repoOwner=cloudposse&repoName=packages&serviceName=cloudposse%2Fpackages&filter=trigger:build~Build;branch:master;pipeline:5baae099b35f251ecadf1fa0~apk) [![Auto Update Status](https://github.com/cloudposse/packages/workflows/auto-update/badge.svg)](https://github.com/cloudposse/packages/actions?query=workflow%3Aauto-update) [![Latest Release](https://img.shields.io/github/release/cloudposse/packages.svg)](https://github.com/cloudposse/packages/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
46-
26+
-->
4727

4828
Cloud Posse distribution of awesome apps.
4929

5030

5131
---
5232

53-
This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
33+
This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
5434
[<img align="right" title="Share via Email" src="https://docs.cloudposse.com/images/ionicons/ios-email-outline-2.0.1-16x16-999999.svg"/>][share_email]
5535
[<img align="right" title="Share on Google+" src="https://docs.cloudposse.com/images/ionicons/social-googleplus-outline-2.0.1-16x16-999999.svg" />][share_googleplus]
5636
[<img align="right" title="Share on Facebook" src="https://docs.cloudposse.com/images/ionicons/social-facebook-outline-2.0.1-16x16-999999.svg" />][share_facebook]
@@ -247,8 +227,9 @@ exit
247227

248228

249229

230+
<!-- markdownlint-disable -->
250231
## Makefile Targets
251-
```
232+
```text
252233
amtool 0.21.0 Tool for interacting with the Alertmanager API
253234
argocd 1.6.2 Declarative GitOpts for Kubernetes
254235
assume-role 0.3.2 Easily assume AWS roles in your terminal.
@@ -346,6 +327,9 @@ terraform-0.11 0.11.14 Terraform is a tool for building, changing,
346327
terraform-0.12 0.12.29 Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.
347328
terraform-0.13 0.13.0 Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.
348329
terraform-docs 0.9.1 Generate docs from terraform modules
330+
terraform_0.11 0.11.14 Terraform (Deprecated package. Use terraform-0.11 instead)
331+
terraform_0.12 0.12.29 Terraform (Deprecated package. Use terraform-0.12 instead)
332+
terraform_0.13 0.13.0 Terraform (Deprecated package. Use terraform-0.13 instead)
349333
terragrunt 0.23.33 Terragrunt is a thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules.
350334
terrahelp 0.7.4 Terrahelp is as a command line utility that provides useful tricks like masking of terraform output.
351335
tfenv 0.4.0 Transform environment variables for use with Terraform (e.g. `HOSTNAME` ⇨ `TF_VAR_hostname`)
@@ -359,12 +343,13 @@ venona 0.32.1 Codefresh runtime-environment agent
359343
vert 0.1.0 Simple CLI for comparing two or more versions
360344
yq 3.3.2 yq is a portable command-line YAML processor
361345
```
346+
<!-- markdownlint-restore -->
362347

363348

364349

365-
## Share the Love
350+
## Share the Love
366351

367-
Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/packages)! (it helps us **a lot**)
352+
Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/packages)! (it helps us **a lot**)
368353

369354
Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =)
370355

@@ -380,7 +365,7 @@ Check out these related projects.
380365

381366
## Help
382367

383-
**Got a question?** We got answers.
368+
**Got a question?** We got answers.
384369

385370
File a GitHub [issue](https://github.com/cloudposse/packages/issues), send us an [email][email] or join our [Slack Community][slack].
386371

@@ -389,7 +374,7 @@ File a GitHub [issue](https://github.com/cloudposse/packages/issues), send us an
389374
## DevOps Accelerator for Startups
390375

391376

392-
We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us.
377+
We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us.
393378

394379
[![Learn More](https://img.shields.io/badge/learn%20more-success.svg?style=for-the-badge)][commercial_support]
395380

@@ -418,11 +403,11 @@ Participate in our [Discourse Forums][discourse]. Here you'll find answers to co
418403

419404
## Newsletter
420405

421-
Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover.
406+
Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover.
422407

423408
## Office Hours
424409

425-
[Join us every Wednesday via Zoom][office_hours] for our weekly "Lunch & Learn" sessions. It's **FREE** for everyone!
410+
[Join us every Wednesday via Zoom][office_hours] for our weekly "Lunch & Learn" sessions. It's **FREE** for everyone!
426411

427412
[![zoom](https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png")][office_hours]
428413

@@ -453,28 +438,30 @@ Copyright © 2017-2020 [Cloud Posse, LLC](https://cpco.io/copyright)
453438

454439

455440

456-
## License
441+
## License
457442

458-
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
443+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
459444

460445
See [LICENSE](LICENSE) for full details.
461446

462-
Licensed to the Apache Software Foundation (ASF) under one
463-
or more contributor license agreements. See the NOTICE file
464-
distributed with this work for additional information
465-
regarding copyright ownership. The ASF licenses this file
466-
to you under the Apache License, Version 2.0 (the
467-
"License"); you may not use this file except in compliance
468-
with the License. You may obtain a copy of the License at
469-
470-
https://www.apache.org/licenses/LICENSE-2.0
471-
472-
Unless required by applicable law or agreed to in writing,
473-
software distributed under the License is distributed on an
474-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
475-
KIND, either express or implied. See the License for the
476-
specific language governing permissions and limitations
477-
under the License.
447+
```text
448+
Licensed to the Apache Software Foundation (ASF) under one
449+
or more contributor license agreements. See the NOTICE file
450+
distributed with this work for additional information
451+
regarding copyright ownership. The ASF licenses this file
452+
to you under the Apache License, Version 2.0 (the
453+
"License"); you may not use this file except in compliance
454+
with the License. You may obtain a copy of the License at
455+
456+
https://www.apache.org/licenses/LICENSE-2.0
457+
458+
Unless required by applicable law or agreed to in writing,
459+
software distributed under the License is distributed on an
460+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
461+
KIND, either express or implied. See the License for the
462+
specific language governing permissions and limitations
463+
under the License.
464+
```
478465

479466

480467

@@ -496,7 +483,7 @@ This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? P
496483

497484
We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We ❤️ [Open Source Software][we_love_open_source].
498485

499-
We offer [paid support][commercial_support] on all of our projects.
486+
We offer [paid support][commercial_support] on all of our projects.
500487

501488
Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation.
502489

docs/targets.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
<!-- markdownlint-disable -->
12
## Makefile Targets
2-
```
3+
```text
34
amtool 0.21.0 Tool for interacting with the Alertmanager API
45
argocd 1.6.2 Declarative GitOpts for Kubernetes
56
assume-role 0.3.2 Easily assume AWS roles in your terminal.
@@ -97,6 +98,9 @@ terraform-0.11 0.11.14 Terraform is a tool for building, changing,
9798
terraform-0.12 0.12.29 Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.
9899
terraform-0.13 0.13.0 Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.
99100
terraform-docs 0.9.1 Generate docs from terraform modules
101+
terraform_0.11 0.11.14 Terraform (Deprecated package. Use terraform-0.11 instead)
102+
terraform_0.12 0.12.29 Terraform (Deprecated package. Use terraform-0.12 instead)
103+
terraform_0.13 0.13.0 Terraform (Deprecated package. Use terraform-0.13 instead)
100104
terragrunt 0.23.33 Terragrunt is a thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules.
101105
terrahelp 0.7.4 Terrahelp is as a command line utility that provides useful tricks like masking of terraform output.
102106
tfenv 0.4.0 Transform environment variables for use with Terraform (e.g. `HOSTNAME` ⇨ `TF_VAR_hostname`)
@@ -110,3 +114,4 @@ venona 0.32.1 Codefresh runtime-environment agent
110114
vert 0.1.0 Simple CLI for comparing two or more versions
111115
yq 3.3.2 yq is a portable command-line YAML processor
112116
```
117+
<!-- markdownlint-restore -->

vendor/terraform-0.11/Makefile

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# Package details
22
export VENDOR ?= hashicorp
3-
export APK_PACKAGE_NAME = terraform_0.11
43
export PACKAGE_REPO_NAME = terraform
4+
export PACKAGE_EXE = terraform
5+
export MASTER_PACKAGE_NAME = terraform
6+
export MAJOR_VERSION = 0.11
7+
export PACKAGE_NAME = $(MASTER_PACKAGE_NAME)-$(MAJOR_VERSION)
58

69
include ../../tasks/Makefile.package
710
include ../../tasks/Makefile.apk
811

12+
# NOTE: This build uses a custom build template ./APKBUILD
913
export APK_BUILD_TEMPLATE ?= APKBUILD.github-binary
1014
export DOWNLOAD_URL ?= https://releases.hashicorp.com/terraform/$(PACKAGE_VERSION)/terraform_$(PACKAGE_VERSION)_$(OS)_$(ARCH).zip
1115
export AUTO_UPDATE_ENABLED = false
16+
export APKBUILD_DEPENDS += dpkg
17+
export APKBUILD_INSTALL_SCRIPTS = $(PACKAGE_NAME).post-install $(PACKAGE_NAME).post-deinstall
18+
export INSTALL_DIR = /usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin
1219

1320
install:
1421
mkdir -p $(TMP)/$(PACKAGE_NAME)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
# This is an Alpine `deinstall` hook that removes the alternative
3+
MASTER_PACKAGE_NAME=terraform
4+
MAJOR_VERSION=0.11
5+
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION}
6+
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin
7+
8+
update-alternatives --remove ${PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
9+
update-alternatives --remove ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
10+
update-alternatives --remove ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
11+
exit 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
MASTER_PACKAGE_NAME=terraform
3+
PRIORITY="11"
4+
MAJOR_VERSION="0.${PRIORITY}"
5+
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION}
6+
7+
# INSTALL_DIR is where the binary is ultimately installed
8+
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin
9+
DIRENV_SUPPORT_DIR=/usr/local/terraform/${MAJOR_VERSION}/bin
10+
11+
mkdir -p ${INSTALL_DIR}
12+
mkdir -p ${DIRENV_SUPPORT_DIR}
13+
14+
# --install <link> <name> <path> <priority>
15+
# <link> is the symlink people will actually invoke
16+
# <name> is the name for this group of alternatives
17+
# <path> is the location of the actual binary
18+
# <priority> is an integer. The alternative with the highest priority
19+
# number will be automatically selected
20+
21+
## Install terraform-0.11 command
22+
update-alternatives --install /usr/bin/${PACKAGE_NAME} ${PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1
23+
24+
# Install /usr/local/terraform/0.11/bin/terraform for `direnv/use terraform`
25+
update-alternatives --install ${DIRENV_SUPPORT_DIR}/terraform ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1
26+
27+
# Install terraform command
28+
update-alternatives --install /usr/bin/${MASTER_PACKAGE_NAME} ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} ${PRIORITY}
29+
exit 0

vendor/terraform-0.12/APKBUILD.draft

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Custom Build for Terraform with hardcoded values
2+
# Contributor: Cloud Posse, LLC <[email protected]>
3+
# Maintainer: Cloud Posse, LLC <[email protected]>
4+
# vim: filetype=sh
5+
6+
pkgver="${PACKAGE_VERSION}"
7+
pkgrel="${PACKAGE_RELEASE}"
8+
mjrver=${pkgver%.*}
9+
pkgname="terraform_${mjrver}"
10+
pkgdesc="${PACKAGE_DESCRIPTION}"
11+
repo=vendor
12+
arch="x86_64"
13+
url="https://releases.hashicorp.com/terraform/${pkgver}/terraform_${pkgver}_linux_amd64.zip"
14+
license="MPL-2.0"
15+
depends="dpkg"
16+
makedepends=""
17+
source="https://releases.hashicorp.com/terraform/${pkgver}/terraform_${pkgver}_linux_amd64.zip"
18+
builddir="$srcdir/$pkgname-$pkgver"
19+
install="${pkgname}.post-install ${pkgname}.post-deinstall"
20+
installdir=${INSTALL_DIR:-/usr/bin/}
21+
exe=terraform
22+
23+
build() {
24+
:
25+
}
26+
27+
check() {
28+
cd $srcdir
29+
./terraform version
30+
}
31+
32+
# This is the packaging stage.
33+
# The built application and support files should be installed into $pkgdir.
34+
package() {
35+
echo "Installing packges to ${pkgdir}"
36+
mkdir -p "${pkgdir}/${installdir}"
37+
for cmd in ${exe}; do
38+
install -m 755 "$(realpath "${srcdir}/${cmd}")" "${pkgdir}/${installdir}/${cmd}"
39+
done
40+
echo "Binaries staged for installation in ${pkgdir}"
41+
find "${pkgdir}"
42+
}

vendor/terraform-0.12/Makefile

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# Package details
22
export VENDOR ?= hashicorp
3-
export APK_PACKAGE_NAME = terraform_0.12
43
export PACKAGE_REPO_NAME = terraform
4+
export PACKAGE_EXE = terraform
5+
export MASTER_PACKAGE_NAME = terraform
6+
export MAJOR_VERSION = 0.12
7+
export PACKAGE_NAME = $(MASTER_PACKAGE_NAME)-$(MAJOR_VERSION)
58

69
include ../../tasks/Makefile.package
710
include ../../tasks/Makefile.apk
811

12+
# NOTE: This build uses a custom build template ./APKBUILD
913
export APK_BUILD_TEMPLATE ?= APKBUILD.github-binary
1014
export DOWNLOAD_URL ?= https://releases.hashicorp.com/terraform/$(PACKAGE_VERSION)/terraform_$(PACKAGE_VERSION)_$(OS)_$(ARCH).zip
1115
export AUTO_UPDATE_ENABLED = false
16+
export APKBUILD_DEPENDS += dpkg
17+
export APKBUILD_INSTALL_SCRIPTS = $(PACKAGE_NAME).post-install $(PACKAGE_NAME).post-deinstall
18+
export INSTALL_DIR = /usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin
1219

1320
install:
1421
mkdir -p $(TMP)/$(PACKAGE_NAME)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
# This is an Alpine `deinstall` hook that removes the alternative
3+
MASTER_PACKAGE_NAME=terraform
4+
MAJOR_VERSION=0.12
5+
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION}
6+
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin
7+
8+
update-alternatives --remove ${PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
9+
update-alternatives --remove ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
10+
update-alternatives --remove ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
11+
exit 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
MASTER_PACKAGE_NAME=terraform
3+
PRIORITY="12"
4+
MAJOR_VERSION="0.${PRIORITY}"
5+
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION}
6+
7+
# INSTALL_DIR is where the binary is ultimately installed
8+
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin
9+
DIRENV_SUPPORT_DIR=/usr/local/terraform/${MAJOR_VERSION}/bin
10+
11+
mkdir -p ${INSTALL_DIR}
12+
mkdir -p ${DIRENV_SUPPORT_DIR}
13+
14+
# --install <link> <name> <path> <priority>
15+
# <link> is the symlink people will actually invoke
16+
# <name> is the name for this group of alternatives
17+
# <path> is the location of the actual binary
18+
# <priority> is an integer. The alternative with the highest priority
19+
# number will be automatically selected
20+
21+
## Install terraform-0.12 command
22+
update-alternatives --install /usr/bin/${PACKAGE_NAME} ${PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1
23+
24+
# Install /usr/local/terraform/0.12/bin/terraform for `direnv/use terraform`
25+
update-alternatives --install ${DIRENV_SUPPORT_DIR}/terraform ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1
26+
27+
# Install terraform command
28+
update-alternatives --install /usr/bin/${MASTER_PACKAGE_NAME} ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} ${PRIORITY}
29+
exit 0

0 commit comments

Comments
 (0)