// Validate force validates the acl's resource type, permission type and operation.
// It returns an error if the operation is not valid for the resource type.
Validate force validates the acl's resource type, permission type and operation.
It returns an error if the operation is not valid for the resource type.
// Validate force validates the acl ' s resource type permission type and operation . // It returns an error if the operation is not valid for the resource type .
func (acl *ACL) Validate() error {
	if string(acl.Operation) == "*" {
		acl.Operation = ACLOperationAll
	}
	acl.ResourceType = ACLResourceType(strings.ToTitle(string(acl.ResourceType)))
	acl.PermissionType = ACLPermissionType(strings.ToTitle(string(acl.PermissionType)))
	acl.Operation = ACLOperation(strings.ToTitle(string(acl.Operation)))
	acl.PatternType = strings.ToUpper(acl.PatternType)
	if !acl.Operation.isValidForResourceType(acl.ResourceType) {
		validOps := ACLOperations[acl.ResourceType]
		errMsg := ""
		if validOps == nil {
			errMsg = fmt.Sprintf("invalid resource type. Valid resource types are: [%s], [%s], [%s] or [%s]",
				ACLResourceTopic, ACLResourceGroup, ACLResourceCluster, ACLResourceTransactionalID)
		} else {
			errMsg = fmt.Sprintf("invalid operation for resource type: [%s]. The valid operations for this type are: [%s]", acl.ResourceType, validOps)
		}
		return fmt.Errorf(errMsg)
	}
	return nil
}
func ( acl * ACL ) Validate ( ) error { if string ( acl . Operation ) == " " { acl . Operation = ACLOperationAll } acl . ResourceType = ACLResourceType ( strings . ToTitle ( string ( acl . ResourceType ) ) ) acl . PermissionType = ACLPermissionType ( strings . ToTitle ( string ( acl . PermissionType ) ) ) acl . Operation = ACLOperation ( strings . ToTitle ( string ( acl . Operation ) ) ) acl . PatternType = strings . ToUpper ( acl . PatternType ) if ! acl . Operation . isValidForResourceType ( acl . ResourceType ) { validOps := ACLOperations [ acl . ResourceType ] errMsg := " " if validOps == nil { errMsg = fmt . Sprintf ( " " , ACLResourceTopic , ACLResourceGroup , ACLResourceCluster , ACLResourceTransactionalID ) } else { errMsg = fmt . Sprintf ( " " , acl . ResourceType , validOps ) } return fmt . Errorf ( errMsg ) } return nil }
Validate force validates the acl's resource type, permission type and operation.
Validate force validates the acl ' s resource type permission type and operation .
// upper the all the letters here on the resourceType, permissionType and operation before any action, // although kafka internally accepts both lowercase and uppercase. // No need to do any special handling, just pass it to Lenses