Skip to content

Commit

Permalink
Create standard Terraform packages using alternatives (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru authored Aug 21, 2020
1 parent f6e2389 commit ce0970d
Show file tree
Hide file tree
Showing 40 changed files with 352 additions and 64 deletions.
3 changes: 3 additions & 0 deletions .github/auto-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ vendor/terraform-0.12: vendor/terraform-0.12/**
vendor/terraform-0.13: vendor/terraform-0.13/**
vendor/terraform-docs: vendor/terraform-docs/**
vendor/terraform: vendor/terraform/**
vendor/terraform_0.11: vendor/terraform_0.11/**
vendor/terraform_0.12: vendor/terraform_0.12/**
vendor/terraform_0.13: vendor/terraform_0.13/**
vendor/terragrunt: vendor/terragrunt/**
vendor/terrahelp: vendor/terrahelp/**
vendor/tfenv: vendor/tfenv/**
Expand Down
99 changes: 43 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
<!--
# 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)

[![README Header][readme_header_img]][readme_header_link]

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

<!--
** DO NOT EDIT THIS FILE
**
** This file was automatically generated by the `build-harness`.
** 1) Make all changes to `README.yaml`
**
** This file was automatically generated by the `build-harness`.
** 1) Make all changes to `README.yaml`
** 2) Run `make init` (you only need to do this once)
** 3) Run`make readme` to rebuild this file.
** 3) Run`make readme` to rebuild this file.
**
** (We maintain HUNDREDS of open source projects. This is how we maintain our sanity.)
**
Expand All @@ -27,30 +23,14 @@
-->
[![README Header][readme_header_img]][readme_header_link]

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

# 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)

-->

Cloud Posse distribution of awesome apps.


---

This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
[<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]
[<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]
[<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]
Expand Down Expand Up @@ -247,8 +227,9 @@ exit



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



## Share the Love
## Share the Love

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

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

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

## Help

**Got a question?** We got answers.
**Got a question?** We got answers.

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

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


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.
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.

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

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

## Newsletter

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.
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.

## Office Hours

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

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

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



## License
## License

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

See [LICENSE](LICENSE) for full details.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
```text
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
```



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

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

We offer [paid support][commercial_support] on all of our projects.
We offer [paid support][commercial_support] on all of our projects.

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.

Expand Down
7 changes: 6 additions & 1 deletion docs/targets.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- markdownlint-disable -->
## Makefile Targets
```
```text
amtool 0.21.0 Tool for interacting with the Alertmanager API
argocd 1.6.2 Declarative GitOpts for Kubernetes
assume-role 0.3.2 Easily assume AWS roles in your terminal.
Expand Down Expand Up @@ -97,6 +98,9 @@ terraform-0.11 0.11.14 Terraform is a tool for building, changing,
terraform-0.12 0.12.29 Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.
terraform-0.13 0.13.0 Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.
terraform-docs 0.9.1 Generate docs from terraform modules
terraform_0.11 0.11.14 Terraform (Deprecated package. Use terraform-0.11 instead)
terraform_0.12 0.12.29 Terraform (Deprecated package. Use terraform-0.12 instead)
terraform_0.13 0.13.0 Terraform (Deprecated package. Use terraform-0.13 instead)
terragrunt 0.23.33 Terragrunt is a thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules.
terrahelp 0.7.4 Terrahelp is as a command line utility that provides useful tricks like masking of terraform output.
tfenv 0.4.0 Transform environment variables for use with Terraform (e.g. `HOSTNAME` ⇨ `TF_VAR_hostname`)
Expand All @@ -110,3 +114,4 @@ venona 0.32.1 Codefresh runtime-environment agent
vert 0.1.0 Simple CLI for comparing two or more versions
yq 3.3.2 yq is a portable command-line YAML processor
```
<!-- markdownlint-restore -->
9 changes: 8 additions & 1 deletion vendor/terraform-0.11/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Package details
export VENDOR ?= hashicorp
export APK_PACKAGE_NAME = terraform_0.11
export PACKAGE_REPO_NAME = terraform
export PACKAGE_EXE = terraform
export MASTER_PACKAGE_NAME = terraform
export MAJOR_VERSION = 0.11
export PACKAGE_NAME = $(MASTER_PACKAGE_NAME)-$(MAJOR_VERSION)

include ../../tasks/Makefile.package
include ../../tasks/Makefile.apk

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

install:
mkdir -p $(TMP)/$(PACKAGE_NAME)
Expand Down
11 changes: 11 additions & 0 deletions vendor/terraform-0.11/terraform-0.11.post-deinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# This is an Alpine `deinstall` hook that removes the alternative
MASTER_PACKAGE_NAME=terraform
MAJOR_VERSION=0.11
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION}
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin

update-alternatives --remove ${PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
update-alternatives --remove ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
update-alternatives --remove ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
exit 0
29 changes: 29 additions & 0 deletions vendor/terraform-0.11/terraform-0.11.post-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
MASTER_PACKAGE_NAME=terraform
PRIORITY="11"
MAJOR_VERSION="0.${PRIORITY}"
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION}

# INSTALL_DIR is where the binary is ultimately installed
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin
DIRENV_SUPPORT_DIR=/usr/local/terraform/${MAJOR_VERSION}/bin

mkdir -p ${INSTALL_DIR}
mkdir -p ${DIRENV_SUPPORT_DIR}

# --install <link> <name> <path> <priority>
# <link> is the symlink people will actually invoke
# <name> is the name for this group of alternatives
# <path> is the location of the actual binary
# <priority> is an integer. The alternative with the highest priority
# number will be automatically selected

## Install terraform-0.11 command
update-alternatives --install /usr/bin/${PACKAGE_NAME} ${PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1

# Install /usr/local/terraform/0.11/bin/terraform for `direnv/use terraform`
update-alternatives --install ${DIRENV_SUPPORT_DIR}/terraform ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1

# Install terraform command
update-alternatives --install /usr/bin/${MASTER_PACKAGE_NAME} ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} ${PRIORITY}
exit 0
42 changes: 42 additions & 0 deletions vendor/terraform-0.12/APKBUILD.draft
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Custom Build for Terraform with hardcoded values
# Contributor: Cloud Posse, LLC <[email protected]>
# Maintainer: Cloud Posse, LLC <[email protected]>
# vim: filetype=sh

pkgver="${PACKAGE_VERSION}"
pkgrel="${PACKAGE_RELEASE}"
mjrver=${pkgver%.*}
pkgname="terraform_${mjrver}"
pkgdesc="${PACKAGE_DESCRIPTION}"
repo=vendor
arch="x86_64"
url="https://releases.hashicorp.com/terraform/${pkgver}/terraform_${pkgver}_linux_amd64.zip"
license="MPL-2.0"
depends="dpkg"
makedepends=""
source="https://releases.hashicorp.com/terraform/${pkgver}/terraform_${pkgver}_linux_amd64.zip"
builddir="$srcdir/$pkgname-$pkgver"
install="${pkgname}.post-install ${pkgname}.post-deinstall"
installdir=${INSTALL_DIR:-/usr/bin/}
exe=terraform

build() {
:
}

check() {
cd $srcdir
./terraform version
}

# This is the packaging stage.
# The built application and support files should be installed into $pkgdir.
package() {
echo "Installing packges to ${pkgdir}"
mkdir -p "${pkgdir}/${installdir}"
for cmd in ${exe}; do
install -m 755 "$(realpath "${srcdir}/${cmd}")" "${pkgdir}/${installdir}/${cmd}"
done
echo "Binaries staged for installation in ${pkgdir}"
find "${pkgdir}"
}
9 changes: 8 additions & 1 deletion vendor/terraform-0.12/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Package details
export VENDOR ?= hashicorp
export APK_PACKAGE_NAME = terraform_0.12
export PACKAGE_REPO_NAME = terraform
export PACKAGE_EXE = terraform
export MASTER_PACKAGE_NAME = terraform
export MAJOR_VERSION = 0.12
export PACKAGE_NAME = $(MASTER_PACKAGE_NAME)-$(MAJOR_VERSION)

include ../../tasks/Makefile.package
include ../../tasks/Makefile.apk

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

install:
mkdir -p $(TMP)/$(PACKAGE_NAME)
Expand Down
11 changes: 11 additions & 0 deletions vendor/terraform-0.12/terraform-0.12.post-deinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# This is an Alpine `deinstall` hook that removes the alternative
MASTER_PACKAGE_NAME=terraform
MAJOR_VERSION=0.12
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION}
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin

update-alternatives --remove ${PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
update-alternatives --remove ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
update-alternatives --remove ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${PACKAGE_NAME} --quiet
exit 0
29 changes: 29 additions & 0 deletions vendor/terraform-0.12/terraform-0.12.post-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
MASTER_PACKAGE_NAME=terraform
PRIORITY="12"
MAJOR_VERSION="0.${PRIORITY}"
PACKAGE_NAME=${MASTER_PACKAGE_NAME}-${MAJOR_VERSION}

# INSTALL_DIR is where the binary is ultimately installed
INSTALL_DIR=/usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin
DIRENV_SUPPORT_DIR=/usr/local/terraform/${MAJOR_VERSION}/bin

mkdir -p ${INSTALL_DIR}
mkdir -p ${DIRENV_SUPPORT_DIR}

# --install <link> <name> <path> <priority>
# <link> is the symlink people will actually invoke
# <name> is the name for this group of alternatives
# <path> is the location of the actual binary
# <priority> is an integer. The alternative with the highest priority
# number will be automatically selected

## Install terraform-0.12 command
update-alternatives --install /usr/bin/${PACKAGE_NAME} ${PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1

# Install /usr/local/terraform/0.12/bin/terraform for `direnv/use terraform`
update-alternatives --install ${DIRENV_SUPPORT_DIR}/terraform ${PACKAGE_NAME}-direnv ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} 1

# Install terraform command
update-alternatives --install /usr/bin/${MASTER_PACKAGE_NAME} ${MASTER_PACKAGE_NAME} ${INSTALL_DIR}/${MASTER_PACKAGE_NAME} ${PRIORITY}
exit 0
Loading

0 comments on commit ce0970d

Please sign in to comment.