drone/types/check/repo.go
Johannes Batzill a74d779dc4 [Webhook] Add display_name/description/latest_execution_result to webhook (#180)
This PR adds the following fields to webhooks:
- 'DisplayName' - the display name of the webhook for easier recognition in UI (no uniqueness guarantees)
- 'Description' - an (optional) description of the webhook
 - 'LatestExecutionResult' - contains the result of the latest execution of the webhook
2023-01-11 17:11:10 -08:00

47 lines
1.0 KiB
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 check
import (
"github.com/harness/gitness/types"
)
var (
ErrRepositoryRequiresParentID = &ValidationError{
"ParentID required - Standalone repositories are not supported.",
}
)
// Repo returns true if the Repo is valid.
type Repo func(*types.Repository) error
// RepoDefault is the default Repo validation.
func RepoDefault(repo *types.Repository) error {
// validate UID
if err := UID(repo.UID); err != nil {
return err
}
// validate the rest
return RepoNoUID(repo)
}
// RepoNoUID validates the repo and ignores the UID field.
func RepoNoUID(repo *types.Repository) error {
// validate repo within a space
if repo.ParentID <= 0 {
return ErrRepositoryRequiresParentID
}
// validate description
if err := Description(repo.Description); err != nil {
return err
}
// TODO: validate defaultBranch, ...
return nil
}