Skip to content

Commit

Permalink
setup pulp integration
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Holloway <[email protected]>
  • Loading branch information
loadtheaccumulator committed Aug 19, 2024
1 parent 7a9cf53 commit 88fd90f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
12 changes: 9 additions & 3 deletions pkg/services/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,14 +878,20 @@ func (s *ImageService) CreateRepoForImage(ctx context.Context, img *models.Image
}
s.log.Debug("OSTree repo was saved to commit")

repo, err := s.RepoBuilder.ImportRepo(repo)
var repository *models.Repo
var err error
if feature.PulpIntegration.IsEnabled() {
repository, err = s.RepoBuilder.StoreRepo(repo)
} else {
repository, err = s.RepoBuilder.ImportRepo(repo)
}
if err != nil {
return nil, err
}

s.log.Info("OSTree repo is ready")
s.log.WithField("url", repository.URL).Info("OSTree repo is ready")

return repo, nil
return repository, nil
}

// SetErrorStatusOnImage is a helper function that sets the error status on images
Expand Down
15 changes: 15 additions & 0 deletions pkg/services/mock_services/repobuilder.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion pkg/services/repobuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var BuildCommand = exec.Command
// RepoBuilderInterface defines the interface of a repository builder
type RepoBuilderInterface interface {
BuildUpdateRepo(id uint) (*models.UpdateTransaction, error)
StoreRepo(r *models.Repo) (*models.Repo, error)
ImportRepo(r *models.Repo) (*models.Repo, error)
CommitTarDownload(c *models.Commit, dest string) (string, error)
CommitTarExtract(c *models.Commit, tarFileName string, dest string) error
Expand Down Expand Up @@ -362,9 +363,17 @@ func (rb *RepoBuilder) BuildUpdateRepo(id uint) (*models.UpdateTransaction, erro
return update, nil
}

// StoreRepo requests Pulp to create/update an ostree repo from an IB commit
func (rb *RepoBuilder) StoreRepo(repo *models.Repo) (*models.Repo, error) {
// FIXME: add the Pulp repo create here
// this allows both to happen until code that updates the DB is added

return rb.ImportRepo(repo)
}

// ImportRepo (unpack and upload) a single repo
func (rb *RepoBuilder) ImportRepo(r *models.Repo) (*models.Repo, error) {

// FIXME: delete after Pulp Store Repo is stable
var cmt models.Commit
cmtDB := db.DB.Where("repo_id = ?", r.ID).First(&cmt)
if cmtDB.Error != nil {
Expand Down

0 comments on commit 88fd90f

Please sign in to comment.