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

cloudapi: Add /distributions/{arch} to cloudapi #4336

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ require (
github.com/osbuild/images v0.88.0
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d
github.com/osbuild/pulp-client v0.1.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.20.2
github.com/segmentio/ksuid v1.0.4
github.com/sirupsen/logrus v1.9.3
Expand Down Expand Up @@ -192,7 +193,6 @@ require (
github.com/opencontainers/selinux v1.11.0 // indirect
github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/proglottis/gpgme v0.1.3 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
Expand Down
35 changes: 35 additions & 0 deletions internal/cloudapi/v2/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1354,3 +1354,38 @@ func uploadStatusFromJobStatus(js *worker.JobStatus, je *clienterrors.Error) Upl
}
return UploadStatusValueSuccess
}

// GetDistributionList returns the list of all supported distribution repositories
// It is arranged by distro name -> architecture -> image type
func (h *apiHandlers) GetDistributionList(ctx echo.Context) error {
distros := make(map[string]map[string]map[string][]rpmmd.RepoConfig)
distroNames := h.server.repos.ListDistros()
sort.Strings(distroNames)
for _, distroName := range distroNames {
distro := h.server.distros.GetDistro(distroName)
if distro == nil {
continue
}

for _, archName := range distro.ListArches() {
arch, _ := distro.GetArch(archName)
for _, imageType := range arch.ListImageTypes() {
repos, err := h.server.repos.ReposByImageTypeName(distroName, archName, imageType)
if err != nil {
continue
}

if _, ok := distros[distroName]; !ok {
distros[distroName] = make(map[string]map[string][]rpmmd.RepoConfig)
}
if _, ok := distros[distroName][archName]; !ok {
distros[distroName][archName] = make(map[string][]rpmmd.RepoConfig)
}

distros[distroName][archName][imageType] = repos
}
}
}

return ctx.JSON(http.StatusOK, distros)
}
Loading
Loading