Skip to content
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

[terraform] 0.12 support #7

Merged
merged 9 commits into from
Jun 5, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
support no modules at all
osterman committed Jun 4, 2019
commit 3c8e1d4f13c08209fd84246016280f54d9ef2013
10 changes: 8 additions & 2 deletions test/terraform/module-pinning.bats
Original file line number Diff line number Diff line change
@@ -11,6 +11,12 @@ function teardown() {

@test "check if terraform modules are properly pinned" {
skip_unless_terraform
grep -Eo '^\s*source\s*=\s*"(.*?)"' *.tf | cut -d'"' -f2 | sort -u | sed 's/^.*?ref=//' > $TMPFILE
grep -E '^(tags/[0-9]+\.[0-9]+.*|)$' $TMPFILE
grep -Eo '^\s*source\s*=\s*"(.*?)"' *.tf | cut -d'"' -f2 | sort -u > $TMPFILE
if [ -s $TMPFILE ]; then
# Verify the modules are pinned to `tags/x.y` or nothing at all (maybe using `version` parameter instead)
sed 's/^.*?ref=//' < $TMPFILE | grep -E '^(tags/[0-9]+\.[0-9]+.*|)$'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why in '^(tags/[0-9]+\.[0-9]+.*|)$', the first . escaped \., but the second one not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second one is not matching a ., but saying anything else (e.g 1.0 or 1.0-alpha or 1.0.2`, etc)

else
# If the file is empty, then no modules are being used
true
fi
}