summaryrefslogtreecommitdiffstats
path: root/models/packages/alpine/search.go
blob: 77eccb90ed5ef6ec2a7544d6e64393a00f13d236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package alpine

import (
	"context"

	packages_model "code.gitea.io/gitea/models/packages"
	alpine_module "code.gitea.io/gitea/modules/packages/alpine"
)

// GetBranches gets all available branches
func GetBranches(ctx context.Context, ownerID int64) ([]string, error) {
	return packages_model.GetDistinctPropertyValues(
		ctx,
		packages_model.TypeAlpine,
		ownerID,
		packages_model.PropertyTypeFile,
		alpine_module.PropertyBranch,
		nil,
	)
}

// GetRepositories gets all available repositories for the given branch
func GetRepositories(ctx context.Context, ownerID int64, branch string) ([]string, error) {
	return packages_model.GetDistinctPropertyValues(
		ctx,
		packages_model.TypeAlpine,
		ownerID,
		packages_model.PropertyTypeFile,
		alpine_module.PropertyRepository,
		&packages_model.DistinctPropertyDependency{
			Name:  alpine_module.PropertyBranch,
			Value: branch,
		},
	)
}

// GetArchitectures gets all available architectures for the given repository
func GetArchitectures(ctx context.Context, ownerID int64, repository string) ([]string, error) {
	return packages_model.GetDistinctPropertyValues(
		ctx,
		packages_model.TypeAlpine,
		ownerID,
		packages_model.PropertyTypeFile,
		alpine_module.PropertyArchitecture,
		&packages_model.DistinctPropertyDependency{
			Name:  alpine_module.PropertyRepository,
			Value: repository,
		},
	)
}