Skip to content

Commit

Permalink
Merge branch 'GoogleCloudPlatform:main' into network-policy-ga
Browse files Browse the repository at this point in the history
  • Loading branch information
swamitagupta authored Nov 22, 2023
2 parents 53a76c5 + 5365d2d commit f527f17
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,90 +98,29 @@ elif [ "$COMMAND" == "downstream" ]; then
COMMIT_MESSAGE="$ORIGINAL_MESSAGE$NEWLINE[upstream:$REFERENCE]"
fi

if [ "$COMMAND" == "base" ]; then
pushd mmv1
if [ "$REPO" == "terraform" ]; then
pushd $LOCAL_PATH
go mod download
find . -type f -not -wholename "./.git*" -not -wholename "./.changelog*" -not -name ".travis.yml" -not -name ".golangci.yml" -not -name "CHANGELOG.md" -not -name "CHANGELOG_v*.md" -not -name "GNUmakefile" -not -name "docscheck.sh" -not -name "LICENSE" -not -name "README.md" -not -wholename "./examples*" -not -name ".go-version" -not -name ".hashibot.hcl" -print0 | xargs -0 git rm
popd
fi

if [ "$REPO" == "terraform-google-conversion" ]; then
# Generate tfplan2cai
pushd $LOCAL_PATH
# clear out the templates as they are copied during
# generation from mmv1/third_party/validator/tests/data
rm -rf ./tfplan2cai/testdata/templates/
rm -rf ./tfplan2cai/testdata/generatedconvert/
rm -rf ./tfplan2cai/converters/google/provider
rm -rf ./tfplan2cai/converters/google/resources
find ./tfplan2cai/test/** -type f -exec git rm {} \;
popd

bundle exec compiler.rb -a -e terraform -f validator -o $LOCAL_PATH/tfplan2cai -v $VERSION

# Generate cai2hcl
pushd $LOCAL_PATH
rm -rf ./cai2hcl/*
popd

bundle exec compiler.rb -a -e terraform -f tgc_cai2hcl -o $LOCAL_PATH/cai2hcl -v $VERSION

if [ "$COMMAND" == "downstream" ]; then
pushd $LOCAL_PATH
go get -d github.com/hashicorp/terraform-provider-google-beta@$BASE_BRANCH
go mod tidy
set +e
make build
set -e
popd
fi
elif [ "$REPO" == "tf-oics" ]; then
# use terraform generator with oics override
bundle exec compiler.rb -a -e terraform -f oics -o $LOCAL_PATH -v $VERSION
else
if [ "$REPO" == "terraform" ]; then
if [ "$VERSION" == "ga" ]; then
bundle exec compiler.rb -a -e $REPO -o $LOCAL_PATH -v $VERSION --no-docs
bundle exec compiler.rb -a -e $REPO -o $LOCAL_PATH -v beta --no-code
else
bundle exec compiler.rb -a -e $REPO -o $LOCAL_PATH -v $VERSION
fi
pushd ../
make tpgtools OUTPUT_PATH=$LOCAL_PATH VERSION=$VERSION

# Only generate TeamCity-related file for TPG and TPGB
if [ "$VERSION" == "ga" ] || [ "$VERSION" == "beta" ]; then
make teamcity-servicemap-generate OUTPUT_PATH=$LOCAL_PATH VERSION=$VERSION
fi
popd
fi
fi
popd
else
if [ "$REPO" == "terraform-google-conversion" ]; then
make clean-tgc OUTPUT_PATH="$LOCAL_PATH"
make tgc OUTPUT_PATH="$LOCAL_PATH"

if [ "$COMMAND" == "downstream" ]; then
pushd $LOCAL_PATH
go get -d github.com/hashicorp/terraform-provider-google-beta@$BASE_BRANCH
go mod tidy
set +e
make build
set -e
popd
fi
elif [ "$REPO" == "tf-oics" ]; then
# use terraform generator with oics override
make tf-oics OUTPUT_PATH="$LOCAL_PATH"
elif [ "$REPO" == "terraform" ]; then
make clean-provider OUTPUT_PATH="$LOCAL_PATH"
make provider OUTPUT_PATH="$LOCAL_PATH" VERSION=$VERSION
if [ "$REPO" == "terraform-google-conversion" ]; then
make clean-tgc OUTPUT_PATH="$LOCAL_PATH"
make tgc OUTPUT_PATH="$LOCAL_PATH"

if [ "$COMMAND" == "downstream" ]; then
pushd $LOCAL_PATH
go get -d github.com/hashicorp/terraform-provider-google-beta@$BASE_BRANCH
go mod tidy
set +e
make build
set -e
popd
fi
elif [ "$REPO" == "tf-oics" ]; then
# use terraform generator with oics override
make tf-oics OUTPUT_PATH="$LOCAL_PATH"
elif [ "$REPO" == "terraform" ]; then
make clean-provider OUTPUT_PATH="$LOCAL_PATH"
make provider OUTPUT_PATH="$LOCAL_PATH" VERSION=$VERSION
fi


pushd $LOCAL_PATH

git config --local user.name "Modular Magician"
Expand Down
19 changes: 15 additions & 4 deletions mmv1/products/datastream/ConnectionProfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,21 @@ examples:
vars:
connection_profile_id: 'my-profile'
- !ruby/object:Provider::Terraform::Examples
name: 'datastream_connection_profile_bigquery_private_connection'
name: 'datastream_connection_profile_postgresql_private_connection'
pull_external: true
primary_resource_id: 'default'
# Random provider
skip_vcr: true
vars:
private_connection_id: 'my-connection'
connection_profile_id: 'my-profile'
network_name: 'my-network'
database_instance_name: 'my-instance'
deletion_protection: 'true'
test_vars_overrides:
deletion_protection: 'false'
oics_vars_overrides:
deletion_protection: 'false'
- !ruby/object:Provider::Terraform::Examples
name: 'datastream_connection_profile_full'
primary_resource_id:
Expand All @@ -57,9 +66,11 @@ examples:
vars:
connection_profile_id: 'my-profile'
database_instance_name: 'my-instance'
deletion_protection:
'true'
# This is covered by the update tests.
deletion_protection: 'true'
test_vars_overrides:
deletion_protection: 'false'
oics_vars_overrides:
deletion_protection: 'false'
skip_test: true
parameters:
- !ruby/object:Api::Type::String
Expand Down
7 changes: 6 additions & 1 deletion mmv1/products/datastream/Stream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ examples:
destination_connection_profile_id: 'destination-profile'
test_vars_overrides:
deletion_protection: 'false'
oics_vars_overrides:
deletion_protection: 'false'
- !ruby/object:Provider::Terraform::Examples
name: 'datastream_stream_full'
pull_external: true
Expand All @@ -87,6 +89,8 @@ examples:
test_vars_overrides:
deletion_protection: 'false'
stream_cmek: 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name'
oics_vars_overrides:
deletion_protection: 'false'
- !ruby/object:Provider::Terraform::Examples
name: 'datastream_stream_postgresql'
primary_resource_id: 'default'
Expand Down Expand Up @@ -136,7 +140,8 @@ examples:
deletion_protection: 'false'
bigquery_destination_table_kms_key_name:
'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name'

oics_vars_overrides:
deletion_protection: 'false'
parameters:
- !ruby/object:Api::Type::String
name: streamId
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
resource "google_datastream_private_connection" "private_connection" {
display_name = "Connection profile"
location = "us-central1"
private_connection_id = "<%= ctx[:vars]['private_connection_id'] %>"

labels = {
key = "value"
}

vpc_peering_config {
vpc = google_compute_network.default.id
subnet = "10.0.0.0/29"
}
}

resource "google_compute_network" "default" {
name = "<%= ctx[:vars]['network_name'] %>"
}

resource "google_sql_database_instance" "instance" {
name = "<%= ctx[:vars]['database_instance_name'] %>"
database_version = "POSTGRES_14"
region = "us-central1"
settings {
tier = "db-f1-micro"

ip_configuration {

// Datastream IPs will vary by region.
authorized_networks {
value = "34.71.242.81"
}

authorized_networks {
value = "34.72.28.29"
}

authorized_networks {
value = "34.67.6.157"
}

authorized_networks {
value = "34.67.234.134"
}

authorized_networks {
value = "34.72.239.218"
}
}
}

deletion_protection = "<%= ctx[:vars]['deletion_protection'] %>"
}

resource "google_sql_database" "db" {
instance = google_sql_database_instance.instance.name
name = "db"
}

resource "random_password" "pwd" {
length = 16
special = false
}

resource "google_sql_user" "user" {
name = "user"
instance = google_sql_database_instance.instance.name
password = random_password.pwd.result
}

resource "google_datastream_connection_profile" "<%= ctx[:primary_resource_id] %>" {
display_name = "Connection profile"
location = "us-central1"
connection_profile_id = "<%= ctx[:vars]['connection_profile_id'] %>"

postgresql_profile {
hostname = google_sql_database_instance.instance.public_ip_address
username = google_sql_user.user.name
password = google_sql_user.user.password
database = google_sql_database.db.name
}

private_connectivity {
private_connection = google_datastream_private_connection.private_connection.id
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ resource "google_datastream_stream" "<%= ctx[:primary_resource_id] %>" {
ordinal_position = 0
}
}
mysql_tables {
table = "includedTable_2"
}
}
}
exclude_objects {
Expand Down

0 comments on commit f527f17

Please sign in to comment.