You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

search.go 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package alpine
  4. import (
  5. "context"
  6. packages_model "code.gitea.io/gitea/models/packages"
  7. alpine_module "code.gitea.io/gitea/modules/packages/alpine"
  8. )
  9. // GetBranches gets all available branches
  10. func GetBranches(ctx context.Context, ownerID int64) ([]string, error) {
  11. return packages_model.GetDistinctPropertyValues(
  12. ctx,
  13. packages_model.TypeAlpine,
  14. ownerID,
  15. packages_model.PropertyTypeFile,
  16. alpine_module.PropertyBranch,
  17. nil,
  18. )
  19. }
  20. // GetRepositories gets all available repositories for the given branch
  21. func GetRepositories(ctx context.Context, ownerID int64, branch string) ([]string, error) {
  22. return packages_model.GetDistinctPropertyValues(
  23. ctx,
  24. packages_model.TypeAlpine,
  25. ownerID,
  26. packages_model.PropertyTypeFile,
  27. alpine_module.PropertyRepository,
  28. &packages_model.DistinctPropertyDependency{
  29. Name: alpine_module.PropertyBranch,
  30. Value: branch,
  31. },
  32. )
  33. }
  34. // GetArchitectures gets all available architectures for the given repository
  35. func GetArchitectures(ctx context.Context, ownerID int64, repository string) ([]string, error) {
  36. return packages_model.GetDistinctPropertyValues(
  37. ctx,
  38. packages_model.TypeAlpine,
  39. ownerID,
  40. packages_model.PropertyTypeFile,
  41. alpine_module.PropertyArchitecture,
  42. &packages_model.DistinctPropertyDependency{
  43. Name: alpine_module.PropertyRepository,
  44. Value: repository,
  45. },
  46. )
  47. }