Skip to content

Commit

Permalink
Pluralizing all list variables; changing address group's Static to …
Browse files Browse the repository at this point in the history
…`StaticAddresses`; changing address group's `Dynamic` to `DynamicMatch`
  • Loading branch information
shinmog committed Jan 14, 2018
1 parent ed9273d commit 394307d
Show file tree
Hide file tree
Showing 16 changed files with 214 additions and 214 deletions.
10 changes: 5 additions & 5 deletions netw/mngtprof/mngtprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Entry struct {
UseridService bool
UseridSyslogListenerSsl bool
UseridSyslogListenerUdp bool
PermittedIp []string
PermittedIps []string
}

// Copy copies the information from source Entry `s` to this object. As the
Expand All @@ -43,7 +43,7 @@ func (o *Entry) Copy(s Entry) {
o.UseridService = s.UseridService
o.UseridSyslogListenerSsl = s.UseridSyslogListenerSsl
o.UseridSyslogListenerUdp = s.UseridSyslogListenerUdp
o.PermittedIp = s.PermittedIp
o.PermittedIps = s.PermittedIps
}

// MngtProf is a namespace struct, included as part of pango.Client.
Expand Down Expand Up @@ -214,7 +214,7 @@ func (o *container_v1) Normalize() Entry {
UseridService: util.AsBool(o.Answer.UseridService),
UseridSyslogListenerSsl: util.AsBool(o.Answer.UseridSyslogListenerSsl),
UseridSyslogListenerUdp: util.AsBool(o.Answer.UseridSyslogListenerUdp),
PermittedIp: util.EntToStr(o.Answer.PermittedIp),
PermittedIps: util.EntToStr(o.Answer.PermittedIps),
}

return ans
Expand All @@ -234,7 +234,7 @@ type entry_v1 struct {
UseridService string `xml:"userid-service"`
UseridSyslogListenerSsl string `xml:"userid-syslog-listener-ssl"`
UseridSyslogListenerUdp string `xml:"userid-syslog-listener-udp"`
PermittedIp *util.Entry `xml:"permitted-ip"`
PermittedIps *util.Entry `xml:"permitted-ip"`
}

