Skip to content

Commit

Permalink
renamed raw link types
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Jul 19, 2023
1 parent b8e4ecd commit 06e7e25
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 64 deletions.
File renamed without changes.
20 changes: 10 additions & 10 deletions types/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,53 +95,53 @@ func (r *LinkDefinition) UnmarshalYAML(unmarshal func(interface{}) error) error
// the Type field is injected artificially
// to allow strict yaml parsing to work.
Type string `yaml:"type"`
RawVEthLink `yaml:",inline"`
LinkVEthRaw `yaml:",inline"`
}
err := unmarshal(&l)
if err != nil {
return err
}
r.LinkConfig = *l.RawVEthLink.ToLinkConfig()
r.LinkConfig = *l.LinkVEthRaw.ToLinkConfig()
case LinkTypeMgmtNet:
var l struct {
Type string `yaml:"type"`
RawMgmtNetLink `yaml:",inline"`
LinkMgmtNetRaw `yaml:",inline"`
}
err := unmarshal(&l)
if err != nil {
return err
}
r.LinkConfig = *l.RawMgmtNetLink.ToLinkConfig()
r.LinkConfig = *l.LinkMgmtNetRaw.ToLinkConfig()
case LinkTypeHost:
var l struct {
Type string `yaml:"type"`
RawHostLink `yaml:",inline"`
LinkHostRaw `yaml:",inline"`
}
err := unmarshal(&l)
if err != nil {
return err
}
r.LinkConfig = *l.RawHostLink.ToLinkConfig()
r.LinkConfig = *l.LinkHostRaw.ToLinkConfig()
case LinkTypeMacVLan:
var l struct {
Type string `yaml:"type"`
RawMacVLanLink `yaml:",inline"`
LinkMACVLANRaw `yaml:",inline"`
}
err := unmarshal(&l)
if err != nil {
return err
}
r.LinkConfig = *l.RawMacVLanLink.ToLinkConfig()
r.LinkConfig = *l.LinkMACVLANRaw.ToLinkConfig()
case LinkTypeMacVTap:
var l struct {
Type string `yaml:"type"`
RawMacVTapLink `yaml:",inline"`
LinkMACVTAPRaw `yaml:",inline"`
}
err := unmarshal(&l)
if err != nil {
return err
}
r.LinkConfig = *l.RawMacVTapLink.ToLinkConfig()
r.LinkConfig = *l.LinkMACVTAPRaw.ToLinkConfig()
case LinkTypeBrief:
// brief link's endpoint format
var l struct {
Expand Down
23 changes: 4 additions & 19 deletions types/link_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package types

import "fmt"

type RawHostLink struct {
// LinkHostRaw is the raw (string) representation of a host link as defined in the topology file.
type LinkHostRaw struct {
LinkCommonParams `yaml:",inline"`
HostInterface string `yaml:"host-interface"`
Endpoint *EndpointRaw `yaml:"endpoint"`
}

func (r *RawHostLink) ToLinkConfig() *LinkConfig {
// ToLinkConfig converts the raw link into a LinkConfig.
func (r *LinkHostRaw) ToLinkConfig() *LinkConfig {
lc := &LinkConfig{
Vars: r.Vars,
Labels: r.Labels,
Expand All @@ -21,20 +23,3 @@ func (r *RawHostLink) ToLinkConfig() *LinkConfig {

return lc
}

// func hostFromLinkConfig(lc *LinkConfig, specialEPIndex int) (*RawHostLink, error) {
// _, hostIf, node, nodeIf := extractHostNodeInterfaceData(lc, specialEPIndex)

// result := &RawHostLink{
// RawLinkType: RawLinkType{
// Type: string(LinkTypeHost),
// Labels: lc.Labels,
// Vars: lc.Vars,
// Instance: nil,
// },
// HostInterface: hostIf,
// Node: node,
// NodeInterface: nodeIf,
// }
// return result, nil
// }
7 changes: 0 additions & 7 deletions types/link_mac.go

This file was deleted.

10 changes: 7 additions & 3 deletions types/link_macvlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ package types

import "fmt"

type RawMacVLanLink struct {
rawMacVXType `yaml:",inline"`
// LinkMACVLANRaw is the raw (string) representation of a macvlan link as defined in the topology file.
type LinkMACVLANRaw struct {
LinkCommonParams `yaml:",inline"`
HostInterface string `yaml:"host-interface"`
Endpoint *EndpointRaw `yaml:"endpoint"`
}

func (r *RawMacVLanLink) ToLinkConfig() *LinkConfig {
// ToLinkConfig converts the raw link into a LinkConfig.
func (r *LinkMACVLANRaw) ToLinkConfig() *LinkConfig {
lc := &LinkConfig{
Vars: r.Vars,
Labels: r.Labels,
Expand Down
10 changes: 7 additions & 3 deletions types/link_macvtap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ package types

import "fmt"

type RawMacVTapLink struct {
rawMacVXType `yaml:",inline"`
// LinkMACVTAPRaw is the raw (string) representation of a macvtap link as defined in the topology file.
type LinkMACVTAPRaw struct {
LinkCommonParams `yaml:",inline"`
HostInterface string `yaml:"host-interface"`
Endpoint *EndpointRaw `yaml:"endpoint"`
}

func (r *RawMacVTapLink) ToLinkConfig() *LinkConfig {
// ToLinkConfig converts the raw link into a LinkConfig.
func (r *LinkMACVTAPRaw) ToLinkConfig() *LinkConfig {
lc := &LinkConfig{
Vars: r.Vars,
Labels: r.Labels,
Expand Down
19 changes: 2 additions & 17 deletions types/link_mgmt-net.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package types

import "fmt"

type RawMgmtNetLink struct {
type LinkMgmtNetRaw struct {
LinkCommonParams `yaml:",inline"`
HostInterface string `yaml:"host-interface"`
Endpoint *EndpointRaw `yaml:"endpoint"`
}

func (r *RawMgmtNetLink) ToLinkConfig() *LinkConfig {
func (r *LinkMgmtNetRaw) ToLinkConfig() *LinkConfig {
lc := &LinkConfig{
Vars: r.Vars,
Labels: r.Labels,
Expand All @@ -21,18 +21,3 @@ func (r *RawMgmtNetLink) ToLinkConfig() *LinkConfig {

return lc
}

// func mgmtNetFromLinkConfig(lc *LinkConfig, specialEPIndex int) (*RawMgmtNetLink, error) {
// _, hostIf, node, nodeIf := extractHostNodeInterfaceData(lc, specialEPIndex)

// result := &RawMgmtNetLink{
// RawLinkType: RawLinkType{Type: string(LinkTypeMgmtNet), Labels: lc.Labels, Vars: lc.Vars, Instance: nil},
// HostInterface: hostIf,
// Endpoint: &EndpointRaw{
// Node: node,
// Iface: nodeIf,
// Mac: "",
// },
// }
// return result, nil
// }
12 changes: 7 additions & 5 deletions types/link_veth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@ package types

import "fmt"

type RawVEthLink struct {
// LinkVEthRaw is the raw (string) representation of a veth link as defined in the topology file.
type LinkVEthRaw struct {
LinkCommonParams `yaml:",inline"`
Endpoints []*EndpointRaw `yaml:"endpoints"`
}

func (r *RawVEthLink) MarshalYAML() (interface{}, error) {
func (r *LinkVEthRaw) MarshalYAML() (interface{}, error) {
x := struct {
Type string `yaml:"type"`
RawVEthLink `yaml:",inline"`
LinkVEthRaw `yaml:",inline"`
}{
Type: string(LinkTypeVEth),
RawVEthLink: *r,
LinkVEthRaw: *r,
}
return x, nil
}

func (r *RawVEthLink) ToLinkConfig() *LinkConfig {
// ToLinkConfig converts the raw link into a LinkConfig.
func (r *LinkVEthRaw) ToLinkConfig() *LinkConfig {
lc := &LinkConfig{
Vars: r.Vars,
Labels: r.Labels,
Expand Down

0 comments on commit 06e7e25

Please sign in to comment.