Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

mapping aws_appstream #232

Merged
merged 3 commits into from
Dec 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,25 @@ These rules enforce best practices and naming conventions:
|aws_apprunner_connection_invalid_provider_type|✔|
|aws_apprunner_custom_domain_association_invalid_domain_name|✔|
|aws_apprunner_service_invalid_service_name|✔|
|aws_appstream_fleet_invalid_description|✔|
|aws_appstream_fleet_invalid_display_name|✔|
|aws_appstream_fleet_invalid_fleet_type|✔|
|aws_appstream_fleet_invalid_name|✔|
|aws_appstream_fleet_invalid_stream_view|✔|
|aws_appstream_image_builder_invalid_appstream_agent_version|✔|
|aws_appstream_image_builder_invalid_description|✔|
|aws_appstream_image_builder_invalid_display_name|✔|
|aws_appstream_image_builder_invalid_name|✔|
|aws_appstream_stack_invalid_description|✔|
|aws_appstream_stack_invalid_display_name|✔|
|aws_appstream_stack_invalid_feedback_url|✔|
|aws_appstream_stack_invalid_redirect_url|✔|
|aws_appstream_user_invalid_authentication_type|✔|
|aws_appstream_user_invalid_first_name|✔|
|aws_appstream_user_invalid_last_name|✔|
|aws_appstream_user_invalid_user_name|✔|
|aws_appstream_user_stack_association_invalid_authentication_type|✔|
|aws_appstream_user_stack_association_invalid_user_name|✔|
|aws_appsync_datasource_invalid_name|✔|
|aws_appsync_datasource_invalid_type|✔|
|aws_appsync_function_invalid_data_source|✔|
Expand Down
67 changes: 67 additions & 0 deletions rules/models/aws_appstream_fleet_invalid_description.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"log"

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

// AwsAppstreamFleetInvalidDescriptionRule checks the pattern is valid
type AwsAppstreamFleetInvalidDescriptionRule struct {
resourceType string
attributeName string
max int
}

// NewAwsAppstreamFleetInvalidDescriptionRule returns new rule with default attributes
func NewAwsAppstreamFleetInvalidDescriptionRule() *AwsAppstreamFleetInvalidDescriptionRule {
return &AwsAppstreamFleetInvalidDescriptionRule{
resourceType: "aws_appstream_fleet",
attributeName: "description",
max: 256,
}
}

// Name returns the rule name
func (r *AwsAppstreamFleetInvalidDescriptionRule) Name() string {
return "aws_appstream_fleet_invalid_description"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsAppstreamFleetInvalidDescriptionRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsAppstreamFleetInvalidDescriptionRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsAppstreamFleetInvalidDescriptionRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsAppstreamFleetInvalidDescriptionRule) Check(runner tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule", r.Name())

return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
if len(val) > r.max {
runner.EmitIssueOnExpr(
r,
"description must be 256 characters or less",
attribute.Expr,
)
}
return nil
})
})
}
67 changes: 67 additions & 0 deletions rules/models/aws_appstream_fleet_invalid_display_name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"log"

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

// AwsAppstreamFleetInvalidDisplayNameRule checks the pattern is valid
type AwsAppstreamFleetInvalidDisplayNameRule struct {
resourceType string
attributeName string
max int
}

// NewAwsAppstreamFleetInvalidDisplayNameRule returns new rule with default attributes
func NewAwsAppstreamFleetInvalidDisplayNameRule() *AwsAppstreamFleetInvalidDisplayNameRule {
return &AwsAppstreamFleetInvalidDisplayNameRule{
resourceType: "aws_appstream_fleet",
attributeName: "display_name",
max: 100,
}
}

// Name returns the rule name
func (r *AwsAppstreamFleetInvalidDisplayNameRule) Name() string {
return "aws_appstream_fleet_invalid_display_name"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsAppstreamFleetInvalidDisplayNameRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsAppstreamFleetInvalidDisplayNameRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsAppstreamFleetInvalidDisplayNameRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsAppstreamFleetInvalidDisplayNameRule) Check(runner tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule", r.Name())

return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
if len(val) > r.max {
runner.EmitIssueOnExpr(
r,
"display_name must be 100 characters or less",
attribute.Expr,
)
}
return nil
})
})
}
78 changes: 78 additions & 0 deletions rules/models/aws_appstream_fleet_invalid_fleet_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"
"log"

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

