Check env var along with app config for software inv (#2406)

This commit is contained in:
Tomas Touceda 2021-10-06 14:17:33 -03:00 committed by GitHub
parent c28e3bbc9a
commit f44c809d85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ import (
"context" "context"
"database/sql" "database/sql"
"fmt" "fmt"
"os"
"strings" "strings"
"time" "time"
@ -155,7 +156,8 @@ func (d *Datastore) SaveHost(ctx context.Context, host *fleet.Host) error {
return errors.Wrap(err, "failed to get app config to see if we need to update host users and inventory") return errors.Wrap(err, "failed to get app config to see if we need to update host users and inventory")
} }
if host.HostSoftware.Modified && ac.HostSettings.EnableSoftwareInventory && len(host.HostSoftware.Software) > 0 { softwareInventoryEnabled := os.Getenv("FLEET_BETA_SOFTWARE_INVENTORY") != "" || ac.HostSettings.EnableSoftwareInventory
if host.HostSoftware.Modified && softwareInventoryEnabled && len(host.HostSoftware.Software) > 0 {
if err := saveHostSoftwareDB(ctx, tx, host); err != nil { if err := saveHostSoftwareDB(ctx, tx, host); err != nil {
return errors.Wrap(err, "failed to save host software") return errors.Wrap(err, "failed to save host software")
} }