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

Allow redisVersion to change, promoted some fields to GA #4838

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 0 additions & 8 deletions mmv1/products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1693,9 +1693,6 @@ objects:
# TODO: make a ResourceRef to Security Policy
- !ruby/object:Api::Type::String
name: 'securityPolicy'
update_verb: :POST
update_url:
'projects/{{project}}/global/backendServices/{{name}}/setSecurityPolicy'
description: |
The security policy associated with this backend service.
- !ruby/object:Api::Type::Enum
Expand Down Expand Up @@ -9208,8 +9205,6 @@ objects:
- !ruby/object:Api::Type::NestedObject
name: 'preservedState'
description: 'The preserved state for this instance.'
update_verb: :POST
update_url: 'projects/{{project}}/zones/{{zone}}/instanceGroupManagers/{{instance_group_manager}}/updatePerInstanceConfigs'
properties:
- !ruby/object:Api::Type::KeyValuePairs
name: 'metadata'
Expand Down Expand Up @@ -9329,7 +9324,6 @@ objects:
name: 'preservedState'
description: 'The preserved state for this instance.'
update_verb: :POST
update_url: 'projects/{{project}}/regions/{{region}}/instanceGroupManagers/{{region_instance_group_manager}}/updatePerInstanceConfigs'
properties:
- !ruby/object:Api::Type::KeyValuePairs
name: 'metadata'
Expand Down Expand Up @@ -18406,8 +18400,6 @@ objects:
the BackendService. The protocol field in the BackendService
must be set to GRPC.
input: true
update_verb: :PATCH
update_url: projects/{{project}}/global/targetGrpcProxies
update_id: 'urlMap'
fingerprint_name: 'fingerprint'
- !ruby/object:Api::Type::Boolean
Expand Down
11 changes: 0 additions & 11 deletions mmv1/products/healthcare/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ objects:
input: true
- !ruby/object:Api::Type::String
name: "timeZone"
update_url: 'projects/{{project}}/locations/{{location}}/datasets/{{name}}'
description: |
The default timezone used by this dataset. Must be a either a valid IANA time zone name such as
"America/New_York" or empty, which defaults to UTC. This is used for parsing times in resources
Expand Down Expand Up @@ -110,7 +109,6 @@ objects:
- !ruby/object:Api::Type::KeyValuePairs
name: labels
required: false
update_url: '{{dataset}}/dicomStores/{{name}}'
description: |
User-supplied key-value pairs used to organize DICOM stores.

Expand All @@ -128,7 +126,6 @@ objects:
- !ruby/object:Api::Type::NestedObject
name: notificationConfig
required: false
update_url: '{{dataset}}/dicomStores/{{name}}'
properties:
- !ruby/object:Api::Type::String
name: pubsubTopic
Expand Down Expand Up @@ -156,7 +153,6 @@ objects:
name: streamConfigs
required: false
min_version: beta
update_url: '{{dataset}}/dicomStores/{{name}}'
description: |
To enable streaming to BigQuery, configure the streamConfigs object in your DICOM store.
streamConfigs is an array, so you can specify multiple BigQuery destinations. You can stream metadata from a single DICOM store to up to five BigQuery tables in a BigQuery dataset.
Expand Down Expand Up @@ -243,7 +239,6 @@ objects:
identifiers, those IDs will be part of the FHIR resource path recorded in Cloud audit logs and Cloud Pub/Sub
notifications.
required: false
update_url: '{{dataset}}/fhirStores/{{name}}'
- !ruby/object:Api::Type::Boolean
name: 'disableReferentialIntegrity'
description: |
Expand Down Expand Up @@ -284,7 +279,6 @@ objects:
- !ruby/object:Api::Type::KeyValuePairs
name: labels
required: false
update_url: '{{dataset}}/fhirStores/{{name}}'
description: |
User-supplied key-value pairs used to organize FHIR stores.

Expand All @@ -302,7 +296,6 @@ objects:
- !ruby/object:Api::Type::NestedObject
name: notificationConfig
required: false
update_url: '{{dataset}}/fhirStores/{{name}}'
properties:
- !ruby/object:Api::Type::String
name: pubsubTopic
Expand Down Expand Up @@ -420,7 +413,6 @@ objects:
- !ruby/object:Api::Type::NestedObject
name: parserConfig
required: false
update_url: '{{dataset}}/hl7V2Stores/{{name}}'
properties:
- !ruby/object:Api::Type::Boolean
name: allowNullHeader
Expand Down Expand Up @@ -463,7 +455,6 @@ objects:
- !ruby/object:Api::Type::KeyValuePairs
name: labels
required: false
update_url: '{{dataset}}/hl7V2Stores/{{name}}'
description: |
User-supplied key-value pairs used to organize HL7v2 stores.

