func SecurityGroupRulesFromProto(rules []*SecurityGroupRule) []oldmodels.SecurityGroupRule { oldrules := make([]oldmodels.SecurityGroupRule, 0, len(rules)) for _, r := range rules { var portRange *oldmodels.PortRange var icmpInfo *oldmodels.ICMPInfo if r.PortRange != nil { portRange = &oldmodels.PortRange{Start: uint16(r.PortRange.Start), End: uint16(r.PortRange.End)} } if r.IcmpInfo != nil { icmpInfo = &oldmodels.ICMPInfo{Type: r.IcmpInfo.Type, Code: r.IcmpInfo.Code} } oldrules = append(oldrules, oldmodels.SecurityGroupRule{ Protocol: oldmodels.ProtocolName(r.Protocol), Destinations: r.Destinations, Ports: convertPortsFromProto(r.Ports), PortRange: portRange, IcmpInfo: icmpInfo, Log: r.Log, }) } return oldrules }
log bool ) BeforeEach(func() { protocol = "tcp" destination = "8.8.8.8/16" ports = nil portRange = nil icmpInfo = nil log = false }) JustBeforeEach(func() { rule = models.SecurityGroupRule{ Protocol: models.ProtocolName(protocol), Destinations: []string{destination}, Ports: ports, PortRange: portRange, IcmpInfo: icmpInfo, Log: log, } validationErr = rule.Validate() }) itAllowsPorts := func() { Describe("ports", func() { Context("with a valid port", func() { BeforeEach(func() { portRange = nil