Skip to content

Commit

Permalink
add plan-time validation; format find file
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed Dec 2, 2021
1 parent 70bd8cb commit a0e46dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/service/codecommit/approval_rule_template_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package codecommit
import (
"fmt"
"log"
"regexp"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/codecommit"
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)
Expand All @@ -24,14 +26,19 @@ func ResourceApprovalRuleTemplateAssociation() *schema.Resource {

Schema: map[string]*schema.Schema{
"approval_rule_template_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringLenBetween(1, 100),
},
"repository_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.All(
validation.StringLenBetween(1, 100),
validation.StringMatch(regexp.MustCompile(`[\w\.-]+`), ""),
),
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions internal/service/codecommit/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package codecommit

import (
"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/codecommit"
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

// FindApprovalRuleTemplateAssociation validates that an approval rule template has the named associated repository
func FindApprovalRuleTemplateAssociation(conn *codecommit.CodeCommit, approvalRuleTemplateName, repositoryName string) error {
input := &codecommit.ListRepositoriesForApprovalRuleTemplateInput{
ApprovalRuleTemplateName: aws.String(approvalRuleTemplateName),
Expand Down

0 comments on commit a0e46dc

Please sign in to comment.