Skip to content

Commit

Permalink
Remove internal fields from monitoring uptime check
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
rileykarson authored and modular-magician committed Jun 25, 2019
1 parent bbd8825 commit 7cbb46d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 266 deletions.
39 changes: 0 additions & 39 deletions google/resource_kms_crypto_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ func resourceKmsCryptoKey() *schema.Resource {
Required: true,
ForceNew: true,
},
"labels": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"purpose": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -113,12 +108,6 @@ func resourceKmsCryptoKeyCreate(d *schema.ResourceData, meta interface{}) error
config := meta.(*Config)

obj := make(map[string]interface{})
labelsProp, err := expandKmsCryptoKeyLabels(d.Get("labels"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("labels"); !isEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) {
obj["labels"] = labelsProp
}
purposeProp, err := expandKmsCryptoKeyPurpose(d.Get("purpose"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -184,9 +173,6 @@ func resourceKmsCryptoKeyRead(d *schema.ResourceData, meta interface{}) error {
return err
}

if err := d.Set("labels", flattenKmsCryptoKeyLabels(res["labels"], d)); err != nil {
return fmt.Errorf("Error reading CryptoKey: %s", err)
}
if err := d.Set("purpose", flattenKmsCryptoKeyPurpose(res["purpose"], d)); err != nil {
return fmt.Errorf("Error reading CryptoKey: %s", err)
}
Expand All @@ -204,12 +190,6 @@ func resourceKmsCryptoKeyUpdate(d *schema.ResourceData, meta interface{}) error
config := meta.(*Config)

obj := make(map[string]interface{})
labelsProp, err := expandKmsCryptoKeyLabels(d.Get("labels"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("labels"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) {
obj["labels"] = labelsProp
}
rotationPeriodProp, err := expandKmsCryptoKeyRotationPeriod(d.Get("rotation_period"), d, config)
if err != nil {
return err
Expand All @@ -236,10 +216,6 @@ func resourceKmsCryptoKeyUpdate(d *schema.ResourceData, meta interface{}) error
log.Printf("[DEBUG] Updating CryptoKey %q: %#v", d.Id(), obj)
updateMask := []string{}

if d.HasChange("labels") {
updateMask = append(updateMask, "labels")
}

if d.HasChange("rotation_period") {
updateMask = append(updateMask, "rotationPeriod,nextRotationTime")
}
Expand Down Expand Up @@ -307,10 +283,6 @@ func resourceKmsCryptoKeyImport(d *schema.ResourceData, meta interface{}) ([]*sc
return []*schema.ResourceData{d}, nil
}

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

func flattenKmsCryptoKeyPurpose(v interface{}, d *schema.ResourceData) interface{} {
return v
}
Expand Down Expand Up @@ -342,17 +314,6 @@ func flattenKmsCryptoKeyVersionTemplateProtectionLevel(v interface{}, d *schema.
return v
}

func expandKmsCryptoKeyLabels(v interface{}, d TerraformResourceData, config *Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
}
m := make(map[string]string)
for k, val := range v.(map[string]interface{}) {
m[k] = val.(string)
}
return m, nil
}

func expandKmsCryptoKeyPurpose(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
3 changes: 0 additions & 3 deletions google/resource_kms_crypto_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,6 @@ resource "google_kms_key_ring" "key_ring" {
resource "google_kms_crypto_key" "crypto_key" {
name = "%s"
key_ring = "${google_kms_key_ring.key_ring.self_link}"
labels = {
key = "value"
}
}
`, projectId, projectId, projectOrg, projectBillingAccount, keyRingName, cryptoKeyName)
}
Expand Down
231 changes: 41 additions & 190 deletions google/resource_monitoring_uptime_check_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,38 +115,6 @@ func resourceMonitoringUptimeCheckConfig() *schema.Resource {
},
ConflictsWith: []string{"tcp_check"},
},
"internal_checkers": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"display_name": {
Type: schema.TypeString,
Optional: true,
},
"gcp_zone": {
Type: schema.TypeString,
Optional: true,
},
"name": {
Type: schema.TypeString,
Optional: true,
},
"network": {
Type: schema.TypeString,
Optional: true,
},
"peer_project_id": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
"is_internal": {
Type: schema.TypeBool,
Optional: true,
},
"monitored_resource": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -227,6 +195,47 @@ func resourceMonitoringUptimeCheckConfig() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"is_internal": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
},
"internal_checkers": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"display_name": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
},
"gcp_zone": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
},
"name": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
},
"network": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
},
"peer_project_id": {
Type: schema.TypeString,
Optional: true,
Deprecated: "This field never worked, and will be removed in 3.0.0.",
},
},
},
},
"project": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -271,18 +280,6 @@ func resourceMonitoringUptimeCheckConfigCreate(d *schema.ResourceData, meta inte
} else if v, ok := d.GetOkExists("selected_regions"); !isEmptyValue(reflect.ValueOf(selectedRegionsProp)) && (ok || !reflect.DeepEqual(v, selectedRegionsProp)) {
obj["selectedRegions"] = selectedRegionsProp
}
isInternalProp, err := expandMonitoringUptimeCheckConfigIsInternal(d.Get("is_internal"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("is_internal"); !isEmptyValue(reflect.ValueOf(isInternalProp)) && (ok || !reflect.DeepEqual(v, isInternalProp)) {
obj["isInternal"] = isInternalProp
}
internalCheckersProp, err := expandMonitoringUptimeCheckConfigInternalCheckers(d.Get("internal_checkers"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("internal_checkers"); !isEmptyValue(reflect.ValueOf(internalCheckersProp)) && (ok || !reflect.DeepEqual(v, internalCheckersProp)) {
obj["internalCheckers"] = internalCheckersProp
}
httpCheckProp, err := expandMonitoringUptimeCheckConfigHttpCheck(d.Get("http_check"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -381,12 +378,6 @@ func resourceMonitoringUptimeCheckConfigRead(d *schema.ResourceData, meta interf
if err := d.Set("selected_regions", flattenMonitoringUptimeCheckConfigSelectedRegions(res["selectedRegions"], d)); err != nil {
return fmt.Errorf("Error reading UptimeCheckConfig: %s", err)
}
if err := d.Set("is_internal", flattenMonitoringUptimeCheckConfigIsInternal(res["isInternal"], d)); err != nil {
return fmt.Errorf("Error reading UptimeCheckConfig: %s", err)
}
if err := d.Set("internal_checkers", flattenMonitoringUptimeCheckConfigInternalCheckers(res["internalCheckers"], d)); err != nil {
return fmt.Errorf("Error reading UptimeCheckConfig: %s", err)
}
if err := d.Set("http_check", flattenMonitoringUptimeCheckConfigHttpCheck(res["httpCheck"], d)); err != nil {
return fmt.Errorf("Error reading UptimeCheckConfig: %s", err)
}
Expand Down Expand Up @@ -431,18 +422,6 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte
} else if v, ok := d.GetOkExists("selected_regions"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, selectedRegionsProp)) {
obj["selectedRegions"] = selectedRegionsProp
}
isInternalProp, err := expandMonitoringUptimeCheckConfigIsInternal(d.Get("is_internal"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("is_internal"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, isInternalProp)) {
obj["isInternal"] = isInternalProp
}
internalCheckersProp, err := expandMonitoringUptimeCheckConfigInternalCheckers(d.Get("internal_checkers"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("internal_checkers"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, internalCheckersProp)) {
obj["internalCheckers"] = internalCheckersProp
}
httpCheckProp, err := expandMonitoringUptimeCheckConfigHttpCheck(d.Get("http_check"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -480,14 +459,6 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte
updateMask = append(updateMask, "selectedRegions")
}

if d.HasChange("is_internal") {
updateMask = append(updateMask, "isInternal")
}

if d.HasChange("internal_checkers") {
updateMask = append(updateMask, "internalCheckers")
}

if d.HasChange("http_check") {
updateMask = append(updateMask, "httpCheck")
}
Expand Down Expand Up @@ -588,52 +559,6 @@ func flattenMonitoringUptimeCheckConfigSelectedRegions(v interface{}, d *schema.
return v
}

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

func flattenMonitoringUptimeCheckConfigInternalCheckers(v interface{}, d *schema.ResourceData) interface{} {
if v == nil {
return v
}
l := v.([]interface{})
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"gcp_zone": flattenMonitoringUptimeCheckConfigInternalCheckersGcpZone(original["gcpZone"], d),
"peer_project_id": flattenMonitoringUptimeCheckConfigInternalCheckersPeerProjectId(original["peerProjectId"], d),
"name": flattenMonitoringUptimeCheckConfigInternalCheckersName(original["name"], d),
"network": flattenMonitoringUptimeCheckConfigInternalCheckersNetwork(original["network"], d),
"display_name": flattenMonitoringUptimeCheckConfigInternalCheckersDisplayName(original["displayName"], d),
})
}
return transformed
}
func flattenMonitoringUptimeCheckConfigInternalCheckersGcpZone(v interface{}, d *schema.ResourceData) interface{} {
return v
}

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

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

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

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

func flattenMonitoringUptimeCheckConfigHttpCheck(v interface{}, d *schema.ResourceData) interface{} {
if v == nil {
return nil
Expand Down Expand Up @@ -818,80 +743,6 @@ func expandMonitoringUptimeCheckConfigSelectedRegions(v interface{}, d Terraform
return v, nil
}

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

func expandMonitoringUptimeCheckConfigInternalCheckers(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
req := make([]interface{}, 0, len(l))
for _, raw := range l {
if raw == nil {
continue
}
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

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

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

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

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

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

req = append(req, transformed)
}
return req, nil
}

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

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

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

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

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

func expandMonitoringUptimeCheckConfigHttpCheck(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
4 changes: 0 additions & 4 deletions website/docs/r/kms_crypto_key.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ The following arguments are supported:
- - -


* `labels` -
(Optional)
Labels with user-defined metadata to apply to this reosure.

* `purpose` -
(Optional)
The immutable purpose of this CryptoKey. See the
Expand Down
Loading

0 comments on commit 7cbb46d

Please sign in to comment.