Expand Down Expand Up @@ -516,7 +507,6 @@ objects:
removed_message: This field has been replaced by notificationConfigs
exact_version: ga
required: false
update_url: '{{dataset}}/hl7V2Stores/{{name}}'
properties:
- !ruby/object:Api::Type::String
name: pubsubTopic
Expand All @@ -534,7 +524,6 @@ objects:
deprecation_message: This field has been replaced by notificationConfigs
exact_version: beta
required: false
update_url: '{{dataset}}/hl7V2Stores/{{name}}'
properties:
- !ruby/object:Api::Type::String
name: pubsubTopic
Expand Down
3 changes: 0 additions & 3 deletions mmv1/products/redis/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ objects:
- REDIS_5_0 for Redis 5.0 compatibility
- REDIS_4_0 for Redis 4.0 compatibility
- REDIS_3_2 for Redis 3.2 compatibility
input: true
- !ruby/object:Api::Type::String
name: reservedIpRange
description: |
Expand All @@ -192,7 +191,6 @@ objects:
input: true
- !ruby/object:Api::Type::Enum
name: transitEncryptionMode
min_version: beta
input: true
description: |
The TLS mode of the Redis instance, If not provided, TLS is disabled for the instance.
Expand All @@ -204,7 +202,6 @@ objects:
default_value: :DISABLED
- !ruby/object:Api::Type::Array
name: 'serverCaCerts'
min_version: beta
description: |
List of server CA certificates for the instance.
output: true
Expand Down
4 changes: 4 additions & 0 deletions mmv1/products/redis/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
encoder: templates/terraform/encoders/redis_location_id_for_fallback_zone.go.erb
decoder: templates/terraform/decoders/redis_instance.go.erb
extra_schema_entry: templates/terraform/extra_schema_entry/redis_instance.erb
constants: templates/terraform/constants/redis_version.go
resource_definition: templates/terraform/resource_definition/redis_instance.erb
examples:
- !ruby/object:Provider::Terraform::Examples
name: "redis_instance_basic"
Expand Down Expand Up @@ -67,6 +69,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
regex: '^[a-z][a-z0-9-]{0,39}[a-z0-9]$'
redisVersion: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
update_url: 'projects/{{project}}/locations/{{region}}/instances/{{name}}:upgrade'
update_verb: :POST
region: !ruby/object:Overrides::Terraform::PropertyOverride
ignore_read: true
required: false
Expand Down
16 changes: 16 additions & 0 deletions mmv1/provider/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ def build_env
}
end

# used to determine and separate objects that have update methods
# that target individual fields
def field_specific_update_methods(properties)
properties_by_custom_update(properties).length.positive?
end

# Filter the properties to keep only the ones requiring custom update
# method and group them by update url & verb.
def properties_by_custom_update(properties, behavior = :new)
Expand All @@ -325,6 +331,16 @@ def properties_by_custom_update(properties, behavior = :new)
end
end

# Filter the properties to keep only the ones don't have custom update
# method and group them by update url & verb.
def properties_without_custom_update(properties)
update_props = properties.select do |p|
p.update_url.nil? || p.update_verb.nil? || p.update_verb == :NOOP
end

update_props
end

# Takes a update_url and returns the list of custom updatable properties
# that can be updated at that URL. This allows flattened objects
# to determine which parent property in the API should be updated with
Expand Down
30 changes: 30 additions & 0 deletions mmv1/templates/terraform/constants/redis_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

// Is the new redis version less than the old one?
func isRedisVersionDecreasing(_ context.Context, old, new, _ interface{}) bool {
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
return isRedisVersionDecreasingFunc(old, new)
}

// separate function for unit testing
func isRedisVersionDecreasingFunc(old, new interface{}) bool {
if old == nil || new == nil {
return false
}
re := regexp.MustCompile(`REDIS_(\d+)_(\d+)`)
oldParsed := re.FindSubmatch([]byte(old.(string)))
newParsed := re.FindSubmatch([]byte(new.(string)))

if oldParsed == nil || newParsed == nil {
return false
}

oldVersion, err := strconv.ParseFloat(fmt.Sprintf("%s.%s", oldParsed[1], oldParsed[2]), 32)
if err != nil {
return false
}
newVersion, err := strconv.ParseFloat(fmt.Sprintf("%s.%s", newParsed[1], newParsed[2]), 32)
if err != nil {
return false
}

return newVersion < oldVersion
}
Loading