Skip to content

Commit

Permalink
resolve issues that would cause lint warnings if we enabled the… (#271)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and danawillow committed Nov 27, 2019
1 parent 84afa5d commit 5dedd6c
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 18 deletions.
6 changes: 1 addition & 5 deletions google/compute_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 1 addition & 4 deletions google/compute_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion google/kms_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion google/pubsub_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion google/storage_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down
4 changes: 2 additions & 2 deletions google/tpu_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 1 addition & 4 deletions google/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5dedd6c

Please sign in to comment.