mirror of
https://github.com/harness/drone.git
synced 2025-05-05 15:32:56 +00:00
[MISC] Fix Linting/Formatting/Generated Files (#697)
This commit is contained in:
parent
4a741f9c30
commit
1ea0025f99
@ -25,14 +25,14 @@ fi
|
|||||||
# The files are then git-added
|
# The files are then git-added
|
||||||
FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep .go | sed 's| |\\ |g')
|
FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep .go | sed 's| |\\ |g')
|
||||||
if [ -n "$FILES" ]; then
|
if [ -n "$FILES" ]; then
|
||||||
make format
|
make format
|
||||||
make lint
|
make lint
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error running make check - please fix before committing"
|
echo "Error running make check - please fix before committing"
|
||||||
echo "if this is a mistake you can skip the checks with 'git commit --no-verify'"
|
echo "if this is a mistake you can skip the checks with 'git commit --no-verify'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "$FILES" | xargs git add
|
echo "$FILES" | xargs git add
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
7
Makefile
7
Makefile
@ -56,7 +56,7 @@ test: generate ## Run the go tests
|
|||||||
format: tools # Format go code and error if any changes are made
|
format: tools # Format go code and error if any changes are made
|
||||||
@echo "Formating ..."
|
@echo "Formating ..."
|
||||||
@goimports -w .
|
@goimports -w .
|
||||||
@gci write --custom-order -s standard -s "prefix(github.com/harness/gitness)" -s default -s blank -s dot .
|
@gci write --skip-generated --custom-order -s standard -s "prefix(github.com/harness/gitness)" -s default -s blank -s dot .
|
||||||
@echo "Formatting complete"
|
@echo "Formatting complete"
|
||||||
|
|
||||||
sec:
|
sec:
|
||||||
@ -75,7 +75,7 @@ lint: tools generate # lint the golang code
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
generate: wire proto
|
generate: wire proto
|
||||||
@echo "Generating Code"
|
@echo "Generated Code"
|
||||||
|
|
||||||
wire: cmd/gitness/wire_gen.go
|
wire: cmd/gitness/wire_gen.go
|
||||||
|
|
||||||
@ -85,13 +85,14 @@ force-wire: ## Force wire code generation
|
|||||||
cmd/gitness/wire_gen.go: cmd/gitness/wire.go
|
cmd/gitness/wire_gen.go: cmd/gitness/wire.go
|
||||||
@sh ./scripts/wire/gitness.sh
|
@sh ./scripts/wire/gitness.sh
|
||||||
|
|
||||||
proto: ## generate proto files for gitrpc integration
|
proto: ## generate proto files for gitrpc integration (and format, as we can't exclude it from being formatted easily)
|
||||||
@protoc --proto_path=./gitrpc/proto \
|
@protoc --proto_path=./gitrpc/proto \
|
||||||
--go_out=./gitrpc/rpc \
|
--go_out=./gitrpc/rpc \
|
||||||
--go_opt=paths=source_relative \
|
--go_opt=paths=source_relative \
|
||||||
--go-grpc_out=./gitrpc/rpc \
|
--go-grpc_out=./gitrpc/rpc \
|
||||||
--go-grpc_opt=paths=source_relative \
|
--go-grpc_opt=paths=source_relative \
|
||||||
./gitrpc/proto/*.proto
|
./gitrpc/proto/*.proto
|
||||||
|
@goimports -w ./gitrpc/rpc
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Install Tools and deps
|
# Install Tools and deps
|
||||||
|
@ -28,6 +28,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// PreReceive executes the pre-receive hook for a git repository.
|
// PreReceive executes the pre-receive hook for a git repository.
|
||||||
|
//
|
||||||
|
//nolint:revive // not yet fully implemented
|
||||||
func (c *Controller) PreReceive(
|
func (c *Controller) PreReceive(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
session *auth.Session,
|
session *auth.Session,
|
||||||
|
@ -23,6 +23,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Update executes the update hook for a git repository.
|
// Update executes the update hook for a git repository.
|
||||||
|
//
|
||||||
|
//nolint:revive // not yet implemented
|
||||||
func (c *Controller) Update(
|
func (c *Controller) Update(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
session *auth.Session,
|
session *auth.Session,
|
||||||
|
@ -85,7 +85,7 @@ func (c *Controller) Create(ctx context.Context, session *auth.Session, in *Crea
|
|||||||
}
|
}
|
||||||
err = c.repoStore.Create(ctx, repo)
|
err = c.repoStore.Create(ctx, repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if dErr := c.DeleteGitRPCRepositories(ctx, session, repo); dErr != nil {
|
if dErr := c.deleteGitRPCRepository(ctx, session, repo); dErr != nil {
|
||||||
log.Ctx(ctx).Warn().Err(dErr).Msg("gitrpc failed to delete repo for cleanup")
|
log.Ctx(ctx).Warn().Err(dErr).Msg("gitrpc failed to delete repo for cleanup")
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("failed to create repository in storage: %w", err)
|
return nil, fmt.Errorf("failed to create repository in storage: %w", err)
|
||||||
|
@ -54,19 +54,21 @@ func (c *Controller) Delete(ctx context.Context, session *auth.Session, repoRef
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) DeleteNoAuth(ctx context.Context, session *auth.Session, repo *types.Repository) error {
|
func (c *Controller) DeleteNoAuth(ctx context.Context, session *auth.Session, repo *types.Repository) error {
|
||||||
if err := c.DeleteGitRPCRepositories(ctx, session, repo); err != nil {
|
if err := c.deleteGitRPCRepository(ctx, session, repo); err != nil {
|
||||||
return err
|
return fmt.Errorf("failed to delete git repository: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.repoStore.Delete(ctx, repo.ID); err != nil {
|
if err := c.repoStore.Delete(ctx, repo.ID); err != nil {
|
||||||
return err
|
return fmt.Errorf("failed to delete repo from db: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) DeleteGitRPCRepositories(
|
func (c *Controller) deleteGitRPCRepository(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
session *auth.Session, repo *types.Repository,
|
session *auth.Session,
|
||||||
|
repo *types.Repository,
|
||||||
) error {
|
) error {
|
||||||
writeParams, err := CreateRPCWriteParams(ctx, c.urlProvider, session, repo)
|
writeParams, err := CreateRPCWriteParams(ctx, c.urlProvider, session, repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -90,7 +90,7 @@ func (c *Controller) sanitizeCreateInput(in *CreateInput) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
in.DisplayName = strings.TrimSpace(in.DisplayName)
|
in.DisplayName = strings.TrimSpace(in.DisplayName)
|
||||||
if err := check.DisplayName(in.DisplayName); err != nil {
|
if err := check.DisplayName(in.DisplayName); err != nil { //nolint:revive
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ func (c *Controller) sanitizeCreateInput(in *CreateInput, uid string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := check.ServiceAccountParent(in.ParentType, in.ParentID); err != nil {
|
if err := check.ServiceAccountParent(in.ParentType, in.ParentID); err != nil { //nolint:revive
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ func (c *Controller) sanitizeCreateInput(in *CreateInput) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
in.Description = strings.TrimSpace(in.Description)
|
in.Description = strings.TrimSpace(in.Description)
|
||||||
if err := check.Description(in.Description); err != nil {
|
if err := check.Description(in.Description); err != nil { //nolint:revive
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ func (c *Controller) checkCreateInput(in *CreateInput) error {
|
|||||||
if err := checkActions(in.Actions); err != nil {
|
if err := checkActions(in.Actions); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := c.uidCheck(in.UID, false); err != nil {
|
if err := c.uidCheck(in.UID, false); err != nil { //nolint:revive
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ func (c *Controller) sanitizeCreateInput(in *CreateInput) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := check.Password(in.Password); err != nil {
|
if err := check.Password(in.Password); err != nil { //nolint:revive
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/harness/gitness/app/api/usererror"
|
"github.com/harness/gitness/app/api/usererror"
|
||||||
"github.com/harness/gitness/app/auth"
|
|
||||||
"github.com/harness/gitness/app/token"
|
"github.com/harness/gitness/app/token"
|
||||||
"github.com/harness/gitness/store"
|
"github.com/harness/gitness/store"
|
||||||
"github.com/harness/gitness/types"
|
"github.com/harness/gitness/types"
|
||||||
@ -40,8 +39,10 @@ type LoginInput struct {
|
|||||||
/*
|
/*
|
||||||
* Login attempts to login as a specific user - returns the session token if successful.
|
* Login attempts to login as a specific user - returns the session token if successful.
|
||||||
*/
|
*/
|
||||||
func (c *Controller) Login(ctx context.Context, session *auth.Session,
|
func (c *Controller) Login(
|
||||||
in *LoginInput) (*types.TokenResponse, error) {
|
ctx context.Context,
|
||||||
|
in *LoginInput,
|
||||||
|
) (*types.TokenResponse, error) {
|
||||||
// no auth check required, password is used for it.
|
// no auth check required, password is used for it.
|
||||||
|
|
||||||
user, err := findUserFromUID(ctx, c.principalStore, in.LoginIdentifier)
|
user, err := findUserFromUID(ctx, c.principalStore, in.LoginIdentifier)
|
||||||
|
@ -104,7 +104,7 @@ func checkCreateInput(in *CreateInput, allowLoopback bool, allowPrivateNetwork b
|
|||||||
if err := checkSecret(in.Secret); err != nil {
|
if err := checkSecret(in.Secret); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := checkTriggers(in.Triggers); err != nil {
|
if err := checkTriggers(in.Triggers); err != nil { //nolint:revive
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
|
|
||||||
"github.com/harness/gitness/app/api/controller/user"
|
"github.com/harness/gitness/app/api/controller/user"
|
||||||
"github.com/harness/gitness/app/api/render"
|
"github.com/harness/gitness/app/api/render"
|
||||||
"github.com/harness/gitness/app/api/request"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// HandleLogin returns an http.HandlerFunc that authenticates
|
// HandleLogin returns an http.HandlerFunc that authenticates
|
||||||
@ -28,7 +27,6 @@ import (
|
|||||||
func HandleLogin(userCtrl *user.Controller, cookieName string) http.HandlerFunc {
|
func HandleLogin(userCtrl *user.Controller, cookieName string) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
session, _ := request.AuthSessionFrom(ctx)
|
|
||||||
|
|
||||||
in := new(user.LoginInput)
|
in := new(user.LoginInput)
|
||||||
err := json.NewDecoder(r.Body).Decode(in)
|
err := json.NewDecoder(r.Body).Decode(in)
|
||||||
@ -37,7 +35,7 @@ func HandleLogin(userCtrl *user.Controller, cookieName string) http.HandlerFunc
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenResponse, err := userCtrl.Login(ctx, session, in)
|
tokenResponse, err := userCtrl.Login(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
render.TranslatedUserError(w, err)
|
render.TranslatedUserError(w, err)
|
||||||
return
|
return
|
||||||
|
@ -18,6 +18,6 @@ import "net/http"
|
|||||||
|
|
||||||
// HandleHealth writes a 200 OK status to the http.Response
|
// HandleHealth writes a 200 OK status to the http.Response
|
||||||
// if the server is healthy.
|
// if the server is healthy.
|
||||||
func HandleHealth(w http.ResponseWriter, r *http.Request) {
|
func HandleHealth(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,6 @@ import (
|
|||||||
|
|
||||||
// HandleVersion writes the server version number
|
// HandleVersion writes the server version number
|
||||||
// to the http.Response body in plain text.
|
// to the http.Response body in plain text.
|
||||||
func HandleVersion(w http.ResponseWriter, r *http.Request) {
|
func HandleVersion(w http.ResponseWriter, _ *http.Request) {
|
||||||
fmt.Fprintf(w, "%s", version.Version)
|
fmt.Fprintf(w, "%s", version.Version)
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ func PaginationNoTotal(r *http.Request, w http.ResponseWriter, page int, size in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PaginationLimit writes the x-total header.
|
// PaginationLimit writes the x-total header.
|
||||||
func PaginationLimit(r *http.Request, w http.ResponseWriter, total int) {
|
func PaginationLimit(_ *http.Request, w http.ResponseWriter, total int) {
|
||||||
w.Header().Set("x-total", strconv.Itoa(total))
|
w.Header().Set("x-total", strconv.Itoa(total))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,8 @@ func (a *MembershipAuthorizer) Check(
|
|||||||
|
|
||||||
func (a *MembershipAuthorizer) CheckAll(ctx context.Context, session *auth.Session,
|
func (a *MembershipAuthorizer) CheckAll(ctx context.Context, session *auth.Session,
|
||||||
permissionChecks ...types.PermissionCheck) (bool, error) {
|
permissionChecks ...types.PermissionCheck) (bool, error) {
|
||||||
for _, p := range permissionChecks {
|
for i := range permissionChecks {
|
||||||
|
p := permissionChecks[i]
|
||||||
if _, err := a.Check(ctx, session, &p.Scope, &p.Resource, p.Permission); err != nil {
|
if _, err := a.Check(ctx, session, &p.Scope, &p.Resource, p.Permission); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,8 @@ func (a *UnsafeAuthorizer) Check(ctx context.Context, session *auth.Session,
|
|||||||
}
|
}
|
||||||
func (a *UnsafeAuthorizer) CheckAll(ctx context.Context, session *auth.Session,
|
func (a *UnsafeAuthorizer) CheckAll(ctx context.Context, session *auth.Session,
|
||||||
permissionChecks ...types.PermissionCheck) (bool, error) {
|
permissionChecks ...types.PermissionCheck) (bool, error) {
|
||||||
for _, p := range permissionChecks {
|
for i := range permissionChecks {
|
||||||
|
p := permissionChecks[i]
|
||||||
if _, err := a.Check(ctx, session, &p.Scope, &p.Resource, p.Permission); err != nil {
|
if _, err := a.Check(ctx, session, &p.Scope, &p.Resource, p.Permission); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -116,8 +116,12 @@ func createAdminUser(
|
|||||||
var findErr error
|
var findErr error
|
||||||
usr, findErr = userCtrl.FindNoAuth(ctx, config.Principal.Admin.UID)
|
usr, findErr = userCtrl.FindNoAuth(ctx, config.Principal.Admin.UID)
|
||||||
if findErr != nil {
|
if findErr != nil {
|
||||||
return nil, fmt.Errorf("failed to find user with uid '%s' (%s) after duplicate error: %w",
|
return nil, fmt.Errorf(
|
||||||
config.Principal.Admin.UID, findErr, createErr)
|
"failed to find user with uid '%s' (%w) after duplicate error: %w",
|
||||||
|
config.Principal.Admin.UID,
|
||||||
|
findErr,
|
||||||
|
createErr,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return usr, nil
|
return usr, nil
|
||||||
@ -210,7 +214,7 @@ func createServicePrincipal(
|
|||||||
svc, findErr = serviceCtrl.FindNoAuth(ctx, uid)
|
svc, findErr = serviceCtrl.FindNoAuth(ctx, uid)
|
||||||
if findErr != nil {
|
if findErr != nil {
|
||||||
return nil, fmt.Errorf(
|
return nil, fmt.Errorf(
|
||||||
"failed to find service with uid '%s' (%s) after duplicate error: %w",
|
"failed to find service with uid '%s' (%w) after duplicate error: %w",
|
||||||
uid,
|
uid,
|
||||||
findErr,
|
findErr,
|
||||||
createErr,
|
createErr,
|
||||||
|
@ -43,19 +43,19 @@ func NewEmbeddedClient(manager ExecutionManager, config *types.Config) client.Cl
|
|||||||
|
|
||||||
// Join notifies the server the runner is joining the cluster.
|
// Join notifies the server the runner is joining the cluster.
|
||||||
// Since the runner is embedded, this can just return nil.
|
// Since the runner is embedded, this can just return nil.
|
||||||
func (e *embedded) Join(ctx context.Context, machine string) error {
|
func (e *embedded) Join(_ context.Context, _ string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leave notifies the server the runner is leaving the cluster.
|
// Leave notifies the server the runner is leaving the cluster.
|
||||||
// Since the runner is embedded, this can just return nil.
|
// Since the runner is embedded, this can just return nil.
|
||||||
func (e *embedded) Leave(ctx context.Context, machine string) error {
|
func (e *embedded) Leave(_ context.Context, _ string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ping sends a ping message to the server to test connectivity.
|
// Ping sends a ping message to the server to test connectivity.
|
||||||
// Since the runner is embedded, this can just return nil.
|
// Since the runner is embedded, this can just return nil.
|
||||||
func (e *embedded) Ping(ctx context.Context, machine string) error {
|
func (e *embedded) Ping(_ context.Context, _ string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ func (e *embedded) Upload(ctx context.Context, step int64, l []*drone.Line) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UploadCard uploads a card to drone server.
|
// UploadCard uploads a card to drone server.
|
||||||
func (e *embedded) UploadCard(ctx context.Context, step int64, card *drone.CardInput) error {
|
func (e *embedded) UploadCard(_ context.Context, _ int64, _ *drone.CardInput) error {
|
||||||
// Implement UploadCard logic here
|
// Implement UploadCard logic here
|
||||||
return nil // Replace with appropriate error handling and logic
|
return nil // Replace with appropriate error handling and logic
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ func (m *Manager) Request(ctx context.Context, args *Request) (*types.Stage, err
|
|||||||
|
|
||||||
// Accept accepts the build stage for execution. It is possible for multiple
|
// Accept accepts the build stage for execution. It is possible for multiple
|
||||||
// agents to pull the same stage from the queue.
|
// agents to pull the same stage from the queue.
|
||||||
func (m *Manager) Accept(ctx context.Context, id int64, machine string) (*types.Stage, error) {
|
func (m *Manager) Accept(_ context.Context, id int64, machine string) (*types.Stage, error) {
|
||||||
log := log.With().
|
log := log.With().
|
||||||
Int64("stage-id", id).
|
Int64("stage-id", id).
|
||||||
Str("machine", machine).
|
Str("machine", machine).
|
||||||
@ -270,7 +270,7 @@ func (m *Manager) UploadLogs(ctx context.Context, step int64, r io.Reader) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Details provides details about the stage.
|
// Details provides details about the stage.
|
||||||
func (m *Manager) Details(ctx context.Context, stageID int64) (*ExecutionContext, error) {
|
func (m *Manager) Details(_ context.Context, stageID int64) (*ExecutionContext, error) {
|
||||||
log := log.With().
|
log := log.With().
|
||||||
Int64("stage-id", stageID).
|
Int64("stage-id", stageID).
|
||||||
Logger()
|
Logger()
|
||||||
@ -367,7 +367,7 @@ func (m *Manager) createNetrc(repo *types.Repository) (*Netrc, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Before signals the build step is about to start.
|
// Before signals the build step is about to start.
|
||||||
func (m *Manager) BeforeStep(ctx context.Context, step *types.Step) error {
|
func (m *Manager) BeforeStep(_ context.Context, step *types.Step) error {
|
||||||
log := log.With().
|
log := log.With().
|
||||||
Str("step.status", string(step.Status)).
|
Str("step.status", string(step.Status)).
|
||||||
Str("step.name", step.Name).
|
Str("step.name", step.Name).
|
||||||
@ -392,7 +392,7 @@ func (m *Manager) BeforeStep(ctx context.Context, step *types.Step) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// After signals the build step is complete.
|
// After signals the build step is complete.
|
||||||
func (m *Manager) AfterStep(ctx context.Context, step *types.Step) error {
|
func (m *Manager) AfterStep(_ context.Context, step *types.Step) error {
|
||||||
log := log.With().
|
log := log.With().
|
||||||
Str("step.status", string(step.Status)).
|
Str("step.status", string(step.Status)).
|
||||||
Str("step.name", step.Name).
|
Str("step.name", step.Name).
|
||||||
@ -421,7 +421,7 @@ func (m *Manager) AfterStep(ctx context.Context, step *types.Step) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BeforeAll signals the build stage is about to start.
|
// BeforeAll signals the build stage is about to start.
|
||||||
func (m *Manager) BeforeStage(ctx context.Context, stage *types.Stage) error {
|
func (m *Manager) BeforeStage(_ context.Context, stage *types.Stage) error {
|
||||||
s := &setup{
|
s := &setup{
|
||||||
Executions: m.Executions,
|
Executions: m.Executions,
|
||||||
Checks: m.Checks,
|
Checks: m.Checks,
|
||||||
@ -437,7 +437,7 @@ func (m *Manager) BeforeStage(ctx context.Context, stage *types.Stage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AfterAll signals the build stage is complete.
|
// AfterAll signals the build stage is complete.
|
||||||
func (m *Manager) AfterStage(ctx context.Context, stage *types.Stage) error {
|
func (m *Manager) AfterStage(_ context.Context, stage *types.Stage) error {
|
||||||
t := &teardown{
|
t := &teardown{
|
||||||
Executions: m.Executions,
|
Executions: m.Executions,
|
||||||
Pipelines: m.Pipelines,
|
Pipelines: m.Pipelines,
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
|
||||||
"github.com/harness/gitness/app/pipeline/logger"
|
"github.com/harness/gitness/app/pipeline/logger"
|
||||||
"github.com/harness/gitness/types"
|
|
||||||
|
|
||||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||||
runtime2 "github.com/drone-runners/drone-runner-docker/engine2/runtime"
|
runtime2 "github.com/drone-runners/drone-runner-docker/engine2/runtime"
|
||||||
@ -32,7 +31,6 @@ import (
|
|||||||
|
|
||||||
func NewExecutionPoller(
|
func NewExecutionPoller(
|
||||||
runner *runtime2.Runner,
|
runner *runtime2.Runner,
|
||||||
config *types.Config,
|
|
||||||
client runnerclient.Client,
|
client runnerclient.Client,
|
||||||
) *poller.Poller {
|
) *poller.Poller {
|
||||||
runWithRecovery := func(ctx context.Context, stage *drone.Stage) (err error) {
|
runWithRecovery := func(ctx context.Context, stage *drone.Stage) (err error) {
|
||||||
@ -44,7 +42,7 @@ func NewExecutionPoller(
|
|||||||
|
|
||||||
// the caller of this method (poller.Poller) discards the error - log it here
|
// the caller of this method (poller.Poller) discards the error - log it here
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Ctx(ctx).Error().Err(err).Msgf("An error occured while calling runner.Run in Poller")
|
log.Ctx(ctx).Error().Err(err).Msgf("An error occurred while calling runner.Run in Poller")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return runner.Run(ctx, stage)
|
return runner.Run(ctx, stage)
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package runner
|
package runner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/harness/gitness/app/pipeline/manager"
|
|
||||||
"github.com/harness/gitness/app/pipeline/plugin"
|
"github.com/harness/gitness/app/pipeline/plugin"
|
||||||
"github.com/harness/gitness/types"
|
"github.com/harness/gitness/types"
|
||||||
|
|
||||||
@ -52,7 +51,6 @@ func NewExecutionRunner(
|
|||||||
config *types.Config,
|
config *types.Config,
|
||||||
client runnerclient.Client,
|
client runnerclient.Client,
|
||||||
pluginManager *plugin.Manager,
|
pluginManager *plugin.Manager,
|
||||||
m manager.ExecutionManager,
|
|
||||||
) (*runtime2.Runner, error) {
|
) (*runtime2.Runner, error) {
|
||||||
// For linux, containers need to have extra hosts set in order to interact with
|
// For linux, containers need to have extra hosts set in order to interact with
|
||||||
// the gitness container.
|
// the gitness container.
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package runner
|
package runner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/harness/gitness/app/pipeline/manager"
|
|
||||||
"github.com/harness/gitness/app/pipeline/plugin"
|
"github.com/harness/gitness/app/pipeline/plugin"
|
||||||
"github.com/harness/gitness/types"
|
"github.com/harness/gitness/types"
|
||||||
|
|
||||||
@ -36,17 +35,15 @@ func ProvideExecutionRunner(
|
|||||||
config *types.Config,
|
config *types.Config,
|
||||||
client runnerclient.Client,
|
client runnerclient.Client,
|
||||||
pluginManager *plugin.Manager,
|
pluginManager *plugin.Manager,
|
||||||
manager manager.ExecutionManager,
|
|
||||||
) (*runtime2.Runner, error) {
|
) (*runtime2.Runner, error) {
|
||||||
return NewExecutionRunner(config, client, pluginManager, manager)
|
return NewExecutionRunner(config, client, pluginManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProvideExecutionPoller provides a poller which can poll the manager
|
// ProvideExecutionPoller provides a poller which can poll the manager
|
||||||
// for new builds and execute them.
|
// for new builds and execute them.
|
||||||
func ProvideExecutionPoller(
|
func ProvideExecutionPoller(
|
||||||
runner *runtime2.Runner,
|
runner *runtime2.Runner,
|
||||||
config *types.Config,
|
|
||||||
client runnerclient.Client,
|
client runnerclient.Client,
|
||||||
) *poller.Poller {
|
) *poller.Poller {
|
||||||
return NewExecutionPoller(runner, config, client)
|
return NewExecutionPoller(runner, client)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func newCanceler() *canceler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *canceler) Cancel(ctx context.Context, id int64) error {
|
func (c *canceler) Cancel(_ context.Context, id int64) error {
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
c.cancelled[id] = time.Now().Add(time.Minute * 5)
|
c.cancelled[id] = time.Now().Add(time.Minute * 5)
|
||||||
|
@ -63,7 +63,7 @@ func newQueue(store store.StageStore, lock lock.MutexManager) (*queue, error) {
|
|||||||
return q, nil
|
return q, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *queue) Schedule(ctx context.Context, stage *types.Stage) error {
|
func (q *queue) Schedule(_ context.Context, _ *types.Stage) error {
|
||||||
select {
|
select {
|
||||||
case q.ready <- struct{}{}:
|
case q.ready <- struct{}{}:
|
||||||
default:
|
default:
|
||||||
@ -71,7 +71,7 @@ func (q *queue) Schedule(ctx context.Context, stage *types.Stage) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *queue) Pause(ctx context.Context) error {
|
func (q *queue) Pause(_ context.Context) error {
|
||||||
q.Lock()
|
q.Lock()
|
||||||
q.paused = true
|
q.paused = true
|
||||||
q.Unlock()
|
q.Unlock()
|
||||||
|
@ -30,7 +30,6 @@ import (
|
|||||||
"github.com/harness/gitness/app/store"
|
"github.com/harness/gitness/app/store"
|
||||||
"github.com/harness/gitness/app/url"
|
"github.com/harness/gitness/app/url"
|
||||||
"github.com/harness/gitness/gitrpc"
|
"github.com/harness/gitness/gitrpc"
|
||||||
"github.com/harness/gitness/types"
|
|
||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
"github.com/go-chi/chi/middleware"
|
"github.com/go-chi/chi/middleware"
|
||||||
@ -44,7 +43,6 @@ type GitHandler interface {
|
|||||||
|
|
||||||
// NewGitHandler returns a new GitHandler.
|
// NewGitHandler returns a new GitHandler.
|
||||||
func NewGitHandler(
|
func NewGitHandler(
|
||||||
config *types.Config,
|
|
||||||
urlProvider url.Provider,
|
urlProvider url.Provider,
|
||||||
repoStore store.RepoStore,
|
repoStore store.RepoStore,
|
||||||
authenticator authn.Authenticator,
|
authenticator authn.Authenticator,
|
||||||
@ -85,14 +83,14 @@ func NewGitHandler(
|
|||||||
r.Get("/info/refs", handlerrepo.GetInfoRefs(client, repoStore, authorizer))
|
r.Get("/info/refs", handlerrepo.GetInfoRefs(client, repoStore, authorizer))
|
||||||
|
|
||||||
// dumb protocol
|
// dumb protocol
|
||||||
r.Get("/HEAD", stubGitHandler(repoStore))
|
r.Get("/HEAD", stubGitHandler())
|
||||||
r.Get("/objects/info/alternates", stubGitHandler(repoStore))
|
r.Get("/objects/info/alternates", stubGitHandler())
|
||||||
r.Get("/objects/info/http-alternates", stubGitHandler(repoStore))
|
r.Get("/objects/info/http-alternates", stubGitHandler())
|
||||||
r.Get("/objects/info/packs", stubGitHandler(repoStore))
|
r.Get("/objects/info/packs", stubGitHandler())
|
||||||
r.Get("/objects/info/{file:[^/]*}", stubGitHandler(repoStore))
|
r.Get("/objects/info/{file:[^/]*}", stubGitHandler())
|
||||||
r.Get("/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38}}", stubGitHandler(repoStore))
|
r.Get("/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38}}", stubGitHandler())
|
||||||
r.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.pack", stubGitHandler(repoStore))
|
r.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.pack", stubGitHandler())
|
||||||
r.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.idx", stubGitHandler(repoStore))
|
r.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.idx", stubGitHandler())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -100,7 +98,7 @@ func NewGitHandler(
|
|||||||
return encode.GitPathBefore(r)
|
return encode.GitPathBefore(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stubGitHandler(repoStore store.RepoStore) http.HandlerFunc {
|
func stubGitHandler() http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
_, _ = w.Write([]byte("Seems like an asteroid destroyed the ancient git protocol"))
|
_, _ = w.Write([]byte("Seems like an asteroid destroyed the ancient git protocol"))
|
||||||
w.WriteHeader(http.StatusBadGateway)
|
w.WriteHeader(http.StatusBadGateway)
|
||||||
|
@ -55,7 +55,6 @@ var WireSet = wire.NewSet(
|
|||||||
)
|
)
|
||||||
|
|
||||||
func ProvideRouter(
|
func ProvideRouter(
|
||||||
config *types.Config,
|
|
||||||
api APIHandler,
|
api APIHandler,
|
||||||
git GitHandler,
|
git GitHandler,
|
||||||
web WebHandler,
|
web WebHandler,
|
||||||
@ -76,7 +75,6 @@ func ProvideRouter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ProvideGitHandler(
|
func ProvideGitHandler(
|
||||||
config *types.Config,
|
|
||||||
urlProvider url.Provider,
|
urlProvider url.Provider,
|
||||||
repoStore store.RepoStore,
|
repoStore store.RepoStore,
|
||||||
authenticator authn.Authenticator,
|
authenticator authn.Authenticator,
|
||||||
@ -85,7 +83,6 @@ func ProvideGitHandler(
|
|||||||
repoCtrl *repo.Controller,
|
repoCtrl *repo.Controller,
|
||||||
) GitHandler {
|
) GitHandler {
|
||||||
return NewGitHandler(
|
return NewGitHandler(
|
||||||
config,
|
|
||||||
urlProvider,
|
urlProvider,
|
||||||
repoStore,
|
repoStore,
|
||||||
authenticator,
|
authenticator,
|
||||||
|
@ -33,13 +33,13 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
CodeOwnerFilePath string
|
FilePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
repoStore store.RepoStore
|
repoStore store.RepoStore
|
||||||
git gitrpc.Interface
|
git gitrpc.Interface
|
||||||
Config Config
|
config Config
|
||||||
}
|
}
|
||||||
|
|
||||||
type codeOwnerFile struct {
|
type codeOwnerFile struct {
|
||||||
@ -48,11 +48,11 @@ type codeOwnerFile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CodeOwners struct {
|
type CodeOwners struct {
|
||||||
CodeOwnerFileSha string
|
FileSHA string
|
||||||
CodeOwnerDetails []codeOwnerDetail
|
Entries []Entry
|
||||||
}
|
}
|
||||||
|
|
||||||
type codeOwnerDetail struct {
|
type Entry struct {
|
||||||
Pattern string
|
Pattern string
|
||||||
Owners []string
|
Owners []string
|
||||||
}
|
}
|
||||||
@ -62,11 +62,10 @@ func New(
|
|||||||
git gitrpc.Interface,
|
git gitrpc.Interface,
|
||||||
config Config,
|
config Config,
|
||||||
) (*Service, error) {
|
) (*Service, error) {
|
||||||
|
|
||||||
service := &Service{
|
service := &Service{
|
||||||
repoStore: repoStore,
|
repoStore: repoStore,
|
||||||
git: git,
|
git: git,
|
||||||
Config: config,
|
config: config,
|
||||||
}
|
}
|
||||||
return service, nil
|
return service, nil
|
||||||
}
|
}
|
||||||
@ -79,22 +78,22 @@ func (s *Service) Get(ctx context.Context,
|
|||||||
}
|
}
|
||||||
codeOwnerFile, err := s.getCodeOwnerFile(ctx, repo)
|
codeOwnerFile, err := s.getCodeOwnerFile(ctx, repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to get codeowner details %w", err)
|
return nil, fmt.Errorf("unable to get codeowner file %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
owner, err := s.ParseCodeOwner(codeOwnerFile.Content)
|
owner, err := s.parseCodeOwner(codeOwnerFile.Content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to parse codeowner %w", err)
|
return nil, fmt.Errorf("unable to parse codeowner %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &CodeOwners{
|
return &CodeOwners{
|
||||||
CodeOwnerFileSha: codeOwnerFile.SHA,
|
FileSHA: codeOwnerFile.SHA,
|
||||||
CodeOwnerDetails: owner,
|
Entries: owner,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) ParseCodeOwner(codeOwnersContent string) ([]codeOwnerDetail, error) {
|
func (s *Service) parseCodeOwner(codeOwnersContent string) ([]Entry, error) {
|
||||||
var codeOwners []codeOwnerDetail
|
var codeOwners []Entry
|
||||||
scanner := bufio.NewScanner(strings.NewReader(codeOwnersContent))
|
scanner := bufio.NewScanner(strings.NewReader(codeOwnersContent))
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
@ -105,13 +104,13 @@ func (s *Service) ParseCodeOwner(codeOwnersContent string) ([]codeOwnerDetail, e
|
|||||||
|
|
||||||
parts := strings.Split(line, " ")
|
parts := strings.Split(line, " ")
|
||||||
if len(parts) < 2 {
|
if len(parts) < 2 {
|
||||||
return nil, fmt.Errorf("invalid line: %s", line)
|
return nil, fmt.Errorf("line has invalid format: '%s'", line)
|
||||||
}
|
}
|
||||||
|
|
||||||
pattern := parts[0]
|
pattern := parts[0]
|
||||||
owners := parts[1:]
|
owners := parts[1:]
|
||||||
|
|
||||||
codeOwner := codeOwnerDetail{
|
codeOwner := Entry{
|
||||||
Pattern: pattern,
|
Pattern: pattern,
|
||||||
Owners: owners,
|
Owners: owners,
|
||||||
}
|
}
|
||||||
@ -119,7 +118,7 @@ func (s *Service) ParseCodeOwner(codeOwnersContent string) ([]codeOwnerDetail, e
|
|||||||
codeOwners = append(codeOwners, codeOwner)
|
codeOwners = append(codeOwners, codeOwner)
|
||||||
}
|
}
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
return nil, fmt.Errorf("error reading input: %v", err)
|
return nil, fmt.Errorf("error reading input: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return codeOwners, nil
|
return codeOwners, nil
|
||||||
@ -132,16 +131,19 @@ func (s *Service) getCodeOwnerFile(ctx context.Context,
|
|||||||
node, err := s.git.GetTreeNode(ctx, &gitrpc.GetTreeNodeParams{
|
node, err := s.git.GetTreeNode(ctx, &gitrpc.GetTreeNodeParams{
|
||||||
ReadParams: params,
|
ReadParams: params,
|
||||||
GitREF: "refs/heads/" + repo.DefaultBranch,
|
GitREF: "refs/heads/" + repo.DefaultBranch,
|
||||||
Path: s.Config.CodeOwnerFilePath,
|
Path: s.config.FilePath,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// todo: check for path not found and return empty codeowners
|
// TODO: check for path not found and return empty codeowners
|
||||||
return nil, fmt.Errorf("unable to retrieve codeowner file %w", err)
|
return nil, fmt.Errorf("unable to retrieve codeowner file %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.Node.Mode != gitrpc.TreeNodeModeFile {
|
if node.Node.Mode != gitrpc.TreeNodeModeFile {
|
||||||
return nil, fmt.Errorf("codeowner file not of right format")
|
return nil, fmt.Errorf(
|
||||||
|
"codeowner file is of format '%s' but expected to be of format '%s'",
|
||||||
|
node.Node.Mode,
|
||||||
|
gitrpc.TreeNodeModeFile,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err := s.git.GetBlob(ctx, &gitrpc.GetBlobParams{
|
output, err := s.git.GetBlob(ctx, &gitrpc.GetBlobParams{
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright 2023 Harness, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package codeowners
|
package codeowners
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -9,9 +23,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestService_ParseCodeOwner(t *testing.T) {
|
func TestService_ParseCodeOwner(t *testing.T) {
|
||||||
content1 := "**/contracts/openapi/v1/ mankrit.singh@harness.io ashish.sanodia@harness.io\n"
|
content1 := `**/contracts/openapi/v1/ mankrit.singh@harness.io ashish.sanodia@harness.io
|
||||||
content2 := "**/contracts/openapi/v1/ mankrit.singh@harness.io ashish.sanodia@harness.io\n/scripts/api mankrit.singh@harness.io ashish.sanodia@harness.io"
|
`
|
||||||
content3 := "# codeowner file \n**/contracts/openapi/v1/ mankrit.singh@harness.io ashish.sanodia@harness.io\n#\n/scripts/api mankrit.singh@harness.io ashish.sanodia@harness.io"
|
content2 := `**/contracts/openapi/v1/ mankrit.singh@harness.io ashish.sanodia@harness.io
|
||||||
|
/scripts/api mankrit.singh@harness.io ashish.sanodia@harness.io`
|
||||||
|
content3 := `# codeowner file
|
||||||
|
**/contracts/openapi/v1/ mankrit.singh@harness.io ashish.sanodia@harness.io
|
||||||
|
#
|
||||||
|
/scripts/api mankrit.singh@harness.io ashish.sanodia@harness.io`
|
||||||
type fields struct {
|
type fields struct {
|
||||||
repoStore store.RepoStore
|
repoStore store.RepoStore
|
||||||
git gitrpc.Interface
|
git gitrpc.Interface
|
||||||
@ -24,13 +43,13 @@ func TestService_ParseCodeOwner(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
fields fields
|
fields fields
|
||||||
args args
|
args args
|
||||||
want []codeOwnerDetail
|
want []Entry
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Code owners Single",
|
name: "Code owners Single",
|
||||||
args: args{codeOwnersContent: content1},
|
args: args{codeOwnersContent: content1},
|
||||||
want: []codeOwnerDetail{{
|
want: []Entry{{
|
||||||
Pattern: "**/contracts/openapi/v1/",
|
Pattern: "**/contracts/openapi/v1/",
|
||||||
Owners: []string{"mankrit.singh@harness.io", "ashish.sanodia@harness.io"},
|
Owners: []string{"mankrit.singh@harness.io", "ashish.sanodia@harness.io"},
|
||||||
},
|
},
|
||||||
@ -39,7 +58,7 @@ func TestService_ParseCodeOwner(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Code owners Multiple",
|
name: "Code owners Multiple",
|
||||||
args: args{codeOwnersContent: content2},
|
args: args{codeOwnersContent: content2},
|
||||||
want: []codeOwnerDetail{{
|
want: []Entry{{
|
||||||
Pattern: "**/contracts/openapi/v1/",
|
Pattern: "**/contracts/openapi/v1/",
|
||||||
Owners: []string{"mankrit.singh@harness.io", "ashish.sanodia@harness.io"},
|
Owners: []string{"mankrit.singh@harness.io", "ashish.sanodia@harness.io"},
|
||||||
},
|
},
|
||||||
@ -52,7 +71,7 @@ func TestService_ParseCodeOwner(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Code owners With comments",
|
name: "Code owners With comments",
|
||||||
args: args{codeOwnersContent: content3},
|
args: args{codeOwnersContent: content3},
|
||||||
want: []codeOwnerDetail{{
|
want: []Entry{{
|
||||||
Pattern: "**/contracts/openapi/v1/",
|
Pattern: "**/contracts/openapi/v1/",
|
||||||
Owners: []string{"mankrit.singh@harness.io", "ashish.sanodia@harness.io"},
|
Owners: []string{"mankrit.singh@harness.io", "ashish.sanodia@harness.io"},
|
||||||
},
|
},
|
||||||
@ -68,9 +87,9 @@ func TestService_ParseCodeOwner(t *testing.T) {
|
|||||||
s := &Service{
|
s := &Service{
|
||||||
repoStore: tt.fields.repoStore,
|
repoStore: tt.fields.repoStore,
|
||||||
git: tt.fields.git,
|
git: tt.fields.git,
|
||||||
Config: tt.fields.Config,
|
config: tt.fields.Config,
|
||||||
}
|
}
|
||||||
got, err := s.ParseCodeOwner(tt.args.codeOwnersContent)
|
got, err := s.parseCodeOwner(tt.args.codeOwnersContent)
|
||||||
if (err != nil) != tt.wantErr {
|
if (err != nil) != tt.wantErr {
|
||||||
t.Errorf("ParseCodeOwner() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("ParseCodeOwner() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
||||||
|
@ -439,7 +439,8 @@ func (s *MembershipStore) mapToMembershipUsers(ctx context.Context,
|
|||||||
|
|
||||||
// attach the principal infos back to the slice items
|
// attach the principal infos back to the slice items
|
||||||
res := make([]types.MembershipUser, len(ms))
|
res := make([]types.MembershipUser, len(ms))
|
||||||
for i, m := range ms {
|
for i := range ms {
|
||||||
|
m := ms[i]
|
||||||
res[i].Membership = mapToMembership(&m.membership)
|
res[i].Membership = mapToMembership(&m.membership)
|
||||||
res[i].Principal = mapToPrincipalInfo(&m.principalInfo)
|
res[i].Principal = mapToPrincipalInfo(&m.principalInfo)
|
||||||
if addedBy, ok := infoMap[m.membership.CreatedBy]; ok {
|
if addedBy, ok := infoMap[m.membership.CreatedBy]; ok {
|
||||||
@ -467,7 +468,8 @@ func (s *MembershipStore) mapToMembershipSpaces(ctx context.Context,
|
|||||||
|
|
||||||
// attach the principal infos back to the slice items
|
// attach the principal infos back to the slice items
|
||||||
res := make([]types.MembershipSpace, len(ms))
|
res := make([]types.MembershipSpace, len(ms))
|
||||||
for i, m := range ms {
|
for i := range ms {
|
||||||
|
m := ms[i]
|
||||||
res[i].Membership = mapToMembership(&m.membership)
|
res[i].Membership = mapToMembership(&m.membership)
|
||||||
space, err := mapToSpace(ctx, s.spacePathStore, &m.space)
|
space, err := mapToSpace(ctx, s.spacePathStore, &m.space)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -56,7 +56,7 @@ type s3store struct {
|
|||||||
session *session.Session
|
session *session.Session
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *s3store) Find(ctx context.Context, step int64) (io.ReadCloser, error) {
|
func (s *s3store) Find(_ context.Context, step int64) (io.ReadCloser, error) {
|
||||||
svc := s3.New(s.session)
|
svc := s3.New(s.session)
|
||||||
out, err := svc.GetObject(&s3.GetObjectInput{
|
out, err := svc.GetObject(&s3.GetObjectInput{
|
||||||
Bucket: aws.String(s.bucket),
|
Bucket: aws.String(s.bucket),
|
||||||
@ -68,7 +68,7 @@ func (s *s3store) Find(ctx context.Context, step int64) (io.ReadCloser, error) {
|
|||||||
return out.Body, nil
|
return out.Body, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *s3store) Create(ctx context.Context, step int64, r io.Reader) error {
|
func (s *s3store) Create(_ context.Context, step int64, r io.Reader) error {
|
||||||
uploader := s3manager.NewUploader(s.session)
|
uploader := s3manager.NewUploader(s.session)
|
||||||
input := &s3manager.UploadInput{
|
input := &s3manager.UploadInput{
|
||||||
ACL: aws.String("private"),
|
ACL: aws.String("private"),
|
||||||
@ -84,7 +84,7 @@ func (s *s3store) Update(ctx context.Context, step int64, r io.Reader) error {
|
|||||||
return s.Create(ctx, step, r)
|
return s.Create(ctx, step, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *s3store) Delete(ctx context.Context, step int64) error {
|
func (s *s3store) Delete(_ context.Context, step int64) error {
|
||||||
svc := s3.New(s.session)
|
svc := s3.New(s.session)
|
||||||
_, err := svc.DeleteObject(&s3.DeleteObjectInput{
|
_, err := svc.DeleteObject(&s3.DeleteObjectInput{
|
||||||
Bucket: aws.String(s.bucket),
|
Bucket: aws.String(s.bucket),
|
||||||
|
@ -76,11 +76,11 @@ func (c FileSystemStore) Upload(ctx context.Context,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c FileSystemStore) GetSignedURL(filePath string) (string, error) {
|
func (c FileSystemStore) GetSignedURL(_ string) (string, error) {
|
||||||
return "", ErrNotSupported
|
return "", ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FileSystemStore) Download(ctx context.Context, filePath string) (io.ReadCloser, error) {
|
func (c *FileSystemStore) Download(_ context.Context, filePath string) (io.ReadCloser, error) {
|
||||||
fileDiskPath := fmt.Sprintf(fileDiskPathFmt, c.basePath, filePath)
|
fileDiskPath := fmt.Sprintf(fileDiskPathFmt, c.basePath, filePath)
|
||||||
|
|
||||||
file, err := os.Open(fileDiskPath)
|
file, err := os.Open(fileDiskPath)
|
||||||
|
@ -88,6 +88,6 @@ func (c *GCSStore) GetSignedURL(filePath string) (string, error) {
|
|||||||
}
|
}
|
||||||
return signedURL, nil
|
return signedURL, nil
|
||||||
}
|
}
|
||||||
func (c *GCSStore) Download(ctx context.Context, filePath string) (io.ReadCloser, error) {
|
func (c *GCSStore) Download(_ context.Context, _ string) (io.ReadCloser, error) {
|
||||||
return nil, fmt.Errorf("not implemented")
|
return nil, fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ type commandTo struct {
|
|||||||
version string
|
version string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandTo) run(k *kingpin.ParseContext) error {
|
func (c *commandTo) run(_ *kingpin.ParseContext) error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
@ -339,6 +339,6 @@ func ProvideCleanupConfig(config *types.Config) cleanup.Config {
|
|||||||
// ProvideCodeOwnerConfig loads the codeowner config from the main config.
|
// ProvideCodeOwnerConfig loads the codeowner config from the main config.
|
||||||
func ProvideCodeOwnerConfig(config *types.Config) codeowners.Config {
|
func ProvideCodeOwnerConfig(config *types.Config) codeowners.Config {
|
||||||
return codeowners.Config{
|
return codeowners.Config{
|
||||||
CodeOwnerFilePath: config.CodeOwners.CodeOwnerFilePath,
|
FilePath: config.CodeOwners.FilePath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@ import (
|
|||||||
"github.com/harness/gitness/types/check"
|
"github.com/harness/gitness/types/check"
|
||||||
|
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -246,18 +247,18 @@ func initSystem(ctx context.Context, config *types.Config) (*server.System, erro
|
|||||||
}
|
}
|
||||||
uploadController := upload.ProvideController(authorizer, repoStore, blobStore)
|
uploadController := upload.ProvideController(authorizer, repoStore, blobStore)
|
||||||
apiHandler := router.ProvideAPIHandler(config, authenticator, repoController, executionController, logsController, spaceController, pipelineController, secretController, triggerController, connectorController, templateController, pluginController, pullreqController, webhookController, githookController, serviceaccountController, controller, principalController, checkController, systemController, uploadController)
|
apiHandler := router.ProvideAPIHandler(config, authenticator, repoController, executionController, logsController, spaceController, pipelineController, secretController, triggerController, connectorController, templateController, pluginController, pullreqController, webhookController, githookController, serviceaccountController, controller, principalController, checkController, systemController, uploadController)
|
||||||
gitHandler := router.ProvideGitHandler(config, provider, repoStore, authenticator, authorizer, gitrpcInterface, repoController)
|
gitHandler := router.ProvideGitHandler(provider, repoStore, authenticator, authorizer, gitrpcInterface, repoController)
|
||||||
webHandler := router.ProvideWebHandler(config)
|
webHandler := router.ProvideWebHandler(config)
|
||||||
routerRouter := router.ProvideRouter(config, apiHandler, gitHandler, webHandler, provider)
|
routerRouter := router.ProvideRouter(apiHandler, gitHandler, webHandler, provider)
|
||||||
serverServer := server2.ProvideServer(config, routerRouter)
|
serverServer := server2.ProvideServer(config, routerRouter)
|
||||||
executionManager := manager.ProvideExecutionManager(config, executionStore, pipelineStore, provider, streamer, fileService, logStore, logStream, checkStore, repoStore, schedulerScheduler, secretStore, stageStore, stepStore, principalStore)
|
executionManager := manager.ProvideExecutionManager(config, executionStore, pipelineStore, provider, streamer, fileService, logStore, logStream, checkStore, repoStore, schedulerScheduler, secretStore, stageStore, stepStore, principalStore)
|
||||||
client := manager.ProvideExecutionClient(executionManager, config)
|
client := manager.ProvideExecutionClient(executionManager, config)
|
||||||
pluginManager := plugin2.ProvidePluginManager(config, pluginStore)
|
pluginManager := plugin2.ProvidePluginManager(config, pluginStore)
|
||||||
runtimeRunner, err := runner.ProvideExecutionRunner(config, client, pluginManager, executionManager)
|
runtimeRunner, err := runner.ProvideExecutionRunner(config, client, pluginManager)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
poller := runner.ProvideExecutionPoller(runtimeRunner, config, client)
|
poller := runner.ProvideExecutionPoller(runtimeRunner, client)
|
||||||
serverConfig, err := server.ProvideGitRPCServerConfig()
|
serverConfig, err := server.ProvideGitRPCServerConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -114,7 +114,7 @@ func (r *BlameReader) unreadLine(line string) {
|
|||||||
r.lastLine = line
|
r.lastLine = line
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:complexity,gocognit,nestif // it's ok
|
//nolint:gocognit,nestif // it's ok
|
||||||
func (r *BlameReader) NextPart() (*types.BlamePart, error) {
|
func (r *BlameReader) NextPart() (*types.BlamePart, error) {
|
||||||
var commit *types.Commit
|
var commit *types.Commit
|
||||||
var lines []string
|
var lines []string
|
||||||
|
@ -140,40 +140,43 @@ func giteaGetAnnotatedTags(ctx context.Context, repoPath string, shas []string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parseTagDataFromCatFile parses a tag from a cat-file output.
|
// parseTagDataFromCatFile parses a tag from a cat-file output.
|
||||||
func parseTagDataFromCatFile(data []byte) (tag types.Tag, err error) {
|
func parseTagDataFromCatFile(data []byte) (types.Tag, error) {
|
||||||
p := 0
|
p := 0
|
||||||
|
|
||||||
|
var err error
|
||||||
|
var tag types.Tag
|
||||||
|
|
||||||
// parse object Id
|
// parse object Id
|
||||||
tag.TargetSha, p, err = giteaParseCatFileLine(data, p, "object")
|
tag.TargetSha, p, err = giteaParseCatFileLine(data, p, "object")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return types.Tag{}, fmt.Errorf("failed to parse cat file 'object' line: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse object type
|
// parse object type
|
||||||
rawType, p, err := giteaParseCatFileLine(data, p, "type")
|
rawType, p, err := giteaParseCatFileLine(data, p, "type")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return types.Tag{}, fmt.Errorf("failed to parse cat file 'type' line: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.TargetType, err = types.ParseGitObjectType(rawType)
|
tag.TargetType, err = types.ParseGitObjectType(rawType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return types.Tag{}, fmt.Errorf("failed to parse raw git object type: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse tag name
|
// parse tag name
|
||||||
tag.Name, p, err = giteaParseCatFileLine(data, p, "tag")
|
tag.Name, p, err = giteaParseCatFileLine(data, p, "tag")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return types.Tag{}, fmt.Errorf("failed to parse cat file 'tag' line: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse tagger
|
// parse tagger
|
||||||
rawTaggerInfo, p, err := giteaParseCatFileLine(data, p, "tagger")
|
rawTaggerInfo, p, err := giteaParseCatFileLine(data, p, "tagger")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return types.Tag{}, fmt.Errorf("failed to parse cat file 'tagger' line: %w", err)
|
||||||
}
|
}
|
||||||
tag.Tagger, err = parseSignatureFromCatFileLine(rawTaggerInfo)
|
tag.Tagger, err = parseSignatureFromCatFileLine(rawTaggerInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return types.Tag{}, fmt.Errorf("failed to parse tagger signature: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// remainder is message and gpg (remove leading and tailing new lines)
|
// remainder is message and gpg (remove leading and tailing new lines)
|
||||||
|
@ -71,9 +71,9 @@ func streamBlamePart(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
commit, errMap := mapGitCommit(&part.Commit)
|
commit, err := mapGitCommit(&part.Commit)
|
||||||
if errMap != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to map git commit: %w", errMap)
|
return fmt.Errorf("failed to map git commit: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
lines := make([][]byte, len(part.Lines))
|
lines := make([][]byte, len(part.Lines))
|
||||||
@ -86,8 +86,8 @@ func streamBlamePart(
|
|||||||
Lines: lines,
|
Lines: lines,
|
||||||
}
|
}
|
||||||
|
|
||||||
if errStream := stream.Send(pack); errStream != nil {
|
if err = stream.Send(pack); err != nil {
|
||||||
return errStream
|
return fmt.Errorf("failed to send blame part: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -8,6 +8,7 @@ package rpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -8,6 +8,7 @@ package rpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -151,7 +152,6 @@ type ServicePackRequest struct {
|
|||||||
// Depending on the service the matching base type has to be passed
|
// Depending on the service the matching base type has to be passed
|
||||||
//
|
//
|
||||||
// Types that are assignable to Base:
|
// Types that are assignable to Base:
|
||||||
//
|
|
||||||
// *ServicePackRequest_ReadBase
|
// *ServicePackRequest_ReadBase
|
||||||
// *ServicePackRequest_WriteBase
|
// *ServicePackRequest_WriteBase
|
||||||
Base isServicePackRequest_Base `protobuf_oneof:"base"`
|
Base isServicePackRequest_Base `protobuf_oneof:"base"`
|
||||||
|
@ -8,6 +8,7 @@ package rpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -8,6 +8,7 @@ package rpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -263,7 +264,6 @@ type CommitFilesAction struct {
|
|||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// Types that are assignable to Payload:
|
// Types that are assignable to Payload:
|
||||||
//
|
|
||||||
// *CommitFilesAction_Header
|
// *CommitFilesAction_Header
|
||||||
// *CommitFilesAction_Content
|
// *CommitFilesAction_Content
|
||||||
Payload isCommitFilesAction_Payload `protobuf_oneof:"payload"`
|
Payload isCommitFilesAction_Payload `protobuf_oneof:"payload"`
|
||||||
@ -347,7 +347,6 @@ type CommitFilesRequest struct {
|
|||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// Types that are assignable to Payload:
|
// Types that are assignable to Payload:
|
||||||
//
|
|
||||||
// *CommitFilesRequest_Header
|
// *CommitFilesRequest_Header
|
||||||
// *CommitFilesRequest_Action
|
// *CommitFilesRequest_Action
|
||||||
Payload isCommitFilesRequest_Payload `protobuf_oneof:"payload"`
|
Payload isCommitFilesRequest_Payload `protobuf_oneof:"payload"`
|
||||||
|
@ -8,6 +8,7 @@ package rpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -8,6 +8,7 @@ package rpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -8,6 +8,7 @@ package rpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -216,7 +217,6 @@ type CreateRepositoryRequest struct {
|
|||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// Types that are assignable to Data:
|
// Types that are assignable to Data:
|
||||||
//
|
|
||||||
// *CreateRepositoryRequest_Header
|
// *CreateRepositoryRequest_Header
|
||||||
// *CreateRepositoryRequest_File
|
// *CreateRepositoryRequest_File
|
||||||
Data isCreateRepositoryRequest_Data `protobuf_oneof:"data"`
|
Data isCreateRepositoryRequest_Data `protobuf_oneof:"data"`
|
||||||
@ -1312,7 +1312,6 @@ type GetBlobResponse struct {
|
|||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// Types that are assignable to Data:
|
// Types that are assignable to Data:
|
||||||
//
|
|
||||||
// *GetBlobResponse_Header
|
// *GetBlobResponse_Header
|
||||||
// *GetBlobResponse_Content
|
// *GetBlobResponse_Content
|
||||||
Data isGetBlobResponse_Data `protobuf_oneof:"data"`
|
Data isGetBlobResponse_Data `protobuf_oneof:"data"`
|
||||||
|
@ -8,6 +8,7 @@ package rpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -298,7 +299,6 @@ type FileUpload struct {
|
|||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// Types that are assignable to Data:
|
// Types that are assignable to Data:
|
||||||
//
|
|
||||||
// *FileUpload_Header
|
// *FileUpload_Header
|
||||||
// *FileUpload_Chunk
|
// *FileUpload_Chunk
|
||||||
Data isFileUpload_Data `protobuf_oneof:"data"`
|
Data isFileUpload_Data `protobuf_oneof:"data"`
|
||||||
|
@ -37,14 +37,14 @@ func NewMemory() LogStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *streamer) Create(ctx context.Context, id int64) error {
|
func (s *streamer) Create(_ context.Context, id int64) error {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
s.streams[id] = newStream()
|
s.streams[id] = newStream()
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *streamer) Delete(ctx context.Context, id int64) error {
|
func (s *streamer) Delete(_ context.Context, id int64) error {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
stream, ok := s.streams[id]
|
stream, ok := s.streams[id]
|
||||||
if ok {
|
if ok {
|
||||||
@ -57,7 +57,7 @@ func (s *streamer) Delete(ctx context.Context, id int64) error {
|
|||||||
return stream.close()
|
return stream.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *streamer) Write(ctx context.Context, id int64, line *Line) error {
|
func (s *streamer) Write(_ context.Context, id int64, line *Line) error {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
stream, ok := s.streams[id]
|
stream, ok := s.streams[id]
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
@ -77,7 +77,7 @@ func (s *streamer) Tail(ctx context.Context, id int64) (<-chan *Line, <-chan err
|
|||||||
return stream.subscribe(ctx)
|
return stream.subscribe(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *streamer) Info(ctx context.Context) *LogStreamInfo {
|
func (s *streamer) Info(_ context.Context) *LogStreamInfo {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
info := &LogStreamInfo{
|
info := &LogStreamInfo{
|
||||||
|
@ -20,5 +20,5 @@ type NoopProfiler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (noopProfiler *NoopProfiler) StartProfiling(serviceName, serviceVersion string) {
|
func (noopProfiler *NoopProfiler) StartProfiling(serviceName, serviceVersion string) {
|
||||||
log.Info().Msg("Not starting profiler")
|
log.Info().Msgf("Not starting profiler for service '%s' with version '%s'", serviceName, serviceVersion)
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ func (r *InMemory) Publish(ctx context.Context, topic string, payload []byte, op
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *InMemory) Close(ctx context.Context) error {
|
func (r *InMemory) Close(_ context.Context) error {
|
||||||
for _, subscriber := range r.registry {
|
for _, subscriber := range r.registry {
|
||||||
if err := subscriber.Close(); err != nil {
|
if err := subscriber.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -175,7 +175,7 @@ func (s *inMemorySubscriber) start(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *inMemorySubscriber) Subscribe(ctx context.Context, topics ...string) error {
|
func (s *inMemorySubscriber) Subscribe(_ context.Context, topics ...string) error {
|
||||||
s.mutex.RLock()
|
s.mutex.RLock()
|
||||||
defer s.mutex.RUnlock()
|
defer s.mutex.RUnlock()
|
||||||
topics = s.formatTopics(topics...)
|
topics = s.formatTopics(topics...)
|
||||||
@ -188,7 +188,7 @@ func (s *inMemorySubscriber) Subscribe(ctx context.Context, topics ...string) er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *inMemorySubscriber) Unsubscribe(ctx context.Context, topics ...string) error {
|
func (s *inMemorySubscriber) Unsubscribe(_ context.Context, topics ...string) error {
|
||||||
s.mutex.RLock()
|
s.mutex.RLock()
|
||||||
defer s.mutex.RUnlock()
|
defer s.mutex.RUnlock()
|
||||||
topics = s.formatTopics(topics...)
|
topics = s.formatTopics(topics...)
|
||||||
|
@ -115,7 +115,7 @@ func (r *Redis) Publish(ctx context.Context, topic string, payload []byte, opts
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Redis) Close(ctx context.Context) error {
|
func (r *Redis) Close(_ context.Context) error {
|
||||||
for _, subscriber := range r.registry {
|
for _, subscriber := range r.registry {
|
||||||
err := subscriber.Close()
|
err := subscriber.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -14,4 +14,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
echo "Updating cmd/gitness/wire_gen.go"
|
echo "Updating cmd/gitness/wire_gen.go"
|
||||||
go run github.com/google/wire/cmd/wire gen github.com/harness/gitness/cmd/gitness
|
go run github.com/google/wire/cmd/wire gen github.com/harness/gitness/cmd/gitness
|
||||||
|
# format generated file as we can't exclude it from being formatted easily.
|
||||||
|
goimports -w ./cmd/gitness/wire_gen.go
|
@ -35,7 +35,7 @@ func NewMemoryProducer(broker *MemoryBroker, namespace string) *MemoryProducer {
|
|||||||
|
|
||||||
// Send sends information to the Broker.
|
// Send sends information to the Broker.
|
||||||
// Returns the message ID in case of success.
|
// Returns the message ID in case of success.
|
||||||
func (p *MemoryProducer) Send(ctx context.Context, streamID string, payload map[string]interface{}) (string, error) {
|
func (p *MemoryProducer) Send(_ context.Context, streamID string, payload map[string]interface{}) (string, error) {
|
||||||
// ensure we transpose streamID using the key namespace
|
// ensure we transpose streamID using the key namespace
|
||||||
transposedStreamID := transposeStreamID(p.namespace, streamID)
|
transposedStreamID := transposeStreamID(p.namespace, streamID)
|
||||||
|
|
||||||
|
@ -283,6 +283,6 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CodeOwners struct {
|
CodeOwners struct {
|
||||||
CodeOwnerFilePath string `envconfig:"GITNESS_CODEOWNERS_FILEPATH" default:".gitness/CODEOWNERS"`
|
FilePath string `envconfig:"GITNESS_CODEOWNERS_FILEPATH" default:".gitness/CODEOWNERS"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user