Skip to content

Commit

Permalink
migrate github 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 6053c0e commit e488c09
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
16 changes: 12 additions & 4 deletions providers/github/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import (
)

type GithubConnection struct {
id uint32
Conf *inventory.Config
asset *inventory.Asset
client *github.Client
id uint32
parentId *uint32
Conf *inventory.Config
asset *inventory.Asset
client *github.Client
}

func NewGithubConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*GithubConnection, error) {
Expand Down Expand Up @@ -71,6 +72,9 @@ func NewGithubConnection(id uint32, asset *inventory.Asset, conf *inventory.Conf
asset: asset,
client: client,
}
if len(asset.Connections) > 0 && asset.Connections[0].ParentConnectionId > 0 {
conn.parentId = &asset.Connections[0].ParentConnectionId
}

return conn, nil
}
Expand All @@ -83,6 +87,10 @@ func (c *GithubConnection) ID() uint32 {
return c.id
}

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

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

asset.Connections[0].Id = conn.ID()
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 e488c09

Please sign in to comment.