mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
Update how google drive fma version is created (#42270)
**Related issue:** Resolves #40751
This commit is contained in:
parent
f55eb085f0
commit
581cae309a
4 changed files with 72 additions and 0 deletions
1
changes/40751-google-drive-brew-version
Normal file
1
changes/40751-google-drive-brew-version
Normal file
|
|
@ -0,0 +1 @@
|
|||
- Fix Google Drive version not matching upstream
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -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},
|
||||
|
|
|
|||
Loading…
Reference in a new issue