Skip to content

Commit

Permalink
remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissng committed Jan 5, 2020
1 parent 38126d6 commit 931b4b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,12 @@ func dataSourceGoogleSQLCaCerts() *schema.Resource {
func dataSourceGoogleSQLCaCertsRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

var project, instance string
if v, ok := d.GetOk("instance"); ok {
fv, err := parseProjectFieldValue("instances", v.(string), "project", d, config, false)
if err != nil {
return err
}
project = fv.Project
instance = fv.Name
} else {
return fmt.Errorf("instance must be set")
fv, err := parseProjectFieldValue("instances", d.Get("instance").(string), "project", d, config, false)
if err != nil {
return err
}
project := fv.Project
instance := fv.Name

log.Printf("[DEBUG] Fetching CA certs from instance %s", instance)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ data "google_sql_ca_certs" "ca_certs" {
locals {
furthest_expiration_time = reverse(sort([for k, v in data.google_sql_ca_certs.ca_certs.certs : v.expiration_time]))[0]
latest_cert = [for v in data.google_sql_ca_certs.ca_certs.certs : v.cert if v.expiration_time == local.furthest_expiration_time]
latest_ca_cert = [for v in data.google_sql_ca_certs.ca_certs.certs : v.cert if v.expiration_time == local.furthest_expiration_time]
}
output "db_latest_ca_cert" {
description = "Latest CA cert used by the primary database server"
value = local.latest_cert
value = local.latest_ca_cert
sensitive = true
}
```
Expand Down

0 comments on commit 931b4b1

Please sign in to comment.