From 5dedd6c7d6a8c1a7faf909ad5c64bac27791ab31 Mon Sep 17 00:00:00 2001 From: The Magician Date: Wed, 27 Nov 2019 12:34:07 -0800 Subject: [PATCH] =?UTF-8?q?resolve=20issues=20that=20would=20cause=20lint?= =?UTF-8?q?=20warnings=20if=20we=20enabled=20the=E2=80=A6=20(#271)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Modular Magician --- google/compute_disk.go | 6 +----- google/compute_firewall.go | 5 +---- google/kms_utils.go | 2 +- google/pubsub_subscription.go | 2 +- google/storage_bucket.go | 2 +- google/tpu_node.go | 4 ++-- google/utils.go | 5 +---- 7 files changed, 8 insertions(+), 18 deletions(-) diff --git a/google/compute_disk.go b/google/compute_disk.go index fe4a3a66a..820b07ec6 100644 --- a/google/compute_disk.go +++ b/google/compute_disk.go @@ -211,11 +211,7 @@ func suppressWindowsFamilyDiff(imageName, familyName string) bool { updatedFamilyString := strings.Replace(familyName, "windows-", "windows-server-", 1) updatedImageName := strings.Replace(imageName, "-dc-", "-", 1) - if strings.Contains(updatedImageName, updatedFamilyString) { - return true - } - - return false + return strings.Contains(updatedImageName, updatedFamilyString) } func GetComputeDiskCaiObject(d TerraformResourceData, config *Config) (Asset, error) { diff --git a/google/compute_firewall.go b/google/compute_firewall.go index f44ef535b..d2c11a3bd 100644 --- a/google/compute_firewall.go +++ b/google/compute_firewall.go @@ -45,10 +45,7 @@ func resourceComputeFirewallRuleHash(v interface{}) int { } func compareCaseInsensitive(k, old, new string, d *schema.ResourceData) bool { - if strings.ToLower(old) == strings.ToLower(new) { - return true - } - return false + return strings.ToLower(old) == strings.ToLower(new) } func GetComputeFirewallCaiObject(d TerraformResourceData, config *Config) (Asset, error) { diff --git a/google/kms_utils.go b/google/kms_utils.go index 2cea50c45..087563545 100644 --- a/google/kms_utils.go +++ b/google/kms_utils.go @@ -87,7 +87,7 @@ func (s *kmsCryptoKeyId) terraformId() string { func validateKmsCryptoKeyRotationPeriod(value interface{}, _ string) (ws []string, errors []error) { period := value.(string) - pattern := regexp.MustCompile("^([0-9.]*\\d)s$") + pattern := regexp.MustCompile(`^([0-9.]*\\d)s$`) match := pattern.FindStringSubmatch(period) if len(match) == 0 { diff --git a/google/pubsub_subscription.go b/google/pubsub_subscription.go index 8a9cbf0cd..8ccd3296b 100644 --- a/google/pubsub_subscription.go +++ b/google/pubsub_subscription.go @@ -127,7 +127,7 @@ func expandPubsubSubscriptionTopic(v interface{}, d TerraformResourceData, confi topic := d.Get("topic").(string) - re := regexp.MustCompile("projects\\/(.*)\\/topics\\/(.*)") + re := regexp.MustCompile(`projects\/(.*)\/topics\/(.*)`) match := re.FindStringSubmatch(topic) if len(match) == 3 { return topic, nil diff --git a/google/storage_bucket.go b/google/storage_bucket.go index 771af7466..b23fe082f 100644 --- a/google/storage_bucket.go +++ b/google/storage_bucket.go @@ -128,7 +128,7 @@ func expandCors(configured []interface{}) []*storage.BucketCors { func expandBucketEncryption(configured interface{}) *storage.BucketEncryption { encs := configured.([]interface{}) - if encs == nil || len(encs) == 0 || encs[0] == nil { + if len(encs) == 0 || encs[0] == nil { return nil } enc := encs[0].(map[string]interface{}) diff --git a/google/tpu_node.go b/google/tpu_node.go index 91c89a0fc..50f8895c1 100644 --- a/google/tpu_node.go +++ b/google/tpu_node.go @@ -43,9 +43,9 @@ func validateHttpHeaders() schema.SchemaValidateFunc { es = append(es, fmt.Errorf("Cannot set the Content-Length header on %s", k)) return } + r := regexp.MustCompile(`(X-Google-|X-AppEngine-).*`) for key := range headers { - match, _ := regexp.MatchString("(X-Google-|X-AppEngine-).*", key) - if match { + if r.MatchString(key) { es = append(es, fmt.Errorf("Cannot set the %s header on %s", key, k)) return } diff --git a/google/utils.go b/google/utils.go index 8aa782f5e..9c9ce2dee 100644 --- a/google/utils.go +++ b/google/utils.go @@ -211,10 +211,7 @@ func caseDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { // `old` is read from the server and always has the full range format (e.g. '80-80', '1024-2048'). // `new` can be either a single port or a port range. func portRangeDiffSuppress(k, old, new string, d *schema.ResourceData) bool { - if old == new+"-"+new { - return true - } - return false + return old == new+"-"+new } // Single-digit hour is equivalent to hour with leading zero e.g. suppress diff 1:00 => 01:00.