From 45101b94a7ed61656f3748e6a494601406ee2f2e Mon Sep 17 00:00:00 2001 From: wata_mac Date: Sat, 8 Jul 2017 19:39:58 +0900 Subject: [PATCH 1/4] Embed rule name and link to detector --- detector/aws_alb_duplicate_name.go | 16 ++++++------- detector/aws_alb_invaid_security_group.go | 16 ++++++------- detector/aws_alb_invalid_subnet.go | 22 ++++++++---------- ...ws_cloudwatch_metric_alarm_invalid_unit.go | 17 +++++++------- ...aws_db_instance_default_parameter_group.go | 19 +++++++-------- .../aws_db_instance_duplicate_identifier.go | 16 ++++++------- ...aws_db_instance_invalid_db_subnet_group.go | 16 ++++++------- .../aws_db_instance_invalid_option_group.go | 16 ++++++------- ...aws_db_instance_invalid_parameter_group.go | 16 ++++++------- detector/aws_db_instance_invalid_type.go | 17 +++++++------- ..._db_instance_invalid_vpc_security_group.go | 16 ++++++------- detector/aws_db_instance_previous_type.go | 17 +++++++------- detector/aws_db_instance_readable_password.go | 19 +++++++-------- ...ticache_cluster_default_parameter_group.go | 19 +++++++-------- .../aws_elasticache_cluster_duplicate_id.go | 16 ++++++------- ...ticache_cluster_invalid_parameter_group.go | 16 ++++++------- ...sticache_cluster_invalid_security_group.go | 16 ++++++------- ...lasticache_cluster_invalid_subnet_group.go | 16 ++++++------- .../aws_elasticache_cluster_invalid_type.go | 23 +++++++++---------- .../aws_elasticache_cluster_previous_type.go | 17 +++++++------- detector/aws_elb_duplicate_name.go | 16 ++++++------- detector/aws_elb_invalid_instance.go | 22 ++++++++---------- detector/aws_elb_invalid_security_group.go | 16 ++++++------- detector/aws_elb_invalid_subnet.go | 22 ++++++++---------- .../aws_instance_default_standard_volume.go | 19 +++++++-------- detector/aws_instance_invalid_ami.go | 22 ++++++++---------- detector/aws_instance_invalid_iam_profile.go | 22 ++++++++---------- detector/aws_instance_invalid_key_name.go | 22 ++++++++---------- detector/aws_instance_invalid_subnet.go | 22 ++++++++---------- detector/aws_instance_invalid_type.go | 17 +++++++------- ...aws_instance_invalid_vpc_security_group.go | 16 ++++++------- .../aws_instance_not_specified_iam_profile.go | 19 +++++++-------- detector/aws_instance_previous_type.go | 17 +++++++------- .../aws_route_invalid_egress_only_gateway.go | 22 ++++++++---------- detector/aws_route_invalid_gateway.go | 22 ++++++++---------- detector/aws_route_invalid_instance.go | 22 ++++++++---------- detector/aws_route_invalid_nat_gateway.go | 22 ++++++++---------- .../aws_route_invalid_network_interface.go | 16 ++++++------- detector/aws_route_invalid_route_table.go | 16 ++++++------- ...ws_route_invalid_vpc_peering_connection.go | 16 ++++++------- detector/aws_route_not_specified_target.go | 19 +++++++-------- .../aws_route_specified_multiple_targets.go | 19 +++++++-------- detector/aws_security_group_duplicate_name.go | 16 ++++++------- detector/detector.go | 7 ++++++ detector/terraform_module_pinned_source.go | 16 ++++++------- 45 files changed, 365 insertions(+), 446 deletions(-) diff --git a/detector/aws_alb_duplicate_name.go b/detector/aws_alb_duplicate_name.go index fcd81929d..64e60d3bc 100644 --- a/detector/aws_alb_duplicate_name.go +++ b/detector/aws_alb_duplicate_name.go @@ -9,22 +9,20 @@ import ( type AwsALBDuplicateNameDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool loadBalancers map[string]bool } func (d *Detector) CreateAwsALBDuplicateNameDetector() *AwsALBDuplicateNameDetector { - return &AwsALBDuplicateNameDetector{ + nd := &AwsALBDuplicateNameDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_alb", - DeepCheck: true, loadBalancers: map[string]bool{}, } + nd.Name = "aws_alb_duplicate_name" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_alb" + nd.DeepCheck = true + return nd } func (d *AwsALBDuplicateNameDetector) PreProcess() { diff --git a/detector/aws_alb_invaid_security_group.go b/detector/aws_alb_invaid_security_group.go index 7a958cec7..685753466 100644 --- a/detector/aws_alb_invaid_security_group.go +++ b/detector/aws_alb_invaid_security_group.go @@ -10,22 +10,20 @@ import ( type AwsALBInvalidSecurityGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool securityGroups map[string]bool } func (d *Detector) CreateAwsALBInvalidSecurityGroupDetector() *AwsALBInvalidSecurityGroupDetector { - return &AwsALBInvalidSecurityGroupDetector{ + nd := &AwsALBInvalidSecurityGroupDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_alb", - DeepCheck: true, securityGroups: map[string]bool{}, } + nd.Name = "aws_alb_invalid_security_group" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_alb" + nd.DeepCheck = true + return nd } func (d *AwsALBInvalidSecurityGroupDetector) PreProcess() { diff --git a/detector/aws_alb_invalid_subnet.go b/detector/aws_alb_invalid_subnet.go index f0f0df3f6..691da3408 100644 --- a/detector/aws_alb_invalid_subnet.go +++ b/detector/aws_alb_invalid_subnet.go @@ -10,22 +10,20 @@ import ( type AwsALBInvalidSubnetDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - subnets map[string]bool + subnets map[string]bool } func (d *Detector) CreateAwsALBInvalidSubnetDetector() *AwsALBInvalidSubnetDetector { - return &AwsALBInvalidSubnetDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_alb", - DeepCheck: true, - subnets: map[string]bool{}, + nd := &AwsALBInvalidSubnetDetector{ + Detector: d, + subnets: map[string]bool{}, } + nd.Name = "aws_alb_invalid_subnet" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_alb" + nd.DeepCheck = true + return nd } func (d *AwsALBInvalidSubnetDetector) PreProcess() { diff --git a/detector/aws_cloudwatch_metric_alarm_invalid_unit.go b/detector/aws_cloudwatch_metric_alarm_invalid_unit.go index 715a966da..5bba1e10f 100644 --- a/detector/aws_cloudwatch_metric_alarm_invalid_unit.go +++ b/detector/aws_cloudwatch_metric_alarm_invalid_unit.go @@ -9,22 +9,21 @@ import ( type AwsCloudWatchMetricAlarmInvalidUnitDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool validUnits map[string]bool } func (d *Detector) CreateAwsCloudWatchMetricAlarmInvalidUnitDetector() *AwsCloudWatchMetricAlarmInvalidUnitDetector { - return &AwsCloudWatchMetricAlarmInvalidUnitDetector{ + nd := &AwsCloudWatchMetricAlarmInvalidUnitDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_cloudwatch_metric_alarm", - DeepCheck: false, validUnits: map[string]bool{}, } + nd.Name = "aws_cloudwatch_metric_alarm_invalid_unit" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_cloudwatch_metric_alarm" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_cloudwatch_metric_alarm_invalid_unit.md" + return nd } func (d *AwsCloudWatchMetricAlarmInvalidUnitDetector) PreProcess() { diff --git a/detector/aws_db_instance_default_parameter_group.go b/detector/aws_db_instance_default_parameter_group.go index de0dc4c67..de99e1db9 100644 --- a/detector/aws_db_instance_default_parameter_group.go +++ b/detector/aws_db_instance_default_parameter_group.go @@ -10,20 +10,17 @@ import ( type AwsDBInstanceDefaultParameterGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool } func (d *Detector) CreateAwsDBInstanceDefaultParameterGroupDetector() *AwsDBInstanceDefaultParameterGroupDetector { - return &AwsDBInstanceDefaultParameterGroupDetector{ - Detector: d, - IssueType: issue.NOTICE, - TargetType: "resource", - Target: "aws_db_instance", - DeepCheck: false, - } + nd := &AwsDBInstanceDefaultParameterGroupDetector{Detector: d} + nd.Name = "aws_db_instance_default_parameter_group" + nd.IssueType = issue.NOTICE + nd.TargetType = "resource" + nd.Target = "aws_db_instance" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_default_parameter_group.md" + return nd } func (d *AwsDBInstanceDefaultParameterGroupDetector) Detect(resource *schema.Resource, issues *[]*issue.Issue) { diff --git a/detector/aws_db_instance_duplicate_identifier.go b/detector/aws_db_instance_duplicate_identifier.go index a7533b446..e8e4b4516 100644 --- a/detector/aws_db_instance_duplicate_identifier.go +++ b/detector/aws_db_instance_duplicate_identifier.go @@ -9,22 +9,20 @@ import ( type AwsDBInstanceDuplicateIdentifierDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool identifiers map[string]bool } func (d *Detector) CreateAwsDBInstanceDuplicateIdentifierDetector() *AwsDBInstanceDuplicateIdentifierDetector { - return &AwsDBInstanceDuplicateIdentifierDetector{ + nd := &AwsDBInstanceDuplicateIdentifierDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_db_instance", - DeepCheck: true, identifiers: map[string]bool{}, } + nd.Name = "aws_db_instance_duplicate_identifier" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_db_instance" + nd.DeepCheck = true + return nd } func (d *AwsDBInstanceDuplicateIdentifierDetector) PreProcess() { diff --git a/detector/aws_db_instance_invalid_db_subnet_group.go b/detector/aws_db_instance_invalid_db_subnet_group.go index 2674d95b3..b685eeddf 100644 --- a/detector/aws_db_instance_invalid_db_subnet_group.go +++ b/detector/aws_db_instance_invalid_db_subnet_group.go @@ -9,22 +9,20 @@ import ( type AwsDBInstanceInvalidDBSubnetGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool subnetGroups map[string]bool } func (d *Detector) CreateAwsDBInstanceInvalidDBSubnetGroupDetector() *AwsDBInstanceInvalidDBSubnetGroupDetector { - return &AwsDBInstanceInvalidDBSubnetGroupDetector{ + nd := &AwsDBInstanceInvalidDBSubnetGroupDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_db_instance", - DeepCheck: true, subnetGroups: map[string]bool{}, } + nd.Name = "aws_db_instance_invalid_db_subnet_group" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_db_instance" + nd.DeepCheck = true + return nd } func (d *AwsDBInstanceInvalidDBSubnetGroupDetector) PreProcess() { diff --git a/detector/aws_db_instance_invalid_option_group.go b/detector/aws_db_instance_invalid_option_group.go index b12fd39fa..fcd1606f5 100644 --- a/detector/aws_db_instance_invalid_option_group.go +++ b/detector/aws_db_instance_invalid_option_group.go @@ -9,22 +9,20 @@ import ( type AwsDBInstanceInvalidOptionGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool optionGroups map[string]bool } func (d *Detector) CreateAwsDBInstanceInvalidOptionGroupDetector() *AwsDBInstanceInvalidOptionGroupDetector { - return &AwsDBInstanceInvalidOptionGroupDetector{ + nd := &AwsDBInstanceInvalidOptionGroupDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_db_instance", - DeepCheck: true, optionGroups: map[string]bool{}, } + nd.Name = "aws_db_instance_invalid_option_group" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_db_instance" + nd.DeepCheck = true + return nd } func (d *AwsDBInstanceInvalidOptionGroupDetector) PreProcess() { diff --git a/detector/aws_db_instance_invalid_parameter_group.go b/detector/aws_db_instance_invalid_parameter_group.go index a17bef066..031b48725 100644 --- a/detector/aws_db_instance_invalid_parameter_group.go +++ b/detector/aws_db_instance_invalid_parameter_group.go @@ -9,22 +9,20 @@ import ( type AwsDBInstanceInvalidParameterGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool parameterGroups map[string]bool } func (d *Detector) CreateAwsDBInstanceInvalidParameterGroupDetector() *AwsDBInstanceInvalidParameterGroupDetector { - return &AwsDBInstanceInvalidParameterGroupDetector{ + nd := &AwsDBInstanceInvalidParameterGroupDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_db_instance", - DeepCheck: true, parameterGroups: map[string]bool{}, } + nd.Name = "aws_db_instance_invalid_parameter_group" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_db_instance" + nd.DeepCheck = true + return nd } func (d *AwsDBInstanceInvalidParameterGroupDetector) PreProcess() { diff --git a/detector/aws_db_instance_invalid_type.go b/detector/aws_db_instance_invalid_type.go index 12b39fa75..657f3d42b 100644 --- a/detector/aws_db_instance_invalid_type.go +++ b/detector/aws_db_instance_invalid_type.go @@ -9,22 +9,21 @@ import ( type AwsDBInstanceInvalidTypeDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool instanceTypes map[string]bool } func (d *Detector) CreateAwsDBInstanceInvalidTypeDetector() *AwsDBInstanceInvalidTypeDetector { - return &AwsDBInstanceInvalidTypeDetector{ + nd := &AwsDBInstanceInvalidTypeDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_db_instance", - DeepCheck: false, instanceTypes: map[string]bool{}, } + nd.Name = "aws_db_instance_invalid_type" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_db_instance" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_invalid_type.md" + return nd } func (d *AwsDBInstanceInvalidTypeDetector) PreProcess() { diff --git a/detector/aws_db_instance_invalid_vpc_security_group.go b/detector/aws_db_instance_invalid_vpc_security_group.go index 37c8246df..5209d8887 100644 --- a/detector/aws_db_instance_invalid_vpc_security_group.go +++ b/detector/aws_db_instance_invalid_vpc_security_group.go @@ -10,22 +10,20 @@ import ( type AwsDBInstanceInvalidVPCSecurityGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool securityGroups map[string]bool } func (d *Detector) CreateAwsDBInstanceInvalidVPCSecurityGroupDetector() *AwsDBInstanceInvalidVPCSecurityGroupDetector { - return &AwsDBInstanceInvalidVPCSecurityGroupDetector{ + nd := &AwsDBInstanceInvalidVPCSecurityGroupDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_db_instance", - DeepCheck: true, securityGroups: map[string]bool{}, } + nd.Name = "aws_db_instance_invalid_vpc_security_group" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_db_instance" + nd.DeepCheck = true + return nd } func (d *AwsDBInstanceInvalidVPCSecurityGroupDetector) PreProcess() { diff --git a/detector/aws_db_instance_previous_type.go b/detector/aws_db_instance_previous_type.go index 70e18ecd5..fe906131d 100644 --- a/detector/aws_db_instance_previous_type.go +++ b/detector/aws_db_instance_previous_type.go @@ -9,22 +9,21 @@ import ( type AwsDBInstancePreviousTypeDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool previousInstanceTypes map[string]bool } func (d *Detector) CreateAwsDBInstancePreviousTypeDetector() *AwsDBInstancePreviousTypeDetector { - return &AwsDBInstancePreviousTypeDetector{ + nd := &AwsDBInstancePreviousTypeDetector{ Detector: d, - IssueType: issue.WARNING, - TargetType: "resource", - Target: "aws_db_instance", - DeepCheck: false, previousInstanceTypes: map[string]bool{}, } + nd.Name = "aws_db_instance_previous_type" + nd.IssueType = issue.WARNING + nd.TargetType = "resource" + nd.Target = "aws_db_instance" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_previous_type.md" + return nd } func (d *AwsDBInstancePreviousTypeDetector) PreProcess() { diff --git a/detector/aws_db_instance_readable_password.go b/detector/aws_db_instance_readable_password.go index 8962536a6..371ee99af 100644 --- a/detector/aws_db_instance_readable_password.go +++ b/detector/aws_db_instance_readable_password.go @@ -7,20 +7,17 @@ import ( type AwsDBInstanceReadablePasswordDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool } func (d *Detector) CreateAwsDBInstanceReadablePasswordDetector() *AwsDBInstanceReadablePasswordDetector { - return &AwsDBInstanceReadablePasswordDetector{ - Detector: d, - IssueType: issue.WARNING, - TargetType: "resource", - Target: "aws_db_instance", - DeepCheck: false, - } + nd := &AwsDBInstanceReadablePasswordDetector{Detector: d} + nd.Name = "aws_db_instance_readable_password" + nd.IssueType = issue.WARNING + nd.TargetType = "resource" + nd.Target = "aws_db_instance" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md" + return nd } func (d *AwsDBInstanceReadablePasswordDetector) Detect(resource *schema.Resource, issues *[]*issue.Issue) { diff --git a/detector/aws_elasticache_cluster_default_parameter_group.go b/detector/aws_elasticache_cluster_default_parameter_group.go index 3c1c82040..5e2421f5d 100644 --- a/detector/aws_elasticache_cluster_default_parameter_group.go +++ b/detector/aws_elasticache_cluster_default_parameter_group.go @@ -10,20 +10,17 @@ import ( type AwsElastiCacheClusterDefaultParameterGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool } func (d *Detector) CreateAwsElastiCacheClusterDefaultParameterGroupDetector() *AwsElastiCacheClusterDefaultParameterGroupDetector { - return &AwsElastiCacheClusterDefaultParameterGroupDetector{ - Detector: d, - IssueType: issue.NOTICE, - TargetType: "resource", - Target: "aws_elasticache_cluster", - DeepCheck: false, - } + nd := &AwsElastiCacheClusterDefaultParameterGroupDetector{Detector: d} + nd.Name = "aws_elasticache_cluster_default_parameter_group" + nd.IssueType = issue.NOTICE + nd.TargetType = "resource" + nd.Target = "aws_elasticache_cluster" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_default_parameter_group.md" + return nd } func (d *AwsElastiCacheClusterDefaultParameterGroupDetector) Detect(resource *schema.Resource, issues *[]*issue.Issue) { diff --git a/detector/aws_elasticache_cluster_duplicate_id.go b/detector/aws_elasticache_cluster_duplicate_id.go index 28d4293f7..82f62ed5e 100644 --- a/detector/aws_elasticache_cluster_duplicate_id.go +++ b/detector/aws_elasticache_cluster_duplicate_id.go @@ -9,22 +9,20 @@ import ( type AwsElastiCacheClusterDuplicateIDDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool cacheClusters map[string]bool } func (d *Detector) CreateAwsElastiCacheClusterDuplicateIDDetector() *AwsElastiCacheClusterDuplicateIDDetector { - return &AwsElastiCacheClusterDuplicateIDDetector{ + nd := &AwsElastiCacheClusterDuplicateIDDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_elasticache_cluster", - DeepCheck: true, cacheClusters: map[string]bool{}, } + nd.Name = "aws_elasticache_cluster_duplicate_id" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_elasticache_cluster" + nd.DeepCheck = true + return nd } func (d *AwsElastiCacheClusterDuplicateIDDetector) PreProcess() { diff --git a/detector/aws_elasticache_cluster_invalid_parameter_group.go b/detector/aws_elasticache_cluster_invalid_parameter_group.go index 627ecdb09..d18cbdd0a 100644 --- a/detector/aws_elasticache_cluster_invalid_parameter_group.go +++ b/detector/aws_elasticache_cluster_invalid_parameter_group.go @@ -9,22 +9,20 @@ import ( type AwsElastiCacheClusterInvalidParameterGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool cacheParameterGroups map[string]bool } func (d *Detector) CreateAwsElastiCacheClusterInvalidParameterGroupDetector() *AwsElastiCacheClusterInvalidParameterGroupDetector { - return &AwsElastiCacheClusterInvalidParameterGroupDetector{ + nd := &AwsElastiCacheClusterInvalidParameterGroupDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_elasticache_cluster", - DeepCheck: true, cacheParameterGroups: map[string]bool{}, } + nd.Name = "aws_elasticache_cluster_invalid_parameter_group" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_elasticache_cluster" + nd.DeepCheck = true + return nd } func (d *AwsElastiCacheClusterInvalidParameterGroupDetector) PreProcess() { diff --git a/detector/aws_elasticache_cluster_invalid_security_group.go b/detector/aws_elasticache_cluster_invalid_security_group.go index 104877f64..22dac68bd 100644 --- a/detector/aws_elasticache_cluster_invalid_security_group.go +++ b/detector/aws_elasticache_cluster_invalid_security_group.go @@ -10,22 +10,20 @@ import ( type AwsElastiCacheClusterInvalidSecurityGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool securityGroups map[string]bool } func (d *Detector) CreateAwsElastiCacheClusterInvalidSecurityGroupDetector() *AwsElastiCacheClusterInvalidSecurityGroupDetector { - return &AwsElastiCacheClusterInvalidSecurityGroupDetector{ + nd := &AwsElastiCacheClusterInvalidSecurityGroupDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_elasticache_cluster", - DeepCheck: true, securityGroups: map[string]bool{}, } + nd.Name = "aws_elasticache_cluster_invalid_security_group" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_elasticache_cluster" + nd.DeepCheck = true + return nd } func (d *AwsElastiCacheClusterInvalidSecurityGroupDetector) PreProcess() { diff --git a/detector/aws_elasticache_cluster_invalid_subnet_group.go b/detector/aws_elasticache_cluster_invalid_subnet_group.go index 511970d7d..f1bdb804f 100644 --- a/detector/aws_elasticache_cluster_invalid_subnet_group.go +++ b/detector/aws_elasticache_cluster_invalid_subnet_group.go @@ -9,22 +9,20 @@ import ( type AwsElastiCacheClusterInvalidSubnetGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool cacheSubnetGroups map[string]bool } func (d *Detector) CreateAwsElastiCacheClusterInvalidSubnetGroupDetector() *AwsElastiCacheClusterInvalidSubnetGroupDetector { - return &AwsElastiCacheClusterInvalidSubnetGroupDetector{ + nd := &AwsElastiCacheClusterInvalidSubnetGroupDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_elasticache_cluster", - DeepCheck: true, cacheSubnetGroups: map[string]bool{}, } + nd.Name = "aws_elasticache_cluster_invalid_subnet_group" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_elasticache_cluster" + nd.DeepCheck = true + return nd } func (d *AwsElastiCacheClusterInvalidSubnetGroupDetector) PreProcess() { diff --git a/detector/aws_elasticache_cluster_invalid_type.go b/detector/aws_elasticache_cluster_invalid_type.go index 888253794..5ed9f1213 100644 --- a/detector/aws_elasticache_cluster_invalid_type.go +++ b/detector/aws_elasticache_cluster_invalid_type.go @@ -9,22 +9,21 @@ import ( type AwsElastiCacheClusterInvalidTypeDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - nodeTypes map[string]bool + nodeTypes map[string]bool } func (d *Detector) CreateAwsElastiCacheClusterInvalidTypeDetector() *AwsElastiCacheClusterInvalidTypeDetector { - return &AwsElastiCacheClusterInvalidTypeDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_elasticache_cluster", - DeepCheck: false, - nodeTypes: map[string]bool{}, + nd := &AwsElastiCacheClusterInvalidTypeDetector{ + Detector: d, + nodeTypes: map[string]bool{}, } + nd.Name = "aws_elasticache_cluster_invalid_type" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_elasticache_cluster" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_invalid_type.md" + return nd } func (d *AwsElastiCacheClusterInvalidTypeDetector) PreProcess() { diff --git a/detector/aws_elasticache_cluster_previous_type.go b/detector/aws_elasticache_cluster_previous_type.go index fd9934e3f..e6289329b 100644 --- a/detector/aws_elasticache_cluster_previous_type.go +++ b/detector/aws_elasticache_cluster_previous_type.go @@ -9,22 +9,21 @@ import ( type AwsElastiCacheClusterPreviousTypeDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool previousNodeTypes map[string]bool } func (d *Detector) CreateAwsElastiCacheClusterPreviousTypeDetector() *AwsElastiCacheClusterPreviousTypeDetector { - return &AwsElastiCacheClusterPreviousTypeDetector{ + nd := &AwsElastiCacheClusterPreviousTypeDetector{ Detector: d, - IssueType: issue.WARNING, - TargetType: "resource", - Target: "aws_elasticache_cluster", - DeepCheck: false, previousNodeTypes: map[string]bool{}, } + nd.Name = "aws_elasticache_cluster_previous_type" + nd.IssueType = issue.WARNING + nd.TargetType = "resource" + nd.Target = "aws_elasticache_cluster" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_previous_type.md" + return nd } func (d *AwsElastiCacheClusterPreviousTypeDetector) PreProcess() { diff --git a/detector/aws_elb_duplicate_name.go b/detector/aws_elb_duplicate_name.go index 627cba640..6631b9329 100644 --- a/detector/aws_elb_duplicate_name.go +++ b/detector/aws_elb_duplicate_name.go @@ -9,22 +9,20 @@ import ( type AwsELBDuplicateNameDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool loadBalancers map[string]bool } func (d *Detector) CreateAwsELBDuplicateNameDetector() *AwsELBDuplicateNameDetector { - return &AwsELBDuplicateNameDetector{ + nd := &AwsELBDuplicateNameDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_elb", - DeepCheck: true, loadBalancers: map[string]bool{}, } + nd.Name = "aws_elb_duplicate_name" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_elb" + nd.DeepCheck = true + return nd } func (d *AwsELBDuplicateNameDetector) PreProcess() { diff --git a/detector/aws_elb_invalid_instance.go b/detector/aws_elb_invalid_instance.go index b42021194..d8ac801be 100644 --- a/detector/aws_elb_invalid_instance.go +++ b/detector/aws_elb_invalid_instance.go @@ -10,22 +10,20 @@ import ( type AwsELBInvalidInstanceDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - instances map[string]bool + instances map[string]bool } func (d *Detector) CreateAwsELBInvalidInstanceDetector() *AwsELBInvalidInstanceDetector { - return &AwsELBInvalidInstanceDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_elb", - DeepCheck: true, - instances: map[string]bool{}, + nd := &AwsELBInvalidInstanceDetector{ + Detector: d, + instances: map[string]bool{}, } + nd.Name = "aws_elb_invalid_instance" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_elb" + nd.DeepCheck = true + return nd } func (d *AwsELBInvalidInstanceDetector) PreProcess() { diff --git a/detector/aws_elb_invalid_security_group.go b/detector/aws_elb_invalid_security_group.go index 983cc8807..87ae239e5 100644 --- a/detector/aws_elb_invalid_security_group.go +++ b/detector/aws_elb_invalid_security_group.go @@ -10,22 +10,20 @@ import ( type AwsELBInvalidSecurityGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool securityGroups map[string]bool } func (d *Detector) CreateAwsELBInvalidSecurityGroupDetector() *AwsELBInvalidSecurityGroupDetector { - return &AwsELBInvalidSecurityGroupDetector{ + nd := &AwsELBInvalidSecurityGroupDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_elb", - DeepCheck: true, securityGroups: map[string]bool{}, } + nd.Name = "aws_elb_invalid_security_group" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_elb" + nd.DeepCheck = true + return nd } func (d *AwsELBInvalidSecurityGroupDetector) PreProcess() { diff --git a/detector/aws_elb_invalid_subnet.go b/detector/aws_elb_invalid_subnet.go index 6545897c6..55e589305 100644 --- a/detector/aws_elb_invalid_subnet.go +++ b/detector/aws_elb_invalid_subnet.go @@ -10,22 +10,20 @@ import ( type AwsELBInvalidSubnetDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - subnets map[string]bool + subnets map[string]bool } func (d *Detector) CreateAwsELBInvalidSubnetDetector() *AwsELBInvalidSubnetDetector { - return &AwsELBInvalidSubnetDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_elb", - DeepCheck: true, - subnets: map[string]bool{}, + nd := &AwsELBInvalidSubnetDetector{ + Detector: d, + subnets: map[string]bool{}, } + nd.Name = "aws_elb_invalid_subnet" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_elb" + nd.DeepCheck = true + return nd } func (d *AwsELBInvalidSubnetDetector) PreProcess() { diff --git a/detector/aws_instance_default_standard_volume.go b/detector/aws_instance_default_standard_volume.go index df7142e26..f234ea9bd 100644 --- a/detector/aws_instance_default_standard_volume.go +++ b/detector/aws_instance_default_standard_volume.go @@ -7,20 +7,17 @@ import ( type AwsInstanceDefaultStandardVolumeDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool } func (d *Detector) CreateAwsInstanceDefaultStandardVolumeDetector() *AwsInstanceDefaultStandardVolumeDetector { - return &AwsInstanceDefaultStandardVolumeDetector{ - Detector: d, - IssueType: issue.WARNING, - TargetType: "resource", - Target: "aws_instance", - DeepCheck: false, - } + nd := &AwsInstanceDefaultStandardVolumeDetector{Detector: d} + nd.Name = "aws_instance_default_standard_volume" + nd.IssueType = issue.WARNING + nd.TargetType = "resource" + nd.Target = "aws_instance" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md" + return nd } func (d *AwsInstanceDefaultStandardVolumeDetector) Detect(resource *schema.Resource, issues *[]*issue.Issue) { diff --git a/detector/aws_instance_invalid_ami.go b/detector/aws_instance_invalid_ami.go index 0eca23029..942d763a6 100644 --- a/detector/aws_instance_invalid_ami.go +++ b/detector/aws_instance_invalid_ami.go @@ -9,22 +9,20 @@ import ( type AwsInstanceInvalidAMIDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - amis map[string]bool + amis map[string]bool } func (d *Detector) CreateAwsInstanceInvalidAMIDetector() *AwsInstanceInvalidAMIDetector { - return &AwsInstanceInvalidAMIDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_instance", - DeepCheck: true, - amis: map[string]bool{}, + nd := &AwsInstanceInvalidAMIDetector{ + Detector: d, + amis: map[string]bool{}, } + nd.Name = "aws_instance_invalid_ami" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_instance" + nd.DeepCheck = true + return nd } func (d *AwsInstanceInvalidAMIDetector) PreProcess() { diff --git a/detector/aws_instance_invalid_iam_profile.go b/detector/aws_instance_invalid_iam_profile.go index 46fae32ca..4d20a3ff3 100644 --- a/detector/aws_instance_invalid_iam_profile.go +++ b/detector/aws_instance_invalid_iam_profile.go @@ -9,22 +9,20 @@ import ( type AwsInstanceInvalidIAMProfileDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - profiles map[string]bool + profiles map[string]bool } func (d *Detector) CreateAwsInstanceInvalidIAMProfileDetector() *AwsInstanceInvalidIAMProfileDetector { - return &AwsInstanceInvalidIAMProfileDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_instance", - DeepCheck: true, - profiles: map[string]bool{}, + nd := &AwsInstanceInvalidIAMProfileDetector{ + Detector: d, + profiles: map[string]bool{}, } + nd.Name = "aws_instance_invalid_iam_profile" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_instance" + nd.DeepCheck = true + return nd } func (d *AwsInstanceInvalidIAMProfileDetector) PreProcess() { diff --git a/detector/aws_instance_invalid_key_name.go b/detector/aws_instance_invalid_key_name.go index bf31769f8..3ccd2bb33 100644 --- a/detector/aws_instance_invalid_key_name.go +++ b/detector/aws_instance_invalid_key_name.go @@ -9,22 +9,20 @@ import ( type AwsInstanceInvalidKeyNameDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - keypairs map[string]bool + keypairs map[string]bool } func (d *Detector) CreateAwsInstanceInvalidKeyNameDetector() *AwsInstanceInvalidKeyNameDetector { - return &AwsInstanceInvalidKeyNameDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_instance", - DeepCheck: true, - keypairs: map[string]bool{}, + nd := &AwsInstanceInvalidKeyNameDetector{ + Detector: d, + keypairs: map[string]bool{}, } + nd.Name = "aws_instance_invalid_key_name" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_instance" + nd.DeepCheck = true + return nd } func (d *AwsInstanceInvalidKeyNameDetector) PreProcess() { diff --git a/detector/aws_instance_invalid_subnet.go b/detector/aws_instance_invalid_subnet.go index 6704c9f70..6e8d1f041 100644 --- a/detector/aws_instance_invalid_subnet.go +++ b/detector/aws_instance_invalid_subnet.go @@ -9,22 +9,20 @@ import ( type AwsInstanceInvalidSubnetDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - subnets map[string]bool + subnets map[string]bool } func (d *Detector) CreateAwsInstanceInvalidSubnetDetector() *AwsInstanceInvalidSubnetDetector { - return &AwsInstanceInvalidSubnetDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_instance", - DeepCheck: true, - subnets: map[string]bool{}, + nd := &AwsInstanceInvalidSubnetDetector{ + Detector: d, + subnets: map[string]bool{}, } + nd.Name = "aws_instance_invalid_subnet" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_instance" + nd.DeepCheck = true + return nd } func (d *AwsInstanceInvalidSubnetDetector) PreProcess() { diff --git a/detector/aws_instance_invalid_type.go b/detector/aws_instance_invalid_type.go index 712efd5a1..8daaa6d9f 100644 --- a/detector/aws_instance_invalid_type.go +++ b/detector/aws_instance_invalid_type.go @@ -9,22 +9,21 @@ import ( type AwsInstanceInvalidTypeDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool instanceTypes map[string]bool } func (d *Detector) CreateAwsInstanceInvalidTypeDetector() *AwsInstanceInvalidTypeDetector { - return &AwsInstanceInvalidTypeDetector{ + nd := &AwsInstanceInvalidTypeDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_instance", - DeepCheck: false, instanceTypes: map[string]bool{}, } + nd.Name = "aws_instance_invalid_type" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_instance" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md" + return nd } func (d *AwsInstanceInvalidTypeDetector) PreProcess() { diff --git a/detector/aws_instance_invalid_vpc_security_group.go b/detector/aws_instance_invalid_vpc_security_group.go index 2041f2b2c..dc1168d31 100644 --- a/detector/aws_instance_invalid_vpc_security_group.go +++ b/detector/aws_instance_invalid_vpc_security_group.go @@ -10,22 +10,20 @@ import ( type AwsInstanceInvalidVPCSecurityGroupDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool securityGroups map[string]bool } func (d *Detector) CreateAwsInstanceInvalidVPCSecurityGroupDetector() *AwsInstanceInvalidVPCSecurityGroupDetector { - return &AwsInstanceInvalidVPCSecurityGroupDetector{ + nd := &AwsInstanceInvalidVPCSecurityGroupDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_instance", - DeepCheck: true, securityGroups: map[string]bool{}, } + nd.Name = "aws_instance_invalid_vpc_security_group" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_instance" + nd.DeepCheck = true + return nd } func (d *AwsInstanceInvalidVPCSecurityGroupDetector) PreProcess() { diff --git a/detector/aws_instance_not_specified_iam_profile.go b/detector/aws_instance_not_specified_iam_profile.go index 596f400dc..9adef9449 100644 --- a/detector/aws_instance_not_specified_iam_profile.go +++ b/detector/aws_instance_not_specified_iam_profile.go @@ -7,20 +7,17 @@ import ( type AwsInstanceNotSpecifiedIAMProfileDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool } func (d *Detector) CreateAwsInstanceNotSpecifiedIAMProfileDetector() *AwsInstanceNotSpecifiedIAMProfileDetector { - return &AwsInstanceNotSpecifiedIAMProfileDetector{ - Detector: d, - IssueType: issue.NOTICE, - TargetType: "resource", - Target: "aws_instance", - DeepCheck: false, - } + nd := &AwsInstanceNotSpecifiedIAMProfileDetector{Detector: d} + nd.Name = "aws_instance_not_specified_iam_profile" + nd.IssueType = issue.NOTICE + nd.TargetType = "resource" + nd.Target = "aws_instance" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_instance_not_specified_iam_profile.md" + return nd } func (d *AwsInstanceNotSpecifiedIAMProfileDetector) Detect(resource *schema.Resource, issues *[]*issue.Issue) { diff --git a/detector/aws_instance_previous_type.go b/detector/aws_instance_previous_type.go index 2d3d1372b..724a0a250 100644 --- a/detector/aws_instance_previous_type.go +++ b/detector/aws_instance_previous_type.go @@ -9,22 +9,21 @@ import ( type AwsInstancePreviousTypeDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool previousInstanceTypes map[string]bool } func (d *Detector) CreateAwsInstancePreviousTypeDetector() *AwsInstancePreviousTypeDetector { - return &AwsInstancePreviousTypeDetector{ + nd := &AwsInstancePreviousTypeDetector{ Detector: d, - IssueType: issue.WARNING, - TargetType: "resource", - Target: "aws_instance", - DeepCheck: false, previousInstanceTypes: map[string]bool{}, } + nd.Name = "aws_instance_previous_type" + nd.IssueType = issue.WARNING + nd.TargetType = "resource" + nd.Target = "aws_instance" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_instance_previous_type.md" + return nd } func (d *AwsInstancePreviousTypeDetector) PreProcess() { diff --git a/detector/aws_route_invalid_egress_only_gateway.go b/detector/aws_route_invalid_egress_only_gateway.go index b2cf3ddba..e5d75f7e6 100644 --- a/detector/aws_route_invalid_egress_only_gateway.go +++ b/detector/aws_route_invalid_egress_only_gateway.go @@ -9,22 +9,20 @@ import ( type AwsRouteInvalidEgressOnlyGatewayDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - egateways map[string]bool + egateways map[string]bool } func (d *Detector) CreateAwsRouteInvalidEgressOnlyGatewayDetector() *AwsRouteInvalidEgressOnlyGatewayDetector { - return &AwsRouteInvalidEgressOnlyGatewayDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_route", - DeepCheck: true, - egateways: map[string]bool{}, + nd := &AwsRouteInvalidEgressOnlyGatewayDetector{ + Detector: d, + egateways: map[string]bool{}, } + nd.Name = "aws_route_invalid_egress_only_gateway" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_route" + nd.DeepCheck = true + return nd } func (d *AwsRouteInvalidEgressOnlyGatewayDetector) PreProcess() { diff --git a/detector/aws_route_invalid_gateway.go b/detector/aws_route_invalid_gateway.go index 25105c984..8e6037466 100644 --- a/detector/aws_route_invalid_gateway.go +++ b/detector/aws_route_invalid_gateway.go @@ -9,22 +9,20 @@ import ( type AwsRouteInvalidGatewayDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - gateways map[string]bool + gateways map[string]bool } func (d *Detector) CreateAwsRouteInvalidGatewayDetector() *AwsRouteInvalidGatewayDetector { - return &AwsRouteInvalidGatewayDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_route", - DeepCheck: true, - gateways: map[string]bool{}, + nd := &AwsRouteInvalidGatewayDetector{ + Detector: d, + gateways: map[string]bool{}, } + nd.Name = "aws_route_invalid_gateway" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_route" + nd.DeepCheck = true + return nd } func (d *AwsRouteInvalidGatewayDetector) PreProcess() { diff --git a/detector/aws_route_invalid_instance.go b/detector/aws_route_invalid_instance.go index 1a4acc014..9156edded 100644 --- a/detector/aws_route_invalid_instance.go +++ b/detector/aws_route_invalid_instance.go @@ -9,22 +9,20 @@ import ( type AwsRouteInvalidInstanceDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - instances map[string]bool + instances map[string]bool } func (d *Detector) CreateAwsRouteInvalidInstanceDetector() *AwsRouteInvalidInstanceDetector { - return &AwsRouteInvalidInstanceDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_route", - DeepCheck: true, - instances: map[string]bool{}, + nd := &AwsRouteInvalidInstanceDetector{ + Detector: d, + instances: map[string]bool{}, } + nd.Name = "aws_route_invalid_instance" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_route" + nd.DeepCheck = true + return nd } func (d *AwsRouteInvalidInstanceDetector) PreProcess() { diff --git a/detector/aws_route_invalid_nat_gateway.go b/detector/aws_route_invalid_nat_gateway.go index 41d87fda9..a0ed6d4b6 100644 --- a/detector/aws_route_invalid_nat_gateway.go +++ b/detector/aws_route_invalid_nat_gateway.go @@ -9,22 +9,20 @@ import ( type AwsRouteInvalidNatGatewayDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool - ngateways map[string]bool + ngateways map[string]bool } func (d *Detector) CreateAwsRouteInvalidNatGatewayDetector() *AwsRouteInvalidNatGatewayDetector { - return &AwsRouteInvalidNatGatewayDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_route", - DeepCheck: true, - ngateways: map[string]bool{}, + nd := &AwsRouteInvalidNatGatewayDetector{ + Detector: d, + ngateways: map[string]bool{}, } + nd.Name = "aws_route_invalid_nat_gateway" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_route" + nd.DeepCheck = true + return nd } func (d *AwsRouteInvalidNatGatewayDetector) PreProcess() { diff --git a/detector/aws_route_invalid_network_interface.go b/detector/aws_route_invalid_network_interface.go index 967c526a8..5de020885 100644 --- a/detector/aws_route_invalid_network_interface.go +++ b/detector/aws_route_invalid_network_interface.go @@ -9,22 +9,20 @@ import ( type AwsRouteInvalidNetworkInterfaceDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool networkInterfaces map[string]bool } func (d *Detector) CreateAwsRouteInvalidNetworkInterfaceDetector() *AwsRouteInvalidNetworkInterfaceDetector { - return &AwsRouteInvalidNetworkInterfaceDetector{ + nd := &AwsRouteInvalidNetworkInterfaceDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_route", - DeepCheck: true, networkInterfaces: map[string]bool{}, } + nd.Name = "aws_route_invalid_network_interface" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_route" + nd.DeepCheck = true + return nd } func (d *AwsRouteInvalidNetworkInterfaceDetector) PreProcess() { diff --git a/detector/aws_route_invalid_route_table.go b/detector/aws_route_invalid_route_table.go index 07570e29a..8963e5898 100644 --- a/detector/aws_route_invalid_route_table.go +++ b/detector/aws_route_invalid_route_table.go @@ -9,22 +9,20 @@ import ( type AwsRouteInvalidRouteTableDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool routeTables map[string]bool } func (d *Detector) CreateAwsRouteInvalidRouteTableDetector() *AwsRouteInvalidRouteTableDetector { - return &AwsRouteInvalidRouteTableDetector{ + nd := &AwsRouteInvalidRouteTableDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_route", - DeepCheck: true, routeTables: map[string]bool{}, } + nd.Name = "aws_route_invalid_route_table" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_route" + nd.DeepCheck = true + return nd } func (d *AwsRouteInvalidRouteTableDetector) PreProcess() { diff --git a/detector/aws_route_invalid_vpc_peering_connection.go b/detector/aws_route_invalid_vpc_peering_connection.go index 7c9f0cc26..323b924cf 100644 --- a/detector/aws_route_invalid_vpc_peering_connection.go +++ b/detector/aws_route_invalid_vpc_peering_connection.go @@ -9,22 +9,20 @@ import ( type AwsRouteInvalidVpcPeeringConnectionDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool vpcPeeringConnections map[string]bool } func (d *Detector) CreateAwsRouteInvalidVpcPeeringConnectionDetector() *AwsRouteInvalidVpcPeeringConnectionDetector { - return &AwsRouteInvalidVpcPeeringConnectionDetector{ + nd := &AwsRouteInvalidVpcPeeringConnectionDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_route", - DeepCheck: true, vpcPeeringConnections: map[string]bool{}, } + nd.Name = "aws_route_invalid_vpc_peering_connection" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_route" + nd.DeepCheck = true + return nd } func (d *AwsRouteInvalidVpcPeeringConnectionDetector) PreProcess() { diff --git a/detector/aws_route_not_specified_target.go b/detector/aws_route_not_specified_target.go index 9d8a9a841..0ab645752 100644 --- a/detector/aws_route_not_specified_target.go +++ b/detector/aws_route_not_specified_target.go @@ -7,20 +7,17 @@ import ( type AwsRouteNotSpecifiedTargetDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool } func (d *Detector) CreateAwsRouteNotSpecifiedTargetDetector() *AwsRouteNotSpecifiedTargetDetector { - return &AwsRouteNotSpecifiedTargetDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_route", - DeepCheck: false, - } + nd := &AwsRouteNotSpecifiedTargetDetector{Detector: d} + nd.Name = "aws_route_not_specified_target" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_route" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_route_not_specified_target.md" + return nd } func (d *AwsRouteNotSpecifiedTargetDetector) Detect(resource *schema.Resource, issues *[]*issue.Issue) { diff --git a/detector/aws_route_specified_multiple_targets.go b/detector/aws_route_specified_multiple_targets.go index 1daca2a8e..87292eb01 100644 --- a/detector/aws_route_specified_multiple_targets.go +++ b/detector/aws_route_specified_multiple_targets.go @@ -7,20 +7,17 @@ import ( type AwsRouteSpecifiedMultipleTargetsDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool } func (d *Detector) CreateAwsRouteSpecifiedMultipleTargetsDetector() *AwsRouteSpecifiedMultipleTargetsDetector { - return &AwsRouteSpecifiedMultipleTargetsDetector{ - Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_route", - DeepCheck: false, - } + nd := &AwsRouteSpecifiedMultipleTargetsDetector{Detector: d} + nd.Name = "aws_route_specified_multiple_targets" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_route" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/aws_route_specified_multiple_targets.md" + return nd } func (d *AwsRouteSpecifiedMultipleTargetsDetector) Detect(resource *schema.Resource, issues *[]*issue.Issue) { diff --git a/detector/aws_security_group_duplicate_name.go b/detector/aws_security_group_duplicate_name.go index 7091f2ce7..9c67fc6f5 100644 --- a/detector/aws_security_group_duplicate_name.go +++ b/detector/aws_security_group_duplicate_name.go @@ -9,24 +9,22 @@ import ( type AwsSecurityGroupDuplicateDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool securiyGroups map[string]bool defaultVpc string } func (d *Detector) CreateAwsSecurityGroupDuplicateDetector() *AwsSecurityGroupDuplicateDetector { - return &AwsSecurityGroupDuplicateDetector{ + nd := &AwsSecurityGroupDuplicateDetector{ Detector: d, - IssueType: issue.ERROR, - TargetType: "resource", - Target: "aws_security_group", - DeepCheck: true, securiyGroups: map[string]bool{}, defaultVpc: "", } + nd.Name = "aws_security_group_duplicate_name" + nd.IssueType = issue.ERROR + nd.TargetType = "resource" + nd.Target = "aws_security_group" + nd.DeepCheck = true + return nd } func (d *AwsSecurityGroupDuplicateDetector) PreProcess() { diff --git a/detector/detector.go b/detector/detector.go index acfa6aec7..f9af96790 100644 --- a/detector/detector.go +++ b/detector/detector.go @@ -28,6 +28,13 @@ type Detector struct { EvalConfig *evaluator.Evaluator Logger *logger.Logger Error bool + + Name string + IssueType string + TargetType string + Target string + DeepCheck bool + Link string } var detectors = map[string]string{ diff --git a/detector/terraform_module_pinned_source.go b/detector/terraform_module_pinned_source.go index 844a65a15..de707f544 100644 --- a/detector/terraform_module_pinned_source.go +++ b/detector/terraform_module_pinned_source.go @@ -10,18 +10,16 @@ import ( type TerraformModulePinnedSourceDetector struct { *Detector - IssueType string - TargetType string - DeepCheck bool } func (d *Detector) CreateTerraformModulePinnedSourceDetector() *TerraformModulePinnedSourceDetector { - return &TerraformModulePinnedSourceDetector{ - Detector: d, - IssueType: issue.WARNING, - TargetType: "module", - DeepCheck: false, - } + nd := &TerraformModulePinnedSourceDetector{Detector: d} + nd.Name = "terraform_module_pinned_source" + nd.IssueType = issue.WARNING + nd.TargetType = "module" + nd.DeepCheck = false + nd.Link = "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md" + return nd } func (d *TerraformModulePinnedSourceDetector) Detect(module *schema.Module, issues *[]*issue.Issue) { From 5eaaff37d13527c2dae98aa101ab438d77a30684 Mon Sep 17 00:00:00 2001 From: wata_mac Date: Sat, 8 Jul 2017 20:32:18 +0900 Subject: [PATCH 2/4] Disable goconst --- gometalinter.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gometalinter.json b/gometalinter.json index 1dc50dc50..ff281283a 100644 --- a/gometalinter.json +++ b/gometalinter.json @@ -8,6 +8,7 @@ "gotype", "lll", "vetshadow", - "gocyclo" + "gocyclo", + "goconst" ] } From 64941ddd5684e5ca06e7f928721b2e106f7b56f7 Mon Sep 17 00:00:00 2001 From: wata_mac Date: Sat, 8 Jul 2017 21:58:27 +0900 Subject: [PATCH 3/4] Print detector name and link --- detector/aws_alb_duplicate_name.go | 9 ++- detector/aws_alb_duplicate_name_test.go | 9 ++- detector/aws_alb_invaid_security_group.go | 9 ++- .../aws_alb_invalid_security_group_test.go | 36 +++++---- detector/aws_alb_invalid_subnet.go | 9 ++- detector/aws_alb_invalid_subnet_test.go | 18 +++-- ...ws_cloudwatch_metric_alarm_invalid_unit.go | 10 ++- ...oudwatch_metric_alarm_invalid_unit_test.go | 20 +++-- ...aws_db_instance_default_parameter_group.go | 10 ++- ...b_instance_default_parameter_group_test.go | 10 ++- .../aws_db_instance_duplicate_identifier.go | 9 ++- ...s_db_instance_duplicate_identifier_test.go | 9 ++- ...aws_db_instance_invalid_db_subnet_group.go | 9 ++- ...b_instance_invalid_db_subnet_group_test.go | 9 ++- .../aws_db_instance_invalid_option_group.go | 9 ++- ...s_db_instance_invalid_option_group_test.go | 9 ++- ...aws_db_instance_invalid_parameter_group.go | 9 ++- ...b_instance_invalid_parameter_group_test.go | 9 ++- detector/aws_db_instance_invalid_type.go | 10 ++- detector/aws_db_instance_invalid_type_test.go | 10 ++- ..._db_instance_invalid_vpc_security_group.go | 9 ++- ...nstance_invalid_vpc_security_group_test.go | 36 +++++---- detector/aws_db_instance_previous_type.go | 10 ++- .../aws_db_instance_previous_type_test.go | 10 ++- detector/aws_db_instance_readable_password.go | 10 ++- .../aws_db_instance_readable_password_test.go | 10 ++- ...ticache_cluster_default_parameter_group.go | 10 ++- ...he_cluster_default_parameter_group_test.go | 10 ++- .../aws_elasticache_cluster_duplicate_id.go | 9 ++- ...s_elasticache_cluster_duplicate_id_test.go | 9 ++- ...ticache_cluster_invalid_parameter_group.go | 9 ++- ...he_cluster_invalid_parameter_group_test.go | 9 ++- ...sticache_cluster_invalid_security_group.go | 9 ++- ...che_cluster_invalid_security_group_test.go | 36 +++++---- ...lasticache_cluster_invalid_subnet_group.go | 9 ++- ...cache_cluster_invalid_subnet_group_test.go | 9 ++- .../aws_elasticache_cluster_invalid_type.go | 10 ++- ...s_elasticache_cluster_invalid_type_test.go | 10 ++- .../aws_elasticache_cluster_previous_type.go | 10 ++- ..._elasticache_cluster_previous_type_test.go | 10 ++- detector/aws_elb_duplicate_name.go | 9 ++- detector/aws_elb_duplicate_name_test.go | 9 ++- detector/aws_elb_invalid_instance.go | 9 ++- detector/aws_elb_invalid_instance_test.go | 36 +++++---- detector/aws_elb_invalid_security_group.go | 9 ++- .../aws_elb_invalid_security_group_test.go | 36 +++++---- detector/aws_elb_invalid_subnet.go | 9 ++- detector/aws_elb_invalid_subnet_test.go | 36 +++++---- .../aws_instance_default_standard_volume.go | 10 ++- ...s_instance_default_standard_volume_test.go | 50 +++++++----- detector/aws_instance_invalid_ami.go | 9 ++- detector/aws_instance_invalid_ami_test.go | 9 ++- detector/aws_instance_invalid_iam_profile.go | 9 ++- .../aws_instance_invalid_iam_profile_test.go | 9 ++- detector/aws_instance_invalid_key_name.go | 9 ++- .../aws_instance_invalid_key_name_test.go | 9 ++- detector/aws_instance_invalid_subnet.go | 9 ++- detector/aws_instance_invalid_subnet_test.go | 9 ++- detector/aws_instance_invalid_type.go | 10 ++- detector/aws_instance_invalid_type_test.go | 10 ++- ...aws_instance_invalid_vpc_security_group.go | 9 ++- ...nstance_invalid_vpc_security_group_test.go | 36 +++++---- .../aws_instance_not_specified_iam_profile.go | 10 ++- ...instance_not_specified_iam_profile_test.go | 10 ++- detector/aws_instance_previous_type.go | 10 ++- detector/aws_instance_previous_type_test.go | 10 ++- .../aws_route_invalid_egress_only_gateway.go | 9 ++- ..._route_invalid_egress_only_gateway_test.go | 9 ++- detector/aws_route_invalid_gateway.go | 9 ++- detector/aws_route_invalid_gateway_test.go | 9 ++- detector/aws_route_invalid_instance.go | 9 ++- detector/aws_route_invalid_instance_test.go | 9 ++- detector/aws_route_invalid_nat_gateway.go | 9 ++- .../aws_route_invalid_nat_gateway_test.go | 9 ++- .../aws_route_invalid_network_interface.go | 9 ++- ...ws_route_invalid_network_interface_test.go | 9 ++- detector/aws_route_invalid_route_table.go | 9 ++- .../aws_route_invalid_route_table_test.go | 9 ++- ...ws_route_invalid_vpc_peering_connection.go | 9 ++- ...ute_invalid_vpc_peering_connection_test.go | 9 ++- detector/aws_route_not_specified_target.go | 10 ++- .../aws_route_not_specified_target_test.go | 10 ++- .../aws_route_specified_multiple_targets.go | 10 ++- ...s_route_specified_multiple_targets_test.go | 10 ++- detector/aws_security_group_duplicate_name.go | 9 ++- .../aws_security_group_duplicate_name_test.go | 27 ++++--- detector/terraform_module_pinned_source.go | 40 ++++++---- .../terraform_module_pinned_source_test.go | 80 +++++++++++-------- integration/general/result.json | 64 +++++++++++---- issue/issue.go | 10 ++- printer/checkstyle.go | 13 ++- printer/checkstyle_test.go | 34 ++++---- printer/default.go | 15 ++-- printer/default_test.go | 45 ++++++----- 94 files changed, 798 insertions(+), 571 deletions(-) diff --git a/detector/aws_alb_duplicate_name.go b/detector/aws_alb_duplicate_name.go index 64e60d3bc..5fe1968d3 100644 --- a/detector/aws_alb_duplicate_name.go +++ b/detector/aws_alb_duplicate_name.go @@ -51,10 +51,11 @@ func (d *AwsALBDuplicateNameDetector) Detect(resource *schema.Resource, issues * if d.loadBalancers[name] && !d.State.Exists(d.Target, resource.Id) { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is duplicate name. It must be unique.", name), - Line: nameToken.Pos.Line, - File: nameToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is duplicate name. It must be unique.", name), + Line: nameToken.Pos.Line, + File: nameToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_alb_duplicate_name_test.go b/detector/aws_alb_duplicate_name_test.go index f5625a02c..6278fe671 100644 --- a/detector/aws_alb_duplicate_name_test.go +++ b/detector/aws_alb_duplicate_name_test.go @@ -37,10 +37,11 @@ resource "aws_alb" "test" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"test-alb-tf\" is duplicate name. It must be unique.", - Line: 3, - File: "test.tf", + Detector: "aws_alb_duplicate_name", + Type: "ERROR", + Message: "\"test-alb-tf\" is duplicate name. It must be unique.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_alb_invaid_security_group.go b/detector/aws_alb_invaid_security_group.go index 685753466..50409adf9 100644 --- a/detector/aws_alb_invaid_security_group.go +++ b/detector/aws_alb_invaid_security_group.go @@ -70,10 +70,11 @@ func (d *AwsALBInvalidSecurityGroupDetector) Detect(resource *schema.Resource, i } if !d.securityGroups[securityGroup] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid security group.", securityGroup), - Line: securityGroupToken.Pos.Line, - File: securityGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid security group.", securityGroup), + Line: securityGroupToken.Pos.Line, + File: securityGroupToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_alb_invalid_security_group_test.go b/detector/aws_alb_invalid_security_group_test.go index 657533042..ae1d866f8 100644 --- a/detector/aws_alb_invalid_security_group_test.go +++ b/detector/aws_alb_invalid_security_group_test.go @@ -39,16 +39,18 @@ resource "aws_alb" "balancer" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"sg-1234abcd\" is invalid security group.", - Line: 4, - File: "test.tf", + Detector: "aws_alb_invalid_security_group", + Type: "ERROR", + Message: "\"sg-1234abcd\" is invalid security group.", + Line: 4, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"sg-abcd1234\" is invalid security group.", - Line: 5, - File: "test.tf", + Detector: "aws_alb_invalid_security_group", + Type: "ERROR", + Message: "\"sg-abcd1234\" is invalid security group.", + Line: 5, + File: "test.tf", }, }, }, @@ -91,16 +93,18 @@ resource "aws_alb" "balancer" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"sg-1234abcd\" is invalid security group.", - Line: 7, - File: "test.tf", + Detector: "aws_alb_invalid_security_group", + Type: "ERROR", + Message: "\"sg-1234abcd\" is invalid security group.", + Line: 7, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"sg-abcd1234\" is invalid security group.", - Line: 7, - File: "test.tf", + Detector: "aws_alb_invalid_security_group", + Type: "ERROR", + Message: "\"sg-abcd1234\" is invalid security group.", + Line: 7, + File: "test.tf", }, }, }, diff --git a/detector/aws_alb_invalid_subnet.go b/detector/aws_alb_invalid_subnet.go index 691da3408..d7bb946f8 100644 --- a/detector/aws_alb_invalid_subnet.go +++ b/detector/aws_alb_invalid_subnet.go @@ -70,10 +70,11 @@ func (d *AwsALBInvalidSubnetDetector) Detect(resource *schema.Resource, issues * } if !d.subnets[subnet] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid subnet ID.", subnet), - Line: subnetToken.Pos.Line, - File: subnetToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid subnet ID.", subnet), + Line: subnetToken.Pos.Line, + File: subnetToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_alb_invalid_subnet_test.go b/detector/aws_alb_invalid_subnet_test.go index aef81be62..7fc029946 100644 --- a/detector/aws_alb_invalid_subnet_test.go +++ b/detector/aws_alb_invalid_subnet_test.go @@ -39,16 +39,18 @@ resource "aws_alb" "balancer" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"subnet-1234abcd\" is invalid subnet ID.", - Line: 4, - File: "test.tf", + Detector: "aws_alb_invalid_subnet", + Type: "ERROR", + Message: "\"subnet-1234abcd\" is invalid subnet ID.", + Line: 4, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"subnet-abcd1234\" is invalid subnet ID.", - Line: 5, - File: "test.tf", + Detector: "aws_alb_invalid_subnet", + Type: "ERROR", + Message: "\"subnet-abcd1234\" is invalid subnet ID.", + Line: 5, + File: "test.tf", }, }, }, diff --git a/detector/aws_cloudwatch_metric_alarm_invalid_unit.go b/detector/aws_cloudwatch_metric_alarm_invalid_unit.go index 5bba1e10f..95bfa030f 100644 --- a/detector/aws_cloudwatch_metric_alarm_invalid_unit.go +++ b/detector/aws_cloudwatch_metric_alarm_invalid_unit.go @@ -72,10 +72,12 @@ func (d *AwsCloudWatchMetricAlarmInvalidUnitDetector) Detect(resource *schema.Re if !d.validUnits[unit] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid unit.", unit), - Line: unitToken.Pos.Line, - File: unitToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid unit.", unit), + Line: unitToken.Pos.Line, + File: unitToken.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_cloudwatch_metric_alarm_invalid_unit_test.go b/detector/aws_cloudwatch_metric_alarm_invalid_unit_test.go index 1bb964a25..dc5c1f367 100644 --- a/detector/aws_cloudwatch_metric_alarm_invalid_unit_test.go +++ b/detector/aws_cloudwatch_metric_alarm_invalid_unit_test.go @@ -29,10 +29,12 @@ resource "aws_cloudwatch_metric_alarm" "test" { }`, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"GB\" is invalid unit.", - Line: 9, - File: "test.tf", + Detector: "aws_cloudwatch_metric_alarm_invalid_unit", + Type: "ERROR", + Message: "\"GB\" is invalid unit.", + Line: 9, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_cloudwatch_metric_alarm_invalid_unit.md", }, }, }, @@ -50,10 +52,12 @@ resource "aws_cloudwatch_metric_alarm" "test" { }`, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"gigabytes\" is invalid unit.", - Line: 9, - File: "test.tf", + Detector: "aws_cloudwatch_metric_alarm_invalid_unit", + Type: "ERROR", + Message: "\"gigabytes\" is invalid unit.", + Line: 9, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_cloudwatch_metric_alarm_invalid_unit.md", }, }, }, diff --git a/detector/aws_db_instance_default_parameter_group.go b/detector/aws_db_instance_default_parameter_group.go index de99e1db9..819e44873 100644 --- a/detector/aws_db_instance_default_parameter_group.go +++ b/detector/aws_db_instance_default_parameter_group.go @@ -36,10 +36,12 @@ func (d *AwsDBInstanceDefaultParameterGroupDetector) Detect(resource *schema.Res if d.isDefaultDbParameterGroup(parameterGroup) { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is default parameter group. You cannot edit it.", parameterGroup), - Line: parameterGroupToken.Pos.Line, - File: parameterGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is default parameter group. You cannot edit it.", parameterGroup), + Line: parameterGroupToken.Pos.Line, + File: parameterGroupToken.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_db_instance_default_parameter_group_test.go b/detector/aws_db_instance_default_parameter_group_test.go index 5f74f40f3..67c0ba8c1 100644 --- a/detector/aws_db_instance_default_parameter_group_test.go +++ b/detector/aws_db_instance_default_parameter_group_test.go @@ -23,10 +23,12 @@ resource "aws_db_instance" "db" { }`, Issues: []*issue.Issue{ { - Type: "NOTICE", - Message: "\"default.mysql5.6\" is default parameter group. You cannot edit it.", - Line: 3, - File: "test.tf", + Detector: "aws_db_instance_default_parameter_group", + Type: "NOTICE", + Message: "\"default.mysql5.6\" is default parameter group. You cannot edit it.", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_default_parameter_group.md", }, }, }, diff --git a/detector/aws_db_instance_duplicate_identifier.go b/detector/aws_db_instance_duplicate_identifier.go index e8e4b4516..1ed9448c1 100644 --- a/detector/aws_db_instance_duplicate_identifier.go +++ b/detector/aws_db_instance_duplicate_identifier.go @@ -51,10 +51,11 @@ func (d *AwsDBInstanceDuplicateIdentifierDetector) Detect(resource *schema.Resou if d.identifiers[identifier] && !d.State.Exists(d.Target, resource.Id) { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is duplicate identifier. It must be unique.", identifier), - Line: identifierToken.Pos.Line, - File: identifierToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is duplicate identifier. It must be unique.", identifier), + Line: identifierToken.Pos.Line, + File: identifierToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_db_instance_duplicate_identifier_test.go b/detector/aws_db_instance_duplicate_identifier_test.go index 76364a7aa..650e57af2 100644 --- a/detector/aws_db_instance_duplicate_identifier_test.go +++ b/detector/aws_db_instance_duplicate_identifier_test.go @@ -37,10 +37,11 @@ resource "aws_db_instance" "test" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"my-db\" is duplicate identifier. It must be unique.", - Line: 3, - File: "test.tf", + Detector: "aws_db_instance_duplicate_identifier", + Type: "ERROR", + Message: "\"my-db\" is duplicate identifier. It must be unique.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_db_instance_invalid_db_subnet_group.go b/detector/aws_db_instance_invalid_db_subnet_group.go index b685eeddf..54aa88364 100644 --- a/detector/aws_db_instance_invalid_db_subnet_group.go +++ b/detector/aws_db_instance_invalid_db_subnet_group.go @@ -51,10 +51,11 @@ func (d *AwsDBInstanceInvalidDBSubnetGroupDetector) Detect(resource *schema.Reso if !d.subnetGroups[subnetGroup] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid DB subnet group name.", subnetGroup), - Line: subnetGroupToken.Pos.Line, - File: subnetGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid DB subnet group name.", subnetGroup), + Line: subnetGroupToken.Pos.Line, + File: subnetGroupToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_db_instance_invalid_db_subnet_group_test.go b/detector/aws_db_instance_invalid_db_subnet_group_test.go index 0ac163b15..2c5e425cb 100644 --- a/detector/aws_db_instance_invalid_db_subnet_group_test.go +++ b/detector/aws_db_instance_invalid_db_subnet_group_test.go @@ -36,10 +36,11 @@ resource "aws_db_instance" "mysql" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"app-server\" is invalid DB subnet group name.", - Line: 3, - File: "test.tf", + Detector: "aws_db_instance_invalid_db_subnet_group", + Type: "ERROR", + Message: "\"app-server\" is invalid DB subnet group name.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_db_instance_invalid_option_group.go b/detector/aws_db_instance_invalid_option_group.go index fcd1606f5..15064de4e 100644 --- a/detector/aws_db_instance_invalid_option_group.go +++ b/detector/aws_db_instance_invalid_option_group.go @@ -51,10 +51,11 @@ func (d *AwsDBInstanceInvalidOptionGroupDetector) Detect(resource *schema.Resour if !d.optionGroups[optionGroup] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid option group name.", optionGroup), - Line: optionGroupToken.Pos.Line, - File: optionGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid option group name.", optionGroup), + Line: optionGroupToken.Pos.Line, + File: optionGroupToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_db_instance_invalid_option_group_test.go b/detector/aws_db_instance_invalid_option_group_test.go index 21a34710c..9666ae10a 100644 --- a/detector/aws_db_instance_invalid_option_group_test.go +++ b/detector/aws_db_instance_invalid_option_group_test.go @@ -36,10 +36,11 @@ resource "aws_db_instance" "mysql" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"app-server\" is invalid option group name.", - Line: 3, - File: "test.tf", + Detector: "aws_db_instance_invalid_option_group", + Type: "ERROR", + Message: "\"app-server\" is invalid option group name.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_db_instance_invalid_parameter_group.go b/detector/aws_db_instance_invalid_parameter_group.go index 031b48725..f081b92a8 100644 --- a/detector/aws_db_instance_invalid_parameter_group.go +++ b/detector/aws_db_instance_invalid_parameter_group.go @@ -51,10 +51,11 @@ func (d *AwsDBInstanceInvalidParameterGroupDetector) Detect(resource *schema.Res if !d.parameterGroups[parameterGroup] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid parameter group name.", parameterGroup), - Line: parameterGroupToken.Pos.Line, - File: parameterGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid parameter group name.", parameterGroup), + Line: parameterGroupToken.Pos.Line, + File: parameterGroupToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_db_instance_invalid_parameter_group_test.go b/detector/aws_db_instance_invalid_parameter_group_test.go index 1b90dbd9e..22de3eab6 100644 --- a/detector/aws_db_instance_invalid_parameter_group_test.go +++ b/detector/aws_db_instance_invalid_parameter_group_test.go @@ -36,10 +36,11 @@ resource "aws_db_instance" "mysql" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"app-server\" is invalid parameter group name.", - Line: 3, - File: "test.tf", + Detector: "aws_db_instance_invalid_parameter_group", + Type: "ERROR", + Message: "\"app-server\" is invalid parameter group name.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_db_instance_invalid_type.go b/detector/aws_db_instance_invalid_type.go index 657f3d42b..256bfb6f1 100644 --- a/detector/aws_db_instance_invalid_type.go +++ b/detector/aws_db_instance_invalid_type.go @@ -71,10 +71,12 @@ func (d *AwsDBInstanceInvalidTypeDetector) Detect(resource *schema.Resource, iss if !d.instanceTypes[instanceType] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid instance type.", instanceType), - Line: instanceTypeToken.Pos.Line, - File: instanceTypeToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid instance type.", instanceType), + Line: instanceTypeToken.Pos.Line, + File: instanceTypeToken.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_db_instance_invalid_type_test.go b/detector/aws_db_instance_invalid_type_test.go index 785d8b695..6079c6e2b 100644 --- a/detector/aws_db_instance_invalid_type_test.go +++ b/detector/aws_db_instance_invalid_type_test.go @@ -23,10 +23,12 @@ resource "aws_db_instance" "mysql" { }`, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"m4.2xlarge\" is invalid instance type.", - Line: 3, - File: "test.tf", + Detector: "aws_db_instance_invalid_type", + Type: "ERROR", + Message: "\"m4.2xlarge\" is invalid instance type.", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_invalid_type.md", }, }, }, diff --git a/detector/aws_db_instance_invalid_vpc_security_group.go b/detector/aws_db_instance_invalid_vpc_security_group.go index 5209d8887..244844197 100644 --- a/detector/aws_db_instance_invalid_vpc_security_group.go +++ b/detector/aws_db_instance_invalid_vpc_security_group.go @@ -69,10 +69,11 @@ func (d *AwsDBInstanceInvalidVPCSecurityGroupDetector) Detect(resource *schema.R } if !d.securityGroups[securityGroup] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid security group.", securityGroup), - Line: securityGroupToken.Pos.Line, - File: securityGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid security group.", securityGroup), + Line: securityGroupToken.Pos.Line, + File: securityGroupToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_db_instance_invalid_vpc_security_group_test.go b/detector/aws_db_instance_invalid_vpc_security_group_test.go index 118192be5..06475793f 100644 --- a/detector/aws_db_instance_invalid_vpc_security_group_test.go +++ b/detector/aws_db_instance_invalid_vpc_security_group_test.go @@ -39,16 +39,18 @@ resource "aws_db_instance" "mysql" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"sg-1234abcd\" is invalid security group.", - Line: 4, - File: "test.tf", + Detector: "aws_db_instance_invalid_vpc_security_group", + Type: "ERROR", + Message: "\"sg-1234abcd\" is invalid security group.", + Line: 4, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"sg-abcd1234\" is invalid security group.", - Line: 5, - File: "test.tf", + Detector: "aws_db_instance_invalid_vpc_security_group", + Type: "ERROR", + Message: "\"sg-abcd1234\" is invalid security group.", + Line: 5, + File: "test.tf", }, }, }, @@ -91,16 +93,18 @@ resource "aws_db_instance" "mysql" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"sg-1234abcd\" is invalid security group.", - Line: 7, - File: "test.tf", + Detector: "aws_db_instance_invalid_vpc_security_group", + Type: "ERROR", + Message: "\"sg-1234abcd\" is invalid security group.", + Line: 7, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"sg-abcd1234\" is invalid security group.", - Line: 7, - File: "test.tf", + Detector: "aws_db_instance_invalid_vpc_security_group", + Type: "ERROR", + Message: "\"sg-abcd1234\" is invalid security group.", + Line: 7, + File: "test.tf", }, }, }, diff --git a/detector/aws_db_instance_previous_type.go b/detector/aws_db_instance_previous_type.go index fe906131d..ed1d98aac 100644 --- a/detector/aws_db_instance_previous_type.go +++ b/detector/aws_db_instance_previous_type.go @@ -53,10 +53,12 @@ func (d *AwsDBInstancePreviousTypeDetector) Detect(resource *schema.Resource, is if d.previousInstanceTypes[instanceType] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is previous generation instance type.", instanceType), - Line: instanceTypeToken.Pos.Line, - File: instanceTypeToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is previous generation instance type.", instanceType), + Line: instanceTypeToken.Pos.Line, + File: instanceTypeToken.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_db_instance_previous_type_test.go b/detector/aws_db_instance_previous_type_test.go index 36a5cf171..d76d758da 100644 --- a/detector/aws_db_instance_previous_type_test.go +++ b/detector/aws_db_instance_previous_type_test.go @@ -23,10 +23,12 @@ resource "aws_db_instance" "mysql" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "\"db.t1.micro\" is previous generation instance type.", - Line: 3, - File: "test.tf", + Detector: "aws_db_instance_previous_type", + Type: "WARNING", + Message: "\"db.t1.micro\" is previous generation instance type.", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_previous_type.md", }, }, }, diff --git a/detector/aws_db_instance_readable_password.go b/detector/aws_db_instance_readable_password.go index 371ee99af..80622fda0 100644 --- a/detector/aws_db_instance_readable_password.go +++ b/detector/aws_db_instance_readable_password.go @@ -32,10 +32,12 @@ func (d *AwsDBInstanceReadablePasswordDetector) Detect(resource *schema.Resource } issue := &issue.Issue{ - Type: d.IssueType, - Message: "Password for the master DB user is readable. recommend using environment variables.", - Line: passwordToken.Pos.Line, - File: passwordToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: "Password for the master DB user is readable. recommend using environment variables.", + Line: passwordToken.Pos.Line, + File: passwordToken.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_db_instance_readable_password_test.go b/detector/aws_db_instance_readable_password_test.go index 77e4c6f84..1b3d1aa18 100644 --- a/detector/aws_db_instance_readable_password_test.go +++ b/detector/aws_db_instance_readable_password_test.go @@ -23,10 +23,12 @@ resource "aws_db_instance" "mysql" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "Password for the master DB user is readable. recommend using environment variables.", - Line: 3, - File: "test.tf", + Detector: "aws_db_instance_readable_password", + Type: "WARNING", + Message: "Password for the master DB user is readable. recommend using environment variables.", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md", }, }, }, diff --git a/detector/aws_elasticache_cluster_default_parameter_group.go b/detector/aws_elasticache_cluster_default_parameter_group.go index 5e2421f5d..f19ee6691 100644 --- a/detector/aws_elasticache_cluster_default_parameter_group.go +++ b/detector/aws_elasticache_cluster_default_parameter_group.go @@ -36,10 +36,12 @@ func (d *AwsElastiCacheClusterDefaultParameterGroupDetector) Detect(resource *sc if d.isDefaultCacheParameterGroup(parameterGroup) { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is default parameter group. You cannot edit it.", parameterGroup), - Line: parameterGroupToken.Pos.Line, - File: parameterGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is default parameter group. You cannot edit it.", parameterGroup), + Line: parameterGroupToken.Pos.Line, + File: parameterGroupToken.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_elasticache_cluster_default_parameter_group_test.go b/detector/aws_elasticache_cluster_default_parameter_group_test.go index 8dc3ed22b..5f18f28d7 100644 --- a/detector/aws_elasticache_cluster_default_parameter_group_test.go +++ b/detector/aws_elasticache_cluster_default_parameter_group_test.go @@ -23,10 +23,12 @@ resource "aws_elasticache_cluster" "cache" { }`, Issues: []*issue.Issue{ { - Type: "NOTICE", - Message: "\"default.redis3.2\" is default parameter group. You cannot edit it.", - Line: 3, - File: "test.tf", + Detector: "aws_elasticache_cluster_default_parameter_group", + Type: "NOTICE", + Message: "\"default.redis3.2\" is default parameter group. You cannot edit it.", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_default_parameter_group.md", }, }, }, diff --git a/detector/aws_elasticache_cluster_duplicate_id.go b/detector/aws_elasticache_cluster_duplicate_id.go index 82f62ed5e..1010a2c44 100644 --- a/detector/aws_elasticache_cluster_duplicate_id.go +++ b/detector/aws_elasticache_cluster_duplicate_id.go @@ -51,10 +51,11 @@ func (d *AwsElastiCacheClusterDuplicateIDDetector) Detect(resource *schema.Resou if d.cacheClusters[id] && !d.State.Exists(d.Target, resource.Id) { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is duplicate Cluster ID. It must be unique.", id), - Line: idToken.Pos.Line, - File: idToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is duplicate Cluster ID. It must be unique.", id), + Line: idToken.Pos.Line, + File: idToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_elasticache_cluster_duplicate_id_test.go b/detector/aws_elasticache_cluster_duplicate_id_test.go index c43b2230f..7c073eccb 100644 --- a/detector/aws_elasticache_cluster_duplicate_id_test.go +++ b/detector/aws_elasticache_cluster_duplicate_id_test.go @@ -37,10 +37,11 @@ resource "aws_elasticache_cluster" "test" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"cluster-example\" is duplicate Cluster ID. It must be unique.", - Line: 3, - File: "test.tf", + Detector: "aws_elasticache_cluster_duplicate_id", + Type: "ERROR", + Message: "\"cluster-example\" is duplicate Cluster ID. It must be unique.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_elasticache_cluster_invalid_parameter_group.go b/detector/aws_elasticache_cluster_invalid_parameter_group.go index d18cbdd0a..f71578b35 100644 --- a/detector/aws_elasticache_cluster_invalid_parameter_group.go +++ b/detector/aws_elasticache_cluster_invalid_parameter_group.go @@ -51,10 +51,11 @@ func (d *AwsElastiCacheClusterInvalidParameterGroupDetector) Detect(resource *sc if !d.cacheParameterGroups[parameterGroup] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid parameter group name.", parameterGroup), - Line: parameterGroupToken.Pos.Line, - File: parameterGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid parameter group name.", parameterGroup), + Line: parameterGroupToken.Pos.Line, + File: parameterGroupToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_elasticache_cluster_invalid_parameter_group_test.go b/detector/aws_elasticache_cluster_invalid_parameter_group_test.go index dd58693ab..930cf01ae 100644 --- a/detector/aws_elasticache_cluster_invalid_parameter_group_test.go +++ b/detector/aws_elasticache_cluster_invalid_parameter_group_test.go @@ -36,10 +36,11 @@ resource "aws_elasticache_cluster" "redis" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"app-server\" is invalid parameter group name.", - Line: 3, - File: "test.tf", + Detector: "aws_elasticache_cluster_invalid_parameter_group", + Type: "ERROR", + Message: "\"app-server\" is invalid parameter group name.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_elasticache_cluster_invalid_security_group.go b/detector/aws_elasticache_cluster_invalid_security_group.go index 22dac68bd..f16d51e38 100644 --- a/detector/aws_elasticache_cluster_invalid_security_group.go +++ b/detector/aws_elasticache_cluster_invalid_security_group.go @@ -70,10 +70,11 @@ func (d *AwsElastiCacheClusterInvalidSecurityGroupDetector) Detect(resource *sch } if !d.securityGroups[securityGroup] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid security group.", securityGroup), - Line: securityGroupToken.Pos.Line, - File: securityGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid security group.", securityGroup), + Line: securityGroupToken.Pos.Line, + File: securityGroupToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_elasticache_cluster_invalid_security_group_test.go b/detector/aws_elasticache_cluster_invalid_security_group_test.go index 5bd594664..370a0330c 100644 --- a/detector/aws_elasticache_cluster_invalid_security_group_test.go +++ b/detector/aws_elasticache_cluster_invalid_security_group_test.go @@ -39,16 +39,18 @@ resource "aws_elasticache_cluster" "redis" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"sg-1234abcd\" is invalid security group.", - Line: 4, - File: "test.tf", + Detector: "aws_elasticache_cluster_invalid_security_group", + Type: "ERROR", + Message: "\"sg-1234abcd\" is invalid security group.", + Line: 4, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"sg-abcd1234\" is invalid security group.", - Line: 5, - File: "test.tf", + Detector: "aws_elasticache_cluster_invalid_security_group", + Type: "ERROR", + Message: "\"sg-abcd1234\" is invalid security group.", + Line: 5, + File: "test.tf", }, }, }, @@ -91,16 +93,18 @@ resource "aws_elasticache_cluster" "redis" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"sg-1234abcd\" is invalid security group.", - Line: 7, - File: "test.tf", + Detector: "aws_elasticache_cluster_invalid_security_group", + Type: "ERROR", + Message: "\"sg-1234abcd\" is invalid security group.", + Line: 7, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"sg-abcd1234\" is invalid security group.", - Line: 7, - File: "test.tf", + Detector: "aws_elasticache_cluster_invalid_security_group", + Type: "ERROR", + Message: "\"sg-abcd1234\" is invalid security group.", + Line: 7, + File: "test.tf", }, }, }, diff --git a/detector/aws_elasticache_cluster_invalid_subnet_group.go b/detector/aws_elasticache_cluster_invalid_subnet_group.go index f1bdb804f..117175921 100644 --- a/detector/aws_elasticache_cluster_invalid_subnet_group.go +++ b/detector/aws_elasticache_cluster_invalid_subnet_group.go @@ -51,10 +51,11 @@ func (d *AwsElastiCacheClusterInvalidSubnetGroupDetector) Detect(resource *schem if !d.cacheSubnetGroups[subnetGroup] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid subnet group name.", subnetGroup), - Line: subnetGroupToken.Pos.Line, - File: subnetGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid subnet group name.", subnetGroup), + Line: subnetGroupToken.Pos.Line, + File: subnetGroupToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_elasticache_cluster_invalid_subnet_group_test.go b/detector/aws_elasticache_cluster_invalid_subnet_group_test.go index c58c427f6..2c5b7485c 100644 --- a/detector/aws_elasticache_cluster_invalid_subnet_group_test.go +++ b/detector/aws_elasticache_cluster_invalid_subnet_group_test.go @@ -36,10 +36,11 @@ resource "aws_elasticache_cluster" "redis" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"app-server\" is invalid subnet group name.", - Line: 3, - File: "test.tf", + Detector: "aws_elasticache_cluster_invalid_subnet_group", + Type: "ERROR", + Message: "\"app-server\" is invalid subnet group name.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_elasticache_cluster_invalid_type.go b/detector/aws_elasticache_cluster_invalid_type.go index 5ed9f1213..23bd54969 100644 --- a/detector/aws_elasticache_cluster_invalid_type.go +++ b/detector/aws_elasticache_cluster_invalid_type.go @@ -70,10 +70,12 @@ func (d *AwsElastiCacheClusterInvalidTypeDetector) Detect(resource *schema.Resou if !d.nodeTypes[nodeType] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid node type.", nodeType), - Line: nodeTypeToken.Pos.Line, - File: nodeTypeToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid node type.", nodeType), + Line: nodeTypeToken.Pos.Line, + File: nodeTypeToken.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_elasticache_cluster_invalid_type_test.go b/detector/aws_elasticache_cluster_invalid_type_test.go index 83e00eb9c..fa4ccecbe 100644 --- a/detector/aws_elasticache_cluster_invalid_type_test.go +++ b/detector/aws_elasticache_cluster_invalid_type_test.go @@ -23,10 +23,12 @@ resource "aws_elasticache_cluster" "redis" { }`, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"t2.micro\" is invalid node type.", - Line: 3, - File: "test.tf", + Detector: "aws_elasticache_cluster_invalid_type", + Type: "ERROR", + Message: "\"t2.micro\" is invalid node type.", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_invalid_type.md", }, }, }, diff --git a/detector/aws_elasticache_cluster_previous_type.go b/detector/aws_elasticache_cluster_previous_type.go index e6289329b..03b7d9646 100644 --- a/detector/aws_elasticache_cluster_previous_type.go +++ b/detector/aws_elasticache_cluster_previous_type.go @@ -53,10 +53,12 @@ func (d *AwsElastiCacheClusterPreviousTypeDetector) Detect(resource *schema.Reso if d.previousNodeTypes[nodeType] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is previous generation node type.", nodeType), - Line: nodeTypeToken.Pos.Line, - File: nodeTypeToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is previous generation node type.", nodeType), + Line: nodeTypeToken.Pos.Line, + File: nodeTypeToken.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_elasticache_cluster_previous_type_test.go b/detector/aws_elasticache_cluster_previous_type_test.go index bc0a1e557..0c2e515af 100644 --- a/detector/aws_elasticache_cluster_previous_type_test.go +++ b/detector/aws_elasticache_cluster_previous_type_test.go @@ -23,10 +23,12 @@ resource "aws_elasticache_cluster" "redis" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "\"cache.t1.micro\" is previous generation node type.", - Line: 3, - File: "test.tf", + Detector: "aws_elasticache_cluster_previous_type", + Type: "WARNING", + Message: "\"cache.t1.micro\" is previous generation node type.", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_previous_type.md", }, }, }, diff --git a/detector/aws_elb_duplicate_name.go b/detector/aws_elb_duplicate_name.go index 6631b9329..2879036ca 100644 --- a/detector/aws_elb_duplicate_name.go +++ b/detector/aws_elb_duplicate_name.go @@ -51,10 +51,11 @@ func (d *AwsELBDuplicateNameDetector) Detect(resource *schema.Resource, issues * if d.loadBalancers[name] && !d.State.Exists(d.Target, resource.Id) { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is duplicate name. It must be unique.", name), - Line: nameToken.Pos.Line, - File: nameToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is duplicate name. It must be unique.", name), + Line: nameToken.Pos.Line, + File: nameToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_elb_duplicate_name_test.go b/detector/aws_elb_duplicate_name_test.go index 27f3a6ce0..738919dfa 100644 --- a/detector/aws_elb_duplicate_name_test.go +++ b/detector/aws_elb_duplicate_name_test.go @@ -37,10 +37,11 @@ resource "aws_elb" "test" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"test-elb-tf\" is duplicate name. It must be unique.", - Line: 3, - File: "test.tf", + Detector: "aws_elb_duplicate_name", + Type: "ERROR", + Message: "\"test-elb-tf\" is duplicate name. It must be unique.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_elb_invalid_instance.go b/detector/aws_elb_invalid_instance.go index d8ac801be..55692fe3d 100644 --- a/detector/aws_elb_invalid_instance.go +++ b/detector/aws_elb_invalid_instance.go @@ -72,10 +72,11 @@ func (d *AwsELBInvalidInstanceDetector) Detect(resource *schema.Resource, issues } if !d.instances[instance] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid instance.", instance), - Line: instanceToken.Pos.Line, - File: instanceToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid instance.", instance), + Line: instanceToken.Pos.Line, + File: instanceToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_elb_invalid_instance_test.go b/detector/aws_elb_invalid_instance_test.go index a2f997591..783a555bd 100644 --- a/detector/aws_elb_invalid_instance_test.go +++ b/detector/aws_elb_invalid_instance_test.go @@ -39,16 +39,18 @@ resource "aws_elb" "balancer" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"i-1234abcd\" is invalid instance.", - Line: 4, - File: "test.tf", + Detector: "aws_elb_invalid_instance", + Type: "ERROR", + Message: "\"i-1234abcd\" is invalid instance.", + Line: 4, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"i-abcd1234\" is invalid instance.", - Line: 5, - File: "test.tf", + Detector: "aws_elb_invalid_instance", + Type: "ERROR", + Message: "\"i-abcd1234\" is invalid instance.", + Line: 5, + File: "test.tf", }, }, }, @@ -91,16 +93,18 @@ resource "aws_elb" "balancer" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"i-1234abcd\" is invalid instance.", - Line: 7, - File: "test.tf", + Detector: "aws_elb_invalid_instance", + Type: "ERROR", + Message: "\"i-1234abcd\" is invalid instance.", + Line: 7, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"i-abcd1234\" is invalid instance.", - Line: 7, - File: "test.tf", + Detector: "aws_elb_invalid_instance", + Type: "ERROR", + Message: "\"i-abcd1234\" is invalid instance.", + Line: 7, + File: "test.tf", }, }, }, diff --git a/detector/aws_elb_invalid_security_group.go b/detector/aws_elb_invalid_security_group.go index 87ae239e5..1ffbb9fc3 100644 --- a/detector/aws_elb_invalid_security_group.go +++ b/detector/aws_elb_invalid_security_group.go @@ -70,10 +70,11 @@ func (d *AwsELBInvalidSecurityGroupDetector) Detect(resource *schema.Resource, i } if !d.securityGroups[securityGroup] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid security group.", securityGroup), - Line: securityGroupToken.Pos.Line, - File: securityGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid security group.", securityGroup), + Line: securityGroupToken.Pos.Line, + File: securityGroupToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_elb_invalid_security_group_test.go b/detector/aws_elb_invalid_security_group_test.go index 55b10ba49..cde4a1dce 100644 --- a/detector/aws_elb_invalid_security_group_test.go +++ b/detector/aws_elb_invalid_security_group_test.go @@ -39,16 +39,18 @@ resource "aws_elb" "balancer" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"sg-1234abcd\" is invalid security group.", - Line: 4, - File: "test.tf", + Detector: "aws_elb_invalid_security_group", + Type: "ERROR", + Message: "\"sg-1234abcd\" is invalid security group.", + Line: 4, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"sg-abcd1234\" is invalid security group.", - Line: 5, - File: "test.tf", + Detector: "aws_elb_invalid_security_group", + Type: "ERROR", + Message: "\"sg-abcd1234\" is invalid security group.", + Line: 5, + File: "test.tf", }, }, }, @@ -91,16 +93,18 @@ resource "aws_elb" "balancer" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"sg-1234abcd\" is invalid security group.", - Line: 7, - File: "test.tf", + Detector: "aws_elb_invalid_security_group", + Type: "ERROR", + Message: "\"sg-1234abcd\" is invalid security group.", + Line: 7, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"sg-abcd1234\" is invalid security group.", - Line: 7, - File: "test.tf", + Detector: "aws_elb_invalid_security_group", + Type: "ERROR", + Message: "\"sg-abcd1234\" is invalid security group.", + Line: 7, + File: "test.tf", }, }, }, diff --git a/detector/aws_elb_invalid_subnet.go b/detector/aws_elb_invalid_subnet.go index 55e589305..9884054e1 100644 --- a/detector/aws_elb_invalid_subnet.go +++ b/detector/aws_elb_invalid_subnet.go @@ -70,10 +70,11 @@ func (d *AwsELBInvalidSubnetDetector) Detect(resource *schema.Resource, issues * } if !d.subnets[subnet] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid subnet ID.", subnet), - Line: subnetToken.Pos.Line, - File: subnetToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid subnet ID.", subnet), + Line: subnetToken.Pos.Line, + File: subnetToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_elb_invalid_subnet_test.go b/detector/aws_elb_invalid_subnet_test.go index 560878264..9a9ecef6d 100644 --- a/detector/aws_elb_invalid_subnet_test.go +++ b/detector/aws_elb_invalid_subnet_test.go @@ -39,16 +39,18 @@ resource "aws_elb" "balancer" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"subnet-1234abcd\" is invalid subnet ID.", - Line: 4, - File: "test.tf", + Detector: "aws_elb_invalid_subnet", + Type: "ERROR", + Message: "\"subnet-1234abcd\" is invalid subnet ID.", + Line: 4, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"subnet-abcd1234\" is invalid subnet ID.", - Line: 5, - File: "test.tf", + Detector: "aws_elb_invalid_subnet", + Type: "ERROR", + Message: "\"subnet-abcd1234\" is invalid subnet ID.", + Line: 5, + File: "test.tf", }, }, }, @@ -91,16 +93,18 @@ resource "aws_elb" "balancer" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"subnet-1234abcd\" is invalid subnet ID.", - Line: 7, - File: "test.tf", + Detector: "aws_elb_invalid_subnet", + Type: "ERROR", + Message: "\"subnet-1234abcd\" is invalid subnet ID.", + Line: 7, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"subnet-abcd1234\" is invalid subnet ID.", - Line: 7, - File: "test.tf", + Detector: "aws_elb_invalid_subnet", + Type: "ERROR", + Message: "\"subnet-abcd1234\" is invalid subnet ID.", + Line: 7, + File: "test.tf", }, }, }, diff --git a/detector/aws_instance_default_standard_volume.go b/detector/aws_instance_default_standard_volume.go index f234ea9bd..b988b3b63 100644 --- a/detector/aws_instance_default_standard_volume.go +++ b/detector/aws_instance_default_standard_volume.go @@ -28,10 +28,12 @@ func (d *AwsInstanceDefaultStandardVolumeDetector) Detect(resource *schema.Resou for i, deviceToken := range deviceTokens { if deviceToken["volume_type"].Text == "" { issue := &issue.Issue{ - Type: d.IssueType, - Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", - Line: resource.Attrs[device].Poses[i].Line, - File: resource.Attrs[device].Poses[i].Filename, + Detector: d.Name, + Type: d.IssueType, + Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", + Line: resource.Attrs[device].Poses[i].Line, + File: resource.Attrs[device].Poses[i].Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_instance_default_standard_volume_test.go b/detector/aws_instance_default_standard_volume_test.go index 3e404d3f6..8f443f12b 100644 --- a/detector/aws_instance_default_standard_volume_test.go +++ b/detector/aws_instance_default_standard_volume_test.go @@ -27,10 +27,12 @@ resource "aws_instance" "web" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", - Line: 5, - File: "test.tf", + Detector: "aws_instance_default_standard_volume", + Type: "WARNING", + Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", + Line: 5, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md", }, }, }, @@ -46,10 +48,12 @@ resource "aws_instance" "web" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", - Line: 5, - File: "test.tf", + Detector: "aws_instance_default_standard_volume", + Type: "WARNING", + Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", + Line: 5, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md", }, }, }, @@ -73,22 +77,28 @@ resource "aws_instance" "web" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", - Line: 5, - File: "test.tf", + Detector: "aws_instance_default_standard_volume", + Type: "WARNING", + Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", + Line: 5, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md", }, { - Type: "WARNING", - Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", - Line: 9, - File: "test.tf", + Detector: "aws_instance_default_standard_volume", + Type: "WARNING", + Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", + Line: 9, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md", }, { - Type: "WARNING", - Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", - Line: 13, - File: "test.tf", + Detector: "aws_instance_default_standard_volume", + Type: "WARNING", + Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", + Line: 13, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md", }, }, }, diff --git a/detector/aws_instance_invalid_ami.go b/detector/aws_instance_invalid_ami.go index 942d763a6..19f01f468 100644 --- a/detector/aws_instance_invalid_ami.go +++ b/detector/aws_instance_invalid_ami.go @@ -51,10 +51,11 @@ func (d *AwsInstanceInvalidAMIDetector) Detect(resource *schema.Resource, issues if !d.amis[ami] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid AMI.", ami), - Line: amiToken.Pos.Line, - File: amiToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid AMI.", ami), + Line: amiToken.Pos.Line, + File: amiToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_instance_invalid_ami_test.go b/detector/aws_instance_invalid_ami_test.go index 39736c1f6..9e1c30617 100644 --- a/detector/aws_instance_invalid_ami_test.go +++ b/detector/aws_instance_invalid_ami_test.go @@ -36,10 +36,11 @@ resource "aws_instance" "web" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"ami-1234abcd\" is invalid AMI.", - Line: 3, - File: "test.tf", + Detector: "aws_instance_invalid_ami", + Type: "ERROR", + Message: "\"ami-1234abcd\" is invalid AMI.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_instance_invalid_iam_profile.go b/detector/aws_instance_invalid_iam_profile.go index 4d20a3ff3..bc7ecf57b 100644 --- a/detector/aws_instance_invalid_iam_profile.go +++ b/detector/aws_instance_invalid_iam_profile.go @@ -51,10 +51,11 @@ func (d *AwsInstanceInvalidIAMProfileDetector) Detect(resource *schema.Resource, if !d.profiles[iamProfile] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid IAM profile name.", iamProfile), - Line: iamProfileToken.Pos.Line, - File: iamProfileToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid IAM profile name.", iamProfile), + Line: iamProfileToken.Pos.Line, + File: iamProfileToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_instance_invalid_iam_profile_test.go b/detector/aws_instance_invalid_iam_profile_test.go index b70db4048..bb1eb8e47 100644 --- a/detector/aws_instance_invalid_iam_profile_test.go +++ b/detector/aws_instance_invalid_iam_profile_test.go @@ -36,10 +36,11 @@ resource "aws_instance" "web" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"app-server\" is invalid IAM profile name.", - Line: 3, - File: "test.tf", + Detector: "aws_instance_invalid_iam_profile", + Type: "ERROR", + Message: "\"app-server\" is invalid IAM profile name.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_instance_invalid_key_name.go b/detector/aws_instance_invalid_key_name.go index 3ccd2bb33..036879fcc 100644 --- a/detector/aws_instance_invalid_key_name.go +++ b/detector/aws_instance_invalid_key_name.go @@ -51,10 +51,11 @@ func (d *AwsInstanceInvalidKeyNameDetector) Detect(resource *schema.Resource, is if !d.keypairs[keyName] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid key name.", keyName), - Line: keyNameToken.Pos.Line, - File: keyNameToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid key name.", keyName), + Line: keyNameToken.Pos.Line, + File: keyNameToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_instance_invalid_key_name_test.go b/detector/aws_instance_invalid_key_name_test.go index bde793835..2e9c6e26a 100644 --- a/detector/aws_instance_invalid_key_name_test.go +++ b/detector/aws_instance_invalid_key_name_test.go @@ -36,10 +36,11 @@ resource "aws_instance" "web" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"foo\" is invalid key name.", - Line: 3, - File: "test.tf", + Detector: "aws_instance_invalid_key_name", + Type: "ERROR", + Message: "\"foo\" is invalid key name.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_instance_invalid_subnet.go b/detector/aws_instance_invalid_subnet.go index 6e8d1f041..eea6e0ea0 100644 --- a/detector/aws_instance_invalid_subnet.go +++ b/detector/aws_instance_invalid_subnet.go @@ -51,10 +51,11 @@ func (d *AwsInstanceInvalidSubnetDetector) Detect(resource *schema.Resource, iss if !d.subnets[subnet] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid subnet ID.", subnet), - Line: subnetToken.Pos.Line, - File: subnetToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid subnet ID.", subnet), + Line: subnetToken.Pos.Line, + File: subnetToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_instance_invalid_subnet_test.go b/detector/aws_instance_invalid_subnet_test.go index 19a2aa2ee..350c39fce 100644 --- a/detector/aws_instance_invalid_subnet_test.go +++ b/detector/aws_instance_invalid_subnet_test.go @@ -36,10 +36,11 @@ resource "aws_instance" "web" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"subnet-1234abcd\" is invalid subnet ID.", - Line: 3, - File: "test.tf", + Detector: "aws_instance_invalid_subnet", + Type: "ERROR", + Message: "\"subnet-1234abcd\" is invalid subnet ID.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_instance_invalid_type.go b/detector/aws_instance_invalid_type.go index 8daaa6d9f..cdb7a23ad 100644 --- a/detector/aws_instance_invalid_type.go +++ b/detector/aws_instance_invalid_type.go @@ -119,10 +119,12 @@ func (d *AwsInstanceInvalidTypeDetector) Detect(resource *schema.Resource, issue if !d.instanceTypes[instanceType] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid instance type.", instanceType), - Line: instanceTypeToken.Pos.Line, - File: instanceTypeToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid instance type.", instanceType), + Line: instanceTypeToken.Pos.Line, + File: instanceTypeToken.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_instance_invalid_type_test.go b/detector/aws_instance_invalid_type_test.go index 942204dec..501de8bf7 100644 --- a/detector/aws_instance_invalid_type_test.go +++ b/detector/aws_instance_invalid_type_test.go @@ -23,10 +23,12 @@ resource "aws_instance" "web" { }`, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"t1.2xlarge\" is invalid instance type.", - Line: 3, - File: "test.tf", + Detector: "aws_instance_invalid_type", + Type: "ERROR", + Message: "\"t1.2xlarge\" is invalid instance type.", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md", }, }, }, diff --git a/detector/aws_instance_invalid_vpc_security_group.go b/detector/aws_instance_invalid_vpc_security_group.go index dc1168d31..650156931 100644 --- a/detector/aws_instance_invalid_vpc_security_group.go +++ b/detector/aws_instance_invalid_vpc_security_group.go @@ -70,10 +70,11 @@ func (d *AwsInstanceInvalidVPCSecurityGroupDetector) Detect(resource *schema.Res } if !d.securityGroups[securityGroup] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid security group.", securityGroup), - Line: securityGroupToken.Pos.Line, - File: securityGroupToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid security group.", securityGroup), + Line: securityGroupToken.Pos.Line, + File: securityGroupToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_instance_invalid_vpc_security_group_test.go b/detector/aws_instance_invalid_vpc_security_group_test.go index 50a47f274..a66fbc03c 100644 --- a/detector/aws_instance_invalid_vpc_security_group_test.go +++ b/detector/aws_instance_invalid_vpc_security_group_test.go @@ -39,16 +39,18 @@ resource "aws_instance" "web" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"sg-1234abcd\" is invalid security group.", - Line: 4, - File: "test.tf", + Detector: "aws_instance_invalid_vpc_security_group", + Type: "ERROR", + Message: "\"sg-1234abcd\" is invalid security group.", + Line: 4, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"sg-abcd1234\" is invalid security group.", - Line: 5, - File: "test.tf", + Detector: "aws_instance_invalid_vpc_security_group", + Type: "ERROR", + Message: "\"sg-abcd1234\" is invalid security group.", + Line: 5, + File: "test.tf", }, }, }, @@ -91,16 +93,18 @@ resource "aws_instance" "web" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"sg-1234abcd\" is invalid security group.", - Line: 7, - File: "test.tf", + Detector: "aws_instance_invalid_vpc_security_group", + Type: "ERROR", + Message: "\"sg-1234abcd\" is invalid security group.", + Line: 7, + File: "test.tf", }, { - Type: "ERROR", - Message: "\"sg-abcd1234\" is invalid security group.", - Line: 7, - File: "test.tf", + Detector: "aws_instance_invalid_vpc_security_group", + Type: "ERROR", + Message: "\"sg-abcd1234\" is invalid security group.", + Line: 7, + File: "test.tf", }, }, }, diff --git a/detector/aws_instance_not_specified_iam_profile.go b/detector/aws_instance_not_specified_iam_profile.go index 9adef9449..6a9373d60 100644 --- a/detector/aws_instance_not_specified_iam_profile.go +++ b/detector/aws_instance_not_specified_iam_profile.go @@ -23,10 +23,12 @@ func (d *Detector) CreateAwsInstanceNotSpecifiedIAMProfileDetector() *AwsInstanc func (d *AwsInstanceNotSpecifiedIAMProfileDetector) Detect(resource *schema.Resource, issues *[]*issue.Issue) { if _, ok := resource.GetToken("iam_instance_profile"); !ok { issue := &issue.Issue{ - Type: d.IssueType, - Message: "\"iam_instance_profile\" is not specified. If you want to change it, you need to recreate instance. (Only less than Terraform 0.8.8)", - Line: resource.Pos.Line, - File: resource.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: "\"iam_instance_profile\" is not specified. If you want to change it, you need to recreate instance. (Only less than Terraform 0.8.8)", + Line: resource.Pos.Line, + File: resource.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_instance_not_specified_iam_profile_test.go b/detector/aws_instance_not_specified_iam_profile_test.go index 2f6435efb..5eb87a403 100644 --- a/detector/aws_instance_not_specified_iam_profile_test.go +++ b/detector/aws_instance_not_specified_iam_profile_test.go @@ -23,10 +23,12 @@ resource "aws_instance" "web" { }`, Issues: []*issue.Issue{ { - Type: "NOTICE", - Message: "\"iam_instance_profile\" is not specified. If you want to change it, you need to recreate instance. (Only less than Terraform 0.8.8)", - Line: 2, - File: "test.tf", + Detector: "aws_instance_not_specified_iam_profile", + Type: "NOTICE", + Message: "\"iam_instance_profile\" is not specified. If you want to change it, you need to recreate instance. (Only less than Terraform 0.8.8)", + Line: 2, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_not_specified_iam_profile.md", }, }, }, diff --git a/detector/aws_instance_previous_type.go b/detector/aws_instance_previous_type.go index 724a0a250..fed6cafe2 100644 --- a/detector/aws_instance_previous_type.go +++ b/detector/aws_instance_previous_type.go @@ -59,10 +59,12 @@ func (d *AwsInstancePreviousTypeDetector) Detect(resource *schema.Resource, issu if d.previousInstanceTypes[instanceType] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is previous generation instance type.", instanceType), - Line: instanceTypeToken.Pos.Line, - File: instanceTypeToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is previous generation instance type.", instanceType), + Line: instanceTypeToken.Pos.Line, + File: instanceTypeToken.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_instance_previous_type_test.go b/detector/aws_instance_previous_type_test.go index 6aea93345..6810b940f 100644 --- a/detector/aws_instance_previous_type_test.go +++ b/detector/aws_instance_previous_type_test.go @@ -23,10 +23,12 @@ resource "aws_instance" "web" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "\"t1.micro\" is previous generation instance type.", - Line: 3, - File: "test.tf", + Detector: "aws_instance_previous_type", + Type: "WARNING", + Message: "\"t1.micro\" is previous generation instance type.", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_previous_type.md", }, }, }, diff --git a/detector/aws_route_invalid_egress_only_gateway.go b/detector/aws_route_invalid_egress_only_gateway.go index e5d75f7e6..c0e161707 100644 --- a/detector/aws_route_invalid_egress_only_gateway.go +++ b/detector/aws_route_invalid_egress_only_gateway.go @@ -51,10 +51,11 @@ func (d *AwsRouteInvalidEgressOnlyGatewayDetector) Detect(resource *schema.Resou if !d.egateways[egateway] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid egress only internet gateway ID.", egateway), - Line: egatewayToken.Pos.Line, - File: egatewayToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid egress only internet gateway ID.", egateway), + Line: egatewayToken.Pos.Line, + File: egatewayToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_route_invalid_egress_only_gateway_test.go b/detector/aws_route_invalid_egress_only_gateway_test.go index 8edb2fa5a..ff689024d 100644 --- a/detector/aws_route_invalid_egress_only_gateway_test.go +++ b/detector/aws_route_invalid_egress_only_gateway_test.go @@ -36,10 +36,11 @@ resource "aws_route" "foo" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"igw-1234abcd\" is invalid egress only internet gateway ID.", - Line: 3, - File: "test.tf", + Detector: "aws_route_invalid_egress_only_gateway", + Type: "ERROR", + Message: "\"igw-1234abcd\" is invalid egress only internet gateway ID.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_route_invalid_gateway.go b/detector/aws_route_invalid_gateway.go index 8e6037466..fa6522c70 100644 --- a/detector/aws_route_invalid_gateway.go +++ b/detector/aws_route_invalid_gateway.go @@ -51,10 +51,11 @@ func (d *AwsRouteInvalidGatewayDetector) Detect(resource *schema.Resource, issue if !d.gateways[gateway] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid internet gateway ID.", gateway), - Line: gatewayToken.Pos.Line, - File: gatewayToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid internet gateway ID.", gateway), + Line: gatewayToken.Pos.Line, + File: gatewayToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_route_invalid_gateway_test.go b/detector/aws_route_invalid_gateway_test.go index 66f214723..a788ec785 100644 --- a/detector/aws_route_invalid_gateway_test.go +++ b/detector/aws_route_invalid_gateway_test.go @@ -36,10 +36,11 @@ resource "aws_route" "foo" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"eigw-1234abcd\" is invalid internet gateway ID.", - Line: 3, - File: "test.tf", + Detector: "aws_route_invalid_gateway", + Type: "ERROR", + Message: "\"eigw-1234abcd\" is invalid internet gateway ID.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_route_invalid_instance.go b/detector/aws_route_invalid_instance.go index 9156edded..1f933f1cd 100644 --- a/detector/aws_route_invalid_instance.go +++ b/detector/aws_route_invalid_instance.go @@ -53,10 +53,11 @@ func (d *AwsRouteInvalidInstanceDetector) Detect(resource *schema.Resource, issu if !d.instances[instance] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid instance ID.", instance), - Line: instanceToken.Pos.Line, - File: instanceToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid instance ID.", instance), + Line: instanceToken.Pos.Line, + File: instanceToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_route_invalid_instance_test.go b/detector/aws_route_invalid_instance_test.go index cc983aa64..e9e2d3795 100644 --- a/detector/aws_route_invalid_instance_test.go +++ b/detector/aws_route_invalid_instance_test.go @@ -36,10 +36,11 @@ resource "aws_route" "foo" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"i-1234abcd\" is invalid instance ID.", - Line: 3, - File: "test.tf", + Detector: "aws_route_invalid_instance", + Type: "ERROR", + Message: "\"i-1234abcd\" is invalid instance ID.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_route_invalid_nat_gateway.go b/detector/aws_route_invalid_nat_gateway.go index a0ed6d4b6..7c0067489 100644 --- a/detector/aws_route_invalid_nat_gateway.go +++ b/detector/aws_route_invalid_nat_gateway.go @@ -51,10 +51,11 @@ func (d *AwsRouteInvalidNatGatewayDetector) Detect(resource *schema.Resource, is if !d.ngateways[ngateway] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid NAT gateway ID.", ngateway), - Line: ngatewayToken.Pos.Line, - File: ngatewayToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid NAT gateway ID.", ngateway), + Line: ngatewayToken.Pos.Line, + File: ngatewayToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_route_invalid_nat_gateway_test.go b/detector/aws_route_invalid_nat_gateway_test.go index 19ef0df77..4404db523 100644 --- a/detector/aws_route_invalid_nat_gateway_test.go +++ b/detector/aws_route_invalid_nat_gateway_test.go @@ -36,10 +36,11 @@ resource "aws_route" "foo" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"nat-1234abcd\" is invalid NAT gateway ID.", - Line: 3, - File: "test.tf", + Detector: "aws_route_invalid_nat_gateway", + Type: "ERROR", + Message: "\"nat-1234abcd\" is invalid NAT gateway ID.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_route_invalid_network_interface.go b/detector/aws_route_invalid_network_interface.go index 5de020885..46e2b4dc1 100644 --- a/detector/aws_route_invalid_network_interface.go +++ b/detector/aws_route_invalid_network_interface.go @@ -51,10 +51,11 @@ func (d *AwsRouteInvalidNetworkInterfaceDetector) Detect(resource *schema.Resour if !d.networkInterfaces[networkInterface] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid network interface ID.", networkInterface), - Line: networkInterfaceToken.Pos.Line, - File: networkInterfaceToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid network interface ID.", networkInterface), + Line: networkInterfaceToken.Pos.Line, + File: networkInterfaceToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_route_invalid_network_interface_test.go b/detector/aws_route_invalid_network_interface_test.go index 229cffa43..a68f0e991 100644 --- a/detector/aws_route_invalid_network_interface_test.go +++ b/detector/aws_route_invalid_network_interface_test.go @@ -36,10 +36,11 @@ resource "aws_route" "foo" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"eni-1234abcd\" is invalid network interface ID.", - Line: 3, - File: "test.tf", + Detector: "aws_route_invalid_network_interface", + Type: "ERROR", + Message: "\"eni-1234abcd\" is invalid network interface ID.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_route_invalid_route_table.go b/detector/aws_route_invalid_route_table.go index 8963e5898..42e9362ab 100644 --- a/detector/aws_route_invalid_route_table.go +++ b/detector/aws_route_invalid_route_table.go @@ -51,10 +51,11 @@ func (d *AwsRouteInvalidRouteTableDetector) Detect(resource *schema.Resource, is if !d.routeTables[routeTable] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid route table ID.", routeTable), - Line: routeTableToken.Pos.Line, - File: routeTableToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid route table ID.", routeTable), + Line: routeTableToken.Pos.Line, + File: routeTableToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_route_invalid_route_table_test.go b/detector/aws_route_invalid_route_table_test.go index ab51ef4bf..73de4743e 100644 --- a/detector/aws_route_invalid_route_table_test.go +++ b/detector/aws_route_invalid_route_table_test.go @@ -36,10 +36,11 @@ resource "aws_route" "foo" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"rtb-nat-gw-a\" is invalid route table ID.", - Line: 3, - File: "test.tf", + Detector: "aws_route_invalid_route_table", + Type: "ERROR", + Message: "\"rtb-nat-gw-a\" is invalid route table ID.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_route_invalid_vpc_peering_connection.go b/detector/aws_route_invalid_vpc_peering_connection.go index 323b924cf..ec8720b39 100644 --- a/detector/aws_route_invalid_vpc_peering_connection.go +++ b/detector/aws_route_invalid_vpc_peering_connection.go @@ -51,10 +51,11 @@ func (d *AwsRouteInvalidVpcPeeringConnectionDetector) Detect(resource *schema.Re if !d.vpcPeeringConnections[vpcPeeringConnection] { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is invalid VPC peering connection ID.", vpcPeeringConnection), - Line: vpcPeeringConnectionToken.Pos.Line, - File: vpcPeeringConnectionToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is invalid VPC peering connection ID.", vpcPeeringConnection), + Line: vpcPeeringConnectionToken.Pos.Line, + File: vpcPeeringConnectionToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_route_invalid_vpc_peering_connection_test.go b/detector/aws_route_invalid_vpc_peering_connection_test.go index 41ea3d645..2d60dbfe2 100644 --- a/detector/aws_route_invalid_vpc_peering_connection_test.go +++ b/detector/aws_route_invalid_vpc_peering_connection_test.go @@ -36,10 +36,11 @@ resource "aws_route" "foo" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"pcx-1234abcd\" is invalid VPC peering connection ID.", - Line: 3, - File: "test.tf", + Detector: "aws_route_invalid_vpc_peering_connection", + Type: "ERROR", + Message: "\"pcx-1234abcd\" is invalid VPC peering connection ID.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/aws_route_not_specified_target.go b/detector/aws_route_not_specified_target.go index 0ab645752..9ea297df7 100644 --- a/detector/aws_route_not_specified_target.go +++ b/detector/aws_route_not_specified_target.go @@ -37,10 +37,12 @@ func (d *AwsRouteNotSpecifiedTargetDetector) Detect(resource *schema.Resource, i } issue := &issue.Issue{ - Type: d.IssueType, - Message: "route target is not specified, each route must contain either a gateway_id, egress_only_gateway_id a nat_gateway_id, an instance_id or a vpc_peering_connection_id or a network_interface_id.", - Line: resource.Pos.Line, - File: resource.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: "route target is not specified, each route must contain either a gateway_id, egress_only_gateway_id a nat_gateway_id, an instance_id or a vpc_peering_connection_id or a network_interface_id.", + Line: resource.Pos.Line, + File: resource.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) } diff --git a/detector/aws_route_not_specified_target_test.go b/detector/aws_route_not_specified_target_test.go index a5a17b1d0..e65ec81ea 100644 --- a/detector/aws_route_not_specified_target_test.go +++ b/detector/aws_route_not_specified_target_test.go @@ -23,10 +23,12 @@ resource "aws_route" "foo" { }`, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "route target is not specified, each route must contain either a gateway_id, egress_only_gateway_id a nat_gateway_id, an instance_id or a vpc_peering_connection_id or a network_interface_id.", - Line: 2, - File: "test.tf", + Detector: "aws_route_not_specified_target", + Type: "ERROR", + Message: "route target is not specified, each route must contain either a gateway_id, egress_only_gateway_id a nat_gateway_id, an instance_id or a vpc_peering_connection_id or a network_interface_id.", + Line: 2, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_route_not_specified_target.md", }, }, }, diff --git a/detector/aws_route_specified_multiple_targets.go b/detector/aws_route_specified_multiple_targets.go index 87292eb01..9dd307f82 100644 --- a/detector/aws_route_specified_multiple_targets.go +++ b/detector/aws_route_specified_multiple_targets.go @@ -29,10 +29,12 @@ func (d *AwsRouteSpecifiedMultipleTargetsDetector) Detect(resource *schema.Resou targetCount++ if targetCount > 1 { issue := &issue.Issue{ - Type: d.IssueType, - Message: "more than 1 target specified, only 1 routing target can be specified.", - Line: resource.Pos.Line, - File: resource.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: "more than 1 target specified, only 1 routing target can be specified.", + Line: resource.Pos.Line, + File: resource.Pos.Filename, + Link: d.Link, } *issues = append(*issues, issue) return diff --git a/detector/aws_route_specified_multiple_targets_test.go b/detector/aws_route_specified_multiple_targets_test.go index 148f4c173..a7ee398f7 100644 --- a/detector/aws_route_specified_multiple_targets_test.go +++ b/detector/aws_route_specified_multiple_targets_test.go @@ -25,10 +25,12 @@ resource "aws_route" "foo" { }`, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "more than 1 target specified, only 1 routing target can be specified.", - Line: 2, - File: "test.tf", + Detector: "aws_route_specified_multiple_targets", + Type: "ERROR", + Message: "more than 1 target specified, only 1 routing target can be specified.", + Line: 2, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/aws_route_specified_multiple_targets.md", }, }, }, diff --git a/detector/aws_security_group_duplicate_name.go b/detector/aws_security_group_duplicate_name.go index 9c67fc6f5..1e82ed276 100644 --- a/detector/aws_security_group_duplicate_name.go +++ b/detector/aws_security_group_duplicate_name.go @@ -78,10 +78,11 @@ func (d *AwsSecurityGroupDuplicateDetector) Detect(resource *schema.Resource, is if d.securiyGroups[vpc+"."+name] && !d.State.Exists(d.Target, resource.Id) { issue := &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("\"%s\" is duplicate name. It must be unique.", name), - Line: nameToken.Pos.Line, - File: nameToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("\"%s\" is duplicate name. It must be unique.", name), + Line: nameToken.Pos.Line, + File: nameToken.Pos.Filename, } *issues = append(*issues, issue) } diff --git a/detector/aws_security_group_duplicate_name_test.go b/detector/aws_security_group_duplicate_name_test.go index 16325781b..8161201ad 100644 --- a/detector/aws_security_group_duplicate_name_test.go +++ b/detector/aws_security_group_duplicate_name_test.go @@ -59,10 +59,11 @@ resource "aws_security_group" "test" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"default\" is duplicate name. It must be unique.", - Line: 3, - File: "test.tf", + Detector: "aws_security_group_duplicate_name", + Type: "ERROR", + Message: "\"default\" is duplicate name. It must be unique.", + Line: 3, + File: "test.tf", }, }, }, @@ -212,10 +213,11 @@ resource "aws_security_group" "test" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"default\" is duplicate name. It must be unique.", - Line: 3, - File: "test.tf", + Detector: "aws_security_group_duplicate_name", + Type: "ERROR", + Message: "\"default\" is duplicate name. It must be unique.", + Line: 3, + File: "test.tf", }, }, }, @@ -316,10 +318,11 @@ resource "aws_security_group" "test" { }, Issues: []*issue.Issue{ { - Type: "ERROR", - Message: "\"default\" is duplicate name. It must be unique.", - Line: 3, - File: "test.tf", + Detector: "aws_security_group_duplicate_name", + Type: "ERROR", + Message: "\"default\" is duplicate name. It must be unique.", + Line: 3, + File: "test.tf", }, }, }, diff --git a/detector/terraform_module_pinned_source.go b/detector/terraform_module_pinned_source.go index de707f544..1c2099aa2 100644 --- a/detector/terraform_module_pinned_source.go +++ b/detector/terraform_module_pinned_source.go @@ -43,18 +43,22 @@ func (d *TerraformModulePinnedSourceDetector) detectGitSource(module *schema.Mod if strings.Contains(lower, "ref=") { if strings.Contains(lower, "ref=master") { return &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("Module source \"%s\" uses default ref \"master\"", module.ModuleSource), - Line: sourceToken.Pos.Line, - File: sourceToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("Module source \"%s\" uses default ref \"master\"", module.ModuleSource), + Line: sourceToken.Pos.Line, + File: sourceToken.Pos.Filename, + Link: d.Link, } } } else { return &issue.Issue{ - Type: d.IssueType, - Message: fmt.Sprintf("Module source \"%s\" is not pinned", module.ModuleSource), - Line: sourceToken.Pos.Line, - File: sourceToken.Pos.Filename, + Detector: d.Name, + Type: d.IssueType, + Message: fmt.Sprintf("Module source \"%s\" is not pinned", module.ModuleSource), + Line: sourceToken.Pos.Line, + File: sourceToken.Pos.Filename, + Link: d.Link, } } @@ -68,18 +72,22 @@ func (d *TerraformModulePinnedSourceDetector) detectMercurialSource(module *sche if strings.Contains(lower, "rev=") { if strings.Contains(lower, "rev=default") { return &issue.Issue{ - Type: issue.WARNING, - Message: fmt.Sprintf("Module source \"%s\" uses default rev \"default\"", module.ModuleSource), - Line: sourceToken.Pos.Line, - File: sourceToken.Pos.Filename, + Detector: d.Name, + Type: issue.WARNING, + Message: fmt.Sprintf("Module source \"%s\" uses default rev \"default\"", module.ModuleSource), + Line: sourceToken.Pos.Line, + File: sourceToken.Pos.Filename, + Link: d.Link, } } } else { return &issue.Issue{ - Type: issue.WARNING, - Message: fmt.Sprintf("Module source \"%s\" is not pinned", module.ModuleSource), - Line: sourceToken.Pos.Line, - File: sourceToken.Pos.Filename, + Detector: d.Name, + Type: issue.WARNING, + Message: fmt.Sprintf("Module source \"%s\" is not pinned", module.ModuleSource), + Line: sourceToken.Pos.Line, + File: sourceToken.Pos.Filename, + Link: d.Link, } } diff --git a/detector/terraform_module_pinned_source_test.go b/detector/terraform_module_pinned_source_test.go index 2a610a096..908dc7f0d 100644 --- a/detector/terraform_module_pinned_source_test.go +++ b/detector/terraform_module_pinned_source_test.go @@ -24,10 +24,12 @@ module "unpinned" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "Module source \"git://hashicorp.com/consul.git\" is not pinned", - Line: 3, - File: "test.tf", + Detector: "terraform_module_pinned_source", + Type: "WARNING", + Message: "Module source \"git://hashicorp.com/consul.git\" is not pinned", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", }, }, }, @@ -39,10 +41,12 @@ module "default git" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "Module source \"git://hashicorp.com/consul.git?ref=master\" uses default ref \"master\"", - Line: 3, - File: "test.tf", + Detector: "terraform_module_pinned_source", + Type: "WARNING", + Message: "Module source \"git://hashicorp.com/consul.git?ref=master\" uses default ref \"master\"", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", }, }, }, @@ -62,10 +66,12 @@ module "unpinned" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "Module source \"github.com/hashicorp/consul\" is not pinned", - Line: 3, - File: "test.tf", + Detector: "terraform_module_pinned_source", + Type: "WARNING", + Message: "Module source \"github.com/hashicorp/consul\" is not pinned", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", }, }, }, @@ -77,10 +83,12 @@ module "default git" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "Module source \"github.com/hashicorp/consul.git?ref=master\" uses default ref \"master\"", - Line: 3, - File: "test.tf", + Detector: "terraform_module_pinned_source", + Type: "WARNING", + Message: "Module source \"github.com/hashicorp/consul.git?ref=master\" uses default ref \"master\"", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", }, }, }, @@ -100,10 +108,12 @@ module "unpinned" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "Module source \"bitbucket.org/hashicorp/consul\" is not pinned", - Line: 3, - File: "test.tf", + Detector: "terraform_module_pinned_source", + Type: "WARNING", + Message: "Module source \"bitbucket.org/hashicorp/consul\" is not pinned", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", }, }, }, @@ -115,10 +125,12 @@ module "default git" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "Module source \"bitbucket.org/hashicorp/consul.git?ref=master\" uses default ref \"master\"", - Line: 3, - File: "test.tf", + Detector: "terraform_module_pinned_source", + Type: "WARNING", + Message: "Module source \"bitbucket.org/hashicorp/consul.git?ref=master\" uses default ref \"master\"", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", }, }, }, @@ -138,10 +150,12 @@ module "default mercurial" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "Module source \"hg::http://hashicorp.com/consul.hg\" is not pinned", - Line: 3, - File: "test.tf", + Detector: "terraform_module_pinned_source", + Type: "WARNING", + Message: "Module source \"hg::http://hashicorp.com/consul.hg\" is not pinned", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", }, }, }, @@ -153,10 +167,12 @@ module "default mercurial" { }`, Issues: []*issue.Issue{ { - Type: "WARNING", - Message: "Module source \"hg::http://hashicorp.com/consul.hg?rev=default\" uses default rev \"default\"", - Line: 3, - File: "test.tf", + Detector: "terraform_module_pinned_source", + Type: "WARNING", + Message: "Module source \"hg::http://hashicorp.com/consul.hg?rev=default\" uses default rev \"default\"", + Line: 3, + File: "test.tf", + Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", }, }, }, diff --git a/integration/general/result.json b/integration/general/result.json index 89c7095cf..be810004c 100644 --- a/integration/general/result.json +++ b/integration/general/result.json @@ -1,98 +1,130 @@ [ { + "detector": "aws_db_instance_readable_password", "type": "WARNING", "message": "Password for the master DB user is readable. recommend using environment variables.", "line": 12, - "file": "github.com/wata727/example-module/aws_db_instance.tf" + "file": "github.com/wata727/example-module/aws_db_instance.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md" }, { + "detector": "aws_db_instance_readable_password", "type": "WARNING", "message": "Password for the master DB user is readable. recommend using environment variables.", "line": 24, - "file": "github.com/wata727/example-module/aws_db_instance.tf" + "file": "github.com/wata727/example-module/aws_db_instance.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md" }, { + "detector": "aws_elasticache_cluster_invalid_type", "type": "ERROR", "message": "\"m4.large\" is invalid node type.", "line": 9, - "file": "github.com/wata727/example-module/aws_elasticache_cluster.tf" + "file": "github.com/wata727/example-module/aws_elasticache_cluster.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_invalid_type.md" }, { + "detector": "aws_instance_not_specified_iam_profile", "type": "NOTICE", "message": "\"iam_instance_profile\" is not specified. If you want to change it, you need to recreate instance. (Only less than Terraform 0.8.8)", "line": 5, - "file": "github.com/wata727/example-module/aws_instance.tf" + "file": "github.com/wata727/example-module/aws_instance.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_not_specified_iam_profile.md" }, { + "detector": "aws_instance_default_standard_volume", "type": "WARNING", "message": "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", "line": 9, - "file": "github.com/wata727/example-module/aws_instance.tf" + "file": "github.com/wata727/example-module/aws_instance.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md" }, { + "detector": "aws_db_instance_previous_type", "type": "WARNING", "message": "\"db.t1.micro\" is previous generation instance type.", "line": 21, - "file": "github.com/wata727/example-module/aws_db_instance.tf" + "file": "github.com/wata727/example-module/aws_db_instance.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_previous_type.md" }, { + "detector": "aws_instance_invalid_type", "type": "ERROR", "message": "\"t1.2xlarge\" is invalid instance type.", "line": 7, - "file": "github.com/wata727/example-module/aws_instance.tf" + "file": "github.com/wata727/example-module/aws_instance.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md" }, { + "detector": "aws_instance_previous_type", "type": "WARNING", "message": "\"t1.micro\" is previous generation instance type.", "line": 17, - "file": "github.com/wata727/example-module/aws_instance.tf" + "file": "github.com/wata727/example-module/aws_instance.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_previous_type.md" }, { + "detector": "aws_db_instance_default_parameter_group", "type": "NOTICE", "message": "\"default.mysql5.6\" is default parameter group. You cannot edit it.", "line": 14, - "file": "github.com/wata727/example-module/aws_db_instance.tf" + "file": "github.com/wata727/example-module/aws_db_instance.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_default_parameter_group.md" }, { + "detector": "aws_route_not_specified_target", "type": "ERROR", "message": "route target is not specified, each route must contain either a gateway_id, egress_only_gateway_id a nat_gateway_id, an instance_id or a vpc_peering_connection_id or a network_interface_id.", "line": 28, - "file": "template.tf" + "file": "template.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_route_not_specified_target.md" }, { + "detector": "aws_route_specified_multiple_targets", "type": "ERROR", "message": "more than 1 target specified, only 1 routing target can be specified.", "line": 33, - "file": "template.tf" + "file": "template.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_route_specified_multiple_targets.md" }, { + "detector": "aws_db_instance_invalid_type", "type": "ERROR", "message": "\"t1.micro\" is invalid instance type.", "line": 9, - "file": "github.com/wata727/example-module/aws_db_instance.tf" + "file": "github.com/wata727/example-module/aws_db_instance.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_invalid_type.md" }, { + "detector": "aws_elasticache_cluster_default_parameter_group", "type": "NOTICE", "message": "\"default.redis3.2\" is default parameter group. You cannot edit it.", "line": 12, - "file": "github.com/wata727/example-module/aws_elasticache_cluster.tf" + "file": "github.com/wata727/example-module/aws_elasticache_cluster.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_default_parameter_group.md" }, { + "detector": "aws_elasticache_cluster_previous_type", "type": "WARNING", "message": "\"cache.t1.micro\" is previous generation node type.", "line": 22, - "file": "github.com/wata727/example-module/aws_elasticache_cluster.tf" + "file": "github.com/wata727/example-module/aws_elasticache_cluster.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_previous_type.md" }, { + "detector": "terraform_module_pinned_source", "type": "WARNING", "message": "Module source \"github.com/wata727/example-module\" is not pinned", "line": 8, - "file": "template_override.tf" + "file": "template_override.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md" }, { + "detector": "aws_cloudwatch_metric_alarm_invalid_unit", "type": "ERROR", "message": "\"percent\" is invalid unit.", "line": 49, - "file": "template.tf" + "file": "template.tf", + "link": "https://github.com/wata727/tflint/blob/master/docs/aws_cloudwatch_metric_alarm_invalid_unit.md" } ] diff --git a/issue/issue.go b/issue/issue.go index fc8ce4eae..41e936d1d 100644 --- a/issue/issue.go +++ b/issue/issue.go @@ -3,10 +3,12 @@ package issue import "fmt" type Issue struct { - Type string `json:"type"` - Message string `json:"message"` - Line int `json:"line"` - File string `json:"file"` + Detector string `json:"detector"` + Type string `json:"type"` + Message string `json:"message"` + Line int `json:"line"` + File string `json:"file"` + Link string `json:"link"` } const ERROR = "ERROR" diff --git a/printer/checkstyle.go b/printer/checkstyle.go index 4deeacfee..938720b4d 100644 --- a/printer/checkstyle.go +++ b/printer/checkstyle.go @@ -10,9 +10,11 @@ import ( ) type Error struct { + Detector string `xml:"detector,attr"` Line int `xml:"line,attr"` Severity string `xml:"severity,attr"` Message string `xml:"message,attr"` + Link string `xml:"link,attr"` } type File struct { @@ -34,7 +36,16 @@ func (p *Printer) CheckstylePrint(issues []*issue.Issue) { if len(v.Files) == 0 || v.Files[len(v.Files)-1].Name != i.File { v.Files = append(v.Files, File{Name: i.File}) } - v.Files[len(v.Files)-1].Errors = append(v.Files[len(v.Files)-1].Errors, Error{Line: i.Line, Severity: toSeverity(i.Type), Message: i.Message}) + v.Files[len(v.Files)-1].Errors = append( + v.Files[len(v.Files)-1].Errors, + Error{ + Detector: i.Detector, + Line: i.Line, + Severity: toSeverity(i.Type), + Message: i.Message, + Link: i.Link, + }, + ) } result, err := xml.MarshalIndent(v, "", " ") diff --git a/printer/checkstyle_test.go b/printer/checkstyle_test.go index 7fc1491b9..70ecfb083 100644 --- a/printer/checkstyle_test.go +++ b/printer/checkstyle_test.go @@ -23,32 +23,36 @@ func TestCheckstylePrint(t *testing.T) { Name: "multi files", Input: []*issue.Issue{ { - File: "template.tf", - Line: 1, - Type: "ERROR", - Message: "example error message", + Detector: "error detector", + File: "template.tf", + Line: 1, + Type: "ERROR", + Message: "example error message", }, { - File: "application.tf", - Line: 10, - Type: "NOTICE", - Message: "example notice message", + Detector: "notice detector", + File: "application.tf", + Line: 10, + Type: "NOTICE", + Message: "example notice message", + Link: "https://github.com/wata727/tflint", }, { - File: "template.tf", - Line: 3, - Type: "WARNING", - Message: "example warning message", + Detector: "warning detector", + File: "template.tf", + Line: 3, + Type: "WARNING", + Message: "example warning message", }, }, Result: ` - + - - + + `, }, diff --git a/printer/default.go b/printer/default.go index cc290927c..7dffe59ea 100644 --- a/printer/default.go +++ b/printer/default.go @@ -41,16 +41,17 @@ func (p *Printer) printByLine(issues []*issue.Issue) { fmt.Fprintf(p.stdout, "%s\n", fileColor(issues[0].File)) for _, i := range issues { issuePrefix := i.Type + ":" + strconv.Itoa(i.Line) + message := fmt.Sprintf("%s (%s)", i.Message, i.Detector) switch i.Type { - case "ERROR": + case issue.ERROR: issuePrefix = errorColor(issuePrefix) - case "WARNING": + case issue.WARNING: issuePrefix = warningColor(issuePrefix) - case "NOTICE": + case issue.NOTICE: issuePrefix = noticeColor(issuePrefix) } - fmt.Fprintf(p.stdout, "\t%s %s\n", issuePrefix, i.Message) + fmt.Fprintf(p.stdout, "\t%s %s\n", issuePrefix, message) } } @@ -61,11 +62,11 @@ func (p *Printer) printSummary(issues []*issue.Issue) { for _, i := range issues { switch i.Type { - case "ERROR": + case issue.ERROR: eIssues = append(eIssues, i) - case "WARNING": + case issue.WARNING: wIssues = append(wIssues, i) - case "NOTICE": + case issue.NOTICE: nIssues = append(nIssues, i) } } diff --git a/printer/default_test.go b/printer/default_test.go index 49d96ae13..1c77f9ac2 100644 --- a/printer/default_test.go +++ b/printer/default_test.go @@ -23,36 +23,41 @@ func TestDefaultPrint(t *testing.T) { Name: "multi files", Input: []*issue.Issue{ { - File: "template.tf", - Line: 1, - Type: "ERROR", - Message: "example error message", + Detector: "error detector", + File: "template.tf", + Line: 1, + Type: "ERROR", + Message: "example error message", }, { - File: "application.tf", - Line: 10, - Type: "NOTICE", - Message: "example notice message", + Detector: "notice detector", + File: "application.tf", + Line: 10, + Type: "NOTICE", + Message: "example notice message", + Link: "https://github.com/wata727/tflint", }, { - File: "template.tf", - Line: 5, - Type: "WARNING", - Message: "example warning message", + Detector: "warning detector", + File: "template.tf", + Line: 5, + Type: "WARNING", + Message: "example warning message", }, { - File: "template.tf", - Line: 3, - Type: "WARNING", - Message: "example warning message", + Detector: "warning detector", + File: "template.tf", + Line: 3, + Type: "WARNING", + Message: "example warning message", }, }, Result: fmt.Sprintf(`%s - %s example notice message + %s example notice message (notice detector) %s - %s example error message - %s example warning message - %s example warning message + %s example error message (error detector) + %s example warning message (warning detector) + %s example warning message (warning detector) Result: %s (%s , %s , %s) `, fileColor("application.tf"), noticeColor("NOTICE:10"), fileColor("template.tf"), errorColor("ERROR:1"), warningColor("WARNING:3"), warningColor("WARNING:5"), fileColor("4 issues"), errorColor("1 errors"), warningColor("2 warnings"), noticeColor("1 notices")), From 434d3337c37f07f4871d87a41dc9c34693f4c9dc Mon Sep 17 00:00:00 2001 From: wata_mac Date: Sat, 8 Jul 2017 22:31:04 +0900 Subject: [PATCH 4/4] Delete global scope detector name --- detector/detector.go | 109 ++++++++++++++++++++------------------ detector/detector_test.go | 19 +++++-- detector/test_helper.go | 18 +++---- 3 files changed, 78 insertions(+), 68 deletions(-) diff --git a/detector/detector.go b/detector/detector.go index f9af96790..4a15a95bc 100644 --- a/detector/detector.go +++ b/detector/detector.go @@ -37,51 +37,51 @@ type Detector struct { Link string } -var detectors = map[string]string{ - "aws_instance_invalid_type": "CreateAwsInstanceInvalidTypeDetector", - "aws_instance_previous_type": "CreateAwsInstancePreviousTypeDetector", - "aws_instance_not_specified_iam_profile": "CreateAwsInstanceNotSpecifiedIAMProfileDetector", - "aws_instance_default_standard_volume": "CreateAwsInstanceDefaultStandardVolumeDetector", - "aws_instance_invalid_iam_profile": "CreateAwsInstanceInvalidIAMProfileDetector", - "aws_instance_invalid_ami": "CreateAwsInstanceInvalidAMIDetector", - "aws_instance_invalid_key_name": "CreateAwsInstanceInvalidKeyNameDetector", - "aws_instance_invalid_subnet": "CreateAwsInstanceInvalidSubnetDetector", - "aws_instance_invalid_vpc_security_group": "CreateAwsInstanceInvalidVPCSecurityGroupDetector", - "aws_alb_invalid_security_group": "CreateAwsALBInvalidSecurityGroupDetector", - "aws_alb_invalid_subnet": "CreateAwsALBInvalidSubnetDetector", - "aws_alb_duplicate_name": "CreateAwsALBDuplicateNameDetector", - "aws_elb_invalid_security_group": "CreateAwsELBInvalidSecurityGroupDetector", - "aws_elb_invalid_subnet": "CreateAwsELBInvalidSubnetDetector", - "aws_elb_invalid_instance": "CreateAwsELBInvalidInstanceDetector", - "aws_elb_duplicate_name": "CreateAwsELBDuplicateNameDetector", - "aws_db_instance_default_parameter_group": "CreateAwsDBInstanceDefaultParameterGroupDetector", - "aws_db_instance_invalid_vpc_security_group": "CreateAwsDBInstanceInvalidVPCSecurityGroupDetector", - "aws_db_instance_invalid_db_subnet_group": "CreateAwsDBInstanceInvalidDBSubnetGroupDetector", - "aws_db_instance_invalid_parameter_group": "CreateAwsDBInstanceInvalidParameterGroupDetector", - "aws_db_instance_invalid_option_group": "CreateAwsDBInstanceInvalidOptionGroupDetector", - "aws_db_instance_invalid_type": "CreateAwsDBInstanceInvalidTypeDetector", - "aws_db_instance_previous_type": "CreateAwsDBInstancePreviousTypeDetector", - "aws_db_instance_readable_password": "CreateAwsDBInstanceReadablePasswordDetector", - "aws_db_instance_duplicate_identifier": "CreateAwsDBInstanceDuplicateIdentifierDetector", - "aws_elasticache_cluster_default_parameter_group": "CreateAwsElastiCacheClusterDefaultParameterGroupDetector", - "aws_elasticache_cluster_invalid_parameter_group": "CreateAwsElastiCacheClusterInvalidParameterGroupDetector", - "aws_elasticache_cluster_invalid_subnet_group": "CreateAwsElastiCacheClusterInvalidSubnetGroupDetector", - "aws_elasticache_cluster_invalid_security_group": "CreateAwsElastiCacheClusterInvalidSecurityGroupDetector", - "aws_elasticache_cluster_invalid_type": "CreateAwsElastiCacheClusterInvalidTypeDetector", - "aws_elasticache_cluster_previous_type": "CreateAwsElastiCacheClusterPreviousTypeDetector", - "aws_elasticache_cluster_duplicate_id": "CreateAwsElastiCacheClusterDuplicateIDDetector", - "aws_security_group_duplicate_name": "CreateAwsSecurityGroupDuplicateDetector", - "aws_route_invalid_route_table": "CreateAwsRouteInvalidRouteTableDetector", - "aws_route_not_specified_target": "CreateAwsRouteNotSpecifiedTargetDetector", - "aws_route_specified_multiple_targets": "CreateAwsRouteSpecifiedMultipleTargetsDetector", - "aws_route_invalid_gateway": "CreateAwsRouteInvalidGatewayDetector", - "aws_route_invalid_egress_only_gateway": "CreateAwsRouteInvalidEgressOnlyGatewayDetector", - "aws_route_invalid_nat_gateway": "CreateAwsRouteInvalidNatGatewayDetector", - "aws_route_invalid_vpc_peering_connection": "CreateAwsRouteInvalidVpcPeeringConnectionDetector", - "aws_route_invalid_instance": "CreateAwsRouteInvalidInstanceDetector", - "aws_route_invalid_network_interface": "CreateAwsRouteInvalidNetworkInterfaceDetector", - "aws_cloudwatch_metric_alarm_invalid_unit": "CreateAwsCloudWatchMetricAlarmInvalidUnitDetector", - "terraform_module_pinned_source": "CreateTerraformModulePinnedSourceDetector", +var detectorFactories = []string{ + "CreateAwsInstanceInvalidTypeDetector", + "CreateAwsInstancePreviousTypeDetector", + "CreateAwsInstanceNotSpecifiedIAMProfileDetector", + "CreateAwsInstanceDefaultStandardVolumeDetector", + "CreateAwsInstanceInvalidIAMProfileDetector", + "CreateAwsInstanceInvalidAMIDetector", + "CreateAwsInstanceInvalidKeyNameDetector", + "CreateAwsInstanceInvalidSubnetDetector", + "CreateAwsInstanceInvalidVPCSecurityGroupDetector", + "CreateAwsALBInvalidSecurityGroupDetector", + "CreateAwsALBInvalidSubnetDetector", + "CreateAwsALBDuplicateNameDetector", + "CreateAwsELBInvalidSecurityGroupDetector", + "CreateAwsELBInvalidSubnetDetector", + "CreateAwsELBInvalidInstanceDetector", + "CreateAwsELBDuplicateNameDetector", + "CreateAwsDBInstanceDefaultParameterGroupDetector", + "CreateAwsDBInstanceInvalidVPCSecurityGroupDetector", + "CreateAwsDBInstanceInvalidDBSubnetGroupDetector", + "CreateAwsDBInstanceInvalidParameterGroupDetector", + "CreateAwsDBInstanceInvalidOptionGroupDetector", + "CreateAwsDBInstanceInvalidTypeDetector", + "CreateAwsDBInstancePreviousTypeDetector", + "CreateAwsDBInstanceReadablePasswordDetector", + "CreateAwsDBInstanceDuplicateIdentifierDetector", + "CreateAwsElastiCacheClusterDefaultParameterGroupDetector", + "CreateAwsElastiCacheClusterInvalidParameterGroupDetector", + "CreateAwsElastiCacheClusterInvalidSubnetGroupDetector", + "CreateAwsElastiCacheClusterInvalidSecurityGroupDetector", + "CreateAwsElastiCacheClusterInvalidTypeDetector", + "CreateAwsElastiCacheClusterPreviousTypeDetector", + "CreateAwsElastiCacheClusterDuplicateIDDetector", + "CreateAwsSecurityGroupDuplicateDetector", + "CreateAwsRouteInvalidRouteTableDetector", + "CreateAwsRouteNotSpecifiedTargetDetector", + "CreateAwsRouteSpecifiedMultipleTargetsDetector", + "CreateAwsRouteInvalidGatewayDetector", + "CreateAwsRouteInvalidEgressOnlyGatewayDetector", + "CreateAwsRouteInvalidNatGatewayDetector", + "CreateAwsRouteInvalidVpcPeeringConnectionDetector", + "CreateAwsRouteInvalidInstanceDetector", + "CreateAwsRouteInvalidNetworkInterfaceDetector", + "CreateAwsCloudWatchMetricAlarmInvalidUnitDetector", + "CreateTerraformModulePinnedSourceDetector", } func NewDetector(templates map[string]*ast.File, schema []*schema.Template, state *state.TFState, tfvars []*ast.File, c *config.Config) (*Detector, error) { @@ -103,12 +103,7 @@ func NewDetector(templates map[string]*ast.File, schema []*schema.Template, stat func (d *Detector) Detect() []*issue.Issue { var issues = []*issue.Issue{} - for ruleName, creatorMethod := range detectors { - if d.Config.IgnoreRule[ruleName] { - d.Logger.Info(fmt.Sprintf("ignore rule `%s`", ruleName)) - continue - } - d.Logger.Info(fmt.Sprintf("detect by `%s`", ruleName)) + for _, creatorMethod := range detectorFactories { d.detect(creatorMethod, &issues) for _, template := range d.Schema { @@ -142,15 +137,19 @@ func (d *Detector) HasError() bool { func (d *Detector) detect(creatorMethod string, issues *[]*issue.Issue) { creator := reflect.ValueOf(d).MethodByName(creatorMethod) detector := creator.Call([]reflect.Value{})[0] + ruleName := reflect.Indirect(detector).FieldByName("Name").String() if d.isSkip( + ruleName, reflect.Indirect(detector).FieldByName("DeepCheck").Bool(), reflect.Indirect(detector).FieldByName("TargetType").String(), reflect.Indirect(detector).FieldByName("Target").String(), ) { - d.Logger.Info("skip this rule.") + d.Logger.Info(fmt.Sprintf("skip `%s`", ruleName)) return } + + d.Logger.Info(fmt.Sprintf("detect by `%s`", ruleName)) if preProcess := detector.MethodByName("PreProcess"); preProcess.IsValid() { preProcess.Call([]reflect.Value{}) } @@ -224,7 +223,11 @@ func (d *Detector) evalToStringTokens(t token.Token) ([]token.Token, error) { return tokens, nil } -func (d *Detector) isSkip(deepCheck bool, targetType string, target string) bool { +func (d *Detector) isSkip(name string, deepCheck bool, targetType string, target string) bool { + if d.Config.IgnoreRule[name] { + return true + } + if deepCheck && !d.Config.DeepCheck { return true } diff --git a/detector/detector_test.go b/detector/detector_test.go index 8604d1431..faaec889f 100644 --- a/detector/detector_test.go +++ b/detector/detector_test.go @@ -53,9 +53,7 @@ func TestDetect(t *testing.T) { }, } - detectors = map[string]string{ - "test_rule": "CreateTestDetector", - } + detectorFactories = []string{"CreateTestDetector"} for _, tc := range cases { prev, _ := filepath.Abs(".") @@ -271,6 +269,7 @@ variable "array" { func TestIsSkip(t *testing.T) { type Input struct { + RuleName string File string DeepCheckMode bool DeepCheckDetector bool @@ -286,6 +285,7 @@ func TestIsSkip(t *testing.T) { { Name: "return false when enabled deep checking", Input: Input{ + RuleName: "aws_instance_invalid_type", File: ` resource "aws_instance" "web" { ami = "ami-12345" @@ -300,6 +300,7 @@ resource "aws_instance" "web" { { Name: "return true when disabled deep checking", Input: Input{ + RuleName: "aws_instance_invalid_type", File: ` resource "aws_instance" "web" { ami = "ami-12345" @@ -314,6 +315,7 @@ resource "aws_instance" "web" { { Name: "return false when disabled deep checking but not deep check detector", Input: Input{ + RuleName: "aws_instance_invalid_type", File: ` resource "aws_instance" "web" { ami = "ami-12345" @@ -328,6 +330,7 @@ resource "aws_instance" "web" { { Name: "return false when enabled deep checking and not deep check detector", Input: Input{ + RuleName: "aws_instance_invalid_type", File: ` resource "aws_instance" "web" { ami = "ami-12345" @@ -342,6 +345,7 @@ resource "aws_instance" "web" { { Name: "return true when target resources are not found", Input: Input{ + RuleName: "aws_instance_invalid_type", File: ` resource "aws_instance" "web" { ami = "ami-12345" @@ -356,6 +360,7 @@ resource "aws_instance" "web" { { Name: "return false when modules are found", Input: Input{ + RuleName: "aws_instance_invalid_type", File: ` module "ec2_instance" { source = "./ec2_instance" @@ -369,6 +374,7 @@ module "ec2_instance" { { Name: "return true when target modules are not found", Input: Input{ + RuleName: "aws_instance_invalid_type", File: ` resource "aws_instance" "web" { ami = "ami-12345" @@ -394,7 +400,12 @@ resource "aws_instance" "web" { } d.Config.DeepCheck = tc.Input.DeepCheckMode - result := d.isSkip(tc.Input.DeepCheckDetector, tc.Input.TargetType, tc.Input.Target) + result := d.isSkip( + tc.Input.RuleName, + tc.Input.DeepCheckDetector, + tc.Input.TargetType, + tc.Input.Target, + ) if result != tc.Result { t.Fatalf("\nBad: %t\nExpected: %t\n\ntestcase: %s", result, tc.Result, tc.Name) } diff --git a/detector/test_helper.go b/detector/test_helper.go index 9bb050225..f4d0f9455 100644 --- a/detector/test_helper.go +++ b/detector/test_helper.go @@ -17,20 +17,16 @@ import ( type TestDetector struct { *Detector - IssueType string - TargetType string - Target string - DeepCheck bool } func (d *Detector) CreateTestDetector() *TestDetector { - return &TestDetector{ - Detector: d, - IssueType: "TEST", - TargetType: "resource", - Target: "aws_instance", - DeepCheck: false, - } + nd := &TestDetector{Detector: d} + nd.Name = "test_rule" + nd.IssueType = "TEST" + nd.TargetType = "resource" + nd.Target = "aws_instance" + nd.DeepCheck = false + return nd } func (d *TestDetector) Detect(resource *schema.Resource, issues *[]*issue.Issue) {