From 133436bce063cd8865131a076372446e3ce9aff3 Mon Sep 17 00:00:00 2001 From: wata_mac Date: Fri, 24 May 2019 23:04:28 +0900 Subject: [PATCH] Change documentation url in json output --- cmd/cli.go | 3 ++- cmd/cli_test.go | 3 ++- cmd/version.go | 4 --- integration/basic/result.json | 8 +++--- integration/module/result.json | 2 +- integration/module/result_windows.json | 2 +- integration/override/result.json | 2 +- integration/variables/result.json | 8 +++--- project/meta.go | 11 ++++++++ ...ws_cloudwatch_metric_alarm_invalid_unit.go | 2 +- ...oudwatch_metric_alarm_invalid_unit_test.go | 2 -- ...aws_db_instance_default_parameter_group.go | 3 ++- ...b_instance_default_parameter_group_test.go | 3 ++- .../awsrules/aws_db_instance_previous_type.go | 3 ++- .../aws_db_instance_previous_type_test.go | 3 ++- .../aws_db_instance_readable_password.go | 3 ++- .../aws_db_instance_readable_password_test.go | 7 +++--- ...ticache_cluster_default_parameter_group.go | 3 ++- ...he_cluster_default_parameter_group_test.go | 3 ++- .../aws_elasticache_cluster_previous_type.go | 3 ++- ..._elasticache_cluster_previous_type_test.go | 3 ++- .../aws_instance_default_standard_volume.go | 3 ++- ...s_instance_default_standard_volume_test.go | 11 ++++---- rules/awsrules/aws_instance_invalid_type.go | 2 +- .../aws_instance_invalid_type_test.go | 1 - rules/awsrules/aws_instance_previous_type.go | 3 ++- .../aws_instance_previous_type_test.go | 3 ++- .../aws_route_not_specified_target.go | 3 ++- .../aws_route_not_specified_target_test.go | 3 ++- .../aws_route_specified_multiple_targets.go | 3 ++- ...s_route_specified_multiple_targets_test.go | 3 ++- .../terraform_module_pinned_source.go | 3 ++- .../terraform_module_pinned_source_test.go | 25 ++++++++++--------- 33 files changed, 85 insertions(+), 59 deletions(-) delete mode 100644 cmd/version.go create mode 100644 project/meta.go diff --git a/cmd/cli.go b/cmd/cli.go index ce2d4f047..41cb5f209 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -11,6 +11,7 @@ import ( "github.com/wata727/tflint/issue" "github.com/wata727/tflint/printer" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/rules" "github.com/wata727/tflint/tflint" ) @@ -64,7 +65,7 @@ func (cli *CLI) Run(args []string) int { // Show version if opts.Version { - fmt.Fprintf(cli.outStream, "TFLint version %s\n", Version) + fmt.Fprintf(cli.outStream, "TFLint version %s\n", project.Version) return ExitCodeOK } diff --git a/cmd/cli_test.go b/cmd/cli_test.go index 9651b821c..89d80108e 100644 --- a/cmd/cli_test.go +++ b/cmd/cli_test.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" "github.com/wata727/tflint/mock" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/rules" "github.com/wata727/tflint/tflint" ) @@ -32,7 +33,7 @@ func TestCLIRun__noIssuesFound(t *testing.T) { Name: "print version", Command: "./tflint --version", Status: ExitCodeOK, - Stdout: fmt.Sprintf("TFLint version %s", Version), + Stdout: fmt.Sprintf("TFLint version %s", project.Version), }, { Name: "print help", diff --git a/cmd/version.go b/cmd/version.go deleted file mode 100644 index 2bc7b10de..000000000 --- a/cmd/version.go +++ /dev/null @@ -1,4 +0,0 @@ -package cmd - -// Version is application version -const Version string = "0.7.6" diff --git a/integration/basic/result.json b/integration/basic/result.json index df34c2a19..aadf5ccb5 100644 --- a/integration/basic/result.json +++ b/integration/basic/result.json @@ -5,7 +5,7 @@ "message": "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, or vpc_peering_connection_id.", "line": 1, "file": "template.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_route_not_specified_target.md" + "link": "https://github.com/wata727/tflint/blob/v0.7.6/docs/rules/aws_route_not_specified_target.md" }, { "detector": "aws_route_specified_multiple_targets", @@ -13,7 +13,7 @@ "message": "More than one routing target specified. It must be one.", "line": 6, "file": "template.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_route_specified_multiple_targets.md" + "link": "https://github.com/wata727/tflint/blob/v0.7.6/docs/rules/aws_route_specified_multiple_targets.md" }, { "detector": "aws_cloudwatch_metric_alarm_invalid_unit", @@ -21,7 +21,7 @@ "message": "\"percent\" is invalid unit.", "line": 22, "file": "template.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_cloudwatch_metric_alarm_invalid_unit.md" + "link": "" }, { "detector": "aws_route_not_specified_target", @@ -29,6 +29,6 @@ "message": "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, or vpc_peering_connection_id.", "line": 27, "file": "template.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_route_not_specified_target.md" + "link": "https://github.com/wata727/tflint/blob/v0.7.6/docs/rules/aws_route_not_specified_target.md" } ] diff --git a/integration/module/result.json b/integration/module/result.json index 258053572..0374b3596 100644 --- a/integration/module/result.json +++ b/integration/module/result.json @@ -5,6 +5,6 @@ "message": "\"t1.2xlarge\" is invalid instance type.", "line": 12, "file": "instances/template.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md" + "link": "" } ] diff --git a/integration/module/result_windows.json b/integration/module/result_windows.json index d6a76666c..747145a20 100644 --- a/integration/module/result_windows.json +++ b/integration/module/result_windows.json @@ -5,6 +5,6 @@ "message": "\"t1.2xlarge\" is invalid instance type.", "line": 12, "file": "instances\\template.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md" + "link": "" } ] diff --git a/integration/override/result.json b/integration/override/result.json index 0a08cc3cd..08ffa4e36 100644 --- a/integration/override/result.json +++ b/integration/override/result.json @@ -5,6 +5,6 @@ "message": "\"t1.1xlarge\" is invalid instance type.", "line": 3, "file": "template_override.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md" + "link": "" } ] diff --git a/integration/variables/result.json b/integration/variables/result.json index 16a91f1e4..c7a481c62 100644 --- a/integration/variables/result.json +++ b/integration/variables/result.json @@ -5,7 +5,7 @@ "message": "\"default\" is invalid instance type.", "line": 24, "file": "template.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md" + "link": "" }, { "detector": "aws_instance_invalid_type", @@ -13,7 +13,7 @@ "message": "\"default_values_file\" is invalid instance type.", "line": 28, "file": "template.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md" + "link": "" }, { "detector": "aws_instance_invalid_type", @@ -21,7 +21,7 @@ "message": "\"auto_values_file\" is invalid instance type.", "line": 32, "file": "template.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md" + "link": "" }, { "detector": "aws_instance_invalid_type", @@ -29,6 +29,6 @@ "message": "\"values_file\" is invalid instance type.", "line": 36, "file": "template.tf", - "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md" + "link": "" } ] diff --git a/project/meta.go b/project/meta.go new file mode 100644 index 000000000..19f830458 --- /dev/null +++ b/project/meta.go @@ -0,0 +1,11 @@ +package project + +import "fmt" + +// Version is application version +const Version string = "0.7.6" + +// ReferenceLink returns the rule reference link +func ReferenceLink(name string) string { + return fmt.Sprintf("https://github.com/wata727/tflint/blob/v%s/docs/rules/%s.md", Version, name) +} diff --git a/rules/awsrules/aws_cloudwatch_metric_alarm_invalid_unit.go b/rules/awsrules/aws_cloudwatch_metric_alarm_invalid_unit.go index 981f722fa..62fc63f6a 100644 --- a/rules/awsrules/aws_cloudwatch_metric_alarm_invalid_unit.go +++ b/rules/awsrules/aws_cloudwatch_metric_alarm_invalid_unit.go @@ -71,7 +71,7 @@ func (r *AwsCloudwatchMetricAlarmInvalidUnitRule) Type() string { // Link returns the rule reference link func (r *AwsCloudwatchMetricAlarmInvalidUnitRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_cloudwatch_metric_alarm_invalid_unit.md" + return "" } // Check checks whether `unit` is included in the valid unit list diff --git a/rules/awsrules/aws_cloudwatch_metric_alarm_invalid_unit_test.go b/rules/awsrules/aws_cloudwatch_metric_alarm_invalid_unit_test.go index 6793a71b9..8850fbc68 100644 --- a/rules/awsrules/aws_cloudwatch_metric_alarm_invalid_unit_test.go +++ b/rules/awsrules/aws_cloudwatch_metric_alarm_invalid_unit_test.go @@ -38,7 +38,6 @@ resource "aws_cloudwatch_metric_alarm" "test" { Message: "\"GB\" is invalid unit.", Line: 9, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_cloudwatch_metric_alarm_invalid_unit.md", }, }, }, @@ -61,7 +60,6 @@ resource "aws_cloudwatch_metric_alarm" "test" { Message: "\"gigabytes\" is invalid unit.", Line: 9, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_cloudwatch_metric_alarm_invalid_unit.md", }, }, }, diff --git a/rules/awsrules/aws_db_instance_default_parameter_group.go b/rules/awsrules/aws_db_instance_default_parameter_group.go index 9cdf9eb1b..b02fc859c 100644 --- a/rules/awsrules/aws_db_instance_default_parameter_group.go +++ b/rules/awsrules/aws_db_instance_default_parameter_group.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/hcl2/hcl" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -41,7 +42,7 @@ func (r *AwsDBInstanceDefaultParameterGroupRule) Type() string { // Link returns the rule reference link func (r *AwsDBInstanceDefaultParameterGroupRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_default_parameter_group.md" + return project.ReferenceLink(r.Name()) } var defaultDBParameterGroupRegexp = regexp.MustCompile("^default") diff --git a/rules/awsrules/aws_db_instance_default_parameter_group_test.go b/rules/awsrules/aws_db_instance_default_parameter_group_test.go index 3ddec8585..69cd9b82a 100644 --- a/rules/awsrules/aws_db_instance_default_parameter_group_test.go +++ b/rules/awsrules/aws_db_instance_default_parameter_group_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -32,7 +33,7 @@ resource "aws_db_instance" "db" { Message: "\"default.mysql5.6\" is default parameter group. You cannot edit it.", Line: 3, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_default_parameter_group.md", + Link: project.ReferenceLink("aws_db_instance_default_parameter_group"), }, }, }, diff --git a/rules/awsrules/aws_db_instance_previous_type.go b/rules/awsrules/aws_db_instance_previous_type.go index 26546b3d4..a354746f1 100644 --- a/rules/awsrules/aws_db_instance_previous_type.go +++ b/rules/awsrules/aws_db_instance_previous_type.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/hcl2/hcl" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -52,7 +53,7 @@ func (r *AwsDBInstancePreviousTypeRule) Type() string { // Link returns the rule reference link func (r *AwsDBInstancePreviousTypeRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_previous_type.md" + return project.ReferenceLink(r.Name()) } // Check checks whether the resource's `instance_class` is included in the list of previous generation instance type diff --git a/rules/awsrules/aws_db_instance_previous_type_test.go b/rules/awsrules/aws_db_instance_previous_type_test.go index e3f74806e..56c07f7e0 100644 --- a/rules/awsrules/aws_db_instance_previous_type_test.go +++ b/rules/awsrules/aws_db_instance_previous_type_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -32,7 +33,7 @@ resource "aws_db_instance" "mysql" { Message: "\"db.t1.micro\" is previous generation instance type.", Line: 3, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_previous_type.md", + Link: project.ReferenceLink("aws_db_instance_previous_type"), }, }, }, diff --git a/rules/awsrules/aws_db_instance_readable_password.go b/rules/awsrules/aws_db_instance_readable_password.go index 005e842b9..018512f2e 100644 --- a/rules/awsrules/aws_db_instance_readable_password.go +++ b/rules/awsrules/aws_db_instance_readable_password.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/lang" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -41,7 +42,7 @@ func (r *AwsDBInstanceReadablePasswordRule) Type() string { // Link returns the rule reference link func (r *AwsDBInstanceReadablePasswordRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md" + return project.ReferenceLink(r.Name()) } // Check checks password diff --git a/rules/awsrules/aws_db_instance_readable_password_test.go b/rules/awsrules/aws_db_instance_readable_password_test.go index b8f9e2bac..d88690452 100644 --- a/rules/awsrules/aws_db_instance_readable_password_test.go +++ b/rules/awsrules/aws_db_instance_readable_password_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -32,7 +33,7 @@ resource "aws_db_instance" "mysql" { Message: "Password for the master DB user is readable. Recommend using environment variables or variable files.", Line: 3, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md", + Link: project.ReferenceLink("aws_db_instance_readable_password"), }, }, }, @@ -53,7 +54,7 @@ resource "aws_db_instance" "mysql" { Message: "Password for the master DB user is readable. Recommend using environment variables or variable files.", Line: 7, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md", + Link: project.ReferenceLink("aws_db_instance_readable_password"), }, }, }, @@ -100,7 +101,7 @@ resource "aws_db_instance" "mysql" { Message: "Password for the master DB user is readable. Recommend using environment variables or variable files.", Line: 10, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md", + Link: project.ReferenceLink("aws_db_instance_readable_password"), }, }, }, diff --git a/rules/awsrules/aws_elasticache_cluster_default_parameter_group.go b/rules/awsrules/aws_elasticache_cluster_default_parameter_group.go index 66840dad8..1854dc5ee 100644 --- a/rules/awsrules/aws_elasticache_cluster_default_parameter_group.go +++ b/rules/awsrules/aws_elasticache_cluster_default_parameter_group.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/hcl2/hcl" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -41,7 +42,7 @@ func (r *AwsElastiCacheClusterDefaultParameterGroupRule) Type() string { // Link returns the rule reference link func (r *AwsElastiCacheClusterDefaultParameterGroupRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_default_parameter_group.md" + return project.ReferenceLink(r.Name()) } var defaultElastiCacheParameterGroupRegexp = regexp.MustCompile("^default") diff --git a/rules/awsrules/aws_elasticache_cluster_default_parameter_group_test.go b/rules/awsrules/aws_elasticache_cluster_default_parameter_group_test.go index dcb437bbc..c50c569c8 100644 --- a/rules/awsrules/aws_elasticache_cluster_default_parameter_group_test.go +++ b/rules/awsrules/aws_elasticache_cluster_default_parameter_group_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -32,7 +33,7 @@ resource "aws_elasticache_cluster" "cache" { Message: "\"default.redis3.2\" is default parameter group. You cannot edit it.", Line: 3, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_default_parameter_group.md", + Link: project.ReferenceLink("aws_elasticache_cluster_default_parameter_group"), }, }, }, diff --git a/rules/awsrules/aws_elasticache_cluster_previous_type.go b/rules/awsrules/aws_elasticache_cluster_previous_type.go index d9fe00908..296e246a0 100644 --- a/rules/awsrules/aws_elasticache_cluster_previous_type.go +++ b/rules/awsrules/aws_elasticache_cluster_previous_type.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/hcl2/hcl" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -52,7 +53,7 @@ func (r *AwsElastiCacheClusterPreviousTypeRule) Type() string { // Link returns the rule reference link func (r *AwsElastiCacheClusterPreviousTypeRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_previous_type.md" + return project.ReferenceLink(r.Name()) } // Check checks whether the resource's `node_type` is included in the list of previous generation node type diff --git a/rules/awsrules/aws_elasticache_cluster_previous_type_test.go b/rules/awsrules/aws_elasticache_cluster_previous_type_test.go index 5c400eef8..6bd1ef6ac 100644 --- a/rules/awsrules/aws_elasticache_cluster_previous_type_test.go +++ b/rules/awsrules/aws_elasticache_cluster_previous_type_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -32,7 +33,7 @@ resource "aws_elasticache_cluster" "redis" { Message: "\"cache.t1.micro\" is previous generation node type.", Line: 3, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_previous_type.md", + Link: project.ReferenceLink("aws_elasticache_cluster_previous_type"), }, }, }, diff --git a/rules/awsrules/aws_instance_default_standard_volume.go b/rules/awsrules/aws_instance_default_standard_volume.go index 5f4cddb3e..ea6f870e5 100644 --- a/rules/awsrules/aws_instance_default_standard_volume.go +++ b/rules/awsrules/aws_instance_default_standard_volume.go @@ -5,6 +5,7 @@ import ( "github.com/hashicorp/hcl2/hcl" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -37,7 +38,7 @@ func (r *AwsInstanceDefaultStandardVolumeRule) Type() string { // Link returns the rule reference link func (r *AwsInstanceDefaultStandardVolumeRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md" + return project.ReferenceLink(r.Name()) } // Check checks whether `volume_type` is defined for `root_block_device` or `ebs_block_device` diff --git a/rules/awsrules/aws_instance_default_standard_volume_test.go b/rules/awsrules/aws_instance_default_standard_volume_test.go index 5a6c8b992..c69875642 100644 --- a/rules/awsrules/aws_instance_default_standard_volume_test.go +++ b/rules/awsrules/aws_instance_default_standard_volume_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -36,7 +37,7 @@ resource "aws_instance" "web" { Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", Line: 5, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md", + Link: project.ReferenceLink("aws_instance_default_standard_volume"), }, }, }, @@ -57,7 +58,7 @@ resource "aws_instance" "web" { Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", Line: 5, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md", + Link: project.ReferenceLink("aws_instance_default_standard_volume"), }, }, }, @@ -102,7 +103,7 @@ resource "aws_instance" "web" { Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", Line: 6, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md", + Link: project.ReferenceLink("aws_instance_default_standard_volume"), }, { Detector: "aws_instance_default_standard_volume", @@ -110,7 +111,7 @@ resource "aws_instance" "web" { Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", Line: 10, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md", + Link: project.ReferenceLink("aws_instance_default_standard_volume"), }, { Detector: "aws_instance_default_standard_volume", @@ -118,7 +119,7 @@ resource "aws_instance" "web" { Message: "\"volume_type\" is not specified. Default standard volume type is not recommended. You can use \"gp2\", \"io1\", etc instead.", Line: 15, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_default_standard_volume.md", + Link: project.ReferenceLink("aws_instance_default_standard_volume"), }, }, }, diff --git a/rules/awsrules/aws_instance_invalid_type.go b/rules/awsrules/aws_instance_invalid_type.go index 902391daf..1403a2614 100644 --- a/rules/awsrules/aws_instance_invalid_type.go +++ b/rules/awsrules/aws_instance_invalid_type.go @@ -55,7 +55,7 @@ func (r *AwsInstanceInvalidTypeRule) Type() string { // Link returns the rule reference link func (r *AwsInstanceInvalidTypeRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md" + return "" } // Check checks whether "aws_instance" has invalid instance type. diff --git a/rules/awsrules/aws_instance_invalid_type_test.go b/rules/awsrules/aws_instance_invalid_type_test.go index dd5f3ffe0..c29cb9579 100644 --- a/rules/awsrules/aws_instance_invalid_type_test.go +++ b/rules/awsrules/aws_instance_invalid_type_test.go @@ -36,7 +36,6 @@ resource "aws_instance" "valid" { Message: "\"t1.2xlarge\" is invalid instance type.", Line: 3, File: "instances.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_invalid_type.md", }, }, }, diff --git a/rules/awsrules/aws_instance_previous_type.go b/rules/awsrules/aws_instance_previous_type.go index 3eda664f6..e3054c64c 100644 --- a/rules/awsrules/aws_instance_previous_type.go +++ b/rules/awsrules/aws_instance_previous_type.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/hcl2/hcl" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -58,7 +59,7 @@ func (r *AwsInstancePreviousTypeRule) Type() string { // Link returns the rule reference link func (r *AwsInstancePreviousTypeRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_instance_previous_type.md" + return project.ReferenceLink(r.Name()) } // Check checks whether the resource's `instance_type` is included in the list of previous generation instance type diff --git a/rules/awsrules/aws_instance_previous_type_test.go b/rules/awsrules/aws_instance_previous_type_test.go index 047c06988..f9f844c26 100644 --- a/rules/awsrules/aws_instance_previous_type_test.go +++ b/rules/awsrules/aws_instance_previous_type_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -32,7 +33,7 @@ resource "aws_instance" "web" { Message: "\"t1.micro\" is previous generation instance type.", Line: 3, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_instance_previous_type.md", + Link: project.ReferenceLink("aws_instance_previous_type"), }, }, }, diff --git a/rules/awsrules/aws_route_not_specified_target.go b/rules/awsrules/aws_route_not_specified_target.go index ba066cfe4..c90665fab 100644 --- a/rules/awsrules/aws_route_not_specified_target.go +++ b/rules/awsrules/aws_route_not_specified_target.go @@ -5,6 +5,7 @@ import ( "github.com/hashicorp/hcl2/hcl" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -37,7 +38,7 @@ func (r *AwsRouteNotSpecifiedTargetRule) Type() string { // Link returns the rule reference link func (r *AwsRouteNotSpecifiedTargetRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_route_not_specified_target.md" + return project.ReferenceLink(r.Name()) } // Check checks whether `gateway_id`, `egress_only_gateway_id`, `nat_gateway_id`, `instance_id` diff --git a/rules/awsrules/aws_route_not_specified_target_test.go b/rules/awsrules/aws_route_not_specified_target_test.go index 2cee1ff3d..91810e621 100644 --- a/rules/awsrules/aws_route_not_specified_target_test.go +++ b/rules/awsrules/aws_route_not_specified_target_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -32,7 +33,7 @@ resource "aws_route" "foo" { Message: "The routing target is not specified, each aws_route must contain either egress_only_gateway_id, gateway_id, instance_id, nat_gateway_id, network_interface_id, transit_gateway_id, or vpc_peering_connection_id.", Line: 2, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_route_not_specified_target.md", + Link: project.ReferenceLink("aws_route_not_specified_target"), }, }, }, diff --git a/rules/awsrules/aws_route_specified_multiple_targets.go b/rules/awsrules/aws_route_specified_multiple_targets.go index f78a814f2..e4117fbbe 100644 --- a/rules/awsrules/aws_route_specified_multiple_targets.go +++ b/rules/awsrules/aws_route_specified_multiple_targets.go @@ -5,6 +5,7 @@ import ( "github.com/hashicorp/hcl2/hcl" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -37,7 +38,7 @@ func (r *AwsRouteSpecifiedMultipleTargetsRule) Type() string { // Link returns the rule reference link func (r *AwsRouteSpecifiedMultipleTargetsRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/aws_route_specified_multiple_targets.md" + return project.ReferenceLink(r.Name()) } // Check checks whether a resource defines `gateway_id`, `egress_only_gateway_id`, `nat_gateway_id` diff --git a/rules/awsrules/aws_route_specified_multiple_targets_test.go b/rules/awsrules/aws_route_specified_multiple_targets_test.go index 9b2899b24..a21380620 100644 --- a/rules/awsrules/aws_route_specified_multiple_targets_test.go +++ b/rules/awsrules/aws_route_specified_multiple_targets_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -34,7 +35,7 @@ resource "aws_route" "foo" { Message: "More than one routing target specified. It must be one.", Line: 2, File: "resource.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/aws_route_specified_multiple_targets.md", + Link: project.ReferenceLink("aws_route_specified_multiple_targets"), }, }, }, diff --git a/rules/terraformrules/terraform_module_pinned_source.go b/rules/terraformrules/terraform_module_pinned_source.go index f412e8f67..765513e6f 100644 --- a/rules/terraformrules/terraform_module_pinned_source.go +++ b/rules/terraformrules/terraform_module_pinned_source.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/terraform/configs" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -40,7 +41,7 @@ func (r *TerraformModulePinnedSourceRule) Type() string { // Link returns the rule reference link func (r *TerraformModulePinnedSourceRule) Link() string { - return "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md" + return project.ReferenceLink(r.Name()) } var reGithub = regexp.MustCompile("(^github.com/(.+)/(.+)$)|(^git@github.com:(.+)/(.+)$)") diff --git a/rules/terraformrules/terraform_module_pinned_source_test.go b/rules/terraformrules/terraform_module_pinned_source_test.go index 1c62aea1e..58068ed86 100644 --- a/rules/terraformrules/terraform_module_pinned_source_test.go +++ b/rules/terraformrules/terraform_module_pinned_source_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/terraform" "github.com/wata727/tflint/issue" + "github.com/wata727/tflint/project" "github.com/wata727/tflint/tflint" ) @@ -34,7 +35,7 @@ module "unpinned" { Message: "Module source \"git://hashicorp.com/consul.git\" is not pinned", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -51,7 +52,7 @@ module "default_git" { Message: "Module source \"git://hashicorp.com/consul.git?ref=master\" uses default ref \"master\"", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -76,7 +77,7 @@ module "unpinned" { Message: "Module source \"github.com/hashicorp/consul\" is not pinned", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -93,7 +94,7 @@ module "default_git" { Message: "Module source \"github.com/hashicorp/consul.git?ref=master\" uses default ref \"master\"", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -118,7 +119,7 @@ module "unpinned" { Message: "Module source \"bitbucket.org/hashicorp/consul\" is not pinned", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -135,7 +136,7 @@ module "default_git" { Message: "Module source \"bitbucket.org/hashicorp/consul.git?ref=master\" uses default ref \"master\"", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -161,7 +162,7 @@ module "unpinned_generic_git_https" { Message: "Module source \"git::https://hashicorp.com/consul.git\" is not pinned", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -179,7 +180,7 @@ module "unpinned_generic_git_ssh" { Message: "Module source \"git::ssh://git@github.com/owner/repo.git\" is not pinned", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -197,7 +198,7 @@ module "default_generic_git_https" { Message: "Module source \"git::https://hashicorp.com/consul.git?ref=master\" uses default ref \"master\"", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -215,7 +216,7 @@ module "default_generic_git_ssh" { Message: "Module source \"git::ssh://git@github.com/owner/repo.git?ref=master\" uses default ref \"master\"", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -250,7 +251,7 @@ module "default_mercurial" { Message: "Module source \"hg::http://hashicorp.com/consul.hg\" is not pinned", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, }, @@ -267,7 +268,7 @@ module "default_mercurial" { Message: "Module source \"hg::http://hashicorp.com/consul.hg?rev=default\" uses default rev \"default\"", Line: 3, File: "module.tf", - Link: "https://github.com/wata727/tflint/blob/master/docs/terraform_module_pinned_source.md", + Link: project.ReferenceLink("terraform_module_pinned_source"), }, }, },