Documentation
¶
Overview ¶
Package utils contains utility functions
Package utils contails useful helper functions ¶
Package utils contains utility functions ¶
Package utils has some utility functions and interfaces ¶
Package utils has some utility functions and interfaces ¶
Package utils has some utility functions and interfaces ¶
Package utils contains utility functions ¶
Package utils contails useful helper functions
Index ¶
- func EqualProtoSlices[T proto.Message](x, y []T) bool
- func ExtractPagination(pageSize int32, pageToken string, pagination map[string]int) (size int, offset int, err error)
- func InitTracerProvider(service string) *sdktrace.TracerProvider
- func InterceptorLogger(l *log.Logger) logging.Logger
- func LimitPagination[T any](result []T, offset int, size int) ([]T, bool)
- func ProtoClone[T proto.Message](protoStruct T) T
- func SetupTLSCredentials(config TLSConfig) (grpc.ServerOption, error)
- type Frr
- type FrrWrapper
- func (n *FrrWrapper) EnterPrivileged(conn *telnet.Conn) error
- func (n *FrrWrapper) ExitPrivileged(conn *telnet.Conn) error
- func (n *FrrWrapper) FrrBgpCmd(ctx context.Context, command string) (string, error)
- func (n *FrrWrapper) FrrZebraCmd(ctx context.Context, command string) (string, error)
- func (n *FrrWrapper) MultiLineCmd(conn *telnet.Conn, command string) (string, error)
- func (n *FrrWrapper) Password(conn *telnet.Conn, delim string) error
- func (n *FrrWrapper) TelnetDialAndCommunicate(ctx context.Context, command string, port int) (string, error)
- type Netlink
- type NetlinkWrapper
- func (n *NetlinkWrapper) AddrAdd(ctx context.Context, link netlink.Link, addr *netlink.Addr) error
- func (n *NetlinkWrapper) AddrDel(ctx context.Context, link netlink.Link, addr *netlink.Addr) error
- func (n *NetlinkWrapper) BridgeVlanAdd(ctx context.Context, link netlink.Link, vid uint16, ...) error
- func (n *NetlinkWrapper) BridgeVlanDel(ctx context.Context, link netlink.Link, vid uint16, ...) error
- func (n *NetlinkWrapper) LinkAdd(ctx context.Context, link netlink.Link) error
- func (n *NetlinkWrapper) LinkByName(ctx context.Context, name string) (netlink.Link, error)
- func (n *NetlinkWrapper) LinkDel(ctx context.Context, link netlink.Link) error
- func (n *NetlinkWrapper) LinkModify(ctx context.Context, link netlink.Link) error
- func (n *NetlinkWrapper) LinkSetDown(ctx context.Context, link netlink.Link) error
- func (n *NetlinkWrapper) LinkSetHardwareAddr(ctx context.Context, link netlink.Link, hwaddr net.HardwareAddr) error
- func (n *NetlinkWrapper) LinkSetMaster(ctx context.Context, link, master netlink.Link) error
- func (n *NetlinkWrapper) LinkSetNoMaster(ctx context.Context, link netlink.Link) error
- func (n *NetlinkWrapper) LinkSetUp(ctx context.Context, link netlink.Link) error
- type ProtoCodec
- type TLSConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualProtoSlices ¶ added in v0.2.0
EqualProtoSlices is a helper function to compare protobuf slices
func ExtractPagination ¶ added in v0.2.0
func ExtractPagination(pageSize int32, pageToken string, pagination map[string]int) (size int, offset int, err error)
ExtractPagination fetches pagination from the database, calculate size and offset
func InitTracerProvider ¶ added in v0.2.0
func InitTracerProvider(service string) *sdktrace.TracerProvider
InitTracerProvider returns an OpenTelemetry TracerProvider configured to use the OTLP exporter that will send spans to OTEL_EXPORTER_OTLP_ENDPOINT url. The returned // TracerProvider will also use a Resource configured with all the information about the application.
func InterceptorLogger ¶ added in v0.2.0
InterceptorLogger creates logger for interceptors based on default Go logger
func LimitPagination ¶ added in v0.2.0
LimitPagination returns subset of the slice per gived size and offset
func ProtoClone ¶ added in v0.2.0
ProtoClone is a helper function to clone and cast protobufs
func SetupTLSCredentials ¶ added in v0.2.0
func SetupTLSCredentials(config TLSConfig) (grpc.ServerOption, error)
SetupTLSCredentials returns a service options to enable TLS for gRPC server
Types ¶
type Frr ¶ added in v0.2.0
type Frr interface { TelnetDialAndCommunicate(ctx context.Context, command string, port int) (string, error) FrrZebraCmd(ctx context.Context, command string) (string, error) FrrBgpCmd(ctx context.Context, command string) (string, error) Password(conn *telnet.Conn, delim string) error EnterPrivileged(conn *telnet.Conn) error ExitPrivileged(conn *telnet.Conn) error }
Frr represents limited subset of functions from Frr package
type FrrWrapper ¶ added in v0.2.0
type FrrWrapper struct {
// contains filtered or unexported fields
}
FrrWrapper wrapper for Frr package
func NewFrrWrapper ¶ added in v0.2.0
func NewFrrWrapper() *FrrWrapper
NewFrrWrapper creates initialized instance of FrrWrapper with default address
func NewFrrWrapperWithArgs ¶ added in v0.2.0
func NewFrrWrapperWithArgs(address string) *FrrWrapper
NewFrrWrapperWithArgs creates initialized instance of FrrWrapper
func (*FrrWrapper) EnterPrivileged ¶ added in v0.2.0
func (n *FrrWrapper) EnterPrivileged(conn *telnet.Conn) error
EnterPrivileged turns on privileged mode command
func (*FrrWrapper) ExitPrivileged ¶ added in v0.2.0
func (n *FrrWrapper) ExitPrivileged(conn *telnet.Conn) error
ExitPrivileged turns off privileged mode command
func (*FrrWrapper) FrrBgpCmd ¶ added in v0.2.0
FrrBgpCmd connects to Bgp telnet with password and runs command
func (*FrrWrapper) FrrZebraCmd ¶ added in v0.2.0
FrrZebraCmd connects to Zebra telnet with password and runs command
func (*FrrWrapper) MultiLineCmd ¶ added in v0.2.0
MultiLineCmd breaks command by lines, sends each and waits for output and returns combined output
func (*FrrWrapper) Password ¶ added in v0.2.0
func (n *FrrWrapper) Password(conn *telnet.Conn, delim string) error
Password handles password sending
func (*FrrWrapper) TelnetDialAndCommunicate ¶ added in v0.2.0
func (n *FrrWrapper) TelnetDialAndCommunicate(ctx context.Context, command string, port int) (string, error)
TelnetDialAndCommunicate connects to telnet with password and runs command
type Netlink ¶
type Netlink interface { LinkByName(context.Context, string) (netlink.Link, error) LinkModify(context.Context, netlink.Link) error LinkSetHardwareAddr(context.Context, netlink.Link, net.HardwareAddr) error AddrAdd(context.Context, netlink.Link, *netlink.Addr) error AddrDel(context.Context, netlink.Link, *netlink.Addr) error LinkAdd(context.Context, netlink.Link) error LinkDel(context.Context, netlink.Link) error LinkSetUp(context.Context, netlink.Link) error LinkSetDown(context.Context, netlink.Link) error LinkSetMaster(context.Context, netlink.Link, netlink.Link) error LinkSetNoMaster(context.Context, netlink.Link) error BridgeVlanAdd(context.Context, netlink.Link, uint16, bool, bool, bool, bool) error BridgeVlanDel(context.Context, netlink.Link, uint16, bool, bool, bool, bool) error }
Netlink represents limited subset of functions from netlink package
type NetlinkWrapper ¶
type NetlinkWrapper struct {
// contains filtered or unexported fields
}
NetlinkWrapper wrapper for netlink package
func NewNetlinkWrapper ¶ added in v0.2.0
func NewNetlinkWrapper() *NetlinkWrapper
NewNetlinkWrapper creates initialized instance of NetlinkWrapper
func (*NetlinkWrapper) BridgeVlanAdd ¶
func (n *NetlinkWrapper) BridgeVlanAdd(ctx context.Context, link netlink.Link, vid uint16, pvid, untagged, self, master bool) error
BridgeVlanAdd is a wrapper for netlink.BridgeVlanAdd
func (*NetlinkWrapper) BridgeVlanDel ¶
func (n *NetlinkWrapper) BridgeVlanDel(ctx context.Context, link netlink.Link, vid uint16, pvid, untagged, self, master bool) error
BridgeVlanDel is a wrapper for netlink.BridgeVlanDel
func (*NetlinkWrapper) LinkByName ¶
LinkByName is a wrapper for netlink.LinkByName
func (*NetlinkWrapper) LinkModify ¶
LinkModify is a wrapper for netlink.LinkModify
func (*NetlinkWrapper) LinkSetDown ¶
LinkSetDown is a wrapper for netlink.LinkSetDown
func (*NetlinkWrapper) LinkSetHardwareAddr ¶
func (n *NetlinkWrapper) LinkSetHardwareAddr(ctx context.Context, link netlink.Link, hwaddr net.HardwareAddr) error
LinkSetHardwareAddr is a wrapper for netlink.LinkSetHardwareAddr
func (*NetlinkWrapper) LinkSetMaster ¶
LinkSetMaster is a wrapper for netlink.LinkSetMaster
func (*NetlinkWrapper) LinkSetNoMaster ¶
LinkSetNoMaster is a wrapper for netlink.LinkSetNoMaster
type ProtoCodec ¶ added in v0.2.0
type ProtoCodec struct{}
ProtoCodec encodes/decodes Go values to/from PROTOBUF.
func (ProtoCodec) Marshal ¶ added in v0.2.0
func (c ProtoCodec) Marshal(v interface{}) ([]byte, error)
Marshal encodes a Go value to PROTOBUF.
func (ProtoCodec) Unmarshal ¶ added in v0.2.0
func (c ProtoCodec) Unmarshal(data []byte, v interface{}) error
Unmarshal decodes a PROTOBUF value into a Go value.
type TLSConfig ¶ added in v0.2.0
TLSConfig contains information required to enable TLS for gRPC server.
func ParseTLSFiles ¶ added in v0.2.0
ParseTLSFiles parses a string containing server certificate, server key and CA certificate separated by `:`