mirror of
https://github.com/harness/drone.git
synced 2025-04-28 05:36:58 +00:00
33 lines
927 B
Go
33 lines
927 B
Go
// Copyright 2022 Harness Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform Free Trial License
|
|
// that can be found in the LICENSE.md file for this repository.
|
|
|
|
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
apiauth "github.com/harness/gitness/internal/api/auth"
|
|
"github.com/harness/gitness/internal/auth"
|
|
"github.com/harness/gitness/types"
|
|
"github.com/harness/gitness/types/enum"
|
|
)
|
|
|
|
func (c *Controller) Find(
|
|
ctx context.Context,
|
|
session *auth.Session,
|
|
repoRef string,
|
|
uid string,
|
|
) (*types.Pipeline, error) {
|
|
repo, err := c.repoStore.FindByRef(ctx, repoRef)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to find repo by ref: %w", err)
|
|
}
|
|
err = apiauth.CheckPipeline(ctx, c.authorizer, session, repo.Path, uid, enum.PermissionPipelineView)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to authorize pipeline: %w", err)
|
|
}
|
|
return c.pipelineStore.FindByUID(ctx, repo.ID, uid)
|
|
}
|