From 57f1bb8bf4bc391e861303bb4d550081b141b6f8 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Wed, 16 Aug 2023 16:08:12 +0200 Subject: [PATCH] upload/pulp: import commit into repository Function for importing a commit artifact (that's already been uploaded) into a given repository. Note that the "repo" argument to the NewOstreeImportAll() function refers to the name of the repository directory inside the archive, which for the commits we produce in osbuild is always "repo". --- internal/upload/pulp/pulp.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/upload/pulp/pulp.go b/internal/upload/pulp/pulp.go index 90541e6b0..ea918813e 100644 --- a/internal/upload/pulp/pulp.go +++ b/internal/upload/pulp/pulp.go @@ -111,3 +111,18 @@ func (cl *Client) CreateOSTreeRepository(name, description string) (string, erro return result.GetPulpHref(), nil } + +// ImportCommit imports a commit that has already been uploaded to a given +// repository. The commitHref must reference a commit tarball artifact. This +// task is asynchronous. The returned value is the href for the import task. +func (cl *Client) ImportCommit(commitHref, repoHref string) (string, error) { + req := cl.client.RepositoriesOstreeAPI.RepositoriesOstreeOstreeImportAll(cl.ctx, repoHref) + importOptions := *pulpclient.NewOstreeImportAll(commitHref, "repo") // our commit archives always use the repo name "repo" + + result, resp, err := req.OstreeImportAll(importOptions).Execute() + if err != nil { + return "", fmt.Errorf("ostree commit import failed: %s (%s)", err.Error(), readBody(resp)) + } + + return result.Task, nil +}