Skip to content

Commit

Permalink
migrate network provider
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Feb 12, 2024
1 parent 3cc53f3 commit c37487c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
17 changes: 13 additions & 4 deletions providers/network/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ import (
)

type HostConnection struct {
id uint32
Conf *inventory.Config
asset *inventory.Asset
id uint32
parentId *uint32
Conf *inventory.Config
asset *inventory.Asset
}

func NewHostConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) *HostConnection {
return &HostConnection{
conn := &HostConnection{
Conf: conf,
id: id,
asset: asset,
}
if len(asset.Connections) > 0 && asset.Connections[0].ParentConnectionId > 0 {
conn.parentId = &asset.Connections[0].ParentConnectionId
}
return conn
}

func (h *HostConnection) Name() string {
Expand All @@ -29,6 +34,10 @@ func (h *HostConnection) ID() uint32 {
return h.id
}

func (c *HostConnection) ParentID() *uint32 {
return c.parentId
}

func (p *HostConnection) Asset() *inventory.Asset {
return p.asset
}
Expand Down
19 changes: 9 additions & 10 deletions providers/network/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba
}

asset.Connections[0].Id = connId
return &plugin.Runtime{
Connection: conn,
Callback: callback,
HasRecording: req.HasRecording,
CreateResource: resources.CreateResource,
NewResource: resources.NewResource,
GetData: resources.GetData,
SetData: resources.SetData,
Upstream: upstream,
}, nil
return plugin.NewRuntime(
conn,
callback,
req.HasRecording,
resources.CreateResource,
resources.NewResource,
resources.GetData,
resources.SetData,
upstream), nil
})
if err != nil {
return nil, err
Expand Down

0 comments on commit c37487c

Please sign in to comment.