-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide abstract HCL access #112
Conversation
schema/schema.go
Outdated
Resources: []*Resource{}, | ||
} | ||
var ret map[string]map[string]interface{} | ||
root, _ := parser.Parse(body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [gas] Errors unhandled.,LOW,HIGH
schema/schema.go
Outdated
} | ||
var ret map[string]map[string]interface{} | ||
root, _ := parser.Parse(body) | ||
hcl.DecodeObject(&ret, root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [gas] Errors unhandled.,LOW,HIGH
} | ||
|
||
for _, template := range templates { | ||
sort.Slice(template.Resources, func(i, j int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [gosimple] Slice not declared by package sort
- [staticcheck] Slice not declared by package sort
- [varcheck] unused variable or constant Slice not declared by package sort
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... sort.Slice
is valid function 🤔
} | ||
} | ||
|
||
func appendTemplates(templates []*Template, files map[string][]byte, override bool) ([]*Template, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [gocyclo] cyclomatic complexity 16 of function appendTemplates() is high (> 15)
} | ||
|
||
for _, template := range templates { | ||
sort.Slice(template.Resources, func(i, j int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [staticcheck] Slice not declared by package sort
- [gosimple] Slice not declared by package sort
- [varcheck] unused variable or constant Slice not declared by package sort
fmt.Fprintln(cli.errStream, fmt.Errorf("ERROR: Parse error: %s", err)) | ||
return ExitCodeError | ||
} | ||
cli.detector, err = detector.NewDetector(templates, schema, state, tfvars, c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [ineffassign] ineffectual assignment to err
} | ||
} | ||
|
||
func appendTemplates(templates []*Template, files map[string][]byte, override bool) ([]*Template, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [gocyclo] cyclomatic complexity 17 of function appendTemplates() is high (> 15)
} | ||
|
||
for _, template := range templates { | ||
sort.Slice(template.Resources, func(i, j int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [varcheck] unused variable or constant Slice not declared by package sort
- [gosimple] Slice not declared by package sort
- [staticcheck] Slice not declared by package sort
fmt.Fprintln(cli.errStream, fmt.Errorf("ERROR: Parse error: %s", err)) | ||
return ExitCodeError | ||
} | ||
cli.detector, err = detector.NewDetector(templates, schema, state, tfvars, c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [ineffassign] ineffectual assignment to err
- [staticcheck] this value of err is never used (SA4006)
} | ||
|
||
for _, template := range templates { | ||
sort.Slice(template.Resources, func(i, j int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [gosimple] Slice not declared by package sort
- [staticcheck] Slice not declared by package sort
- [varcheck] unused variable or constant Slice not declared by package sort
1b08c3f
to
1b4bece
Compare
} | ||
|
||
for _, template := range templates { | ||
sort.Slice(template.Resources, func(i, j int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gometalinter]
- [staticcheck] Slice not declared by package sort
- [varcheck] unused variable or constant Slice not declared by package sort
- [gosimple] Slice not declared by package sort
Fix #103
Currently, TFLint takes a direct reference to the interface provided by hashicorp/hcl. But, In this approach, handling of override is very difficult.
As a countermeasure for this problem, introduce
schema
package. In this approach, all access to HCL is through this package. So, override implementation is in this package.