Skip to content

Commit

Permalink
Fix naming issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jjacobson93 committed Jul 31, 2023
1 parent 7b5077d commit 2a6a531
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions acl/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func IsValidNodeIdentityName(name string) bool {
return validNodeIdentityName.MatchString(name)
}

// IsValidPolicyName returns nil if the provided name can be used as an
// ValidatePolicyName returns nil if the provided name can be used as an
// ACLPolicy Name otherwise a useful error is returned.
func IsValidPolicyName(name string) error {
func ValidatePolicyName(name string) error {
if len(name) < 1 || len(name) > PolicyNameMaxLength {
return fmt.Errorf("Invalid Policy: invalid Name. Length must be greater than 0 and less than %d", PolicyNameMaxLength)
}
Expand Down
4 changes: 2 additions & 2 deletions acl/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
)

func Test_IsValidPolicyName(t *testing.T) {
func Test_ValidatePolicyName(t *testing.T) {
for _, tc := range []struct {
description string
name string
Expand Down Expand Up @@ -72,7 +72,7 @@ func Test_IsValidPolicyName(t *testing.T) {
},
} {
t.Run(tc.description, func(t *testing.T) {
require.Equal(t, tc.valid, IsValidPolicyName(tc.name) == nil)
require.Equal(t, tc.valid, ValidatePolicyName(tc.name) == nil)
})
}
}
2 changes: 1 addition & 1 deletion agent/consul/acl_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ func (a *ACL) PolicySet(args *structs.ACLPolicySetRequest, reply *structs.ACLPol
return fmt.Errorf("Invalid Policy: no Name is set")
}

if err := acl.IsValidPolicyName(policy.Name); err != nil {
if err := acl.ValidatePolicyName(policy.Name); err != nil {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions agent/consul/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func (s *Server) initializeACLs(ctx context.Context) error {

// Create/Upgrade the builtin policies
for _, policy := range structs.ACLBuiltinPolicies {
if err := s.initializePolicy(policy); err != nil {
if err := s.writeBuiltinACLPolicy(policy); err != nil {
return err
}
}
Expand Down Expand Up @@ -470,7 +470,7 @@ func (s *Server) initializeACLs(ctx context.Context) error {
}

// writeBuiltinACLPolicy writes the given built-in policy to Raft if the policy
// is not found or if the policy rules have been changed. The name and
// is not found or if the policy rules have been changed. The name and
// description of a built-in policy are user-editable and must be preserved
// during updates. This function must only be called in a primary datacenter.
func (s *Server) writeBuiltinACLPolicy(newPolicy structs.ACLPolicy) error {
Expand Down

0 comments on commit 2a6a531

Please sign in to comment.