mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
replaced validator with strings package
This commit is contained in:
parent
74f38e9ba2
commit
1dadc0df64
1 changed files with 18 additions and 11 deletions
|
@ -13,7 +13,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/fxamacker/cbor/v2"
|
"github.com/fxamacker/cbor/v2"
|
||||||
"github.com/go-playground/validator/v10"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// // centralAuth
|
// // centralAuth
|
||||||
|
@ -37,7 +36,6 @@ type accessLists struct {
|
||||||
schemaMain *schemaMain
|
schemaMain *schemaMain
|
||||||
// Holds the generated based on the editable structures for ACL handling.
|
// Holds the generated based on the editable structures for ACL handling.
|
||||||
schemaGenerated *schemaGenerated
|
schemaGenerated *schemaGenerated
|
||||||
validator *validator.Validate
|
|
||||||
errorKernel *errorKernel
|
errorKernel *errorKernel
|
||||||
configuration *Configuration
|
configuration *Configuration
|
||||||
pki *pki
|
pki *pki
|
||||||
|
@ -47,7 +45,6 @@ func newAccessLists(pki *pki, errorKernel *errorKernel, configuration *Configura
|
||||||
a := accessLists{
|
a := accessLists{
|
||||||
schemaMain: newSchemaMain(configuration),
|
schemaMain: newSchemaMain(configuration),
|
||||||
schemaGenerated: newSchemaGenerated(),
|
schemaGenerated: newSchemaGenerated(),
|
||||||
validator: validator.New(),
|
|
||||||
errorKernel: errorKernel,
|
errorKernel: errorKernel,
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
pki: pki,
|
pki: pki,
|
||||||
|
@ -448,9 +445,14 @@ func (a *accessLists) nodeMapToSlice(host Node) sourceNode {
|
||||||
// groupNodesAddNode adds a node to a group. If the group does
|
// groupNodesAddNode adds a node to a group. If the group does
|
||||||
// not exist it will be created.
|
// not exist it will be created.
|
||||||
func (c *centralAuth) groupNodesAddNode(ng nodeGroup, n Node) {
|
func (c *centralAuth) groupNodesAddNode(ng nodeGroup, n Node) {
|
||||||
err := c.accessLists.validator.Var(ng, "startswith=grp_nodes_")
|
//err := c.accessLists.validator.Var(ng, "startswith=grp_nodes_")
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
log.Printf("error: group name do not start with grp_nodes_: %v\n", err)
|
// log.Printf("error: group name do not start with grp_nodes_: %v\n", err)
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
|
||||||
|
if !strings.HasPrefix(string(ng), "grp_nodes_") {
|
||||||
|
log.Printf("error: group name do not start with grp_nodes_\n")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +466,7 @@ func (c *centralAuth) groupNodesAddNode(ng nodeGroup, n Node) {
|
||||||
|
|
||||||
// fmt.Printf(" * groupNodesAddNode: After adding to group node looks like: %+v\n", a.schemaMain.NodeGroupMap)
|
// fmt.Printf(" * groupNodesAddNode: After adding to group node looks like: %+v\n", a.schemaMain.NodeGroupMap)
|
||||||
|
|
||||||
err = c.generateACLsForAllNodes()
|
err := c.generateACLsForAllNodes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
er := fmt.Errorf("error: groupNodesAddNode: %v", err)
|
er := fmt.Errorf("error: groupNodesAddNode: %v", err)
|
||||||
log.Printf("%v\n", er)
|
log.Printf("%v\n", er)
|
||||||
|
@ -519,9 +521,14 @@ func (c *centralAuth) groupNodesDeleteGroup(ng nodeGroup) {
|
||||||
// groupCommandsAddCommand adds a command to a group. If the group does
|
// groupCommandsAddCommand adds a command to a group. If the group does
|
||||||
// not exist it will be created.
|
// not exist it will be created.
|
||||||
func (c *centralAuth) groupCommandsAddCommand(cg commandGroup, cmd command) {
|
func (c *centralAuth) groupCommandsAddCommand(cg commandGroup, cmd command) {
|
||||||
err := c.accessLists.validator.Var(cg, "startswith=grp_commands_")
|
// err := c.accessLists.validator.Var(cg, "startswith=grp_commands_")
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Printf("error: group name do not start with grp_commands_ : %v\n", err)
|
// log.Printf("error: group name do not start with grp_commands_ : %v\n", err)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
if !strings.HasPrefix(string(cg), "grp_commands_") {
|
||||||
|
log.Printf("error: group name do not start with grp_commands_\n")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,7 +542,7 @@ func (c *centralAuth) groupCommandsAddCommand(cg commandGroup, cmd command) {
|
||||||
|
|
||||||
//fmt.Printf(" * groupCommandsAddCommand: After adding command=%v to command group=%v map looks like: %+v\n", c, cg, a.schemaMain.CommandGroupMap)
|
//fmt.Printf(" * groupCommandsAddCommand: After adding command=%v to command group=%v map looks like: %+v\n", c, cg, a.schemaMain.CommandGroupMap)
|
||||||
|
|
||||||
err = c.generateACLsForAllNodes()
|
err := c.generateACLsForAllNodes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
er := fmt.Errorf("error: groupCommandsAddCommand: %v", err)
|
er := fmt.Errorf("error: groupCommandsAddCommand: %v", err)
|
||||||
log.Printf("%v\n", er)
|
log.Printf("%v\n", er)
|
||||||
|
|
Loading…
Reference in a new issue