Skip to content

Commit

Permalink
Inspec project_metric
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
slevenick authored and modular-magician committed Jan 22, 2020
1 parent ebdead1 commit c11ad70
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
23 changes: 23 additions & 0 deletions google-beta/resource_logging_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ or just for responses that failed.`,
[The Unified Code for Units of Measure](http://unitsofmeasure.org/ucum.html) standard`,
Default: "1",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: `The metric type, including its DNS name prefix. The type is not URL-encoded.
All user-defined metric types have the DNS name 'custom.googleapis.com' or 'external.googleapis.com'.`,
},
},
},
},
Expand Down Expand Up @@ -543,6 +549,8 @@ func flattenLoggingMetricMetricDescriptor(v interface{}, d *schema.ResourceData)
flattenLoggingMetricMetricDescriptorLabels(original["labels"], d)
transformed["display_name"] =
flattenLoggingMetricMetricDescriptorDisplayName(original["displayName"], d)
transformed["type"] =
flattenLoggingMetricMetricDescriptorType(original["type"], d)
return []interface{}{transformed}
}
func flattenLoggingMetricMetricDescriptorUnit(v interface{}, d *schema.ResourceData) interface{} {
Expand Down Expand Up @@ -597,6 +605,10 @@ func flattenLoggingMetricMetricDescriptorDisplayName(v interface{}, d *schema.Re
return v
}

func flattenLoggingMetricMetricDescriptorType(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenLoggingMetricLabelExtractors(v interface{}, d *schema.ResourceData) interface{} {
return v
}
Expand Down Expand Up @@ -771,6 +783,13 @@ func expandLoggingMetricMetricDescriptor(v interface{}, d TerraformResourceData,
transformed["displayName"] = transformedDisplayName
}

transformedType, err := expandLoggingMetricMetricDescriptorType(original["type"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedType); val.IsValid() && !isEmptyValue(val) {
transformed["type"] = transformedType
}

return transformed, nil
}

Expand Down Expand Up @@ -839,6 +858,10 @@ func expandLoggingMetricMetricDescriptorDisplayName(v interface{}, d TerraformRe
return v, nil
}

func expandLoggingMetricMetricDescriptorType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandLoggingMetricLabelExtractors(v interface{}, d TerraformResourceData, config *Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
Expand Down
1 change: 1 addition & 0 deletions google-beta/resource_sql_database_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"

sqladmin "google.golang.org/api/sqladmin/v1beta4"
)

Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/logging_metric.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ The `metric_descriptor` block supports:
without an ending period, for example "Request count". This field is optional but it is
recommended to be set for any metrics associated with user-visible concepts, such as Quota.

* `type` -
The metric type, including its DNS name prefix. The type is not URL-encoded.
All user-defined metric types have the DNS name `custom.googleapis.com` or `external.googleapis.com`.


The `labels` block supports:

Expand Down

0 comments on commit c11ad70

Please sign in to comment.