Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace logger from the standard logger #340

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 2 additions & 3 deletions aws/client.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package aws

import (
"log"

"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
"github.com/aws/aws-sdk-go/service/ecs"
Expand All @@ -19,6 +17,7 @@ import (
"github.com/aws/aws-sdk-go/service/rds/rdsiface"
awsbase "github.com/hashicorp/aws-sdk-go-base"
"github.com/mitchellh/go-homedir"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
)

//go:generate go run github.com/golang/mock/mockgen -destination mock/ec2.go -package mock github.com/aws/aws-sdk-go/service/ec2/ec2iface EC2API
Expand Down Expand Up @@ -56,7 +55,7 @@ type Credentials struct {

// NewClient returns a new Client with configured session
func NewClient(creds Credentials) (*Client, error) {
log.Print("[INFO] Initialize AWS Client")
logger.Info("Initialize AWS Client")

config, err := getBaseConfig(creds)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions aws/runner.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package aws

import (
"log"

"github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

Expand Down Expand Up @@ -45,7 +44,7 @@ func (r *Runner) EachStringSliceExprs(expr hcl.Expression, proc func(val string,

exprs, diags := hcl.ExprList(expr)
if diags.HasErrors() {
log.Printf("[DEBUG] Expr is not static list: %s", diags)
logger.Debug("Expr is not static list: %s", diags)
for range vals {
exprs = append(exprs, expr)
}
Expand Down
6 changes: 3 additions & 3 deletions rules/api/aws_alb_invalid_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package api

import (
"fmt"
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -77,12 +77,12 @@ func (r *AwsALBInvalidSecurityGroupRule) Check(rr tflint.Runner) error {
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeSecurityGroups")
logger.Debug("invoking DescribeSecurityGroups")
var err error
r.data, err = runner.AwsClient.DescribeSecurityGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeSecurityGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
6 changes: 3 additions & 3 deletions rules/api/aws_alb_invalid_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package api

import (
"fmt"
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -77,12 +77,12 @@ func (r *AwsALBInvalidSubnetRule) Check(rr tflint.Runner) error {
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeSubnets")
logger.Debug("invoking DescribeSubnets")
var err error
r.data, err = runner.AwsClient.DescribeSubnets()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeSubnets; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
6 changes: 3 additions & 3 deletions rules/api/aws_db_instance_invalid_db_subnet_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package api

import (
"fmt"
"log"

"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -76,12 +76,12 @@ func (r *AwsDBInstanceInvalidDBSubnetGroupRule) Check(rr tflint.Runner) error {
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeDBSubnetGroups")
logger.Debug("invoking DescribeDBSubnetGroups")
var err error
r.data, err = runner.AwsClient.DescribeDBSubnetGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeDBSubnetGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
6 changes: 3 additions & 3 deletions rules/api/aws_db_instance_invalid_option_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package api

import (
"fmt"
"log"

"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -76,12 +76,12 @@ func (r *AwsDBInstanceInvalidOptionGroupRule) Check(rr tflint.Runner) error {
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeOptionGroups")
logger.Debug("invoking DescribeOptionGroups")
var err error
r.data, err = runner.AwsClient.DescribeOptionGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeOptionGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
6 changes: 3 additions & 3 deletions rules/api/aws_db_instance_invalid_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package api

import (
"fmt"
"log"

"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -76,12 +76,12 @@ func (r *AwsDBInstanceInvalidParameterGroupRule) Check(rr tflint.Runner) error {
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeDBParameterGroups")
logger.Debug("invoking DescribeDBParameterGroups")
var err error
r.data, err = runner.AwsClient.DescribeDBParameterGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeDBParameterGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
6 changes: 3 additions & 3 deletions rules/api/aws_db_instance_invalid_vpc_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package api

import (
"fmt"
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -77,12 +77,12 @@ func (r *AwsDBInstanceInvalidVpcSecurityGroupRule) Check(rr tflint.Runner) error
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeSecurityGroups")
logger.Debug("invoking DescribeSecurityGroups")
var err error
r.data, err = runner.AwsClient.DescribeSecurityGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeSecurityGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
6 changes: 3 additions & 3 deletions rules/api/aws_elasticache_cluster_invalid_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package api

import (
"fmt"
"log"

"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -76,12 +76,12 @@ func (r *AwsElastiCacheClusterInvalidParameterGroupRule) Check(rr tflint.Runner)
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeCacheParameterGroups")
logger.Debug("invoking DescribeCacheParameterGroups")
var err error
r.data, err = runner.AwsClient.DescribeCacheParameterGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeCacheParameterGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
6 changes: 3 additions & 3 deletions rules/api/aws_elasticache_cluster_invalid_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package api

import (
"fmt"
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -77,12 +77,12 @@ func (r *AwsElastiCacheClusterInvalidSecurityGroupRule) Check(rr tflint.Runner)
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeSecurityGroups")
logger.Debug("invoking DescribeSecurityGroups")
var err error
r.data, err = runner.AwsClient.DescribeSecurityGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeSecurityGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
6 changes: 3 additions & 3 deletions rules/api/aws_elasticache_cluster_invalid_subnet_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package api

import (
"fmt"
"log"

"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -76,12 +76,12 @@ func (r *AwsElastiCacheClusterInvalidSubnetGroupRule) Check(rr tflint.Runner) er
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeCacheSubnetGroups")
logger.Debug("invoking DescribeCacheSubnetGroups")
var err error
r.data, err = runner.AwsClient.DescribeCacheSubnetGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeCacheSubnetGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package api

import (
"fmt"
"log"

"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -76,12 +76,12 @@ func (r *AwsElastiCacheReplicationGroupInvalidParameterGroupRule) Check(rr tflin
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeCacheParameterGroups")
logger.Debug("invoking DescribeCacheParameterGroups")
var err error
r.data, err = runner.AwsClient.DescribeCacheParameterGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeCacheParameterGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package api

import (
"fmt"
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -77,12 +77,12 @@ func (r *AwsElastiCacheReplicationGroupInvalidSecurityGroupRule) Check(rr tflint
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeSecurityGroups")
logger.Debug("invoking DescribeSecurityGroups")
var err error
r.data, err = runner.AwsClient.DescribeSecurityGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeSecurityGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package api

import (
"fmt"
"log"

"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -76,12 +76,12 @@ func (r *AwsElastiCacheReplicationGroupInvalidSubnetGroupRule) Check(rr tflint.R
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeCacheSubnetGroups")
logger.Debug("invoking DescribeCacheSubnetGroups")
var err error
r.data, err = runner.AwsClient.DescribeCacheSubnetGroups()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeCacheSubnetGroups; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
6 changes: 3 additions & 3 deletions rules/api/aws_elb_invalid_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package api

import (
"fmt"
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
"github.com/terraform-linters/tflint-ruleset-aws/aws"
)
Expand Down Expand Up @@ -77,12 +77,12 @@ func (r *AwsELBInvalidInstanceRule) Check(rr tflint.Runner) error {
}

if !r.dataPrepared {
log.Print("[DEBUG] invoking DescribeInstances")
logger.Debug("invoking DescribeInstances")
var err error
r.data, err = runner.AwsClient.DescribeInstances()
if err != nil {
err := fmt.Errorf("An error occurred while invoking DescribeInstances; %w", err)
log.Printf("[ERROR] %s", err)
logger.Error("%s", err)
return err
}
r.dataPrepared = true
Expand Down
Loading