@@ -22,7 +22,6 @@ import (
2222 "github.com/go-openapi/strfmt"
2323 parser "github.com/haproxytech/client-native/v6/config-parser"
2424 parser_errors "github.com/haproxytech/client-native/v6/config-parser/errors"
25- "github.com/haproxytech/client-native/v6/config-parser/types"
2625
2726 "github.com/haproxytech/client-native/v6/models"
2827)
@@ -85,9 +84,9 @@ func (c *client) GetACL(id int64, parentType, parentName string, transactionID s
8584 return v , nil , c .HandleError (strconv .FormatInt (id , 10 ), parentType , parentName , "" , false , err )
8685 }
8786
88- acl := ParseACL ( data .(types .ACL ) )
87+ acl := data .(models .ACL )
8988
90- return v , acl , nil
89+ return v , & acl , nil
9190}
9291
9392// DeleteACL deletes a ACL line in configuration. One of version or transactionID is
@@ -130,7 +129,7 @@ func (c *client) CreateACL(id int64, parentType string, parentName string, data
130129 return err
131130 }
132131
133- if err := p .Insert (section , parentName , "acl" , SerializeACL ( * data ) , int (id )); err != nil {
132+ if err := p .Insert (section , parentName , "acl" , * data , int (id )); err != nil {
134133 return c .HandleError (strconv .FormatInt (id , 10 ), parentType , parentName , t , transactionID == "" , err )
135134 }
136135
@@ -160,7 +159,7 @@ func (c *client) EditACL(id int64, parentType string, parentName string, data *m
160159 return c .HandleError (strconv .FormatInt (id , 10 ), parentType , parentName , t , transactionID == "" , err )
161160 }
162161
163- if err := p .Set (section , parentName , "acl" , SerializeACL ( * data ) , int (id )); err != nil {
162+ if err := p .Set (section , parentName , "acl" , * data , int (id )); err != nil {
164163 return c .HandleError (strconv .FormatInt (id , 10 ), parentType , parentName , t , transactionID == "" , err )
165164 }
166165
@@ -200,7 +199,7 @@ func (c *client) ReplaceAcls(parentType string, parentName string, data models.A
200199 }
201200
202201 for i , newACL := range data {
203- if err := p .Insert (section , parentName , "acl" , SerializeACL ( * newACL ) , i ); err != nil {
202+ if err := p .Insert (section , parentName , "acl" , * newACL , i ); err != nil {
204203 return c .HandleError (strconv .FormatInt (int64 (i ), 10 ), parentType , parentName , t , transactionID == "" , err )
205204 }
206205 }
@@ -218,42 +217,17 @@ func ParseACLs(section parser.Section, name string, p parser.Parser, aclName ...
218217 return nil , err
219218 }
220219
221- aclLines , ok := data .([]types .ACL )
220+ aclLines , ok := data .([]models .ACL )
222221 if ! ok {
223222 return nil , errors .New ("type assert error []types.ACL" )
224223 }
225224 lACL := len (aclName )
226- for _ , r := range aclLines {
227- acl := ParseACL (r )
228- if acl != nil {
229- if lACL > 0 && aclName [0 ] == acl .ACLName {
230- acls = append (acls , acl )
231- } else if lACL == 0 {
232- acls = append (acls , acl )
233- }
225+ for _ , acl := range aclLines {
226+ if lACL > 0 && aclName [0 ] == acl .ACLName {
227+ acls = append (acls , & acl )
228+ } else if lACL == 0 {
229+ acls = append (acls , & acl )
234230 }
235231 }
236232 return acls , nil
237233}
238-
239- func ParseACL (f types.ACL ) * models.ACL {
240- return & models.ACL {
241- ACLName : f .Name ,
242- Criterion : f .Criterion ,
243- Value : f .Value ,
244- Metadata : parseMetadata (f .Comment ),
245- }
246- }
247-
248- func SerializeACL (f models.ACL ) types.ACL {
249- comment , err := serializeMetadata (f .Metadata )
250- if err != nil {
251- comment = ""
252- }
253- return types.ACL {
254- Name : f .ACLName ,
255- Criterion : f .Criterion ,
256- Value : f .Value ,
257- Comment : comment ,
258- }
259- }
0 commit comments