mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-08 07:41:41 +08:00
for any service set defaults
This commit is contained in:
parent
effb7eb5d7
commit
f14d916936
2 changed files with 8 additions and 0 deletions
|
|
@ -207,6 +207,10 @@ func createAcl(w http.ResponseWriter, r *http.Request) {
|
|||
acl.CreatedBy = user.UserName
|
||||
acl.CreatedAt = time.Now().UTC()
|
||||
acl.Default = false
|
||||
if acl.ServiceType == models.Any {
|
||||
acl.Port = []string{}
|
||||
acl.Proto = models.ALL
|
||||
}
|
||||
// validate create acl policy
|
||||
if !logic.IsAclPolicyValid(acl) {
|
||||
logic.ReturnErrorResponse(w, r, logic.FormatError(errors.New("invalid policy"), "badrequest"))
|
||||
|
|
|
|||
|
|
@ -325,6 +325,10 @@ func UpdateAcl(newAcl, acl models.Acl) error {
|
|||
acl.Proto = newAcl.Proto
|
||||
acl.ServiceType = newAcl.ServiceType
|
||||
}
|
||||
if newAcl.ServiceType == models.Any {
|
||||
acl.Port = []string{}
|
||||
acl.Proto = models.ALL
|
||||
}
|
||||
acl.Enabled = newAcl.Enabled
|
||||
d, err := json.Marshal(acl)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue