-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into lukeheath-patch-12
- Loading branch information
Showing
20 changed files
with
449 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Adds a daily job that keeps the App Store app version displayed in Fleet in sync with the actual | ||
latest version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package vpp | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/fleetdm/fleet/v4/server/fleet" | ||
"github.com/fleetdm/fleet/v4/server/mdm/apple/itunes" | ||
) | ||
|
||
// RefreshVersions updatest the LatestVersion fields for the VPP apps stored in Fleet. | ||
func RefreshVersions(ctx context.Context, ds fleet.Datastore) error { | ||
apps, err := ds.GetAllVPPApps(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
var adamIDs []string | ||
appsByAdamID := make(map[string]*fleet.VPPApp) | ||
for _, app := range apps { | ||
adamIDs = append(adamIDs, app.AdamID) | ||
appsByAdamID[app.AdamID] = app | ||
} | ||
|
||
meta, err := itunes.GetAssetMetadata(adamIDs, &itunes.AssetMetadataFilter{Entity: "software"}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
var appsToUpdate []*fleet.VPPApp | ||
for _, adamID := range adamIDs { | ||
if m, ok := meta[adamID]; ok { | ||
if m.Version != appsByAdamID[adamID].LatestVersion { | ||
appsByAdamID[adamID].LatestVersion = m.Version | ||
appsToUpdate = append(appsToUpdate, appsByAdamID[adamID]) | ||
} | ||
} | ||
} | ||
|
||
if err := ds.InsertVPPApps(ctx, appsToUpdate); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.