Skip to content

Commit

Permalink
migrate google-workspace 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 01c0b7d commit 895dfdd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
14 changes: 11 additions & 3 deletions providers/google-workspace/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
)

type GoogleWorkspaceConnection struct {
id uint32
Conf *inventory.Config
asset *inventory.Asset
id uint32
parentId *uint32
Conf *inventory.Config
asset *inventory.Asset
// Add custom connection fields here
serviceAccountSubject string
customerId string
Expand All @@ -27,6 +28,9 @@ func NewGoogleWorkspaceConnection(id uint32, asset *inventory.Asset, conf *inven
id: id,
asset: asset,
}
if len(asset.Connections) > 0 && asset.Connections[0].ParentConnectionId > 0 {
conn.parentId = &asset.Connections[0].ParentConnectionId
}

if len(conf.Credentials) != 0 {
conn.cred = conf.Credentials[0]
Expand Down Expand Up @@ -57,6 +61,10 @@ func (c *GoogleWorkspaceConnection) ID() uint32 {
return c.id
}

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

func (c *GoogleWorkspaceConnection) Asset() *inventory.Asset {
return c.asset
}
Expand Down
19 changes: 9 additions & 10 deletions providers/google-workspace/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 895dfdd

Please sign in to comment.