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

Sync Feature branch major release 5.0.0 into main #9110

Merged
merged 84 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
ccbd669
Enhance BigQuery table schema input validation (#8460)
wj-chen Jul 28, 2023
86a8657
Merge pull request #8530 from GoogleCloudPlatform/pre_tgc_beta_main
shuyama1 Aug 3, 2023
5441a1d
Merge pull request #8551 from GoogleCloudPlatform/post_tgc_beta
shuyama1 Aug 3, 2023
3427050
Breaking changes for Firebase apps deletion policy (#8458)
rainshen49 Aug 4, 2023
f3460af
Merge pull request #8552 from GoogleCloudPlatform/main_copy
shuyama1 Aug 4, 2023
a102bc6
remove deprecated (#8529)
yanweiguo Aug 8, 2023
87e4f29
Enforce mutual exclusivity among view, materialized view, and schema …
wj-chen Aug 9, 2023
2d5e1f3
Merge pull request #8599 from GoogleCloudPlatform/main_sync
shuyama1 Aug 10, 2023
a08a156
Bugfix: Use API's default value for enableEndpointIndependentMapping …
shijeesh-ns Aug 11, 2023
0fc437a
Remove dataprofileresult and dataqualityresult (#8583)
saurabh-net Aug 15, 2023
f390fc9
Add new types KeyValueLabels and KeyValueAnnotations (#8519)
zli82016 Aug 15, 2023
1ac6933
make routineType required in the BigQuery Routine resource (#8573)
wj-chen Aug 15, 2023
764e379
Add default value to metric.filter in the resource google_compute_aut…
zli82016 Aug 15, 2023
5de4e81
Modify labels fields for DCL resources (#8563)
zli82016 Aug 15, 2023
f94c19d
remove deprecated fields (#8531)
gfxcc Aug 16, 2023
74d45a2
Modify labels field for some handwritten resources (#8579)
zli82016 Aug 17, 2023
5b240fd
Remove Terraform support for game services (#8669)
hao-nan-li Aug 18, 2023
9750a64
resolve conflicts
shuyama1 Aug 23, 2023
7d4ce17
Use base branch for pre-build validation merge (#8748)
ScottSuarez Aug 23, 2023
91bbdc5
fix yaml lint errors
shuyama1 Aug 23, 2023
ac90779
added back Datascan changes
shuyama1 Aug 24, 2023
85f270d
Merge pull request #8747 from GoogleCloudPlatform/main_sync
shuyama1 Aug 24, 2023
636e9ca
Merge pull request #8785 from GoogleCloudPlatform/main_sync
shuyama1 Aug 29, 2023
086a67c
Make SQL database flags a set (#8118)
smcgivern Aug 30, 2023
415c90d
Mark `num_finite_buckets` required for cloud logging metric bucket_op…
pengq-google Aug 30, 2023
2afc9e6
Remove default value for rule.rate_limit_options.encorce_on_key on re…
hao-nan-li Aug 30, 2023
ae21b64
Display default provider values at plan-time (#8569)
NickElliot Sep 1, 2023
a8cc8aa
resolve conflicts
shuyama1 Sep 6, 2023
8fc61a4
Remove cloud iot service (#8868)
zli82016 Sep 6, 2023
bf3f834
Add provider default labels (#8670)
zli82016 Sep 6, 2023
9884248
Merge branch 'FEATURE-BRANCH-major-release-5.0.0' into main_sync
shuyama1 Sep 6, 2023
fb61cfb
Change the default value of unique_writer_identity in resource loggin…
pengq-google Sep 6, 2023
88e50fc
Merge branch 'FEATURE-BRANCH-major-release-5.0.0' into main_sync
shuyama1 Sep 6, 2023
723cf2c
Merge pull request #8855 from GoogleCloudPlatform/main_sync
shuyama1 Sep 7, 2023
665f32f
Change several fields in Access Context Manager from list to set (#8788)
Charlesleonius Sep 7, 2023
1a3c02a
Use Create instead of Patch to create google_service_networking_conne…
zli82016 Sep 7, 2023
85bf78e
Remove firebase_project_location (#8783)
rainshen49 Sep 7, 2023
186acac
Don't override Terraform unmanaged labels (#8881)
zli82016 Sep 7, 2023
df9725a
existing Data Sources now return errors on 404s (#8858)
NickElliot Sep 11, 2023
acdfd68
Make `location` required on `google_cloudfunctions2_function` (#8928)
ScottSuarez Sep 12, 2023
ccc68de
Transitioned `volumes.cloud_sql_instance.instances` to SET from array…
ScottSuarez Sep 12, 2023
75dcc62
Support provider default labels for DCL resources (#8893)
zli82016 Sep 13, 2023
b19359c
resolve conflicts
shuyama1 Sep 13, 2023
ffda752
resolve more conflicts
shuyama1 Sep 14, 2023
11a4b1c
Merge pull request #8945 from GoogleCloudPlatform/main_sync
shuyama1 Sep 14, 2023
a63b21f
Removed the `automatic` field from the `google_secret_manager_secret`…
abheda-crest Sep 15, 2023
dbd00e3
Apply new annotations model to more resources (#8931)
zli82016 Sep 15, 2023
1a32f8d
remove container cluster `enable_binary_authorization` (#8784)
c2thorn Sep 15, 2023
0ef602f
Apply new labels model to more resources (part 1) (#8950)
zli82016 Sep 15, 2023
912551f
Breaking change: Stop deleting failed GKE clusters, taint instead (#8…
rileykarson Sep 18, 2023
d6b01a2
Apply new labels model to more resources (part 2) (#8980)
zli82016 Sep 18, 2023
34cf135
Apply provider default labels to handwritten resources (#8966)
zli82016 Sep 18, 2023
194578c
Merge branch 'FEATURE-BRANCH-major-release-5.0.0' into main_sync
shuyama1 Sep 19, 2023
14abe60
Apply new labels model to more resources (part 3) (#9000)
zli82016 Sep 19, 2023
259b2da
Merge pull request #9006 from GoogleCloudPlatform/main_sync
shuyama1 Sep 20, 2023
4f06425
Default ReconcileConnections from service attachment API (#9026)
bobyu-google Sep 20, 2023
4a03c32
remove container network policy provider default (#8965)
c2thorn Sep 20, 2023
7bef6de
Change container node pool defaults (#8967)
c2thorn Sep 21, 2023
a98d8fb
Fix failed tests related to google_service_networking_connection (#8904)
zli82016 Sep 21, 2023
63fe377
Unblock Feature branch by no merging main if BASE_BRANCH != main (#9040)
ScottSuarez Sep 21, 2023
4aa41b7
Check if labels field exists in customDiff function (#9043)
zli82016 Sep 22, 2023
e225a61
Fix Inconsistent logic when getting zone/region/location (#8587)
BBBmau Sep 22, 2023
83df041
Unignore empty values in the `provider` configuration block in 5.0.0 …
SarahFrench Sep 22, 2023
6374511
Sync 5.0.0 with main (#9039)
c2thorn Sep 22, 2023
756e2d9
Update Instance.yaml to remove LOOKER_MODELER edition (#9033)
efeelaiho Sep 22, 2023
fe50764
Make labels field have all labels in data sources (#9037)
zli82016 Sep 22, 2023
c896b46
Breaking change: Rework taint model in GKE (#9011)
rileykarson Sep 22, 2023
18480ba
update google_dataflow_flex_template_job to send sdkpipeline paramete…
NickElliot Sep 22, 2023
99bfccd
Add validation to provider fields in both SDK and PF implementations …
SarahFrench Sep 23, 2023
ca2f0da
Labels state upgrader (#8996)
zli82016 Sep 23, 2023
6cdbf4d
Update to wrap generated import format regex in ^ and $ (#8913)
NickElliot Sep 25, 2023
f190b2c
Change `consumer_accept_lists` to a set (#9058)
c2thorn Sep 25, 2023
f3f7fb0
Make `google_monitoring_metric_descriptor.labels` ForceNew (#8914)
c2thorn Sep 25, 2023
fc2e34e
5.0.0 - Upgrade DCL to 1.52 (#9055)
c2thorn Sep 25, 2023
e59be4f
Labels compute instance template (#9051)
zli82016 Sep 25, 2023
e19357f
improve autoscaling_policy support in google_compute_node_group (#9044)
NickElliot Sep 26, 2023
2257c19
Disable delete for bare metal admin cluster resource (#8823)
naitianliu-google Sep 26, 2023
887cf20
Add deletion_protection to container cluster (#9013)
c2thorn Sep 26, 2023
262bbe6
5.0.0 - remove computed keys from JSON in monitoring dashboard (#9065)
c2thorn Sep 26, 2023
1155209
Apply new labels model to google_gke_backup_restore_plan (#9093)
zli82016 Sep 26, 2023
a6dcbbc
Merge branch 'FEATURE-BRANCH-major-release-5.0.0' into main_sync
c2thorn Sep 27, 2023
9e3193c
remove alloydb backup test overrides
c2thorn Sep 27, 2023
b4e3fd4
Merge pull request #9107 from GoogleCloudPlatform/main_sync
shuyama1 Sep 27, 2023
d7c4745
Temporary fix for TGC tests (#9116)
c2thorn Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
76 changes: 38 additions & 38 deletions .ci/gcb-generate-diffs-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,45 +202,45 @@ steps:
- "17" # Build step # remove after 08/2023
- terraform-google-conversion # remove after 08/2023

- name: 'gcr.io/graphite-docker-images/go-plus'
id: tgc-test-integration-0.12.31
entrypoint: '/workspace/.ci/scripts/go-plus/tgc-tester-integration/test_tgc_integration.sh'
allowFailure: true
secretEnv: ["GITHUB_TOKEN"]
waitFor: ["tpgb-head", "tpgb-base", "tgc-head", "tgc-base"]
env:
- TERRAFORM_VERSION=0.12.31
- TEST_PROJECT=$_VALIDATOR_TEST_PROJECT
- TEST_FOLDER_ID=$_VALIDATOR_TEST_FOLDER
- TEST_ANCESTRY=$_VALIDATOR_TEST_ANCESTRY
- TEST_ORG_ID=$_VALIDATOR_TEST_ORG
args:
- $_PR_NUMBER
- $COMMIT_SHA
- $BUILD_ID
- $PROJECT_ID
- "18" # Build step
- terraform-google-conversion
# - name: 'gcr.io/graphite-docker-images/go-plus'
# id: tgc-test-integration-0.12.31
# entrypoint: '/workspace/.ci/scripts/go-plus/terraform-validator-tester-integration/test_terraform_validator_integration.sh'
# allowFailure: true
# secretEnv: ["GITHUB_TOKEN"]
# waitFor: ["tpgb-head", "tpgb-base", "tgc-head", "tgc-base"]
# env:
# - TERRAFORM_VERSION=0.12.31
# - TEST_PROJECT=$_VALIDATOR_TEST_PROJECT
# - TEST_FOLDER_ID=$_VALIDATOR_TEST_FOLDER
# - TEST_ANCESTRY=$_VALIDATOR_TEST_ANCESTRY
# - TEST_ORG_ID=$_VALIDATOR_TEST_ORG
# args:
# - $_PR_NUMBER
# - $COMMIT_SHA
# - $BUILD_ID
# - $PROJECT_ID
# - "18" # Build step
# - terraform-google-conversion

- name: 'gcr.io/graphite-docker-images/go-plus'
id: tgc-test-integration-0.13.7
entrypoint: '/workspace/.ci/scripts/go-plus/tgc-tester-integration/test_tgc_integration.sh'
allowFailure: true
secretEnv: ["GITHUB_TOKEN"]
waitFor: ["tpgb-head", "tpgb-base", "tgc-head", "tgc-base"]
env:
- TERRAFORM_VERSION=0.13.7
- TEST_PROJECT=$_VALIDATOR_TEST_PROJECT
- TEST_FOLDER_ID=$_VALIDATOR_TEST_FOLDER
- TEST_ANCESTRY=$_VALIDATOR_TEST_ANCESTRY
- TEST_ORG_ID=$_VALIDATOR_TEST_ORG
args:
- $_PR_NUMBER
- $COMMIT_SHA
- $BUILD_ID
- $PROJECT_ID
- "19" # Build step
- terraform-google-conversion
# - name: 'gcr.io/graphite-docker-images/go-plus'
# id: tgc-test-integration-0.13.7
# entrypoint: '/workspace/.ci/scripts/go-plus/terraform-validator-tester-integration/test_terraform_validator_integration.sh'
# allowFailure: true
# secretEnv: ["GITHUB_TOKEN"]
# waitFor: ["tpgb-head", "tpgb-base", "tgc-head", "tgc-base"]
# env:
# - TERRAFORM_VERSION=0.13.7
# - TEST_PROJECT=$_VALIDATOR_TEST_PROJECT
# - TEST_FOLDER_ID=$_VALIDATOR_TEST_FOLDER
# - TEST_ANCESTRY=$_VALIDATOR_TEST_ANCESTRY
# - TEST_ORG_ID=$_VALIDATOR_TEST_ORG
# args:
# - $_PR_NUMBER
# - $COMMIT_SHA
# - $BUILD_ID
# - $PROJECT_ID
# - "19" # Build step
# - terraform-google-conversion

- name: 'gcr.io/graphite-docker-images/go-plus'
id: tpgb-test
Expand Down
1 change: 0 additions & 1 deletion .ci/infra/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ module "project-services" {
"firebasestorage.googleapis.com",
"firestore.googleapis.com",
"firestorekeyvisualizer.googleapis.com",
"gameservices.googleapis.com",
"gkebackup.googleapis.com",
"gkeconnect.googleapis.com",
"gkehub.googleapis.com",
Expand Down
119 changes: 117 additions & 2 deletions mmv1/api/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ module Properties
# mmv1/templates/terraform/state_migrations/
# used for maintaining state stability with resources first provisioned on older api versions.
attr_reader :schema_version
# From this schema version on, state_upgrader code is generated for the resource.
# When unset, state_upgrade_base_schema_version defauts to 0.
# Normally, it is not needed to be set.
attr_reader :state_upgrade_base_schema_version
attr_reader :state_upgraders
# This block inserts the named function and its attribute into the
# resource schema -- the code for the migrate_state function must
Expand All @@ -217,6 +221,10 @@ module Properties
# public ca external account keys
attr_reader :skip_read

# Set to true for resources that wish to disable automatic generation of default provider
# value customdiff functions
attr_reader :skip_default_cdiff

# This enables resources that get their project via a reference to a different resource
# instead of a project field to use User Project Overrides
attr_reader :supports_indirect_user_project_override
Expand Down Expand Up @@ -318,10 +326,12 @@ def validate
check :error_retry_predicates, type: Array, item_type: String
check :error_abort_predicates, type: Array, item_type: String
check :schema_version, type: Integer
check :state_upgrade_base_schema_version, type: Integer, default: 0
check :state_upgraders, type: :boolean, default: false
check :migrate_state, type: String
check :skip_delete, type: :boolean, default: false
check :skip_read, type: :boolean, default: false
check :skip_default_cdiff, type: :boolean, default: false
check :supports_indirect_user_project_override, type: :boolean, default: false
check :legacy_long_form_project, type: :boolean, default: false
check :read_error_transform, type: String
Expand All @@ -342,6 +352,10 @@ def all_properties
((@properties || []) + (@parameters || []))
end

def properties_with_excluded
@properties || []
end

def properties
(@properties || []).reject(&:exclude)
end
Expand Down Expand Up @@ -385,8 +399,13 @@ def all_resourcerefs
# At Create, they have no value but they can just be read in anyways, and after a Read
# they will need to be set in every Update.
def settable_properties
all_user_properties.reject { |v| v.output && !v.is_a?(Api::Type::Fingerprint) }
.reject(&:url_param_only)
props = all_user_properties.reject do |v|
v.output && !v.is_a?(Api::Type::Fingerprint) && !v.is_a?(Api::Type::KeyValueEffectiveLabels)
end
props = props.reject(&:url_param_only)
props.reject do |v|
v.is_a?(Api::Type::KeyValueLabels) || v.is_a?(Api::Type::KeyValueAnnotations)
end
end

# Properties that will be returned in the API body
Expand Down Expand Up @@ -439,6 +458,102 @@ def decoder?
!@transport&.decoder.nil?
end

def add_labels_related_fields(props, parent)
props.each do |p|
if p.is_a? Api::Type::KeyValueLabels
add_labels_fields(props, parent, p)
elsif p.is_a? Api::Type::KeyValueAnnotations
add_annotations_fields(props, parent, p)
elsif (p.is_a? Api::Type::NestedObject) && !p.all_properties.nil?
p.properties = add_labels_related_fields(p.all_properties, p)
end
end
props
end

def add_labels_fields(props, parent, labels)
# The effective_labels field is used to write to API, instead of the labels field.
labels.ignore_write = true
labels.description = "#{labels.description}\n\n#{get_labels_field_note(labels.name)}"

@custom_diff ||= []
if parent.nil? || parent.flatten_object
@custom_diff.append('tpgresource.SetLabelsDiff')
elsif parent.name == 'metadata'
@custom_diff.append('tpgresource.SetMetadataLabelsDiff')
end

props << build_terraform_labels_field('labels', labels.field_min_version)
props << build_effective_labels_field('labels', labels)
end

def add_annotations_fields(props, parent, annotations)
# The effective_annotations field is used to write to API,
# instead of the annotations field.
annotations.ignore_write = true

@custom_diff ||= []
if parent.nil?
@custom_diff.append('tpgresource.SetAnnotationsDiff')
elsif parent.name == 'metadata'
@custom_diff.append('tpgresource.SetMetadataAnnotationsDiff')
end

props << build_effective_labels_field('annotations', annotations)
end

def build_effective_labels_field(name, labels)
description = "All of #{name} (key/value pairs)\
present on the resource in GCP, including the #{name} configured through Terraform,\
other clients and services."

Api::Type::KeyValueEffectiveLabels.new(
name: "effective#{name.capitalize}",
output: true,
api_name: name,
description:,
min_version: labels.field_min_version,
update_verb: labels.update_verb,
update_url: labels.update_url,
immutable: labels.immutable
)
end

def build_terraform_labels_field(name, min_version)
description = "The combination of #{name} configured directly on the resource
and default #{name} configured on the provider."

Api::Type::KeyValueTerraformLabels.new(
name: "terraform#{name.capitalize}",
output: true,
api_name: name,
description:,
min_version:,
ignore_write: true
)
end

# Return labels fields that should be added to ImportStateVerifyIgnore
def ignore_read_labels_fields(props)
fields = []
props.each do |p|
if (p.is_a? Api::Type::KeyValueLabels) ||
(p.is_a? Api::Type::KeyValueTerraformLabels) ||
(p.is_a? Api::Type::KeyValueAnnotations)
fields << p.terraform_lineage
elsif (p.is_a? Api::Type::NestedObject) && !p.all_properties.nil?
fields.concat(ignore_read_labels_fields(p.all_properties))
end
end
fields
end

def get_labels_field_note(title)
"**Note**: This field is non-authoritative, and will only manage the #{title} present " \
"in your configuration.
Please refer to the field `effective_#{title}` for all of the #{title} present on the resource."
end

# ====================
# Version-related methods
# ====================
Expand Down
70 changes: 69 additions & 1 deletion mmv1/api/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Fields
include Api::Object::Named::Properties

attr_reader :default_value
attr_reader :description
attr_accessor :description
attr_reader :exclude

# Add a deprecation message for a field that's been deprecated in the API
Expand Down Expand Up @@ -266,6 +266,14 @@ def lineage
"#{__parent.lineage}.#{name&.underscore}"
end

# Prints the access path of the field in the configration eg: metadata.0.labels
# The only intended purpose is to get the value of the labes field by calling d.Get().
def terraform_lineage
return name&.underscore if __parent.nil? || __parent.flatten_object

"#{__parent.terraform_lineage}.0.#{name&.underscore}"
end

def to_json(opts = nil)
# ignore fields that will contain references to parent resources and
# those which will be added later
Expand Down Expand Up @@ -728,6 +736,8 @@ def properties
@properties.reject(&:exclude)
end

attr_writer :properties

def nested_properties
properties
end
Expand Down Expand Up @@ -755,6 +765,64 @@ def exclude_if_not_in_version!(version)
# simpler property to generate and means we can avoid conditional logic
# in Map.
class KeyValuePairs < Composite
# Ignore writing the "effective_labels" and "effective_annotations" fields to API.
attr_accessor :ignore_write

def initialize(name: nil, output: nil, api_name: nil, description: nil, min_version: nil,
ignore_write: nil, update_verb: nil, update_url: nil, immutable: nil)
super()

@name = name
@output = output
@api_name = api_name
@description = description
@min_version = min_version
@ignore_write = ignore_write
@update_verb = update_verb
@update_url = update_url
@immutable = immutable
end

def validate
super
check :ignore_write, type: :boolean, default: false
end

def field_min_version
@min_version
end
end

# An array of string -> string key -> value pairs used specifically for the "labels" field.
# The field name with this type should be "labels" literally.
class KeyValueLabels < KeyValuePairs
def validate
super
return unless @name != 'labels'

raise "The field #{name} has the type KeyValueLabels, but the field name is not 'labels'!"
end
end

# An array of string -> string key -> value pairs used for the "terraform_labels" field.
class KeyValueTerraformLabels < KeyValuePairs
end

# An array of string -> string key -> value pairs used for the "effective_labels"
# and "effective_annotations" fields.
class KeyValueEffectiveLabels < KeyValuePairs
end

# An array of string -> string key -> value pairs used specifically for the "annotations" field.
# The field name with this type should be "annotations" literally.
class KeyValueAnnotations < KeyValuePairs
def validate
super
return unless @name != 'annotations'

raise "The field #{name} has the type KeyValueAnnotations,\
but the field name is not 'annotations'!"
end
end

# Map from string keys -> nested object entries
Expand Down
3 changes: 3 additions & 0 deletions mmv1/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@
end
res_yaml = File.read(file_path)
resource = Api::Compiler.new(res_yaml).run
resource.properties = resource.add_labels_related_fields(
resource.properties_with_excluded, nil
)
resource.validate
resources.push(resource)
end
Expand Down
Loading
Loading