Skip to content

Commit

Permalink
add pulp ostree import commit
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Holloway <[email protected]>
  • Loading branch information
loadtheaccumulator committed Nov 27, 2024
1 parent aa63994 commit 789de88
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pkg/clients/pulp/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,43 @@ func (ps *PulpService) RepositoriesImport(ctx context.Context, id uuid.UUID, rep
return result, nil
}

// RepositoriesImportCommit updates an existing repo containing one or more commits
func (ps *PulpService) RepositoriesImportCommit(ctx context.Context, id uuid.UUID, repoName, artifactHref string, ostreeRef string) (*OstreeOstreeRepositoryResponse, error) {
body := OstreeImportCommitsToRef{
Artifact: artifactHref,
Ref: ostreeRef,
RepositoryName: repoName,
}

// OstreeImportCommits includes the OSTree ref for updating a tree that has at least one commit
// Use OstreeImportAll for the initial commit
// see https://pulpproject.org/pulp_ostree/docs/user/guides/import-commit/
resp, err := ps.cwr.RepositoriesOstreeOstreeImportCommitsWithResponse(ctx, ps.dom, id, body, addAuthenticationHeader)
if err != nil {
return nil, err
}

if resp.JSON202 == nil {
return nil, fmt.Errorf("unexpected response: %d, body: %s", resp.StatusCode(), string(resp.Body))
}

hrefs, err := ps.WaitForTask(ctx, resp.JSON202.Task)
if err != nil {
return nil, err
}
if len(hrefs) != 1 {
return nil, fmt.Errorf("unexpected number of created resources: %d", len(hrefs))
}
href := hrefs[0]

result, err := ps.RepositoriesRead(ctx, ScanUUID(&href))
if err != nil {
return nil, err
}

return result, nil
}

func (ps *PulpService) RepositoriesRead(ctx context.Context, id uuid.UUID) (*OstreeOstreeRepositoryResponse, error) {
req := RepositoriesOstreeOstreeReadParams{}
resp, err := ps.cwr.RepositoriesOstreeOstreeReadWithResponse(ctx, ps.dom, id, &req, addAuthenticationHeader)
Expand Down

0 comments on commit 789de88

Please sign in to comment.