Skip to content

Commit

Permalink
Merge pull request #284 from wata727/change_documentation_url
Browse files Browse the repository at this point in the history
Change documentation url in json output
  • Loading branch information
wata727 authored May 24, 2019
2 parents babd6da + 133436b commit 8b5e711
Show file tree
Hide file tree
Showing 33 changed files with 85 additions and 59 deletions.
3 changes: 2 additions & 1 deletion cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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",
Expand Down
4 changes: 0 additions & 4 deletions cmd/version.go

This file was deleted.

8 changes: 4 additions & 4 deletions integration/basic/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@
"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",
"type": "ERROR",
"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",
"type": "ERROR",
"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",
"type": "ERROR",
"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"
}
]
2 changes: 1 addition & 1 deletion integration/module/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": ""
}
]
2 changes: 1 addition & 1 deletion integration/module/result_windows.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": ""
}
]
2 changes: 1 addition & 1 deletion integration/override/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": ""
}
]
8 changes: 4 additions & 4 deletions integration/variables/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@
"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",
"type": "ERROR",
"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",
"type": "ERROR",
"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",
"type": "ERROR",
"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": ""
}
]
11 changes: 11 additions & 0 deletions project/meta.go
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion rules/awsrules/aws_cloudwatch_metric_alarm_invalid_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
Expand All @@ -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",
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion rules/awsrules/aws_db_instance_default_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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"),
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion rules/awsrules/aws_db_instance_previous_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion rules/awsrules/aws_db_instance_previous_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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"),
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion rules/awsrules/aws_db_instance_readable_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions rules/awsrules/aws_db_instance_readable_password_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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"),
},
},
},
Expand All @@ -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"),
},
},
},
Expand Down Expand Up @@ -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"),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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"),
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion rules/awsrules/aws_elasticache_cluster_previous_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion rules/awsrules/aws_elasticache_cluster_previous_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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"),
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion rules/awsrules/aws_instance_default_standard_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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`
Expand Down
Loading

0 comments on commit 8b5e711

Please sign in to comment.