func specify_v1(e Entry) interface{} {
Expand All @@ -251,7 +251,7 @@ func specify_v1(e Entry) interface{} {
UseridService: util.YesNo(e.UseridService),
UseridSyslogListenerSsl: util.YesNo(e.UseridSyslogListenerSsl),
UseridSyslogListenerUdp: util.YesNo(e.UseridSyslogListenerUdp),
PermittedIp: util.StrToEnt(e.PermittedIp),
PermittedIps: util.StrToEnt(e.PermittedIps),
}

return ans
Expand Down
2 changes: 1 addition & 1 deletion netw/mngtprof/mngtprof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestNormalization(t *testing.T) {
{"test3", Entry{
Name: "test3",
Ping: true,
PermittedIp: []string{"10.1.1.1", "10.2.2.2"},
PermittedIps: []string{"10.1.1.1", "10.2.2.2"},
}},
}

Expand Down
32 changes: 16 additions & 16 deletions netw/zone/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type Entry struct {
ZoneProfile string
LogSetting string
EnableUserId bool
IncludeAcl []string
ExcludeAcl []string
IncludeAcls []string
ExcludeAcls []string
}

// Copy copies the information from source Entry `s` to this object. As the
Expand All @@ -31,8 +31,8 @@ func (o *Entry) Copy(s Entry) {
o.ZoneProfile = s.ZoneProfile
o.LogSetting = s.LogSetting
o.EnableUserId = s.EnableUserId
o.IncludeAcl = s.IncludeAcl
o.ExcludeAcl = s.ExcludeAcl
o.IncludeAcls = s.IncludeAcls
o.ExcludeAcls = s.ExcludeAcls
}

// Zone is a namespace struct, included as part of pango.Client.
Expand Down Expand Up @@ -214,11 +214,11 @@ func (o *container_v1) Normalize() Entry {
ans.Mode = "external"
ans.Interfaces = o.Answer.External.Interfaces
}
if o.Answer.IncludeAcl != nil {
ans.IncludeAcl = o.Answer.IncludeAcl.Acls
if o.Answer.IncludeAcls != nil {
ans.IncludeAcls = o.Answer.IncludeAcls.Acls
}
if o.Answer.ExcludeAcl != nil {
ans.ExcludeAcl = o.Answer.ExcludeAcl.Acls
if o.Answer.ExcludeAcls != nil {
ans.ExcludeAcls = o.Answer.ExcludeAcls.Acls
}

return ans
Expand All @@ -235,8 +235,8 @@ type entry_v1 struct {
Profile string `xml:"network>zone-protection-profile,omitempty"`
LogSetting string `xml:"network>log-setting,omitempty"`
EnableUserId string `xml:"enable-user-identification"`
IncludeAcl *aclList `xml:"user-acl>include-list"`
ExcludeAcl *aclList `xml:"user-acl>exclude-list"`
IncludeAcls *aclList `xml:"user-acl>include-list"`
ExcludeAcls *aclList `xml:"user-acl>exclude-list"`
}

type zoneInterfaceList struct {
Expand Down Expand Up @@ -267,13 +267,13 @@ func specify_v1(e Entry) interface{} {
case "external":
ans.External = il
}
if len(e.IncludeAcl) > 0 {
inu := &aclList{e.IncludeAcl}
ans.IncludeAcl = inu
if len(e.IncludeAcls) > 0 {
inu := &aclList{e.IncludeAcls}
ans.IncludeAcls = inu
}
if len(e.ExcludeAcl) > 0 {
exu := &aclList{e.ExcludeAcl}
ans.ExcludeAcl = exu
if len(e.ExcludeAcls) > 0 {
exu := &aclList{e.ExcludeAcls}
ans.ExcludeAcls = exu
}

return ans
Expand Down
8 changes: 4 additions & 4 deletions netw/zone/zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ func TestNormalization(t *testing.T) {
Interfaces: []string{"ethernet1/1", "ethernet1/2"},
ZoneProfile: "profile1",
LogSetting: "setting1",
IncludeAcl: []string{"10.1.2.0/24"},
IncludeAcls: []string{"10.1.2.0/24"},
}},
{"layer2 zone", "vsys2", Entry{
Name: "three",
Mode: "layer2",
Interfaces: []string{"ethernet1/3", "ethernet1/4"},
ExcludeAcl: []string{"10.100.1.0/24"},
ExcludeAcls: []string{"10.100.1.0/24"},
}},
{"vwire zone", "vsys3", Entry{
Name: "four",
Mode: "virtual-wire",
Interfaces: []string{"ethernet1/5", "ethernet1/6"},
IncludeAcl: []string{"10.1.3.0/24"},
IncludeAcls: []string{"10.1.3.0/24"},
}},
{"tap zone", "vsys4", Entry{
Name: "five",
Mode: "external",
Interfaces: []string{"ethernet1/7", "ethernet1/8"},
ExcludeAcl: []string{"10.100.2.0/24"},
ExcludeAcls: []string{"10.100.2.0/24"},
}},
}

Expand Down
10 changes: 5 additions & 5 deletions objs/addr/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Entry struct {
Value string
Type string
Description string
Tag []string
Tags []string
}

// Copy copies the information from source Entry `s` to this object. As the
Expand All @@ -33,7 +33,7 @@ func (o *Entry) Copy(s Entry) {
o.Value = s.Value
o.Type = s.Type
o.Description = s.Description
o.Tag = s.Tag
o.Tags = s.Tags
}

// Addr is a namespace struct, included as part of pango.Client.
Expand Down Expand Up @@ -196,7 +196,7 @@ func (o *container_v1) Normalize() Entry {
ans := Entry{
Name: o.Answer.Name,
Description: o.Answer.Description,
Tag: util.MemToStr(o.Answer.Tag),
Tags: util.MemToStr(o.Answer.Tags),
}
switch {
case o.Answer.IpNetmask != nil:
Expand All @@ -220,7 +220,7 @@ type entry_v1 struct {
IpRange *valType `xml:"ip-range"`
Fqdn *valType `xml:"fqdn"`
Description string `xml:"description"`
Tag *util.Member `xml:"tag"`
Tags *util.Member `xml:"tag"`
}

type valType struct {
Expand All @@ -231,7 +231,7 @@ func specify_v1(e Entry) interface{} {
ans := entry_v1{
Name: e.Name,
Description: e.Description,
Tag: util.StrToMem(e.Tag),
Tags: util.StrToMem(e.Tags),
}
vt := &valType{e.Value}
switch e.Type {
Expand Down
4 changes: 2 additions & 2 deletions objs/addr/addr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ func TestNormalization(t *testing.T) {
Value: "10.1.1.0/24",
Type: IpNetmask,
Description: "my description",
Tag: []string{"tag1", "tag2"},
Tags: []string{"tag1", "tag2"},
}},
{"test ip range", "vsys2", Entry{
Name: "two",
Value: "10.1.1.1-10.1.1.254",
Type: IpRange,
Description: "my description",
Tag: []string{"tag3", "tag4"},
Tags: []string{"tag3", "tag4"},
}},
{"test fqdn", "vsys3", Entry{
Name: "three",
Expand Down
38 changes: 19 additions & 19 deletions objs/addrgrp/addrgrp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ import (


// Entry is a normalized, version independent representation of an address
// group. The value set in Dynamic should be something like the following:
// group. The value set in DynamicMatch should be something like the following:
//
// * 'tag1'
// * 'tag1' or 'tag2' and 'tag3'
//
// The tags param is for administrative tags for this address object
// The Tags param is for administrative tags for this address object
// group itself.
type Entry struct {
Name string
Description string
Static []string
Dynamic string
Tag []string
StaticAddresses []string
DynamicMatch string
Tags []string
}

// Copy copies the information from source Entry `s` to this object. As the
// Name field relates to the XPATH of this object, this field is not copied.
func (o *Entry) Copy(s Entry) {
o.Description = s.Description
o.Static = s.Static
o.Dynamic = s.Dynamic
o.Tag = s.Tag
o.StaticAddresses = s.StaticAddresses
o.DynamicMatch = s.DynamicMatch
o.Tags = s.Tags
}

// AddrGrp is a namespace struct, included as part of pango.Client.
Expand Down Expand Up @@ -196,11 +196,11 @@ func (o *container_v1) Normalize() Entry {
ans := Entry{
Name: o.Answer.Name,
Description: o.Answer.Description,
Static: util.MemToStr(o.Answer.Static),
Tag: util.MemToStr(o.Answer.Tag),
StaticAddresses: util.MemToStr(o.Answer.StaticAddresses),
Tags: util.MemToStr(o.Answer.Tags),
}
if o.Answer.Dynamic != nil {
ans.Dynamic = *o.Answer.Dynamic
if o.Answer.DynamicMatch != nil {
ans.DynamicMatch = *o.Answer.DynamicMatch
}

return ans
Expand All @@ -210,20 +210,20 @@ type entry_v1 struct {
XMLName xml.Name `xml:"entry"`
Name string `xml:"name,attr"`
Description string `xml:"description"`
Static *util.Member `xml:"static"`
Dynamic *string `xml:"dynamic>filter"`
Tag *util.Member `xml:"tag"`
StaticAddresses *util.Member `xml:"static"`
DynamicMatch *string `xml:"dynamic>filter"`
Tags *util.Member `xml:"tag"`
}

func specify_v1(e Entry) interface{} {
ans := entry_v1{
Name: e.Name,
Description: e.Description,
Static: util.StrToMem(e.Static),
Tag: util.StrToMem(e.Tag),
StaticAddresses: util.StrToMem(e.StaticAddresses),
Tags: util.StrToMem(e.Tags),
}
if e.Dynamic != "" {
ans.Dynamic = &e.Dynamic
if e.DynamicMatch != "" {
ans.DynamicMatch = &e.DynamicMatch
}

return ans
Expand Down
12 changes: 6 additions & 6 deletions objs/addrgrp/addrgrp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ func TestNormalization(t *testing.T) {
{"test static no tags", "", Entry{
Name: "one",
Description: "my description",
Static: []string{"adr1", "adr2"},
StaticAddresses: []string{"adr1", "adr2"},
}},
{"test static with tags", "", Entry{
Name: "one",
Description: "my description",
Static: []string{"adr1", "adr2"},
Tag: []string{"tag1", "tag2"},
StaticAddresses: []string{"adr1", "adr2"},
Tags: []string{"tag1", "tag2"},
}},
{"test dynamic no tags", "", Entry{
Name: "one",
Description: "my description",
Dynamic: "'tag1' or 'tag2' and 'tag3'",
DynamicMatch: "'tag1' or 'tag2' and 'tag3'",
}},
{"test dynamic with tags", "", Entry{
Name: "one",
Description: "my description",
Dynamic: "'tag1' or 'tag2' and 'tag3'",
Tag: []string{"tag1", "tag2"},
DynamicMatch: "'tag1' or 'tag2' and 'tag3'",
Tags: []string{"tag1", "tag2"},
}},
}

Expand Down
10 changes: 5 additions & 5 deletions objs/srvc/srvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Entry struct {
Protocol string
SourcePort string
DestinationPort string
Tag []string
Tags []string
}

// Copy copies the information from source Entry `s` to this object. As the
Expand All @@ -31,7 +31,7 @@ func (o *Entry) Copy(s Entry) {
o.Protocol = s.Protocol
o.SourcePort = s.SourcePort
o.DestinationPort = s.DestinationPort
o.Tag = s.Tag
o.Tags = s.Tags
}

// Srvc is a namespace struct, included as part of pango.Client.
Expand Down Expand Up @@ -194,7 +194,7 @@ func (o *container_v1) Normalize() Entry {
ans := Entry{
Name: o.Answer.Name,
Description: o.Answer.Description,
Tag: util.MemToStr(o.Answer.Tag),
Tags: util.MemToStr(o.Answer.Tags),
}
switch {
case o.Answer.TcpProto != nil:
Expand All @@ -216,7 +216,7 @@ type entry_v1 struct {
TcpProto *protoDef `xml:"protocol>tcp"`
UdpProto *protoDef `xml:"protocol>udp"`
Description string `xml:"description"`
Tag *util.Member `xml:"tag"`
Tags *util.Member `xml:"tag"`
}

type protoDef struct {
Expand All @@ -228,7 +228,7 @@ func specify_v1(e Entry) interface{} {
ans := entry_v1{
Name: e.Name,
Description: e.Description,
Tag: util.StrToMem(e.Tag),
Tags: util.StrToMem(e.Tags),
}
switch e.Protocol {
case "tcp":
Expand Down
Loading

0 comments on commit 394307d

Please sign in to comment.