Repository navigation
Combine FMAs by name instead of slug token #59205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import ( | |
| "log/slog" | ||
| "os" | ||
| "path" | ||
| "regexp" | ||
| "slices" | ||
| "strings" | ||
|
|
||
|
|
@@ -157,19 +158,30 @@ func updateAppsListFile(ctx context.Context, outApp *maintained_apps.FMAManifest | |
| return ctxerr.Wrap(ctx, err, "unmarshaling output apps list file") | ||
| } | ||
|
|
||
| platform := outApp.Platform() | ||
| platformNameSuffix := regexp.MustCompile(` for (macOS|Mac|Windows)$`) | ||
| var found bool | ||
| var existingSlugWithSameName string | ||
| for _, a := range outputAppsFile.Apps { | ||
| if a.Slug == outApp.Slug { | ||
| found = true | ||
| break | ||
| continue | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apply the collision check only when adding a new slug. If an existing app's incoming name changes to another app's name, this The catalog name is not updated for an existing slug. Resolve whether the slug exists before checking name collisions. Keep collision validation for new slugs. This preserves existing refreshes and still rejects conflicting additions. The PR objective specifies a “creation-time check.”
|
||
| } | ||
|
|
||
| // The Fleet-maintained apps list combines apps by name, so names must be unique per platform. | ||
| // The table compares names with utf8mb4_unicode_ci, but EqualFold is close enough for this check. | ||
| if a.Platform == platform && strings.EqualFold(platformNameSuffix.ReplaceAllString(a.Name, ""), platformNameSuffix.ReplaceAllString(outApp.Name, "")) { | ||
| existingSlugWithSameName = a.Slug | ||
| } | ||
| } | ||
|
|
||
| if !found { | ||
| platform := outApp.Platform() | ||
| if platform == "" { | ||
| return ctxerr.New(ctx, fmt.Sprintf("invalid platform found for slug %s", outApp.Slug)) | ||
| } | ||
| if existingSlugWithSameName != "" { | ||
| return ctxerr.New(ctx, fmt.Sprintf("%s uses the name %q, which %s already uses on the same platform", outApp.Slug, outApp.Name, existingSlugWithSameName)) | ||
| } | ||
|
|
||
| outputAppsFile.Apps = append(outputAppsFile.Apps, maintained_apps.FMAListFileApp{ | ||
| Name: outApp.Name, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove platform suffixes without case sensitivity.
With existing
Docker Desktopatdocker-desktop/darwin, incomingDocker Desktop for MACOSatdocker/darwinpasses this check. The regex leavesfor MACOSintact, so the laterEqualFoldcannot detect the conflict. Go regex matching is case-sensitive unlessiis enabled. (pkg.go.dev)The supplied SQL uses
utf8mb4_unicode_ciand no case-sensitive regex override. Its suffix removal therefore groups these names together. MySQL regex matching follows the input collation by default. (dev.mysql.com)Add
(?i)to this regex. Add a same-platform rejection test with a differently cased suffix. Keep the platform guard so cross-platform additions remain valid.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No app currently uses
for MACOSin its name, and we'll want to eventually not use this paradigm anyway for combining apps.