Update how google drive fma version is created (#42270)

**Related issue:** Resolves #40751
This commit is contained in:
Dante Catalfamo 2026-03-27 16:54:22 -04:00 committed by GitHub
parent f55eb085f0
commit 581cae309a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1 @@
- Fix Google Drive version not matching upstream

View file

@ -0,0 +1,21 @@
package externalrefs
import (
"strings"
maintained_apps "github.com/fleetdm/fleet/v4/ee/maintained-apps"
)
func GoogleDriveVersionShortener(app *maintained_apps.FMAManifestApp) (*maintained_apps.FMAManifestApp, error) {
homebrewVersion := app.Version
// If the google drive version has three or more places, remove all but two
// https://github.com/fleetdm/fleet/issues/40751
if strings.Count(homebrewVersion, ".") > 1 {
split := strings.Split(homebrewVersion, ".")
shortVersion := strings.Join(split[0:2], ".")
app.Version = shortVersion
}
return app, nil
}

View file

@ -0,0 +1,49 @@
package externalrefs
import (
"testing"
maintained_apps "github.com/fleetdm/fleet/v4/ee/maintained-apps"
"github.com/stretchr/testify/assert"
)
func TestGoogleDriveVersionShortener(t *testing.T) {
tcs := []struct {
Name string
Version string
Expected string
}{
{
Name: "no subversion",
Version: "123",
Expected: "123",
},
{
Name: "one subversion",
Version: "123.45",
Expected: "123.45",
},
{
Name: "two subversion",
Version: "123.45.67",
Expected: "123.45",
},
{
Name: "three subversions",
Version: "123.45.67.89",
Expected: "123.45",
},
}
for _, tc := range tcs {
t.Run(tc.Name, func(t *testing.T) {
fma := &maintained_apps.FMAManifestApp{
Version: tc.Version,
}
fma2, err := GoogleDriveVersionShortener(fma)
assert.Equal(t, tc.Expected, fma.Version)
assert.Equal(t, tc.Expected, fma2.Version)
assert.NoError(t, err)
})
}
}

View file

@ -12,6 +12,7 @@ var Funcs = map[string][]func(*maintained_apps.FMAManifestApp) (*maintained_apps
"brave-browser/darwin": {BraveVersionTransformer},
"whatsapp/darwin": {WhatsAppVersionShortener, WhatsAppInstallerURL},
"google-chrome/darwin": {ChromePKGInstaller},
"google-drive/darwin": {GoogleDriveVersionShortener},
"1password/darwin": {OnePasswordPKGInstaller},
"zoom/darwin": {ZoomPKGInstaller},
"slack/darwin": {SlackPKGInstaller},