Skip to content

Commit

Permalink
fix: parse profiles for 'digital-ocean' platform
Browse files Browse the repository at this point in the history
As `digital-ocean` has a dash, we need to do a little trick, as we
should support both:

* `digital-ocean-amd64`
* `metal-rpi_generic-arm64`

The first has platform `digital-ocean`, while the second is platform
`metal` and board `rpi_generic`.

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Nov 2, 2023
1 parent 43a6388 commit db21b76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ func parsePlatformArch(s string, prof *profile.Profile) error {
return xerrors.NewTaggedf[InvalidErrorTag]("invalid platform-arch: %q", s)
}

// special case for 'digital-ocean' platform which has a dash in it
if platform == "digital" && strings.HasPrefix(rest, "ocean-") {
platform = "digital-ocean"
rest = strings.TrimPrefix(rest, "ocean-")
}

prof.Platform = platform

if platform == constants.PlatformMetal && strings.HasSuffix(rest, "-"+string(artifacts.ArchArm64)) {
Expand Down
16 changes: 16 additions & 0 deletions internal/profile/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ func TestParseFromPath(t *testing.T) {
},
},
},
{
path: "digital-ocean-amd64.raw.gz",

expectedProfile: profile.Profile{
Platform: "digital-ocean",
Arch: "amd64",
Output: profile.Output{
Kind: profile.OutKindImage,
OutFormat: profile.OutFormatGZ,
ImageOptions: &profile.ImageOptions{
DiskFormat: profile.DiskFormatRaw,
DiskSize: profile.DefaultRAWDiskSize,
},
},
},
},
} {
t.Run(test.path, func(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit db21b76

Please sign in to comment.