Skip to content

Commit

Permalink
SkipDiscovery -> DelayDiscovery
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Mar 6, 2024
1 parent dc21a6e commit d3be245
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 222 deletions.
6 changes: 3 additions & 3 deletions explorer/scan/local_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (s *LocalScanner) distributeJob(job *Job, ctx context.Context, upstream *up
assetsToSync := make([]*inventory.Asset, 0, len(batch))
for i := range batch {
// If discovery has been skipped, then we don't sync that asset just yet. We will do that during the scan
if batch[i].Asset.Connections[0].SkipDiscovery {
if batch[i].Asset.Connections[0].DelayDiscovery {
continue
}
assetsToSync = append(assetsToSync, batch[i].Asset)
Expand Down Expand Up @@ -341,8 +341,8 @@ func (s *LocalScanner) distributeJob(job *Job, ctx context.Context, upstream *up
default:
}

if asset.Connections[0].SkipDiscovery {
asset.Connections[0].SkipDiscovery = false
if asset.Connections[0].DelayDiscovery {
asset.Connections[0].DelayDiscovery = false
if err := runtime.Connect(&plugin.ConnectReq{Asset: asset}); err != nil {
log.Error().Err(err).Str("asset", asset.Name).Msg("failed to connect to asset")
reporter.AddScanError(asset, err)
Expand Down
423 changes: 212 additions & 211 deletions providers-sdk/v1/inventory/inventory.pb.go

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions providers-sdk/v1/inventory/inventory.proto
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ message Config {
// connection
string platform_id = 26;
repeated string capabilities = 29;
// Determines whether to skip discovery during the connection phase
bool skip_discovery = 31;
// Determines whether to delay discovery during the connection phase. Discovery
// will only happen if this is false
bool delay_discovery = 31;
}

message Sudo {
Expand Down
2 changes: 1 addition & 1 deletion providers/os/connection/container/image_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewImageConnection(id uint32, conf *inventory.Config, asset *inventory.Asse
// FIXME: DEPRECATED, remove in v12.0 vv
// The SkipDiscovery flag should always be set from v12
if conf.Options == nil || conf.Options[plugin.DISABLE_DELAYED_DISCOVERY_OPTION] == "" {
conf.SkipDiscovery = true // Skip discovery, to make sure we don't directly download the image
conf.DelayDiscovery = true // Delay discovery, to make sure we don't directly download the image
}
// ^^
f, err := tar.RandomFile()
Expand Down
4 changes: 2 additions & 2 deletions providers/os/connection/docker/container_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func NewDockerEngineContainer(id uint32, conf *inventory.Config, asset *inventor
// FIXME: DEPRECATED, remove in v12.0 vv
// The SkipDiscovery flag should always be set from v12
if conf.Options == nil || conf.Options[plugin.DISABLE_DELAYED_DISCOVERY_OPTION] == "" {
conf.SkipDiscovery = true // Skip discovery, to make sure we don't directly download the image
conf.DelayDiscovery = true // Delay discovery, to make sure we don't directly download the image
}
// ^^
asset.Name = ci.Name
Expand Down Expand Up @@ -304,7 +304,7 @@ func NewContainerImageConnection(id uint32, conf *inventory.Config, asset *inven
// FIXME: DEPRECATED, remove in v12.0 vv
// The SkipDiscovery flag should always be set from v12
if conf.Options == nil || conf.Options[plugin.DISABLE_DELAYED_DISCOVERY_OPTION] == "" {
conf.SkipDiscovery = true // Skip discovery, to make sure we don't directly download the image
conf.DelayDiscovery = true // Delay discovery, to make sure we don't directly download the image
}
// ^^

Expand Down
4 changes: 2 additions & 2 deletions providers/os/provider/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ func (s *Service) detect(asset *inventory.Asset, conn shared.Connection) error {
slices.Sort(asset.PlatformIds)
asset.PlatformIds = slices.Compact(asset.PlatformIds)

// If the asset connection had the SkipDiscovery flag and the current asset doesn't, we just performed
// If the asset connection had the DelayDiscovery flag and the current asset doesn't, we just performed
// discovery for the asset and we need to update it.
if conn.Asset().Connections[0].SkipDiscovery && !asset.Connections[0].SkipDiscovery {
if conn.Asset().Connections[0].DelayDiscovery && !asset.Connections[0].DelayDiscovery {
conn.UpdateAsset(asset)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion providers/os/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba
}

// We only need to run the detection step when we don't have any asset information yet.
if !req.Asset.Connections[0].SkipDiscovery && (req.Asset.Platform == nil || req.Asset.Platform.Name == "") {
if !req.Asset.Connections[0].DelayDiscovery && (req.Asset.Platform == nil || req.Asset.Platform.Name == "") {
if err := s.detect(req.Asset, conn); err != nil {
return nil, err
}
Expand Down

0 comments on commit d3be245

Please sign in to comment.