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

add terraform-provider-google-beta to ci #502

Merged
merged 63 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
6f36892
add terraform-provider-google-beta to ci
danawillow Sep 26, 2018
3ccf867
properly add beta submodule
danawillow Sep 26, 2018
73048eb
add forgotten yml file
danawillow Sep 26, 2018
f4c8a5c
remove bad submodule
danawillow Sep 26, 2018
eca1e52
actually add submodule
danawillow Sep 26, 2018
0223d22
remove it again
danawillow Sep 26, 2018
ff18984
actually actually add submodule
danawillow Sep 26, 2018
0439c11
update submodule dir based on version
danawillow Sep 26, 2018
f971c11
quote version
danawillow Sep 26, 2018
39fbaec
use other way of specifying submodule url
danawillow Sep 26, 2018
248a4e3
skip generation if product doesn't exist at specified version
danawillow Sep 27, 2018
1cc61a6
generate tf at ga first, then at beta
danawillow Sep 27, 2018
fff3560
Merge branch 'master' into tfbeta
danawillow Oct 2, 2018
3da348f
copy git dir correctly
danawillow Oct 2, 2018
c0bbeb9
maybe actually set the right version to generate, who really knows ba…
danawillow Oct 3, 2018
0fde8ad
try to run beta provider tests as part of terraform test job
danawillow Oct 3, 2018
80dc82f
add beta provider in a few more places
danawillow Oct 3, 2018
ca035fb
make arrays correctly
danawillow Oct 3, 2018
e178fe8
fix issue with empty string becoming the word null
danawillow Oct 3, 2018
3d616b9
more loops
danawillow Oct 3, 2018
47aada0
add terraform-beta-generated output back
danawillow Oct 3, 2018
8275eec
Merge branch 'master' into tfbeta
danawillow Oct 5, 2018
78d03a5
put all files in google-beta if the version is beta
danawillow Oct 6, 2018
627bd3f
add common files
danawillow Oct 6, 2018
3bce028
fix test target dir
danawillow Oct 6, 2018
cfdbee6
mark labelfingerprint beta for globaladdress
danawillow Oct 8, 2018
2e54ebb
stop explicitly generating some beta apis
danawillow Oct 8, 2018
7ef2ac5
generate at lower version if product not at version
danawillow Oct 8, 2018
a68e462
remove deprecation messages
danawillow Oct 8, 2018
98b8eb4
return true if no versions for _bundles
danawillow Oct 8, 2018
1ec9255
rubocop
danawillow Oct 8, 2018
078fb25
another exists if there are no versions
danawillow Oct 8, 2018
9e953ce
auth api name should be ga
danawillow Oct 8, 2018
26691c9
Merge branch 'master' into tfbeta
danawillow Oct 9, 2018
313af83
add 2.0.0 branch to beta submodule and extra newline back to tf docs
danawillow Oct 9, 2018
98ad75d
Merge branch 'master' into tfbeta
danawillow Oct 12, 2018
62b6eb9
Merge branch 'master' into tfbeta
danawillow Oct 15, 2018
a39616c
add another loop
danawillow Oct 15, 2018
678361d
update submodule to track 2.0.0 branch
danawillow Oct 15, 2018
5663803
Merge branch 'master' into tfbeta
danawillow Oct 17, 2018
8a7321f
convert files that need to be different between versions to erb
danawillow Oct 17, 2018
15760e2
rubocop
danawillow Oct 17, 2018
efb2d8e
fix args to compile_files
danawillow Oct 17, 2018
fcd7777
Basic structure for singular InSpec resources (#573)
slevenick Oct 17, 2018
2923c48
move puppet logging to debug instead of info (#574)
chrisst Oct 17, 2018
9533dd9
small changes noticed when inspecting generated code
danawillow Oct 17, 2018
33a4c2a
Terraform: Add project, organization, folder, service account tests t…
rileykarson Oct 17, 2018
e077beb
Terraform: Add import tests for CloudIoTRegistry (#576)
rileykarson Oct 17, 2018
b80f580
add version var to all examples
danawillow Oct 17, 2018
70d8f28
fix indentation
danawillow Oct 17, 2018
8c280d1
more indentation fixes
danawillow Oct 17, 2018
84e25bd
Add Storage ObjectAccessControl to Terraform (#562)
rileykarson Oct 17, 2018
62afbbb
fix expand for machine type in composer environment (#571)
emilymye Oct 17, 2018
19ace70
Terraform: Add storage, missing project resource test files to MM. (#…
rileykarson Oct 18, 2018
1f6c48c
nested exclude for versioned properties (#575)
emilymye Oct 18, 2018
abe3d0c
maps and variables in ci
danawillow Oct 18, 2018
ff19553
fix point-to-submodules
danawillow Oct 18, 2018
be6dd56
fix create-pr
danawillow Oct 18, 2018
91291cc
add missing -v
danawillow Oct 18, 2018
234e48c
small changes the magician tried to overwrite
danawillow Oct 19, 2018
b6e66c2
Add OiCS link generation to the Terraform docs. (#572)
rileykarson Oct 19, 2018
1934858
Merge 234e48cc3b3cafb835ac22ee37607b1fa2313aca into b6e66c2de271a510e…
danawillow Oct 19, 2018
c9daa49
Update tracked submodules -> HEAD on Fri Oct 19 17:55:09 UTC 2018
modular-magician Oct 19, 2018
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
50 changes: 35 additions & 15 deletions .ci/ci.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ resources:
authorship_restriction: true
no_label: automerged

- name: terraform-intermediate
{% for v in vars.terraform_v.itervalues() %}
- name: {{ v.short_name }}-intermediate
type: git-branch
source:
uri: [email protected]:((github-account.username))/terraform-provider-google.git
uri: [email protected]:((github-account.username))/{{ v.provider_name }}.git
private_key: ((repo-key.private_key))
{% endfor %}

- name: ansible-intermediate
type: git-branch
Expand Down Expand Up @@ -136,18 +138,25 @@ jobs:
status: pending
path: magic-modules
- aggregate:
{% for k, v in vars.terraform_v.iteritems() %}
- do:
# consumes: magic-modules-branched
# produces: terraform-generated
- task: generate-terraform
- task: generate-{{v.short_name}}
file: magic-modules-branched/.ci/magic-modules/generate-terraform.yml
# Puts 'terraform-generated' into the robot's fork.
- put: terraform-intermediate
params:
repository: terraform-generated
branch_file: magic-modules-branched/branchname
only_if_diff: true
force: true
VERSION: {{k}}
PROVIDER_NAME: {{v.provider_name}}
SHORT_NAME: {{v.short_name}}
# Puts 'terraform-generated' into the robot's fork.
- aggregate:
- put: {{v.short_name}}-intermediate
params:
repository: terraform-generated/{{k}}
branch_file: magic-modules-branched/branchname
only_if_diff: true
force: true
{% endfor %}
- do:
# consumes: magic-modules-branched
# produces: ansible-generated
Expand Down Expand Up @@ -226,6 +235,7 @@ jobs:
CREDS: ((repo-key.private_key))
PUPPET_MODULES: {{','.join(vars.puppet_modules)}}
CHEF_MODULES: {{','.join(vars.chef_modules)}}
TERRAFORM_VERSIONS: "{{','.join(vars.terraform_properties_serialized)}}"
TERRAFORM_ENABLED: true
ANSIBLE_ENABLED: true
INSPEC_ENABLED: true
Expand All @@ -243,11 +253,18 @@ jobs:
version: every
trigger: true
params:
submodules: [build/terraform]
submodules: [{{','.join(vars.terraform_submodules)}}]
passed: [mm-generate]
- task: test
file: magic-modules/.ci/unit-tests/task.yml
timeout: 30m
- aggregate:
{% for v in vars.terraform_v.itervalues() %}
- task: test-{{v.short_name}}
file: magic-modules/.ci/unit-tests/task.yml
timeout: 30m
params:
PROVIDER_NAME: {{v.provider_name}}
SHORT_NAME: {{v.short_name}}
TEST_DIR: {{v.test_dir}}
{% endfor %}
on_failure:
do:
- get: magic-modules-new-prs
Expand Down Expand Up @@ -407,6 +424,7 @@ jobs:
CHEF_REPO_USER: GoogleCloudPlatform
CHEF_MODULES: {{','.join(vars.chef_modules)}}
{%- endif %}
TERRAFORM_VERSIONS: "{{','.join(vars.terraform_properties_serialized)}}"
on_failure:
put: magic-modules-new-prs
params:
Expand All @@ -420,9 +438,10 @@ jobs:
# the pipeline (when a PR needs to be updated), this does that updating by pushing
# the new code to the repository/branch from which a pull request is already open.
- aggregate:
- put: terraform-intermediate
{% for v in vars.terraform_v.itervalues() %}
- put: {{v.short_name}}-intermediate
params:
repository: magic-modules-with-comment/build/terraform
repository: magic-modules-with-comment/build/{{ v.short_name }}
branch_file: magic-modules-with-comment/original_pr_branch_name
# Every time a change runs through this pipeline, it will generate a commit with
# a different hash - the hash includes timestamps. Therefore, even if there's no
Expand All @@ -432,6 +451,7 @@ jobs:
# not push the update even though the commit hashes are different.
only_if_diff: true
force: true
{% endfor %}
- put: ansible-intermediate
params:
repository: magic-modules-with-comment/build/ansible
Expand Down
51 changes: 32 additions & 19 deletions .ci/magic-modules/create-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ echo "$ORIGINAL_PR_BRANCH" > ./original_pr_branch_name
BRANCH_NAME="$(git config -f .gitmodules --get submodule.build/terraform.branch)"
IFS="," read -ra PUPPET_PRODUCTS <<< "$PUPPET_MODULES"
IFS="," read -ra CHEF_PRODUCTS <<< "$CHEF_MODULES"
IFS="," read -ra TERRAFORM_VERSIONS <<< "$TERRAFORM_VERSIONS"

git checkout -b "$BRANCH_NAME"

if [ "$BRANCH_NAME" = "$ORIGINAL_PR_BRANCH" ]; then
Expand All @@ -34,22 +36,28 @@ if [ "$BRANCH_NAME" = "$ORIGINAL_PR_BRANCH" ]; then
# There is no existing PR - this is the first pass through the pipeline and
# we will need to create a PR using 'hub'.
if [ -n "$TERRAFORM_REPO_USER" ]; then
pushd build/terraform

git log -1 --pretty=%B > ./downstream_body
echo "" >> ./downstream_body
echo "<!-- This change is generated by MagicModules. -->" >> ./downstream_body
if [ -n "$ORIGINAL_PR_USER" ]; then
echo "/cc @$ORIGINAL_PR_USER" >> ./downstream_body
fi

git checkout -b "$BRANCH_NAME"
if TF_PR=$(hub pull-request -b "$TERRAFORM_REPO_USER/terraform-provider-google:2.0.0" -F ./downstream_body); then
DEPENDENCIES="${DEPENDENCIES}depends: $TF_PR ${NEWLINE}"
else
echo "Terraform - did not generate a PR."
fi
popd
for VERSION in "${TERRAFORM_VERSIONS[@]}"; do
Copy link
Contributor

Choose a reason for hiding this comment

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

I still kind of think this is a sort of false generality - the best version of generality would be a lookup from version string to provider name. I also kind of think that it's odd to special-case one out of two values here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just to confirm what this would mean in practice- having a map variable that we can do the PROVIDER_NAME/SUBMODULE_DIR/etc lookups in?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's the best implementation I can imagine, yeah. As-is, I argue we're very likely to need to change it up if we ever add an tpg-alpha, and a lookup gives us flexibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is great!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

IFS=":" read -ra TERRAFORM_DATA <<< "$VERSION"
PROVIDER_NAME="${TERRAFORM_DATA[0]}"
SUBMODULE_DIR="${TERRAFORM_DATA[1]}"

pushd build/$SUBMODULE_DIR

git log -1 --pretty=%B > ./downstream_body
echo "" >> ./downstream_body
echo "<!-- This change is generated by MagicModules. -->" >> ./downstream_body
if [ -n "$ORIGINAL_PR_USER" ]; then
echo "/cc @$ORIGINAL_PR_USER" >> ./downstream_body
fi

git checkout -b "$BRANCH_NAME"
if TF_PR=$(hub pull-request -b "$TERRAFORM_REPO_USER/$PROVIDER_NAME:2.0.0" -F ./downstream_body); then
DEPENDENCIES="${DEPENDENCIES}depends: $TF_PR ${NEWLINE}"
else
echo "$SUBMODULE_DIR - did not generate a PR."
fi
popd
done
fi

if [ -n "$ANSIBLE_REPO_USER" ]; then
Expand Down Expand Up @@ -163,9 +171,14 @@ else
git branch -f "$ORIGINAL_PR_BRANCH"

if [ -n "$TERRAFORM_REPO_USER" ]; then
pushd build/terraform
git branch -f "$ORIGINAL_PR_BRANCH"
popd
for VERSION in "${TERRAFORM_VERSIONS[@]}"; do
IFS=":" read -ra TERRAFORM_DATA <<< "$VERSION"
PROVIDER_NAME="${TERRAFORM_DATA[0]}"
SUBMODULE_DIR="${TERRAFORM_DATA[1]}"
pushd "build/$SUBMODULE_DIR"
git branch -f "$ORIGINAL_PR_BRANCH"
popd
done
fi

for PRD in "${PUPPET_PRODUCTS[@]}"; do
Expand Down
1 change: 1 addition & 0 deletions .ci/magic-modules/create-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ params:
PUPPET_MODULES: ""
CHEF_REPO_USER: ""
CHEF_MODULES: ""
TERRAFORM_VERSIONS: ""
14 changes: 7 additions & 7 deletions .ci/magic-modules/generate-terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export GOPATH="${PWD}/go"
mkdir -p "${GOPATH}/src/github.com/terraform-providers"

pushd magic-modules-branched
ln -s "${PWD}/build/terraform/" "${GOPATH}/src/github.com/terraform-providers/terraform-provider-google"
ln -s "${PWD}/build/$SHORT_NAME/" "${GOPATH}/src/github.com/terraform-providers/$PROVIDER_NAME"
popd

pushd "${GOPATH}/src/github.com/terraform-providers/terraform-provider-google"
pushd "${GOPATH}/src/github.com/terraform-providers/$PROVIDER_NAME"
go get
popd

Expand All @@ -27,17 +27,17 @@ LAST_COMMIT_AUTHOR="$(git log --pretty="%an <%ae>" -n1 HEAD)"
bundle install

# Build all terraform products
bundle exec compiler -a -e terraform -o "${GOPATH}/src/github.com/terraform-providers/terraform-provider-google/"
bundle exec compiler -a -e terraform -o "${GOPATH}/src/github.com/terraform-providers/$PROVIDER_NAME/" -v $VERSION

# This command can crash - if that happens, the script should not fail.
set +e
Copy link
Contributor

Choose a reason for hiding this comment

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

This is where you'll need to add --tag terraform-beta if you want the magician to understand differences in pr template tags.

TERRAFORM_COMMIT_MSG="$(python .ci/magic-modules/extract_from_pr_description.py --tag terraform < .git/body)"
TERRAFORM_COMMIT_MSG="$(python .ci/magic-modules/extract_from_pr_description.py --tag $SHORT_NAME < .git/body)"
set -e
if [ -z "$TERRAFORM_COMMIT_MSG" ]; then
TERRAFORM_COMMIT_MSG="Magic Modules changes."
fi

pushd "build/terraform"
pushd "build/$SHORT_NAME"
# These config entries will set the "committer".
git config --global user.email "[email protected]"
git config --global user.name "Modular Magician"
Expand All @@ -47,9 +47,9 @@ git add -A
git commit -m "$TERRAFORM_COMMIT_MSG" --author="$LAST_COMMIT_AUTHOR" || true # don't crash if no changes
git checkout -B "$(cat ../../branchname)"

apply_patches "$PATCH_DIR/terraform-providers/terraform-provider-google" "$TERRAFORM_COMMIT_MSG" "$LAST_COMMIT_AUTHOR" "2.0.0"
apply_patches "$PATCH_DIR/terraform-providers/$PROVIDER_NAME" "$TERRAFORM_COMMIT_MSG" "$LAST_COMMIT_AUTHOR" "2.0.0"

popd
popd

git clone magic-modules-branched/build/terraform ./terraform-generated
git clone magic-modules-branched/build/$SHORT_NAME ./terraform-generated/$VERSION
5 changes: 5 additions & 0 deletions .ci/magic-modules/generate-terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ outputs:

run:
path: magic-modules-branched/.ci/magic-modules/generate-terraform.sh

params:
VERSION: ""
PROVIDER_NAME: ""
SHORT_NAME: ""
17 changes: 12 additions & 5 deletions .ci/magic-modules/point-to-submodules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,18 @@ for PRD in "${PRODUCT_ARRAY[@]}"; do
done

if [ "$TERRAFORM_ENABLED" = "true" ]; then
git config -f .gitmodules submodule.build/terraform.branch "$BRANCH"
git config -f .gitmodules submodule.build/terraform.url "[email protected]:$GH_USERNAME/terraform-provider-google.git"
git submodule sync build/terraform
ssh-agent bash -c "ssh-add ~/github_private_key; git submodule update --remote --init build/terraform"
git add build/terraform
IFS="," read -ra TERRAFORM_VERSIONS <<< "$TERRAFORM_VERSIONS"
for VERSION in "${TERRAFORM_VERSIONS[@]}"; do
IFS=":" read -ra TERRAFORM_DATA <<< "$VERSION"
PROVIDER_NAME="${TERRAFORM_DATA[0]}"
SUBMODULE_DIR="${TERRAFORM_DATA[1]}"

git config -f .gitmodules "submodule.build/$SUBMODULE_DIR.branch" "$BRANCH"
git config -f .gitmodules "submodule.build/$SUBMODULE_DIR.url" "[email protected]:$GH_USERNAME/$PROVIDER_NAME.git"
git submodule sync "build/$SUBMODULE_DIR"
ssh-agent bash -c "ssh-add ~/github_private_key; git submodule update --remote --init build/$SUBMODULE_DIR"
git add "build/$SUBMODULE_DIR"
done
fi

if [ "$ANSIBLE_ENABLED" = "true" ]; then
Expand Down
1 change: 1 addition & 0 deletions .ci/magic-modules/point-to-submodules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ params:
GH_USERNAME: ""
CREDS: ""
TERRAFORM_ENABLED: false
TERRAFORM_VERSIONS: ""
ANSIBLE_ENABLED: false
INSPEC_ENABLED: false
PUPPET_MODULES: ""
Expand Down
6 changes: 3 additions & 3 deletions .ci/unit-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ set -x

# Create GOPATH structure
mkdir -p "${GOPATH}/src/github.com/terraform-providers"
ln -s "${PWD}/$1" "${GOPATH}/src/github.com/terraform-providers/terraform-provider-google"
ln -s "${PWD}/magic-modules/build/$SHORT_NAME" "${GOPATH}/src/github.com/terraform-providers/$PROVIDER_NAME"

cd "${GOPATH}/src/github.com/terraform-providers/terraform-provider-google"
cd "${GOPATH}/src/github.com/terraform-providers/$PROVIDER_NAME"

go test -v ./google -parallel 16 -run '^Test' -timeout 1m
go test -v ./$TEST_DIR -parallel 16 -run '^Test' -timeout 1m
6 changes: 4 additions & 2 deletions .ci/unit-tests/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ image_resource:
tag: '1.9.3'
run:
path: magic-modules/.ci/unit-tests/run.sh
args:
- magic-modules/build/terraform/
params:
PROVIDER_NAME: ""
SHORT_NAME: ""
TEST_DIR: ""
27 changes: 26 additions & 1 deletion .ci/vars.tmpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
{% set chef_modules = ['_bundle', 'auth', 'compute', 'sql', 'storage', 'spanner', 'container', 'dns', 'iam'] %}
{% set puppet_modules = ['_bundle', 'auth', 'bigquery', 'compute', 'sql', 'storage', 'spanner', 'container', 'dns', 'pubsub', 'resourcemanager'] %}
{% set puppet_no_release = ['bigquery'] %}
{% set terraform_v = {
'ga': {
'provider_name': 'terraform-provider-google',
'short_name': 'terraform',
'test_dir': 'google'
},
'beta': {
'provider_name': 'terraform-provider-google-beta',
'short_name': 'terraform-beta',
'test_dir': 'google-beta'
}
}
%}
{% macro names_as_list(repo, names) -%}
{% for name in names %}
build/{{repo}}/{{name}}
{%- endfor %}
{% endmacro -%}
{% macro build_folder(names) -%}
{% for name in names %}
build/{{name}}
{%- endfor %}
{% endmacro -%}
{% set puppet_submodules = names_as_list('puppet', puppet_modules).split() %}
{% set chef_submodules = names_as_list('chef', chef_modules).split() %}
{% set terraform_submodules = build_folder(terraform_v.values()|map(attribute='short_name')).split() %}
{%
set all_submodules = puppet_submodules + chef_submodules +
(['build/terraform'] + ['build/ansible'] + ['build/inspec'])
(terraform_submodules + ['build/ansible'] + ['build/inspec'])
%}
{% set all_submodules_yaml_format = '[' + ','.join(all_submodules) + ']' %}
{% set chef_test_excludes = {
Expand All @@ -37,3 +56,9 @@ build/{{repo}}/{{name}}
]
}
%}
{% macro serialize_terraform_properties(objs) -%}
{% for obj in objs %}
{{obj.provider_name}}:{{obj.short_name}}
{%- endfor %}
{% endmacro -%}
{% set terraform_properties_serialized = serialize_terraform_properties(terraform_v.values()).split() %}
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ this PR's changes from the commit messages for downstream commits.
-----------------------------------------------------------------
# [all]
## [terraform]
### [terraform-beta]
## [puppet]
### [puppet-bigquery]
### [puppet-compute]
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
[submodule "build/chef/iam"]
path = build/chef/iam
url = [email protected]:GoogleCloudPlatform/chef-google-iam.git
[submodule "build/terraform-beta"]
path = build/terraform-beta
url = [email protected]:terraform-providers/terraform-provider-google-beta.git
branch = 2.0.0
[submodule "build/inspec"]
path = build/inspec
url = [email protected]:modular-magician/inspec-gcp.git
1 change: 1 addition & 0 deletions build/terraform-beta
Submodule terraform-beta added at 2b5eb9
Loading