Skip to content

Commit

Permalink
cloudapi: Use distro repos if none included in imageRequest
Browse files Browse the repository at this point in the history
In order to support cloudapi blueprint requests from the cmdline using
composer-cli it needs to select the repositories based on the selected
distribution instead of requiring the user to include them with the
request.

If the image request includes repositories they are used, which matches
the current behavior. If the repository list is empty it will use the
distribution name to select from the repositories shipped with
osbuild-composer.
  • Loading branch information
bcl committed Feb 12, 2024
1 parent a4c1175 commit 709c8ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 9 additions & 0 deletions internal/cloudapi/v2/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
return err
}

// If no repositories are included with the imageRequest use the defaults for the distro
if len(ir.Repositories) == 0 {
dr, err := h.server.repos.ReposByImageTypeName(distribution.Name(), arch.Name(), imageType.Name())
if err != nil {
return err
}
repos = append(repos, dr...)
}

// Get the initial ImageOptions with image size set
imageOptions := ir.GetImageOptions(imageType, bp)

Expand Down
1 change: 0 additions & 1 deletion internal/cloudapi/v2/v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func newV2Server(t *testing.T, dir string, depsolveChannels []string, enableJWT
distros := distrofactory.NewTestDefault()
require.NotNil(t, distros)

// TODO pass it a real path?
repos, err := reporegistry.NewTestedDefault()
require.Nil(t, err)
require.NotNil(t, repos)
Expand Down

0 comments on commit 709c8ca

Please sign in to comment.