mirror of https://github.com/harness/drone.git
[MISC] Fix Linting/Formatting/Generated Files (#697)
parent
4a741f9c30
commit
1ea0025f99
|
@ -25,14 +25,14 @@ fi
|
|||
# The files are then git-added
|
||||
FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep .go | sed 's| |\\ |g')
|
||||
if [ -n "$FILES" ]; then
|
||||
make format
|
||||
make lint
|
||||
if [ $? -ne 0 ]; then
|
||||
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'"
|
||||
exit 1
|
||||
fi
|
||||
echo "$FILES" | xargs git add
|
||||
make format
|
||||
make lint
|
||||
if [ $? -ne 0 ]; then
|
||||
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'"
|
||||
exit 1
|
||||
fi
|
||||
echo "$FILES" | xargs git add
|
||||
fi
|
||||
|
||||
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
|
||||
@echo "Formating ..."
|
||||
@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"
|
||||
|
||||
sec:
|
||||
|
@ -75,7 +75,7 @@ lint: tools generate # lint the golang code
|
|||
###############################################################################
|
||||
|
||||
generate: wire proto
|
||||
@echo "Generating Code"
|
||||
@echo "Generated Code"
|
||||
|
||||
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
|
||||
@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 \
|
||||
--go_out=./gitrpc/rpc \
|
||||
--go_opt=paths=source_relative \
|
||||
--go-grpc_out=./gitrpc/rpc \
|
||||
--go-grpc_opt=paths=source_relative \
|
||||
./gitrpc/proto/*.proto
|
||||
@goimports -w ./gitrpc/rpc
|
||||
|
||||
###############################################################################
|
||||
# Install Tools and deps
|
||||
|
|
|
@ -28,6 +28,8 @@ import (
|
|||
)
|
||||
|
||||
// PreReceive executes the pre-receive hook for a git repository.
|
||||
//
|
||||
//nolint:revive // not yet fully implemented
|
||||
func (c *Controller) PreReceive(
|
||||
ctx context.Context,
|
||||
session *auth.Session,
|
||||
|
|
|
@ -23,6 +23,8 @@ import (
|
|||
)
|
||||
|
||||
// Update executes the update hook for a git repository.
|
||||
//
|
||||
//nolint:revive // not yet implemented
|
||||
func (c *Controller) Update(
|
||||
ctx context.Context,
|
||||
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)
|
||||
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")
|
||||
}
|
||||
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 {
|
||||
if err := c.DeleteGitRPCRepositories(ctx, session, repo); err != nil {
|
||||
return err
|
||||
if err := c.deleteGitRPCRepository(ctx, session, repo); err != nil {
|
||||
return fmt.Errorf("failed to delete git repository: %w", err)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func (c *Controller) DeleteGitRPCRepositories(
|
||||
func (c *Controller) deleteGitRPCRepository(
|
||||
ctx context.Context,
|
||||
session *auth.Session, repo *types.Repository,
|
||||
session *auth.Session,
|
||||
repo *types.Repository,
|
||||
) error {
|
||||
writeParams, err := CreateRPCWriteParams(ctx, c.urlProvider, session, repo)
|
||||
if err != nil {
|
||||
|
|
|
@ -90,7 +90,7 @@ func (c *Controller) sanitizeCreateInput(in *CreateInput) error {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ func (c *Controller) sanitizeCreateInput(in *CreateInput, uid string) error {
|
|||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ func (c *Controller) sanitizeCreateInput(in *CreateInput) error {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ func (c *Controller) checkCreateInput(in *CreateInput) error {
|
|||
if err := checkActions(in.Actions); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.uidCheck(in.UID, false); err != nil {
|
||||
if err := c.uidCheck(in.UID, false); err != nil { //nolint:revive
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ func (c *Controller) sanitizeCreateInput(in *CreateInput) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := check.Password(in.Password); err != nil {
|
||||
if err := check.Password(in.Password); err != nil { //nolint:revive
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/harness/gitness/app/api/usererror"
|
||||
"github.com/harness/gitness/app/auth"
|
||||
"github.com/harness/gitness/app/token"
|
||||
"github.com/harness/gitness/store"
|
||||
"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.
|
||||
*/
|
||||
func (c *Controller) Login(ctx context.Context, session *auth.Session,
|
||||
in *LoginInput) (*types.TokenResponse, error) {
|
||||
func (c *Controller) Login(
|
||||
ctx context.Context,
|
||||
in *LoginInput,
|
||||
) (*types.TokenResponse, error) {
|
||||
// no auth check required, password is used for it.
|
||||
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
if err := checkTriggers(in.Triggers); err != nil {
|
||||
if err := checkTriggers(in.Triggers); err != nil { //nolint:revive
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
|
||||
"github.com/harness/gitness/app/api/controller/user"
|
||||
"github.com/harness/gitness/app/api/render"
|
||||
"github.com/harness/gitness/app/api/request"
|
||||
)
|
||||
|
||||
// HandleLogin returns an http.HandlerFunc that authenticates
|
||||
|
@ -28,7 +27,6 @@ import (
|
|||
func HandleLogin(userCtrl *user.Controller, cookieName string) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
session, _ := request.AuthSessionFrom(ctx)
|
||||
|
||||
in := new(user.LoginInput)
|
||||
err := json.NewDecoder(r.Body).Decode(in)
|
||||
|
@ -37,7 +35,7 @@ func HandleLogin(userCtrl *user.Controller, cookieName string) http.HandlerFunc
|
|||
return
|
||||
}
|
||||
|
||||
tokenResponse, err := userCtrl.Login(ctx, session, in)
|
||||
tokenResponse, err := userCtrl.Login(ctx, in)
|
||||
if err != nil {
|
||||
render.TranslatedUserError(w, err)
|
||||
return
|
||||
|
|
|
@ -18,6 +18,6 @@ import "net/http"
|
|||
|
||||
// HandleHealth writes a 200 OK status to the http.Response
|
||||
// if the server is healthy.
|
||||
func HandleHealth(w http.ResponseWriter, r *http.Request) {
|
||||
func HandleHealth(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@ import (
|
|||
|
||||
// HandleVersion writes the server version number
|
||||
// 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)
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ func PaginationNoTotal(r *http.Request, w http.ResponseWriter, page int, size in
|
|||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,8 @@ func (a *MembershipAuthorizer) Check(
|
|||
|
||||
func (a *MembershipAuthorizer) CheckAll(ctx context.Context, session *auth.Session,
|
||||
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 {
|
||||
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,
|
||||
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 {
|
||||
return false, err
|
||||
}
|
||||
|
|
|
@ -116,8 +116,12 @@ func createAdminUser(
|
|||
var findErr error
|
||||
usr, findErr = userCtrl.FindNoAuth(ctx, config.Principal.Admin.UID)
|
||||
if findErr != nil {
|
||||
return nil, fmt.Errorf("failed to find user with uid '%s' (%s) after duplicate error: %w",
|
||||
config.Principal.Admin.UID, findErr, createErr)
|
||||
return nil, fmt.Errorf(
|
||||
"failed to find user with uid '%s' (%w) after duplicate error: %w",
|
||||
config.Principal.Admin.UID,
|
||||
findErr,
|
||||
createErr,
|
||||
)
|
||||
}
|
||||
|
||||
return usr, nil
|
||||
|
@ -210,7 +214,7 @@ func createServicePrincipal(
|
|||
svc, findErr = serviceCtrl.FindNoAuth(ctx, uid)
|
||||
if findErr != nil {
|
||||
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,
|
||||
findErr,
|
||||
createErr,
|
||||
|
|
|
@ -43,19 +43,19 @@ func NewEmbeddedClient(manager ExecutionManager, config *types.Config) client.Cl
|
|||
|
||||
// Join notifies the server the runner is joining the cluster.
|
||||
// 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
|
||||
}
|
||||
|
||||
// Leave notifies the server the runner is leaving the cluster.
|
||||
// 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
|
||||
}
|
||||
|
||||
// Ping sends a ping message to the server to test connectivity.
|
||||
// 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
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ func (e *embedded) Upload(ctx context.Context, step int64, l []*drone.Line) erro
|
|||
}
|
||||
|
||||
// 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
|
||||
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
|
||||
// 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().
|
||||
Int64("stage-id", id).
|
||||
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.
|
||||
func (m *Manager) Details(ctx context.Context, stageID int64) (*ExecutionContext, error) {
|
||||
func (m *Manager) Details(_ context.Context, stageID int64) (*ExecutionContext, error) {
|
||||
log := log.With().
|
||||
Int64("stage-id", stageID).
|
||||
Logger()
|
||||
|
@ -367,7 +367,7 @@ func (m *Manager) createNetrc(repo *types.Repository) (*Netrc, error) {
|
|||
}
|
||||
|
||||
// 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().
|
||||
Str("step.status", string(step.Status)).
|
||||
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.
|
||||
func (m *Manager) AfterStep(ctx context.Context, step *types.Step) error {
|
||||
func (m *Manager) AfterStep(_ context.Context, step *types.Step) error {
|
||||
log := log.With().
|
||||
Str("step.status", string(step.Status)).
|
||||
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.
|
||||
func (m *Manager) BeforeStage(ctx context.Context, stage *types.Stage) error {
|
||||
func (m *Manager) BeforeStage(_ context.Context, stage *types.Stage) error {
|
||||
s := &setup{
|
||||
Executions: m.Executions,
|
||||
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.
|
||||
func (m *Manager) AfterStage(ctx context.Context, stage *types.Stage) error {
|
||||
func (m *Manager) AfterStage(_ context.Context, stage *types.Stage) error {
|
||||
t := &teardown{
|
||||
Executions: m.Executions,
|
||||
Pipelines: m.Pipelines,
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"runtime/debug"
|
||||
|
||||
"github.com/harness/gitness/app/pipeline/logger"
|
||||
"github.com/harness/gitness/types"
|
||||
|
||||
"github.com/drone-runners/drone-runner-docker/engine/resource"
|
||||
runtime2 "github.com/drone-runners/drone-runner-docker/engine2/runtime"
|
||||
|
@ -32,7 +31,6 @@ import (
|
|||
|
||||
func NewExecutionPoller(
|
||||
runner *runtime2.Runner,
|
||||
config *types.Config,
|
||||
client runnerclient.Client,
|
||||
) *poller.Poller {
|
||||
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
|
||||
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)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package runner
|
||||
|
||||
import (
|
||||
"github.com/harness/gitness/app/pipeline/manager"
|
||||
"github.com/harness/gitness/app/pipeline/plugin"
|
||||
"github.com/harness/gitness/types"
|
||||
|
||||
|
@ -52,7 +51,6 @@ func NewExecutionRunner(
|
|||
config *types.Config,
|
||||
client runnerclient.Client,
|
||||
pluginManager *plugin.Manager,
|
||||
m manager.ExecutionManager,
|
||||
) (*runtime2.Runner, error) {
|
||||
// For linux, containers need to have extra hosts set in order to interact with
|
||||
// the gitness container.
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package runner
|
||||
|
||||
import (
|
||||
"github.com/harness/gitness/app/pipeline/manager"
|
||||
"github.com/harness/gitness/app/pipeline/plugin"
|
||||
"github.com/harness/gitness/types"
|
||||
|
||||
|
@ -36,17 +35,15 @@ func ProvideExecutionRunner(
|
|||
config *types.Config,
|
||||
client runnerclient.Client,
|
||||
pluginManager *plugin.Manager,
|
||||
manager manager.ExecutionManager,
|
||||
) (*runtime2.Runner, error) {
|
||||
return NewExecutionRunner(config, client, pluginManager, manager)
|
||||
return NewExecutionRunner(config, client, pluginManager)
|
||||
}
|
||||
|
||||
// ProvideExecutionPoller provides a poller which can poll the manager
|
||||
// for new builds and execute them.
|
||||
func ProvideExecutionPoller(
|
||||
runner *runtime2.Runner,
|
||||
config *types.Config,
|
||||
client runnerclient.Client,
|
||||
) *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()
|
||||
defer c.Unlock()
|
||||
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
|
||||
}
|
||||
|
||||
func (q *queue) Schedule(ctx context.Context, stage *types.Stage) error {
|
||||
func (q *queue) Schedule(_ context.Context, _ *types.Stage) error {
|
||||
select {
|
||||
case q.ready <- struct{}{}:
|
||||
default:
|
||||
|
@ -71,7 +71,7 @@ func (q *queue) Schedule(ctx context.Context, stage *types.Stage) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (q *queue) Pause(ctx context.Context) error {
|
||||
func (q *queue) Pause(_ context.Context) error {
|
||||
q.Lock()
|
||||
q.paused = true
|
||||
q.Unlock()
|
||||
|
|
|
@ -30,7 +30,6 @@ import (
|
|||
"github.com/harness/gitness/app/store"
|
||||
"github.com/harness/gitness/app/url"
|
||||
"github.com/harness/gitness/gitrpc"
|
||||
"github.com/harness/gitness/types"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/go-chi/chi/middleware"
|
||||
|
@ -44,7 +43,6 @@ type GitHandler interface {
|
|||
|
||||
// NewGitHandler returns a new GitHandler.
|
||||
func NewGitHandler(
|
||||
config *types.Config,
|
||||
urlProvider url.Provider,
|
||||
repoStore store.RepoStore,
|
||||
authenticator authn.Authenticator,
|
||||
|
@ -85,14 +83,14 @@ func NewGitHandler(
|
|||
r.Get("/info/refs", handlerrepo.GetInfoRefs(client, repoStore, authorizer))
|
||||
|
||||
// dumb protocol
|
||||
r.Get("/HEAD", stubGitHandler(repoStore))
|
||||
r.Get("/objects/info/alternates", stubGitHandler(repoStore))
|
||||
r.Get("/objects/info/http-alternates", stubGitHandler(repoStore))
|
||||
r.Get("/objects/info/packs", stubGitHandler(repoStore))
|
||||
r.Get("/objects/info/{file:[^/]*}", stubGitHandler(repoStore))
|
||||
r.Get("/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38}}", stubGitHandler(repoStore))
|
||||
r.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.pack", stubGitHandler(repoStore))
|
||||
r.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.idx", stubGitHandler(repoStore))
|
||||
r.Get("/HEAD", stubGitHandler())
|
||||
r.Get("/objects/info/alternates", stubGitHandler())
|
||||
r.Get("/objects/info/http-alternates", stubGitHandler())
|
||||
r.Get("/objects/info/packs", stubGitHandler())
|
||||
r.Get("/objects/info/{file:[^/]*}", stubGitHandler())
|
||||
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())
|
||||
r.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.idx", stubGitHandler())
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -100,7 +98,7 @@ func NewGitHandler(
|
|||
return encode.GitPathBefore(r)
|
||||
}
|
||||
|
||||
func stubGitHandler(repoStore store.RepoStore) http.HandlerFunc {
|
||||
func stubGitHandler() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, _ = w.Write([]byte("Seems like an asteroid destroyed the ancient git protocol"))
|
||||
w.WriteHeader(http.StatusBadGateway)
|
||||
|
|
|
@ -55,7 +55,6 @@ var WireSet = wire.NewSet(
|
|||
)
|
||||
|
||||
func ProvideRouter(
|
||||
config *types.Config,
|
||||
api APIHandler,
|
||||
git GitHandler,
|
||||
web WebHandler,
|
||||
|
@ -76,7 +75,6 @@ func ProvideRouter(
|
|||
}
|
||||
|
||||
func ProvideGitHandler(
|
||||
config *types.Config,
|
||||
urlProvider url.Provider,
|
||||
repoStore store.RepoStore,
|
||||
authenticator authn.Authenticator,
|
||||
|
@ -85,7 +83,6 @@ func ProvideGitHandler(
|
|||
repoCtrl *repo.Controller,
|
||||
) GitHandler {
|
||||
return NewGitHandler(
|
||||
config,
|
||||
urlProvider,
|
||||
repoStore,
|
||||
authenticator,
|
||||
|
|
|
@ -33,13 +33,13 @@ const (
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
CodeOwnerFilePath string
|
||||
FilePath string
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
repoStore store.RepoStore
|
||||
git gitrpc.Interface
|
||||
Config Config
|
||||
config Config
|
||||
}
|
||||
|
||||
type codeOwnerFile struct {
|
||||
|
@ -48,11 +48,11 @@ type codeOwnerFile struct {
|
|||
}
|
||||
|
||||
type CodeOwners struct {
|
||||
CodeOwnerFileSha string
|
||||
CodeOwnerDetails []codeOwnerDetail
|
||||
FileSHA string
|
||||
Entries []Entry
|
||||
}
|
||||
|
||||
type codeOwnerDetail struct {
|
||||
type Entry struct {
|
||||
Pattern string
|
||||
Owners []string
|
||||
}
|
||||
|
@ -62,11 +62,10 @@ func New(
|
|||
git gitrpc.Interface,
|
||||
config Config,
|
||||
) (*Service, error) {
|
||||
|
||||
service := &Service{
|
||||
repoStore: repoStore,
|
||||
git: git,
|
||||
Config: config,
|
||||
config: config,
|
||||
}
|
||||
return service, nil
|
||||
}
|
||||
|
@ -79,22 +78,22 @@ func (s *Service) Get(ctx context.Context,
|
|||
}
|
||||
codeOwnerFile, err := s.getCodeOwnerFile(ctx, repo)
|
||||
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 {
|
||||
return nil, fmt.Errorf("unable to parse codeowner %w", err)
|
||||
}
|
||||
|
||||
return &CodeOwners{
|
||||
CodeOwnerFileSha: codeOwnerFile.SHA,
|
||||
CodeOwnerDetails: owner,
|
||||
FileSHA: codeOwnerFile.SHA,
|
||||
Entries: owner,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) ParseCodeOwner(codeOwnersContent string) ([]codeOwnerDetail, error) {
|
||||
var codeOwners []codeOwnerDetail
|
||||
func (s *Service) parseCodeOwner(codeOwnersContent string) ([]Entry, error) {
|
||||
var codeOwners []Entry
|
||||
scanner := bufio.NewScanner(strings.NewReader(codeOwnersContent))
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
|
@ -105,13 +104,13 @@ func (s *Service) ParseCodeOwner(codeOwnersContent string) ([]codeOwnerDetail, e
|
|||
|
||||
parts := strings.Split(line, " ")
|
||||
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]
|
||||
owners := parts[1:]
|
||||
|
||||
codeOwner := codeOwnerDetail{
|
||||
codeOwner := Entry{
|
||||
Pattern: pattern,
|
||||
Owners: owners,
|
||||
}
|
||||
|
@ -119,7 +118,7 @@ func (s *Service) ParseCodeOwner(codeOwnersContent string) ([]codeOwnerDetail, e
|
|||
codeOwners = append(codeOwners, codeOwner)
|
||||
}
|
||||
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
|
||||
|
@ -132,16 +131,19 @@ func (s *Service) getCodeOwnerFile(ctx context.Context,
|
|||
node, err := s.git.GetTreeNode(ctx, &gitrpc.GetTreeNodeParams{
|
||||
ReadParams: params,
|
||||
GitREF: "refs/heads/" + repo.DefaultBranch,
|
||||
Path: s.Config.CodeOwnerFilePath,
|
||||
Path: s.config.FilePath,
|
||||
})
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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{
|
||||
|
|
|
@ -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
|
||||
|
||||
import (
|
||||
|
@ -9,9 +23,14 @@ import (
|
|||
)
|
||||
|
||||
func TestService_ParseCodeOwner(t *testing.T) {
|
||||
content1 := "**/contracts/openapi/v1/ mankrit.singh@harness.io ashish.sanodia@harness.io\n"
|
||||
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"
|
||||
content1 := `**/contracts/openapi/v1/ 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 {
|
||||
repoStore store.RepoStore
|
||||
git gitrpc.Interface
|
||||
|
@ -24,13 +43,13 @@ func TestService_ParseCodeOwner(t *testing.T) {
|
|||
name string
|
||||
fields fields
|
||||
args args
|
||||
want []codeOwnerDetail
|
||||
want []Entry
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Code owners Single",
|
||||
args: args{codeOwnersContent: content1},
|
||||
want: []codeOwnerDetail{{
|
||||
want: []Entry{{
|
||||
Pattern: "**/contracts/openapi/v1/",
|
||||
Owners: []string{"mankrit.singh@harness.io", "ashish.sanodia@harness.io"},
|
||||
},
|
||||
|
@ -39,7 +58,7 @@ func TestService_ParseCodeOwner(t *testing.T) {
|
|||
{
|
||||
name: "Code owners Multiple",
|
||||
args: args{codeOwnersContent: content2},
|
||||
want: []codeOwnerDetail{{
|
||||
want: []Entry{{
|
||||
Pattern: "**/contracts/openapi/v1/",
|
||||
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",
|
||||
args: args{codeOwnersContent: content3},
|
||||
want: []codeOwnerDetail{{
|
||||
want: []Entry{{
|
||||
Pattern: "**/contracts/openapi/v1/",
|
||||
Owners: []string{"mankrit.singh@harness.io", "ashish.sanodia@harness.io"},
|
||||
},
|
||||
|
@ -68,9 +87,9 @@ func TestService_ParseCodeOwner(t *testing.T) {
|
|||
s := &Service{
|
||||
repoStore: tt.fields.repoStore,
|
||||
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 {
|
||||
t.Errorf("ParseCodeOwner() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
|
|
|
@ -439,7 +439,8 @@ func (s *MembershipStore) mapToMembershipUsers(ctx context.Context,
|
|||
|
||||
// attach the principal infos back to the slice items
|
||||
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].Principal = mapToPrincipalInfo(&m.principalInfo)
|
||||
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
|
||||
res := make([]types.MembershipSpace, len(ms))
|
||||
for i, m := range ms {
|
||||
for i := range ms {
|
||||
m := ms[i]
|
||||
res[i].Membership = mapToMembership(&m.membership)
|
||||
space, err := mapToSpace(ctx, s.spacePathStore, &m.space)
|
||||
if err != nil {
|
||||
|
|
|
@ -56,7 +56,7 @@ type s3store struct {
|
|||
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)
|
||||
out, err := svc.GetObject(&s3.GetObjectInput{
|
||||
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
|
||||
}
|
||||
|
||||
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)
|
||||
input := &s3manager.UploadInput{
|
||||
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)
|
||||
}
|
||||
|
||||
func (s *s3store) Delete(ctx context.Context, step int64) error {
|
||||
func (s *s3store) Delete(_ context.Context, step int64) error {
|
||||
svc := s3.New(s.session)
|
||||
_, err := svc.DeleteObject(&s3.DeleteObjectInput{
|
||||
Bucket: aws.String(s.bucket),
|
||||
|
|
|
@ -76,11 +76,11 @@ func (c FileSystemStore) Upload(ctx context.Context,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c FileSystemStore) GetSignedURL(filePath string) (string, error) {
|
||||
func (c FileSystemStore) GetSignedURL(_ string) (string, error) {
|
||||
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)
|
||||
|
||||
file, err := os.Open(fileDiskPath)
|
||||
|
|
|
@ -88,6 +88,6 @@ func (c *GCSStore) GetSignedURL(filePath string) (string, error) {
|
|||
}
|
||||
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")
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ type commandTo struct {
|
|||
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)
|
||||
defer cancel()
|
||||
|
||||
|
|
|
@ -339,6 +339,6 @@ func ProvideCleanupConfig(config *types.Config) cleanup.Config {
|
|||
// ProvideCodeOwnerConfig loads the codeowner config from the main config.
|
||||
func ProvideCodeOwnerConfig(config *types.Config) 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/lib/pq"
|
||||
|
||||
_ "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)
|
||||
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)
|
||||
routerRouter := router.ProvideRouter(config, apiHandler, gitHandler, webHandler, provider)
|
||||
routerRouter := router.ProvideRouter(apiHandler, gitHandler, webHandler, provider)
|
||||
serverServer := server2.ProvideServer(config, routerRouter)
|
||||
executionManager := manager.ProvideExecutionManager(config, executionStore, pipelineStore, provider, streamer, fileService, logStore, logStream, checkStore, repoStore, schedulerScheduler, secretStore, stageStore, stepStore, principalStore)
|
||||
client := manager.ProvideExecutionClient(executionManager, config)
|
||||
pluginManager := plugin2.ProvidePluginManager(config, pluginStore)
|
||||
runtimeRunner, err := runner.ProvideExecutionRunner(config, client, pluginManager, executionManager)
|
||||
runtimeRunner, err := runner.ProvideExecutionRunner(config, client, pluginManager)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
poller := runner.ProvideExecutionPoller(runtimeRunner, config, client)
|
||||
poller := runner.ProvideExecutionPoller(runtimeRunner, client)
|
||||
serverConfig, err := server.ProvideGitRPCServerConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -114,7 +114,7 @@ func (r *BlameReader) unreadLine(line string) {
|
|||
r.lastLine = line
|
||||
}
|
||||
|
||||
//nolint:complexity,gocognit,nestif // it's ok
|
||||
//nolint:gocognit,nestif // it's ok
|
||||
func (r *BlameReader) NextPart() (*types.BlamePart, error) {
|
||||
var commit *types.Commit
|
||||
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.
|
||||
func parseTagDataFromCatFile(data []byte) (tag types.Tag, err error) {
|
||||
func parseTagDataFromCatFile(data []byte) (types.Tag, error) {
|
||||
p := 0
|
||||
|
||||
var err error
|
||||
var tag types.Tag
|
||||
|
||||
// parse object Id
|
||||
tag.TargetSha, p, err = giteaParseCatFileLine(data, p, "object")
|
||||
if err != nil {
|
||||
return
|
||||
return types.Tag{}, fmt.Errorf("failed to parse cat file 'object' line: %w", err)
|
||||
}
|
||||
|
||||
// parse object type
|
||||
rawType, p, err := giteaParseCatFileLine(data, p, "type")
|
||||
if err != nil {
|
||||
return
|
||||
return types.Tag{}, fmt.Errorf("failed to parse cat file 'type' line: %w", err)
|
||||
}
|
||||
|
||||
tag.TargetType, err = types.ParseGitObjectType(rawType)
|
||||
if err != nil {
|
||||
return
|
||||
return types.Tag{}, fmt.Errorf("failed to parse raw git object type: %w", err)
|
||||
}
|
||||
|
||||
// parse tag name
|
||||
tag.Name, p, err = giteaParseCatFileLine(data, p, "tag")
|
||||
if err != nil {
|
||||
return
|
||||
return types.Tag{}, fmt.Errorf("failed to parse cat file 'tag' line: %w", err)
|
||||
}
|
||||
|
||||
// parse tagger
|
||||
rawTaggerInfo, p, err := giteaParseCatFileLine(data, p, "tagger")
|
||||
if err != nil {
|
||||
return
|
||||
return types.Tag{}, fmt.Errorf("failed to parse cat file 'tagger' line: %w", err)
|
||||
}
|
||||
tag.Tagger, err = parseSignatureFromCatFileLine(rawTaggerInfo)
|
||||
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)
|
||||
|
|
|
@ -71,9 +71,9 @@ func streamBlamePart(
|
|||
return nil
|
||||
}
|
||||
|
||||
commit, errMap := mapGitCommit(&part.Commit)
|
||||
if errMap != nil {
|
||||
return fmt.Errorf("failed to map git commit: %w", errMap)
|
||||
commit, err := mapGitCommit(&part.Commit)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to map git commit: %w", err)
|
||||
}
|
||||
|
||||
lines := make([][]byte, len(part.Lines))
|
||||
|
@ -86,8 +86,8 @@ func streamBlamePart(
|
|||
Lines: lines,
|
||||
}
|
||||
|
||||
if errStream := stream.Send(pack); errStream != nil {
|
||||
return errStream
|
||||
if err = stream.Send(pack); err != nil {
|
||||
return fmt.Errorf("failed to send blame part: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -8,6 +8,7 @@ package rpc
|
|||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -8,6 +8,7 @@ package rpc
|
|||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -151,7 +152,6 @@ type ServicePackRequest struct {
|
|||
// Depending on the service the matching base type has to be passed
|
||||
//
|
||||
// Types that are assignable to Base:
|
||||
//
|
||||
// *ServicePackRequest_ReadBase
|
||||
// *ServicePackRequest_WriteBase
|
||||
Base isServicePackRequest_Base `protobuf_oneof:"base"`
|
||||
|
|
|
@ -8,6 +8,7 @@ package rpc
|
|||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -8,6 +8,7 @@ package rpc
|
|||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -263,7 +264,6 @@ type CommitFilesAction struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to Payload:
|
||||
//
|
||||
// *CommitFilesAction_Header
|
||||
// *CommitFilesAction_Content
|
||||
Payload isCommitFilesAction_Payload `protobuf_oneof:"payload"`
|
||||
|
@ -347,7 +347,6 @@ type CommitFilesRequest struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to Payload:
|
||||
//
|
||||
// *CommitFilesRequest_Header
|
||||
// *CommitFilesRequest_Action
|
||||
Payload isCommitFilesRequest_Payload `protobuf_oneof:"payload"`
|
||||
|
|
|
@ -8,6 +8,7 @@ package rpc
|
|||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -8,6 +8,7 @@ package rpc
|
|||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -8,6 +8,7 @@ package rpc
|
|||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -216,7 +217,6 @@ type CreateRepositoryRequest struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to Data:
|
||||
//
|
||||
// *CreateRepositoryRequest_Header
|
||||
// *CreateRepositoryRequest_File
|
||||
Data isCreateRepositoryRequest_Data `protobuf_oneof:"data"`
|
||||
|
@ -1312,7 +1312,6 @@ type GetBlobResponse struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to Data:
|
||||
//
|
||||
// *GetBlobResponse_Header
|
||||
// *GetBlobResponse_Content
|
||||
Data isGetBlobResponse_Data `protobuf_oneof:"data"`
|
||||
|
|
|
@ -8,6 +8,7 @@ package rpc
|
|||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -298,7 +299,6 @@ type FileUpload struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to Data:
|
||||
//
|
||||
// *FileUpload_Header
|
||||
// *FileUpload_Chunk
|
||||
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.streams[id] = newStream()
|
||||
s.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *streamer) Delete(ctx context.Context, id int64) error {
|
||||
func (s *streamer) Delete(_ context.Context, id int64) error {
|
||||
s.Lock()
|
||||
stream, ok := s.streams[id]
|
||||
if ok {
|
||||
|
@ -57,7 +57,7 @@ func (s *streamer) Delete(ctx context.Context, id int64) error {
|
|||
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()
|
||||
stream, ok := s.streams[id]
|
||||
s.Unlock()
|
||||
|
@ -77,7 +77,7 @@ func (s *streamer) Tail(ctx context.Context, id int64) (<-chan *Line, <-chan err
|
|||
return stream.subscribe(ctx)
|
||||
}
|
||||
|
||||
func (s *streamer) Info(ctx context.Context) *LogStreamInfo {
|
||||
func (s *streamer) Info(_ context.Context) *LogStreamInfo {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
info := &LogStreamInfo{
|
||||
|
|
|
@ -20,5 +20,5 @@ type NoopProfiler struct {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func (r *InMemory) Close(ctx context.Context) error {
|
||||
func (r *InMemory) Close(_ context.Context) error {
|
||||
for _, subscriber := range r.registry {
|
||||
if err := subscriber.Close(); err != nil {
|
||||
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()
|
||||
defer s.mutex.RUnlock()
|
||||
topics = s.formatTopics(topics...)
|
||||
|
@ -188,7 +188,7 @@ func (s *inMemorySubscriber) Subscribe(ctx context.Context, topics ...string) er
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *inMemorySubscriber) Unsubscribe(ctx context.Context, topics ...string) error {
|
||||
func (s *inMemorySubscriber) Unsubscribe(_ context.Context, topics ...string) error {
|
||||
s.mutex.RLock()
|
||||
defer s.mutex.RUnlock()
|
||||
topics = s.formatTopics(topics...)
|
||||
|
|
|
@ -115,7 +115,7 @@ func (r *Redis) Publish(ctx context.Context, topic string, payload []byte, opts
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *Redis) Close(ctx context.Context) error {
|
||||
func (r *Redis) Close(_ context.Context) error {
|
||||
for _, subscriber := range r.registry {
|
||||
err := subscriber.Close()
|
||||
if err != nil {
|
||||
|
|
|
@ -14,4 +14,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
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.
|
||||
// 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
|
||||
transposedStreamID := transposeStreamID(p.namespace, streamID)
|
||||
|
||||
|
|
|
@ -283,6 +283,6 @@ type Config struct {
|
|||
}
|
||||
|
||||
CodeOwners struct {
|
||||
CodeOwnerFilePath string `envconfig:"GITNESS_CODEOWNERS_FILEPATH" default:".gitness/CODEOWNERS"`
|
||||
FilePath string `envconfig:"GITNESS_CODEOWNERS_FILEPATH" default:".gitness/CODEOWNERS"`
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue