From f885de4c682fb821dd200a3a19048092b356adcf Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Fri, 14 Jan 2022 20:38:17 +0100 Subject: [PATCH] distro: remove OSTreeImageOptions type and use ostree.RequestParams --- cmd/osbuild-pipeline/main.go | 3 ++- internal/cloudapi/v2/v2.go | 4 ++-- internal/distro/distro.go | 10 ++-------- .../distro/distro_test_common/distro_test_common.go | 3 ++- internal/weldr/api.go | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/cmd/osbuild-pipeline/main.go b/cmd/osbuild-pipeline/main.go index d80493de2..d81e3038a 100644 --- a/cmd/osbuild-pipeline/main.go +++ b/cmd/osbuild-pipeline/main.go @@ -10,6 +10,7 @@ import ( "path" "github.com/osbuild/osbuild-composer/internal/distroregistry" + "github.com/osbuild/osbuild-composer/internal/ostree" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/distro" @@ -145,7 +146,7 @@ func main() { manifest, err := imageType.Manifest(composeRequest.Blueprint.Customizations, distro.ImageOptions{ Size: imageType.Size(0), - OSTree: distro.OSTreeImageOptions{ + OSTree: ostree.RequestParams{ Ref: composeRequest.OSTree.Ref, Parent: composeRequest.OSTree.Parent, URL: composeRequest.OSTree.URL, diff --git a/internal/cloudapi/v2/v2.go b/internal/cloudapi/v2/v2.go index 0f74eb7d6..6dd2ac58f 100644 --- a/internal/cloudapi/v2/v2.go +++ b/internal/cloudapi/v2/v2.go @@ -275,11 +275,11 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error { // set default ostree ref, if one not provided ostreeOptions := ir.Ostree if ostreeOptions == nil || ostreeOptions.Ref == nil { - imageOptions.OSTree = distro.OSTreeImageOptions{Ref: imageType.OSTreeRef()} + imageOptions.OSTree = ostree.RequestParams{Ref: imageType.OSTreeRef()} } else if !ostree.VerifyRef(*ostreeOptions.Ref) { return HTTPError(ErrorInvalidOSTreeRef) } else { - imageOptions.OSTree = distro.OSTreeImageOptions{Ref: *ostreeOptions.Ref} + imageOptions.OSTree = ostree.RequestParams{Ref: *ostreeOptions.Ref} } var parent string diff --git a/internal/distro/distro.go b/internal/distro/distro.go index c7341223e..c6553d263 100644 --- a/internal/distro/distro.go +++ b/internal/distro/distro.go @@ -12,6 +12,7 @@ import ( "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/disk" + "github.com/osbuild/osbuild-composer/internal/ostree" "github.com/osbuild/osbuild-composer/internal/rpmmd" ) @@ -127,18 +128,11 @@ type ImageType interface { // The ImageOptions specify options for a specific image build type ImageOptions struct { - OSTree OSTreeImageOptions + OSTree ostree.RequestParams Size uint64 Subscription *SubscriptionImageOptions } -// The OSTreeImageOptions specify ostree-specific image options -type OSTreeImageOptions struct { - Ref string - Parent string - URL string -} - // The SubscriptionImageOptions specify subscription-specific image options // ServerUrl denotes the host to register the system with // BaseUrl specifies the repository URL for DNF diff --git a/internal/distro/distro_test_common/distro_test_common.go b/internal/distro/distro_test_common/distro_test_common.go index 009ff10f7..135be8702 100644 --- a/internal/distro/distro_test_common/distro_test_common.go +++ b/internal/distro/distro_test_common/distro_test_common.go @@ -15,6 +15,7 @@ import ( "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/distro" "github.com/osbuild/osbuild-composer/internal/distroregistry" + "github.com/osbuild/osbuild-composer/internal/ostree" "github.com/osbuild/osbuild-composer/internal/rpmmd" ) @@ -103,7 +104,7 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, regis got, err := imageType.Manifest(tt.ComposeRequest.Blueprint.Customizations, distro.ImageOptions{ Size: imageType.Size(0), - OSTree: distro.OSTreeImageOptions{ + OSTree: ostree.RequestParams{ Ref: imageType.OSTreeRef(), }, }, diff --git a/internal/weldr/api.go b/internal/weldr/api.go index 0d822d282..7be7d1bbd 100644 --- a/internal/weldr/api.go +++ b/internal/weldr/api.go @@ -2300,7 +2300,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request manifest, err := imageType.Manifest(bp.Customizations, distro.ImageOptions{ Size: size, - OSTree: distro.OSTreeImageOptions{ + OSTree: ostree.RequestParams{ Ref: cr.OSTree.Ref, Parent: cr.OSTree.Parent, URL: cr.OSTree.URL,