// AwsAppstreamFleetInvalidFleetTypeRule checks the pattern is valid
type AwsAppstreamFleetInvalidFleetTypeRule struct {
resourceType string
attributeName string
enum []string
}

// NewAwsAppstreamFleetInvalidFleetTypeRule returns new rule with default attributes
func NewAwsAppstreamFleetInvalidFleetTypeRule() *AwsAppstreamFleetInvalidFleetTypeRule {
return &AwsAppstreamFleetInvalidFleetTypeRule{
resourceType: "aws_appstream_fleet",
attributeName: "fleet_type",
enum: []string{
"ALWAYS_ON",
"ON_DEMAND",
"ELASTIC",
},
}
}

// Name returns the rule name
func (r *AwsAppstreamFleetInvalidFleetTypeRule) Name() string {
return "aws_appstream_fleet_invalid_fleet_type"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsAppstreamFleetInvalidFleetTypeRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsAppstreamFleetInvalidFleetTypeRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsAppstreamFleetInvalidFleetTypeRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsAppstreamFleetInvalidFleetTypeRule) Check(runner tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule", r.Name())

return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssueOnExpr(
r,
fmt.Sprintf(`"%s" is an invalid value as fleet_type`, truncateLongMessage(val)),
attribute.Expr,
)
}
return nil
})
})
}
69 changes: 69 additions & 0 deletions rules/models/aws_appstream_fleet_invalid_name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"
"log"
"regexp"

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

// AwsAppstreamFleetInvalidNameRule checks the pattern is valid
type AwsAppstreamFleetInvalidNameRule struct {
resourceType string
attributeName string
pattern *regexp.Regexp
}

// NewAwsAppstreamFleetInvalidNameRule returns new rule with default attributes
func NewAwsAppstreamFleetInvalidNameRule() *AwsAppstreamFleetInvalidNameRule {
return &AwsAppstreamFleetInvalidNameRule{
resourceType: "aws_appstream_fleet",
attributeName: "name",
pattern: regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,100}$`),
}
}

// Name returns the rule name
func (r *AwsAppstreamFleetInvalidNameRule) Name() string {
return "aws_appstream_fleet_invalid_name"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsAppstreamFleetInvalidNameRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsAppstreamFleetInvalidNameRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsAppstreamFleetInvalidNameRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsAppstreamFleetInvalidNameRule) Check(runner tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule", r.Name())

return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
if !r.pattern.MatchString(val) {
runner.EmitIssueOnExpr(
r,
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,100}$`),
attribute.Expr,
)
}
return nil
})
})
}
77 changes: 77 additions & 0 deletions rules/models/aws_appstream_fleet_invalid_stream_view.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"
"log"

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

// AwsAppstreamFleetInvalidStreamViewRule checks the pattern is valid
type AwsAppstreamFleetInvalidStreamViewRule struct {
resourceType string
attributeName string
enum []string
}

// NewAwsAppstreamFleetInvalidStreamViewRule returns new rule with default attributes
func NewAwsAppstreamFleetInvalidStreamViewRule() *AwsAppstreamFleetInvalidStreamViewRule {
return &AwsAppstreamFleetInvalidStreamViewRule{
resourceType: "aws_appstream_fleet",
attributeName: "stream_view",
enum: []string{
"APP",
"DESKTOP",
},
}
}

// Name returns the rule name
func (r *AwsAppstreamFleetInvalidStreamViewRule) Name() string {
return "aws_appstream_fleet_invalid_stream_view"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsAppstreamFleetInvalidStreamViewRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsAppstreamFleetInvalidStreamViewRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsAppstreamFleetInvalidStreamViewRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsAppstreamFleetInvalidStreamViewRule) Check(runner tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule", r.Name())

return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssueOnExpr(
r,
fmt.Sprintf(`"%s" is an invalid value as stream_view`, truncateLongMessage(val)),
attribute.Expr,
)
}
return nil
})
})
}
Loading