Skip to content

Commit

Permalink
Update hand-written resources with AtLeastOneOf and ExactlyOneOf
Browse files Browse the repository at this point in the history
…attributes (#2608)
  • Loading branch information
megan07 authored and slevenick committed Nov 12, 2019
1 parent fa706ec commit bb222ed
Show file tree
Hide file tree
Showing 28 changed files with 1,337 additions and 475 deletions.
4 changes: 4 additions & 0 deletions products/appengine/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ objects:
Example: 12345.
- !ruby/object:Api::Type::Enum
name: 'sslManagementType'
required: true
description: |
SSL management type for this domain. If `AUTOMATIC`, a managed certificate is automatically provisioned.
If `MANUAL`, `certificateId` must be manually specified in order to configure SSL for this domain.
Expand Down Expand Up @@ -407,6 +408,7 @@ objects:
- !ruby/object:Api::Type::String
name: 'sourceUrl'
description: 'Source URL'
required: true
- !ruby/object:Api::Type::Integer
name: 'filesCount'
description: 'files count'
Expand All @@ -428,6 +430,7 @@ objects:
SHA1 checksum of the file
- !ruby/object:Api::Type::String
name: 'sourceUrl'
required: true
description: |
Source URL
- !ruby/object:Api::Type::NestedObject
Expand All @@ -438,6 +441,7 @@ objects:
properties:
- !ruby/object:Api::Type::String
name: 'shell'
required: true
description: |
The format should be a shell command that can be fed to bash -c.
- !ruby/object:Api::Type::String
Expand Down
1 change: 1 addition & 0 deletions products/bigtable/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ objects:
properties:
- !ruby/object:Api::Type::String
name: 'clusterId'
required: true
description: |
The cluster to which read/write requests should be routed.
- !ruby/object:Api::Type::Boolean
Expand Down
5 changes: 5 additions & 0 deletions products/cloudbuild/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ objects:
properties:
- !ruby/object:Api::Type::String
name: 'branch'
required: true
description: |
Regex of branches to match.
- !ruby/object:Api::Type::Enum
Expand Down Expand Up @@ -212,12 +213,14 @@ objects:
If any of the images fail to be pushed, the build status is marked FAILURE.
- !ruby/object:Api::Type::Array
name: 'steps'
required: true
description: |
The operations to be performed on the workspace.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: 'name'
required: true
description: |
The name of the container image that will run this particular build step.
Expand Down Expand Up @@ -314,13 +317,15 @@ objects:
properties:
- !ruby/object:Api::Type::String
name: 'name'
required: true
description: |
Name of the volume to mount.
Volume names must be unique per build step and must be valid names for
Docker volumes. Each named volume must be used by at least two build steps.
- !ruby/object:Api::Type::String
name: 'path'
required: true
description: |
Path at which to mount the volume.
Expand Down
5 changes: 3 additions & 2 deletions products/cloudrun/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ objects:
properties:
- !ruby/object:Api::Type::NestedObject
name: template
required: true
description: |-
template holds the latest specification for the Revision to
be stamped out. The template references the container image, and may also
Expand Down Expand Up @@ -341,7 +342,7 @@ objects:
- !ruby/object:Api::Type::NestedObject
name: configMapRef
description: |-
The ConfigMap to select from
The ConfigMap to select from.
properties:
- !ruby/object:Api::Type::Boolean
name: optional
Expand All @@ -360,7 +361,7 @@ objects:
- !ruby/object:Api::Type::NestedObject
name: secretRef
description: |-
The Secret to select from
The Secret to select from.
properties:
- !ruby/object:Api::Type::NestedObject
name: localObjectReference
Expand Down
2 changes: 2 additions & 0 deletions products/cloudscheduler/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ objects:
properties:
- !ruby/object:Api::Type::String
name: serviceAccountEmail
required: true
description: |
Service account email to be used for generating OAuth token.
The service account must be within the same project as the job.
Expand All @@ -284,6 +285,7 @@ objects:
properties:
- !ruby/object:Api::Type::String
name: serviceAccountEmail
required: true
description: |
Service account email to be used for generating OAuth token.
The service account must be within the same project as the job.
Expand Down
1 change: 1 addition & 0 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
# https://github.com/GoogleCloudPlatform/magic-modules/issues/1019
ignore_read: true
sensitive: true
required: true
custom_flatten: templates/terraform/custom_flatten/compute_snapshot_snapshot_encryption_raw_key.go.erb
snapshotEncryptionKey.kmsKeyName: !ruby/object:Overrides::Terraform::PropertyOverride
# This is a beta field that showed up in GA. Removed from both.
Expand Down
2 changes: 2 additions & 0 deletions products/dns/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ objects:
- !ruby/object:Api::Type::Array
name: 'networks'
description: 'The list of VPC networks that can see this zone.'
required: true
item_type: !ruby/object:Api::Type::NestedObject
properties:
# TODO(drebes): Make 'networkUrl' a ResourceRef once cross-module references
Expand All @@ -180,6 +181,7 @@ objects:
The fully qualified URL of the VPC network to bind to.
This should be formatted like
`https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`
required: true
- !ruby/object:Api::Type::NestedObject
name: 'forwardingConfig'
description: |
Expand Down
1 change: 1 addition & 0 deletions products/monitoring/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ objects:
- !ruby/object:Api::Type::String
name: content
description: String or regex content to match (max 1024 bytes)
required: true
- !ruby/object:Api::Type::Array
name: selectedRegions
description: The list of regions from which the check will be run. Some regions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func appEngineApplicationFeatureSettingsResource() *schema.Resource {
Schema: map[string]*schema.Schema{
"split_health_checks": {
Type: schema.TypeBool,
Optional: true,
Required: true,
},
},
}
Expand Down
13 changes: 6 additions & 7 deletions third_party/terraform/resources/resource_bigquery_table.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,16 @@ func resourceBigQueryTable() *schema.Resource {
// Range: [Optional] Range of a sheet to query from. Only used when non-empty.
// Typical format: !:
"range": {
<% if version.nil? || version == 'ga' -%>
Removed: "This field is in beta. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/guides/provider_versions.html for more details.",
<% end -%>
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: []string{"external_data_configuration.0.google_sheets_options.0.range"},
},
// SkipLeadingRows: [Optional] The number of rows at the top
// of the sheet that BigQuery will skip when reading the data.
"skip_leading_rows": {
Type: schema.TypeInt,
Optional: true,
Type: schema.TypeInt,
Optional: true,
AtLeastOneOf: []string{"external_data_configuration.0.google_sheets_options.0.skip_leading_rows"},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func resourceCloudIoTRegistry() *schema.Resource {
Schema: map[string]*schema.Schema{
"public_key_certificate": {
Type: schema.TypeMap,
Optional: true,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"format": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ var composerEnvironmentReservedEnvVar = map[string]struct{}{
"SQL_USER": {},
}

var composerSoftwareConfigKeys = []string{
"config.0.software_config.0.airflow_config_overrides",
"config.0.software_config.0.pypi_packages",
"config.0.software_config.0.env_variables",
"config.0.software_config.0.image_version",
"config.0.software_config.0.python_version",
}

func resourceComposerEnvironment() *schema.Resource {
return &schema.Resource{
Create: resourceComposerEnvironmentCreate,
Expand Down Expand Up @@ -162,8 +170,7 @@ func resourceComposerEnvironment() *schema.Resource {
Schema: map[string]*schema.Schema{
"use_ip_aliases": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Required: true,
ForceNew: true,
},
"cluster_secondary_range_name": {
Expand Down Expand Up @@ -208,30 +215,35 @@ func resourceComposerEnvironment() *schema.Resource {
"airflow_config_overrides": {
Type: schema.TypeMap,
Optional: true,
AtLeastOneOf: composerSoftwareConfigKeys,
Elem: &schema.Schema{Type: schema.TypeString},
},
"pypi_packages": {
Type: schema.TypeMap,
Optional: true,
AtLeastOneOf: composerSoftwareConfigKeys,
Elem: &schema.Schema{Type: schema.TypeString},
ValidateFunc: validateComposerEnvironmentPypiPackages,
},
"env_variables": {
Type: schema.TypeMap,
Optional: true,
AtLeastOneOf: composerSoftwareConfigKeys,
Elem: &schema.Schema{Type: schema.TypeString},
ValidateFunc: validateComposerEnvironmentEnvVariables,
},
"image_version": {
Type: schema.TypeString,
Computed: true,
Optional: true,
AtLeastOneOf: composerSoftwareConfigKeys,
ValidateFunc: validateRegexp(composerEnvironmentVersionRegexp),
DiffSuppressFunc: composerImageVersionDiffSuppress,
},
"python_version": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: composerSoftwareConfigKeys,
Computed: true,
ForceNew: true,
},
Expand All @@ -248,9 +260,8 @@ func resourceComposerEnvironment() *schema.Resource {
Schema: map[string]*schema.Schema{
"enable_private_endpoint": {
Type: schema.TypeBool,
Optional: true,
Required: true,
ForceNew: true,
Default: true,
},
"master_ipv4_cidr_block": {
Type: schema.TypeString,
Expand Down
Loading

0 comments on commit bb222ed

Please sign in to comment.