Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pulp ostree import commit #2753

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions pkg/clients/pulp/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (ps *PulpService) RepositoriesCreate(ctx context.Context, name string) (*Os
return resp.JSON201, nil
}

// RepositoriesImport imports an initial commit into a repo
func (ps *PulpService) RepositoriesImport(ctx context.Context, id uuid.UUID, repoName, artifactHref string) (*OstreeOstreeRepositoryResponse, error) {
body := OstreeImportAll{
Artifact: artifactHref,
Expand Down Expand Up @@ -58,6 +59,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
Loading