code.gitea.io/gitea@v1.21.7/models/packages/alpine/search.go (about)

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