-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add terraform-config-inspect for apk and deb #748
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0dc50ce
Add terraform-config-inspect for apk and deb
Nuru 2390f33
Update README etc.
Nuru bcb1a4d
Update Docker build to build go binary
Nuru 491b02b
Attempt to fix remote build error
Nuru 66bc89a
Merge branch 'master' into tf-config-inspect
Nuru baa38cd
debugging
Nuru c7a7a43
tmp dir perms
Nuru 50def42
More tmp dir stuff
Nuru 7253164
alakazam
Nuru 1b4db9b
Remove redundant failing mktemp
Nuru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
# | ||
# This workflow was created automatically from the `package-template.yml` by running `make -C .github workflows` | ||
# DO NOT EDIT THIS WORKFLOW, changes will be lost on the next update. | ||
# | ||
|
||
name: "terraform-config-inspect" | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
paths: | ||
- apk/** | ||
- deb/** | ||
- rpm/** | ||
- tasks/** | ||
- vendor/terraform-config-inspect/** | ||
- .github/workflows/terraform-config-inspect.yml | ||
|
||
|
||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- apk/** | ||
- deb/** | ||
- rpm/** | ||
- tasks/** | ||
- vendor/terraform-config-inspect/** | ||
- .github/workflows/terraform-config-inspect.yml | ||
|
||
jobs: | ||
matrix: | ||
if: github.event_name != 'schedule' | ||
runs-on: ubuntu-latest | ||
outputs: | ||
package-enabled: ${{ steps.info.outputs.package_enabled }} | ||
package-matrix: ${{steps.info.outputs.package_matrix}} | ||
apk-enabled: ${{ steps.info.outputs.package_enabled == 'true' && steps.info.outputs.apk_package_enabled == 'true' }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Export package build matrix | ||
shell: bash | ||
id: info | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
run: | | ||
echo setting ouputs | ||
make -C vendor/terraform-config-inspect info/github | ||
echo | ||
echo outputs set | ||
make -C vendor/terraform-config-inspect info/github | sed s'/::set-output name=//' | sed 's/::/=/' | ||
|
||
|
||
# Build for alpine linux | ||
# Kept separate because it is old and slightly different than the other package builds | ||
alpine: | ||
needs: matrix | ||
if: github.event_name != 'schedule' && needs.matrix.outputs.apk-enabled != 'false' | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# These versions must be strings. E.g. Otherwise `3.10` -> `3.1` | ||
alpine: | ||
- '3.12' | ||
env: | ||
APK_KEY_RSA: "${{ secrets.APK_KEY_RSA }}" | ||
APK_PACKAGES_PATH: ${{github.workspace}}/artifacts/${{matrix.alpine}} | ||
PACKAGER: [email protected] | ||
PACKAGER_PRIVKEY: /dev/shm/[email protected] | ||
PACKAGER_PUBKEY: ${{github.workspace}}/artifacts/[email protected] | ||
|
||
container: cloudposse/packages-apkbuild:${{matrix.alpine}} | ||
steps: | ||
# Checkout the packages repo so we can build the packages as a monorepo | ||
- name: "Checkout source code at current commit" | ||
uses: actions/checkout@v2 | ||
|
||
# Export the apk keys as files from secrets | ||
- name: "Export keys" | ||
run: "make -C .github/ export" | ||
|
||
# Build the alpine packages for the matrix version of alpine | ||
- name: "Build alpine packages" | ||
run: "make -C vendor/${{github.workflow}} apk" | ||
|
||
# Verify the packages were built or error | ||
- name: "List packages" | ||
run: 'find ${APK_PACKAGES_PATH} -type f -name \*.apk | xargs --no-run-if-empty ls -l | grep .' | ||
|
||
# Export the artifact filename including path | ||
# Path must be relative to workdir for Cloudsmith action to be able to find it | ||
- name: "Set output path to artifact" | ||
id: artifact | ||
shell: bash | ||
run: | | ||
artifact=$(find artifacts/${{matrix.alpine}} -type f -name \*.apk) | ||
echo "::set-output name=path::$artifact" | ||
echo "set output path=$artifact" | ||
echo creating '"pip"' cache directory for Cloudsmith | ||
mkdir -p $HOME/.cache/pip && chmod -R 777 $HOME/.cache || echo Ignoring error creating '"pip"' cache directory | ||
|
||
|
||
# Determine which package organization we should use (e.g. dev or prod) | ||
- name: "Determine package repo" | ||
shell: bash | ||
id: repo | ||
run: | | ||
if [[ ${GITHUB_REF} == 'refs/heads/master' ]]; then | ||
echo "::set-output name=org::${{github.repository_owner}}" | ||
else | ||
echo "::set-output name=org::${{github.repository_owner}}-dev" | ||
fi | ||
env: | ||
GITHUB_REF: ${{ github.ref }} | ||
|
||
# Publish the artifacts | ||
- name: "Push artifact to package repository" | ||
uses: cloudsmith-io/[email protected] | ||
with: | ||
api-key: ${{ secrets.CLOUDSMITH_API_KEY }} | ||
command: 'push' | ||
format: 'alpine' | ||
owner: '${{steps.repo.outputs.org}}' # Your Cloudsmith account name or org name (namespace) | ||
repo: 'packages' # Your Cloudsmith Repository name (slug) | ||
distro: 'alpine' # Your Distribution (i.e debian, ubuntu, alpine) | ||
release: 'any-version' # Use "any-version" if your package is compatible with more than one version of alpine linux | ||
republish: 'true' # Needed if version is not changing | ||
file: '${{steps.artifact.outputs.path}}' # Package filename (including path) | ||
no-wait-for-sync: 'true' # Skip the waiting for package synchronisation (i.e. upload only) | ||
|
||
# Build packages with fpm package manager | ||
package: | ||
needs: matrix | ||
# Should not be needed, but without these conditions, this job would fail with an error if the matrix is [] | ||
# and would run with package-type empty if matrix is ["apk"] | ||
if: > | ||
github.event_name != 'schedule' && needs.matrix.outputs.package-enabled != 'false' | ||
&& needs.matrix.outputs.package-matrix != '[]' && needs.matrix.outputs.package-matrix != '["apk"]' | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
package-type: ${{ fromJSON(needs.matrix.outputs.package-matrix) }} | ||
exclude: | ||
- package-type: 'apk' | ||
env: | ||
# We are in a bit of a bind here because of how GitHub actions work as of 2020-11-19 | ||
# Although the "workspace" is mounted to the container, it is not mounted | ||
# at `/github/workspace` or ${{github.workspace}}, although through some | ||
# mechanism, an environment variable whose value starts with ${{github.workspace}} | ||
# will have ${{github.workspace}} replaced with the correct mount point. | ||
# | ||
# We need an absolute path for the package build system, since every build happens | ||
# in a different directory, but because the mount point changes, we also | ||
# need a path relative to the initial working directory to communicate between | ||
# the package building container and the cloudsmith action. | ||
PACKAGES_PATH: ${{github.workspace}}/artifacts/${{matrix.package-type}}/any-version | ||
PACKAGE_RELPATH: artifacts/${{matrix.package-type}}/any-version | ||
|
||
# Unfortunately, there is no reasonable way to configure the docker image tag based on the package-type | ||
container: cloudposse/packages-${{matrix.package-type}}build:latest | ||
steps: | ||
# Checkout the packages repo so we can build the packages as a monorepo | ||
- name: "Checkout source code at current commit" | ||
uses: actions/checkout@v2 | ||
|
||
# Build the packages for the matrix version | ||
- name: "Build ${{matrix.package-type}} packages" | ||
shell: bash | ||
run: | | ||
echo Current directory is $(pwd) | ||
[[ $PACKAGES_PATH =~ ^$(pwd) ]] || { echo Package dir \"$PACKAGES_PATH\" not beneath workdir \"$(pwd)\" >&2; exit 1; } | ||
make -C vendor/${{github.workflow}} ${{matrix.package-type}} | ||
|
||
# Export the artifact filename including path | ||
- name: "Set output path to artifact" | ||
id: artifact | ||
shell: bash | ||
run: | | ||
[[ -n $PACKAGE_RELPATH ]] || { echo Error: PACKAGE_RELPATH is not set >&2; exit 1; } | ||
packages=($(find ${PACKAGE_RELPATH} -type f -name \*.${{matrix.package-type}})) | ||
echo List packages found: | ||
printf "%s\n" "${packages[@]}" | xargs --no-run-if-empty ls -l | ||
echo Error if not exactly 1 package found | ||
(( ${#packages[@]} == 1 )) || { echo "Error: other than 1 package found (${#packages[@]})" >&2; exit 1; } | ||
|
||
echo "setting output name=path::$packages" | ||
echo "::set-output name=path::$packages" | ||
|
||
echo creating '"pip"' cache directory for Cloudsmith | ||
mkdir -p $HOME/.cache/pip && chmod -R 777 $HOME/.cache || echo Ignoring error creating '"pip"' cache directory | ||
|
||
# Determine which package organization we should use (e.g. dev or prod) | ||
- name: "Determine package repo" | ||
shell: bash | ||
id: repo | ||
run: | | ||
if [[ ${GITHUB_REF} == 'refs/heads/master' ]]; then | ||
echo "::set-output name=org::${{github.repository_owner}}" | ||
else | ||
echo "::set-output name=org::${{github.repository_owner}}-dev" | ||
fi | ||
env: | ||
GITHUB_REF: ${{ github.ref }} | ||
|
||
# Publish the artifacts | ||
- name: "Push artifact to package repository" | ||
uses: cloudsmith-io/[email protected] | ||
with: | ||
api-key: ${{ secrets.CLOUDSMITH_API_KEY }} | ||
command: 'push' | ||
format: '${{matrix.package-type}}' | ||
owner: '${{steps.repo.outputs.org}}' # Your Cloudsmith account name or org name (namespace) | ||
repo: 'packages' # Your Cloudsmith Repository name (slug) | ||
distro: 'any-distro' # Use "any-distro" since our package is compatible with more than more distribution | ||
release: 'any-version' # Use "any-version" since our package is compatible with more than more version | ||
republish: 'true' # Needed if version is not changing | ||
file: '${{steps.artifact.outputs.path}}' # Package filename (including path) | ||
no-wait-for-sync: 'true' # Skip the waiting for package synchronisation (i.e. upload only) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A helper library for shallow inspection of Terraform configurations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MPL-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## Package - terraform-config-inspect | ||
export VENDOR = hashicorp | ||
export PACKAGE_NAME = terraform-config-inspect | ||
export DOWNLOAD_URL ?= $(PACKAGE_EXE) | ||
export APK_BUILD_TEMPLATE ?= APKBUILD.github-binary | ||
export APK_PACKAGE_VERSION := $(shell cat VERSION | sed s/\+.*//) | ||
export INSTALL_PATH=/usr/local/bin | ||
|
||
# RPM should be relatively easy, but we will get to it later | ||
export PACKAGE_TYPES_DISABLED = rpm | ||
|
||
# Custom auto-update target | ||
export PACKAGE_VERSION_TARGET := go-update | ||
|
||
include ../../tasks/Makefile.vendor_includes | ||
|
||
version.go: VERSION | ||
go generate | ||
|
||
$(INSTALL_PATH)/$(PACKAGE_EXE): main.go version.go VERSION | ||
mkdir -p $(INSTALL_PATH) | ||
go build -o $(INSTALL_PATH)/$(PACKAGE_EXE) | ||
|
||
test: | ||
@echo Test: expecting exe version like $(APK_PACKAGE_VERSION) or $(DEB_PACKAGE_VERSION) from VERSION $(shell cat VERSION) | ||
@echo Running: $(PACKAGE_EXE) --version && $(PACKAGE_EXE) --version | ||
$(PACKAGE_EXE) --version | grep -q -F $(APK_PACKAGE_VERSION) | ||
|
||
## This may be required for apk building and varies from package to package | ||
# Custom post-package processing (Note the double colon to append to current inherited package/prepare task) | ||
#package/prepare:: | ||
# echo cp src/gh_$(PACKAGE_VERSION)_$(OS)_$(ARCH)/bin/$(PACKAGE_EXE) src | ||
|
||
apk/prepare:: $(INSTALL_PATH)/$(PACKAGE_EXE) | ||
cp -p $(INSTALL_PATH)/$(PACKAGE_EXE) $(APK_TMP_DIR) | ||
chown nobody $(APK_TMP_DIR)/$(PACKAGE_EXE) | ||
|
||
install: $(INSTALL_PATH)/$(PACKAGE_EXE) | ||
|
||
go-update: | ||
go get -u github.com/hashicorp/terraform-config-inspect | ||
printf "%s" $$(grep -F github.com/hashicorp/terraform-config-inspect go.mod| sed -e 's/.* v//' -e 's/\.0-/./' -e 's/-/+git/') > VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.20201102131242+git0c45ba392e51 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module github.com/cloudposse/packages | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/agext/levenshtein v1.2.3 // indirect | ||
github.com/google/go-cmp v0.5.4 // indirect | ||
github.com/hashicorp/hcl v1.0.0 // indirect | ||
github.com/hashicorp/hcl/v2 v2.8.0 // indirect | ||
github.com/hashicorp/terraform-config-inspect v0.0.0-20201102131242-0c45ba392e51 | ||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect | ||
github.com/spf13/pflag v1.0.5 | ||
github.com/zclconf/go-cty v1.7.0 // indirect | ||
golang.org/x/text v0.3.4 // indirect | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the timestamp of the commit or when you ran it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you can tell from looking at it, November 02 is not the timestamp of when I ran it. This is a slightly modified version of the version string the
go
modules use for version tracking. I expect it is the timestamp of the commit, plus of course the partial git SHA of the commit.