mirror of https://github.com/harness/drone.git
[MISC] Move configurations to their respective packages (#256)
parent
001d706998
commit
bfb0466b11
|
@ -16,45 +16,32 @@ import (
|
||||||
"github.com/harness/gitness/internal/services/webhook"
|
"github.com/harness/gitness/internal/services/webhook"
|
||||||
"github.com/harness/gitness/types"
|
"github.com/harness/gitness/types"
|
||||||
|
|
||||||
"github.com/google/wire"
|
|
||||||
"github.com/kelseyhightower/envconfig"
|
"github.com/kelseyhightower/envconfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
// load returns the system configuration from the
|
// LoadConfig returns the system configuration from the
|
||||||
// host environment.
|
// host environment.
|
||||||
func load() (*types.Config, error) {
|
func LoadConfig() (*types.Config, error) {
|
||||||
config := new(types.Config)
|
config := new(types.Config)
|
||||||
// read the configuration from the environment and
|
|
||||||
// populate the configuration structure.
|
|
||||||
err := envconfig.Process("", config)
|
err := envconfig.Process("", config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ensureInstanceIDIsSet(config)
|
config.InstanceID, err = getSanitizedMachineName()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to ensure that instance ID is set in config: %w", err)
|
return nil, fmt.Errorf("unable to ensure that instance ID is set in config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ensureGitRootIsSet(config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("unable to ensure that git root is set in config: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ensureGitServerHookIsSet(config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("unable to ensure that server hook is set in config: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureInstanceIDIsSet(config *types.Config) error {
|
// getSanitizedMachineName gets the name of the machine and returns it in sanitized format.
|
||||||
if config.InstanceID == "" {
|
func getSanitizedMachineName() (string, error) {
|
||||||
// use the hostname as default id of the instance
|
// use the hostname as default id of the instance
|
||||||
hostName, err := os.Hostname()
|
hostName, err := os.Hostname()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always cast to lower and remove all unwanted chars
|
// Always cast to lower and remove all unwanted chars
|
||||||
|
@ -75,76 +62,76 @@ func ensureInstanceIDIsSet(config *types.Config) error {
|
||||||
}
|
}
|
||||||
}, hostName)
|
}, hostName)
|
||||||
|
|
||||||
config.InstanceID = hostName
|
return hostName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
// ProvideGitRPCServerConfig loads the gitrpc server config from the environment.
|
||||||
}
|
// It backfills certain config elements to work with cmdone.
|
||||||
|
func ProvideGitRPCServerConfig() (server.Config, error) {
|
||||||
func ensureGitRootIsSet(config *types.Config) error {
|
config := server.Config{}
|
||||||
if config.Git.Root == "" {
|
err := envconfig.Process("", &config)
|
||||||
homedir, err := os.UserHomeDir()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return server.Config{}, fmt.Errorf("failed to load gitrpc server config: %w", err)
|
||||||
}
|
}
|
||||||
|
if config.GitHookPath == "" {
|
||||||
config.Git.Root = filepath.Join(homedir, ".gitness")
|
var executablePath string
|
||||||
}
|
executablePath, err = os.Executable()
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func ensureGitServerHookIsSet(config *types.Config) error {
|
|
||||||
if config.Git.ServerHookPath == "" {
|
|
||||||
executablePath, err := os.Executable()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get path of current executable: %w", err)
|
return server.Config{}, fmt.Errorf("failed to get path of current executable: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Git.ServerHookPath = executablePath
|
config.GitHookPath = executablePath
|
||||||
|
}
|
||||||
|
if config.GitRoot == "" {
|
||||||
|
var homedir string
|
||||||
|
homedir, err = os.UserHomeDir()
|
||||||
|
if err != nil {
|
||||||
|
return server.Config{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
config.GitRoot = filepath.Join(homedir, ".gitness")
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackageConfigsWireSet contains providers that generate configs required for sub packages.
|
return config, nil
|
||||||
var PackageConfigsWireSet = wire.NewSet(
|
}
|
||||||
ProvideGitRPCServerConfig,
|
|
||||||
ProvideGitRPCClientConfig,
|
|
||||||
ProvideEventsConfig,
|
|
||||||
ProvideWebhookConfig,
|
|
||||||
)
|
|
||||||
|
|
||||||
func ProvideGitRPCServerConfig(config *types.Config) server.Config {
|
// ProvideGitRPCClientConfig loads the gitrpc client config from the environment.
|
||||||
return server.Config{
|
func ProvideGitRPCClientConfig() (gitrpc.Config, error) {
|
||||||
Bind: config.Server.GRPC.Bind,
|
config := gitrpc.Config{}
|
||||||
GitRoot: config.Git.Root,
|
err := envconfig.Process("", &config)
|
||||||
TmpDir: config.Git.TmpDir,
|
if err != nil {
|
||||||
ServerHookPath: config.Git.ServerHookPath,
|
return gitrpc.Config{}, fmt.Errorf("failed to load gitrpc client config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProvideEventsConfig loads the events config from the environment.
|
||||||
|
func ProvideEventsConfig() (events.Config, error) {
|
||||||
|
config := events.Config{}
|
||||||
|
err := envconfig.Process("", &config)
|
||||||
|
if err != nil {
|
||||||
|
return events.Config{}, fmt.Errorf("failed to load events config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProvideWebhookConfig loads the webhook config from the environment.
|
||||||
|
// It backfills certain config elements if required.
|
||||||
|
func ProvideWebhookConfig() (webhook.Config, error) {
|
||||||
|
config := webhook.Config{}
|
||||||
|
err := envconfig.Process("", &config)
|
||||||
|
if err != nil {
|
||||||
|
return webhook.Config{}, fmt.Errorf("failed to load events config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.EventReaderName == "" {
|
||||||
|
config.EventReaderName, err = getSanitizedMachineName()
|
||||||
|
if err != nil {
|
||||||
|
return webhook.Config{}, fmt.Errorf("failed to get sanitized machine name: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProvideGitRPCClientConfig(config *types.Config) gitrpc.Config {
|
return config, nil
|
||||||
return gitrpc.Config{
|
|
||||||
Bind: config.Server.GRPC.Bind,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ProvideEventsConfig(config *types.Config) events.Config {
|
|
||||||
return events.Config{
|
|
||||||
Mode: events.Mode(config.Events.Mode),
|
|
||||||
Namespace: config.Events.Namespace,
|
|
||||||
MaxStreamLength: config.Events.MaxStreamLength,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ProvideWebhookConfig(config *types.Config) webhook.Config {
|
|
||||||
return webhook.Config{
|
|
||||||
// Use instanceID as readerName as every instance should be one reader
|
|
||||||
EventReaderName: config.InstanceID,
|
|
||||||
Concurrency: config.Webhook.Concurrency,
|
|
||||||
MaxRetryCount: config.Webhook.MaxRetryCount,
|
|
||||||
AllowLoopback: config.Webhook.AllowLoopback,
|
|
||||||
AllowPrivateNetwork: config.Webhook.AllowPrivateNetwork,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright 2022 Harness Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the Polyform Free Trial License
|
||||||
|
// that can be found in the LICENSE.md file for this repository.
|
||||||
|
|
||||||
|
// go:build harness
|
||||||
|
|
||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/harness/gitness/harness/types"
|
||||||
|
|
||||||
|
"github.com/kelseyhightower/envconfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ProvideHarnessConfig() (*types.Config, error) {
|
||||||
|
config := new(types.Config)
|
||||||
|
err := envconfig.Process("", config)
|
||||||
|
return config, err
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
pullreqevents "github.com/harness/gitness/internal/events/pullreq"
|
pullreqevents "github.com/harness/gitness/internal/events/pullreq"
|
||||||
|
|
||||||
"github.com/harness/gitness/events"
|
"github.com/harness/gitness/events"
|
||||||
|
@ -20,7 +21,6 @@ import (
|
||||||
"github.com/harness/gitness/harness/client"
|
"github.com/harness/gitness/harness/client"
|
||||||
"github.com/harness/gitness/harness/router"
|
"github.com/harness/gitness/harness/router"
|
||||||
"github.com/harness/gitness/harness/store"
|
"github.com/harness/gitness/harness/store"
|
||||||
"github.com/harness/gitness/harness/types"
|
|
||||||
"github.com/harness/gitness/harness/types/check"
|
"github.com/harness/gitness/harness/types/check"
|
||||||
"github.com/harness/gitness/internal/api/controller/githook"
|
"github.com/harness/gitness/internal/api/controller/githook"
|
||||||
"github.com/harness/gitness/internal/api/controller/pullreq"
|
"github.com/harness/gitness/internal/api/controller/pullreq"
|
||||||
|
@ -48,7 +48,7 @@ import (
|
||||||
func initSystem(ctx context.Context, config *gitnesstypes.Config) (*system, error) {
|
func initSystem(ctx context.Context, config *gitnesstypes.Config) (*system, error) {
|
||||||
wire.Build(
|
wire.Build(
|
||||||
newSystem,
|
newSystem,
|
||||||
PackageConfigsWireSet,
|
ProvideHarnessConfig,
|
||||||
ProvideRedis,
|
ProvideRedis,
|
||||||
bootstrap.WireSet,
|
bootstrap.WireSet,
|
||||||
database.WireSet,
|
database.WireSet,
|
||||||
|
@ -67,16 +67,19 @@ func initSystem(ctx context.Context, config *gitnesstypes.Config) (*system, erro
|
||||||
serviceaccount.WireSet,
|
serviceaccount.WireSet,
|
||||||
gitevents.WireSet,
|
gitevents.WireSet,
|
||||||
pullreqevents.WireSet,
|
pullreqevents.WireSet,
|
||||||
|
ProvideGitRPCServerConfig,
|
||||||
gitrpcserver.WireSet,
|
gitrpcserver.WireSet,
|
||||||
|
ProvideGitRPCClientConfig,
|
||||||
gitrpc.WireSet,
|
gitrpc.WireSet,
|
||||||
types.LoadConfig,
|
|
||||||
router.WireSet,
|
router.WireSet,
|
||||||
authn.WireSet,
|
authn.WireSet,
|
||||||
authz.WireSet,
|
authz.WireSet,
|
||||||
client.WireSet,
|
client.WireSet,
|
||||||
store.WireSet,
|
store.WireSet,
|
||||||
check.WireSet,
|
check.WireSet,
|
||||||
|
ProvideEventsConfig,
|
||||||
events.WireSet,
|
events.WireSet,
|
||||||
|
ProvideWebhookConfig,
|
||||||
webhook.WireSet,
|
webhook.WireSet,
|
||||||
githook.WireSet,
|
githook.WireSet,
|
||||||
lock.WireSet,
|
lock.WireSet,
|
||||||
|
|
|
@ -7,6 +7,7 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/harness/gitness/events"
|
"github.com/harness/gitness/events"
|
||||||
"github.com/harness/gitness/gitrpc"
|
"github.com/harness/gitness/gitrpc"
|
||||||
server2 "github.com/harness/gitness/gitrpc/server"
|
server2 "github.com/harness/gitness/gitrpc/server"
|
||||||
|
@ -16,7 +17,6 @@ import (
|
||||||
"github.com/harness/gitness/harness/client"
|
"github.com/harness/gitness/harness/client"
|
||||||
"github.com/harness/gitness/harness/router"
|
"github.com/harness/gitness/harness/router"
|
||||||
"github.com/harness/gitness/harness/store"
|
"github.com/harness/gitness/harness/store"
|
||||||
types2 "github.com/harness/gitness/harness/types"
|
|
||||||
"github.com/harness/gitness/harness/types/check"
|
"github.com/harness/gitness/harness/types/check"
|
||||||
"github.com/harness/gitness/internal/api/controller/githook"
|
"github.com/harness/gitness/internal/api/controller/githook"
|
||||||
"github.com/harness/gitness/internal/api/controller/pullreq"
|
"github.com/harness/gitness/internal/api/controller/pullreq"
|
||||||
|
@ -45,7 +45,7 @@ import (
|
||||||
|
|
||||||
func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
checkUser := check.ProvideUserCheck()
|
checkUser := check.ProvideUserCheck()
|
||||||
typesConfig, err := types2.LoadConfig()
|
typesConfig, err := ProvideHarnessConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,10 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
gitrpcConfig := ProvideGitRPCClientConfig(config)
|
gitrpcConfig, err := ProvideGitRPCClientConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
gitrpcInterface, err := gitrpc.ProvideClient(gitrpcConfig)
|
gitrpcInterface, err := gitrpc.ProvideClient(gitrpcConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -114,7 +117,10 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
pullReqActivityStore := database.ProvidePullReqActivityStore(db, principalInfoCache)
|
pullReqActivityStore := database.ProvidePullReqActivityStore(db, principalInfoCache)
|
||||||
pullReqReviewStore := database.ProvidePullReqReviewStore(db)
|
pullReqReviewStore := database.ProvidePullReqReviewStore(db)
|
||||||
pullReqReviewerStore := database.ProvidePullReqReviewerStore(db, principalInfoCache)
|
pullReqReviewerStore := database.ProvidePullReqReviewerStore(db, principalInfoCache)
|
||||||
eventsConfig := ProvideEventsConfig(config)
|
eventsConfig, err := ProvideEventsConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
universalClient, err := ProvideRedis(config)
|
universalClient, err := ProvideRedis(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -130,9 +136,12 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
lockConfig := lock.ProvideConfig(config)
|
lockConfig := lock.ProvideConfig(config)
|
||||||
mutexManager := lock.ProvideMutexManager(lockConfig, universalClient)
|
mutexManager := lock.ProvideMutexManager(lockConfig, universalClient)
|
||||||
pullreqController := pullreq.ProvideController(db, provider, authorizer, pullReqStore, pullReqActivityStore, pullReqReviewStore, pullReqReviewerStore, repoStore, principalStore, gitrpcInterface, reporter, mutexManager)
|
pullreqController := pullreq.ProvideController(db, provider, authorizer, pullReqStore, pullReqActivityStore, pullReqReviewStore, pullReqReviewerStore, repoStore, principalStore, gitrpcInterface, reporter, mutexManager)
|
||||||
|
webhookConfig, err := ProvideWebhookConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
webhookStore := database.ProvideWebhookStore(db)
|
webhookStore := database.ProvideWebhookStore(db)
|
||||||
webhookExecutionStore := database.ProvideWebhookExecutionStore(db)
|
webhookExecutionStore := database.ProvideWebhookExecutionStore(db)
|
||||||
webhookConfig := ProvideWebhookConfig(config)
|
|
||||||
readerFactory, err := events3.ProvideReaderFactory(eventsSystem)
|
readerFactory, err := events3.ProvideReaderFactory(eventsSystem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -141,7 +150,7 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
webhookController := webhook2.ProvideController(config, db, authorizer, webhookStore, webhookExecutionStore, repoStore, webhookService)
|
webhookController := webhook2.ProvideController(webhookConfig, db, authorizer, webhookStore, webhookExecutionStore, repoStore, webhookService)
|
||||||
eventsReporter, err := events3.ProvideReporter(eventsSystem)
|
eventsReporter, err := events3.ProvideReporter(eventsSystem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -152,7 +161,10 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
webHandler := router2.ProvideWebHandler(config)
|
webHandler := router2.ProvideWebHandler(config)
|
||||||
routerRouter := router2.ProvideRouter(config, apiHandler, gitHandler, webHandler)
|
routerRouter := router2.ProvideRouter(config, apiHandler, gitHandler, webHandler)
|
||||||
serverServer := server.ProvideServer(config, routerRouter)
|
serverServer := server.ProvideServer(config, routerRouter)
|
||||||
serverConfig := ProvideGitRPCServerConfig(config)
|
serverConfig, err := ProvideGitRPCServerConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
server3, err := server2.ProvideServer(serverConfig)
|
server3, err := server2.ProvideServer(serverConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (c *command) run(*kingpin.ParseContext) error {
|
||||||
|
|
||||||
// create the system configuration store by loading
|
// create the system configuration store by loading
|
||||||
// data from the environment.
|
// data from the environment.
|
||||||
config, err := load()
|
config, err := LoadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("encountered an error while loading configuration: %w", err)
|
return fmt.Errorf("encountered an error while loading configuration: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ import (
|
||||||
func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
wire.Build(
|
wire.Build(
|
||||||
newSystem,
|
newSystem,
|
||||||
PackageConfigsWireSet,
|
|
||||||
ProvideRedis,
|
ProvideRedis,
|
||||||
bootstrap.WireSet,
|
bootstrap.WireSet,
|
||||||
database.WireSet,
|
database.WireSet,
|
||||||
|
@ -66,11 +65,15 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
authz.WireSet,
|
authz.WireSet,
|
||||||
gitevents.WireSet,
|
gitevents.WireSet,
|
||||||
pullreqevents.WireSet,
|
pullreqevents.WireSet,
|
||||||
|
ProvideGitRPCServerConfig,
|
||||||
gitrpcserver.WireSet,
|
gitrpcserver.WireSet,
|
||||||
|
ProvideGitRPCClientConfig,
|
||||||
gitrpc.WireSet,
|
gitrpc.WireSet,
|
||||||
store.WireSet,
|
store.WireSet,
|
||||||
check.WireSet,
|
check.WireSet,
|
||||||
|
ProvideEventsConfig,
|
||||||
events.WireSet,
|
events.WireSet,
|
||||||
|
ProvideWebhookConfig,
|
||||||
webhook.WireSet,
|
webhook.WireSet,
|
||||||
githook.WireSet,
|
githook.WireSet,
|
||||||
lock.WireSet,
|
lock.WireSet,
|
||||||
|
|
|
@ -7,6 +7,7 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/harness/gitness/events"
|
"github.com/harness/gitness/events"
|
||||||
"github.com/harness/gitness/gitrpc"
|
"github.com/harness/gitness/gitrpc"
|
||||||
server2 "github.com/harness/gitness/gitrpc/server"
|
server2 "github.com/harness/gitness/gitrpc/server"
|
||||||
|
@ -62,7 +63,10 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
pathCache := cache.ProvidePathCache(pathStore, pathTransformation)
|
pathCache := cache.ProvidePathCache(pathStore, pathTransformation)
|
||||||
repoStore := database.ProvideRepoStore(db, pathCache)
|
repoStore := database.ProvideRepoStore(db, pathCache)
|
||||||
spaceStore := database.ProvideSpaceStore(db, pathCache)
|
spaceStore := database.ProvideSpaceStore(db, pathCache)
|
||||||
gitrpcConfig := ProvideGitRPCClientConfig(config)
|
gitrpcConfig, err := ProvideGitRPCClientConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
gitrpcInterface, err := gitrpc.ProvideClient(gitrpcConfig)
|
gitrpcInterface, err := gitrpc.ProvideClient(gitrpcConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -75,7 +79,10 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
pullReqActivityStore := database.ProvidePullReqActivityStore(db, principalInfoCache)
|
pullReqActivityStore := database.ProvidePullReqActivityStore(db, principalInfoCache)
|
||||||
pullReqReviewStore := database.ProvidePullReqReviewStore(db)
|
pullReqReviewStore := database.ProvidePullReqReviewStore(db)
|
||||||
pullReqReviewerStore := database.ProvidePullReqReviewerStore(db, principalInfoCache)
|
pullReqReviewerStore := database.ProvidePullReqReviewerStore(db, principalInfoCache)
|
||||||
eventsConfig := ProvideEventsConfig(config)
|
eventsConfig, err := ProvideEventsConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
universalClient, err := ProvideRedis(config)
|
universalClient, err := ProvideRedis(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -91,9 +98,12 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
lockConfig := lock.ProvideConfig(config)
|
lockConfig := lock.ProvideConfig(config)
|
||||||
mutexManager := lock.ProvideMutexManager(lockConfig, universalClient)
|
mutexManager := lock.ProvideMutexManager(lockConfig, universalClient)
|
||||||
pullreqController := pullreq.ProvideController(db, provider, authorizer, pullReqStore, pullReqActivityStore, pullReqReviewStore, pullReqReviewerStore, repoStore, principalStore, gitrpcInterface, reporter, mutexManager)
|
pullreqController := pullreq.ProvideController(db, provider, authorizer, pullReqStore, pullReqActivityStore, pullReqReviewStore, pullReqReviewerStore, repoStore, principalStore, gitrpcInterface, reporter, mutexManager)
|
||||||
|
webhookConfig, err := ProvideWebhookConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
webhookStore := database.ProvideWebhookStore(db)
|
webhookStore := database.ProvideWebhookStore(db)
|
||||||
webhookExecutionStore := database.ProvideWebhookExecutionStore(db)
|
webhookExecutionStore := database.ProvideWebhookExecutionStore(db)
|
||||||
webhookConfig := ProvideWebhookConfig(config)
|
|
||||||
readerFactory, err := events3.ProvideReaderFactory(eventsSystem)
|
readerFactory, err := events3.ProvideReaderFactory(eventsSystem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -102,7 +112,7 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
webhookController := webhook2.ProvideController(config, db, authorizer, webhookStore, webhookExecutionStore, repoStore, service)
|
webhookController := webhook2.ProvideController(webhookConfig, db, authorizer, webhookStore, webhookExecutionStore, repoStore, service)
|
||||||
eventsReporter, err := events3.ProvideReporter(eventsSystem)
|
eventsReporter, err := events3.ProvideReporter(eventsSystem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -115,7 +125,10 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) {
|
||||||
webHandler := router.ProvideWebHandler(config)
|
webHandler := router.ProvideWebHandler(config)
|
||||||
routerRouter := router.ProvideRouter(config, apiHandler, gitHandler, webHandler)
|
routerRouter := router.ProvideRouter(config, apiHandler, gitHandler, webHandler)
|
||||||
serverServer := server.ProvideServer(config, routerRouter)
|
serverServer := server.ProvideServer(config, routerRouter)
|
||||||
serverConfig := ProvideGitRPCServerConfig(config)
|
serverConfig, err := ProvideGitRPCServerConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
server3, err := server2.ProvideServer(serverConfig)
|
server3, err := server2.ProvideServer(serverConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package events
|
package events
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -38,8 +39,22 @@ const (
|
||||||
|
|
||||||
// Config defines the config of the events system.
|
// Config defines the config of the events system.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Mode Mode `json:"mode"`
|
Mode Mode `envconfig:"GITNESS_EVENTS_MODE" default:"inmemory"`
|
||||||
Namespace string `json:"namespace"`
|
Namespace string `envconfig:"GITNESS_EVENTS_NAMESPACE" default:"gitness"`
|
||||||
MaxStreamLength int64 `json:"max_stream_length"`
|
MaxStreamLength int64 `envconfig:"GITNESS_EVENTS_MAX_STREAM_LENGTH" default:"10000"`
|
||||||
ApproxMaxStreamLength bool `json:"approx_max_stream_length"`
|
ApproxMaxStreamLength bool `envconfig:"GITNESS_EVENTS_APPROX_MAX_STREAM_LENGTH" default:"true"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Config) Validate() error {
|
||||||
|
if c == nil {
|
||||||
|
return errors.New("config is required")
|
||||||
|
}
|
||||||
|
if c.Mode != ModeRedis && c.Mode != ModeInMemory {
|
||||||
|
return fmt.Errorf("config.Mode '%s' is not supported", c.Mode)
|
||||||
|
}
|
||||||
|
if c.MaxStreamLength < 1 {
|
||||||
|
return errors.New("config.MaxStreamLength has to be a positive number")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,10 @@ var WireSet = wire.NewSet(
|
||||||
)
|
)
|
||||||
|
|
||||||
func ProvideSystem(config Config, redisClient redis.UniversalClient) (*System, error) {
|
func ProvideSystem(config Config, redisClient redis.UniversalClient) (*System, error) {
|
||||||
|
if err := config.Validate(); err != nil {
|
||||||
|
return nil, fmt.Errorf("provided config is invalid: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
var system *System
|
var system *System
|
||||||
var err error
|
var err error
|
||||||
switch config.Mode {
|
switch config.Mode {
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
package gitrpc
|
package gitrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/harness/gitness/gitrpc/rpc"
|
"github.com/harness/gitness/gitrpc/rpc"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
@ -21,7 +23,11 @@ type Client struct {
|
||||||
mergeService rpc.MergeServiceClient
|
mergeService rpc.MergeServiceClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(remoteAddr string) (*Client, error) {
|
func New(config Config) (*Client, error) {
|
||||||
|
if err := config.Validate(); err != nil {
|
||||||
|
return nil, fmt.Errorf("provided config is invalid: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
// create interceptors
|
// create interceptors
|
||||||
logIntc := NewClientLogInterceptor()
|
logIntc := NewClientLogInterceptor()
|
||||||
|
|
||||||
|
@ -36,7 +42,7 @@ func New(remoteAddr string) (*Client, error) {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := grpc.Dial(remoteAddr, grpcOpts...)
|
conn, err := grpc.Dial(config.Addr, grpcOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,22 @@
|
||||||
|
|
||||||
package gitrpc
|
package gitrpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
// Config represents the config for the gitrpc client.
|
// Config represents the config for the gitrpc client.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Bind string
|
Addr string `envconfig:"GITRPC_CLIENT_ADDR" default:"127.0.0.1:3001"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Config) Validate() error {
|
||||||
|
if c == nil {
|
||||||
|
return errors.New("config is required")
|
||||||
|
}
|
||||||
|
if c.Addr == "" {
|
||||||
|
return errors.New("config.Addr is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,16 +60,16 @@ type RepositoryService struct {
|
||||||
adapter GitAdapter
|
adapter GitAdapter
|
||||||
store Storage
|
store Storage
|
||||||
reposRoot string
|
reposRoot string
|
||||||
serverHookPath string
|
gitHookPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRepositoryService(adapter GitAdapter, store Storage, reposRoot string,
|
func NewRepositoryService(adapter GitAdapter, store Storage, reposRoot string,
|
||||||
serverHookPath string) (*RepositoryService, error) {
|
gitHookPath string) (*RepositoryService, error) {
|
||||||
return &RepositoryService{
|
return &RepositoryService{
|
||||||
adapter: adapter,
|
adapter: adapter,
|
||||||
store: store,
|
store: store,
|
||||||
reposRoot: reposRoot,
|
reposRoot: reposRoot,
|
||||||
serverHookPath: serverHookPath,
|
gitHookPath: gitHookPath,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,10 +170,10 @@ func (s RepositoryService) CreateRepository(stream rpc.RepositoryService_CreateR
|
||||||
// setup server hook symlinks pointing to configured server hook binary
|
// setup server hook symlinks pointing to configured server hook binary
|
||||||
for _, hook := range gitServerHookNames {
|
for _, hook := range gitServerHookNames {
|
||||||
hookPath := path.Join(repoPath, gitHooksDir, hook)
|
hookPath := path.Join(repoPath, gitHooksDir, hook)
|
||||||
err = os.Symlink(s.serverHookPath, hookPath)
|
err = os.Symlink(s.gitHookPath, hookPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return status.Errorf(codes.Internal,
|
return status.Errorf(codes.Internal,
|
||||||
"failed to setup symlink for hook '%s' ('%s' -> '%s'): %s", hook, hookPath, s.serverHookPath, err)
|
"failed to setup symlink for hook '%s' ('%s' -> '%s'): %s", hook, hookPath, s.gitHookPath, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,35 @@
|
||||||
|
|
||||||
package server
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
// Config represents the configuration for the gitrpc server.
|
// Config represents the configuration for the gitrpc server.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
GitRoot string
|
// Bind specifies the addr used to bind the grpc server.
|
||||||
TmpDir string
|
Bind string `envconfig:"GITRPC_SERVER_BIND" default:":3001"`
|
||||||
Bind string
|
// GitRoot specifies the directory containing git related data (e.g. repos, ...)
|
||||||
ServerHookPath string
|
GitRoot string `envconfig:"GITRPC_SERVER_GIT_ROOT"`
|
||||||
|
// TmpDir (optional) specifies the directory for temporary data (e.g. repo clones, ...)
|
||||||
|
TmpDir string `envconfig:"GITRPC_SERVER_TMP_DIR"`
|
||||||
|
// GitHookPath points to the binary used as git server hook.
|
||||||
|
GitHookPath string `envconfig:"GITRPC_SERVER_GIT_HOOK_PATH"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Config) Validate() error {
|
||||||
|
if c == nil {
|
||||||
|
return errors.New("config is required")
|
||||||
|
}
|
||||||
|
if c.Bind == "" {
|
||||||
|
return errors.New("config.Bind is required")
|
||||||
|
}
|
||||||
|
if c.GitRoot == "" {
|
||||||
|
return errors.New("config.GitRoot is required")
|
||||||
|
}
|
||||||
|
if c.GitHookPath == "" {
|
||||||
|
return errors.New("config.GitHookPath is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -32,6 +33,9 @@ type Server struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(config Config) (*Server, error) {
|
func NewServer(config Config) (*Server, error) {
|
||||||
|
if err := config.Validate(); err != nil {
|
||||||
|
return nil, fmt.Errorf("configuration is invalid: %w", err)
|
||||||
|
}
|
||||||
// Create repos folder
|
// Create repos folder
|
||||||
reposRoot := filepath.Join(config.GitRoot, repoSubdirName)
|
reposRoot := filepath.Join(config.GitRoot, repoSubdirName)
|
||||||
if _, err := os.Stat(reposRoot); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(reposRoot); errors.Is(err, os.ErrNotExist) {
|
||||||
|
@ -66,7 +70,7 @@ func NewServer(config Config) (*Server, error) {
|
||||||
store := storage.NewLocalStore()
|
store := storage.NewLocalStore()
|
||||||
|
|
||||||
// initialize services
|
// initialize services
|
||||||
repoService, err := service.NewRepositoryService(adapter, store, reposRoot, config.ServerHookPath)
|
repoService, err := service.NewRepositoryService(adapter, store, reposRoot, config.GitHookPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,5 +12,5 @@ var WireSet = wire.NewSet(
|
||||||
)
|
)
|
||||||
|
|
||||||
func ProvideClient(config Config) (Interface, error) {
|
func ProvideClient(config Config) (Interface, error) {
|
||||||
return New(config.Bind)
|
return New(config)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"github.com/harness/gitness/internal/auth/authz"
|
"github.com/harness/gitness/internal/auth/authz"
|
||||||
"github.com/harness/gitness/internal/services/webhook"
|
"github.com/harness/gitness/internal/services/webhook"
|
||||||
"github.com/harness/gitness/internal/store"
|
"github.com/harness/gitness/internal/store"
|
||||||
"github.com/harness/gitness/types"
|
|
||||||
|
|
||||||
"github.com/google/wire"
|
"github.com/google/wire"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
|
@ -19,9 +18,9 @@ var WireSet = wire.NewSet(
|
||||||
ProvideController,
|
ProvideController,
|
||||||
)
|
)
|
||||||
|
|
||||||
func ProvideController(config *types.Config, db *sqlx.DB, authorizer authz.Authorizer,
|
func ProvideController(config webhook.Config, db *sqlx.DB, authorizer authz.Authorizer,
|
||||||
webhookStore store.WebhookStore, webhookExecutionStore store.WebhookExecutionStore,
|
webhookStore store.WebhookStore, webhookExecutionStore store.WebhookExecutionStore,
|
||||||
repoStore store.RepoStore, webhookService *webhook.Service) *Controller {
|
repoStore store.RepoStore, webhookService *webhook.Service) *Controller {
|
||||||
return NewController(config.Webhook.AllowLoopback, config.Webhook.AllowPrivateNetwork,
|
return NewController(config.AllowLoopback, config.AllowPrivateNetwork,
|
||||||
db, authorizer, webhookStore, webhookExecutionStore, repoStore, webhookService)
|
db, authorizer, webhookStore, webhookExecutionStore, repoStore, webhookService)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ package webhook
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -23,11 +24,28 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
EventReaderName string `json:"event_reader_name"`
|
EventReaderName string `envconfig:"GITNESS_WEBHOOK_EVENT_READER_NAME"`
|
||||||
Concurrency int `json:"concurrency"`
|
Concurrency int `envconfig:"GITNESS_WEBHOOK_CONCURRENCY" default:"4"`
|
||||||
MaxRetryCount int64 `json:"max_retry_count"`
|
MaxRetryCount int64 `envconfig:"GITNESS_WEBHOOK_MAX_RETRY_COUNT" default:"3"`
|
||||||
AllowPrivateNetwork bool `json:"allow_private_network"`
|
AllowPrivateNetwork bool `envconfig:"GITNESS_WEBHOOK_ALLOW_PRIVATE_NETWORK" default:"false"`
|
||||||
AllowLoopback bool `json:"allow_loopback"`
|
AllowLoopback bool `envconfig:"GITNESS_WEBHOOK_ALLOW_LOOPBACK" default:"false"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Config) Validate() error {
|
||||||
|
if c == nil {
|
||||||
|
return errors.New("config is required")
|
||||||
|
}
|
||||||
|
if c.EventReaderName == "" {
|
||||||
|
return errors.New("config.EventReaderName is required")
|
||||||
|
}
|
||||||
|
if c.Concurrency < 1 {
|
||||||
|
return errors.New("config.Concurrency has to be a positive number")
|
||||||
|
}
|
||||||
|
if c.MaxRetryCount < 0 {
|
||||||
|
return errors.New("config.MaxRetryCount can't be negative")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Service is responsible for processing webhook events.
|
// Service is responsible for processing webhook events.
|
||||||
|
@ -49,6 +67,9 @@ func NewService(ctx context.Context, config Config,
|
||||||
webhookStore store.WebhookStore, webhookExecutionStore store.WebhookExecutionStore,
|
webhookStore store.WebhookStore, webhookExecutionStore store.WebhookExecutionStore,
|
||||||
repoStore store.RepoStore, urlProvider *url.Provider,
|
repoStore store.RepoStore, urlProvider *url.Provider,
|
||||||
principalStore store.PrincipalStore, gitRPCClient gitrpc.Interface) (*Service, error) {
|
principalStore store.PrincipalStore, gitRPCClient gitrpc.Interface) (*Service, error) {
|
||||||
|
if err := config.Validate(); err != nil {
|
||||||
|
return nil, fmt.Errorf("provided config is invalid: %w", err)
|
||||||
|
}
|
||||||
service := &Service{
|
service := &Service{
|
||||||
webhookStore: webhookStore,
|
webhookStore: webhookStore,
|
||||||
webhookExecutionStore: webhookExecutionStore,
|
webhookExecutionStore: webhookExecutionStore,
|
||||||
|
|
|
@ -39,9 +39,6 @@ type Config struct {
|
||||||
|
|
||||||
// Git defines the git configuration parameters
|
// Git defines the git configuration parameters
|
||||||
Git struct {
|
Git struct {
|
||||||
Root string `envconfig:"GITNESS_GIT_ROOT"`
|
|
||||||
TmpDir string `envconfig:"GITNESS_GIT_TMP_DIR"` // directory for temporary data (repo clone)
|
|
||||||
ServerHookPath string `envconfig:"GITNESS_GIT_SERVER_HOOK_PATH"` // path to binary used as git server hook
|
|
||||||
DefaultBranch string `envconfig:"GITNESS_GIT_DEFAULTBRANCH" default:"main"`
|
DefaultBranch string `envconfig:"GITNESS_GIT_DEFAULTBRANCH" default:"main"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,11 +53,6 @@ type Config struct {
|
||||||
GitHost string `envconfig:"GITNESS_HTTP_GIT_HOST" default:"git.localhost"`
|
GitHost string `envconfig:"GITNESS_HTTP_GIT_HOST" default:"git.localhost"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GRPC defines the grpc configuration parameters
|
|
||||||
GRPC struct {
|
|
||||||
Bind string `envconfig:"GITNESS_GRPC_BIND" default:":3001"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Acme defines Acme configuration parameters.
|
// Acme defines Acme configuration parameters.
|
||||||
Acme struct {
|
Acme struct {
|
||||||
Enabled bool `envconfig:"GITNESS_ACME_ENABLED"`
|
Enabled bool `envconfig:"GITNESS_ACME_ENABLED"`
|
||||||
|
@ -123,13 +115,6 @@ type Config struct {
|
||||||
Password string `envconfig:"GITNESS_REDIS_PASSWORD"`
|
Password string `envconfig:"GITNESS_REDIS_PASSWORD"`
|
||||||
}
|
}
|
||||||
|
|
||||||
Events struct {
|
|
||||||
Mode string `envconfig:"GITNESS_EVENTS_MODE" default:"inmemory"`
|
|
||||||
Namespace string `envconfig:"GITNESS_EVENTS_NAMESPACE" default:"gitness"`
|
|
||||||
MaxStreamLength int64 `envconfig:"GITNESS_EVENTS_MAX_STREAM_LENGTH" default:"1000"`
|
|
||||||
ApproxMaxStreamLength bool `envconfig:"GITNESS_EVENTS_APPROX_MAX_STREAM_LENGTH" default:"true"`
|
|
||||||
}
|
|
||||||
|
|
||||||
Lock struct {
|
Lock struct {
|
||||||
// Provider is a name of distributed lock service like redis, memory, file etc...
|
// Provider is a name of distributed lock service like redis, memory, file etc...
|
||||||
Provider string `envconfig:"GITNESS_LOCK_PROVIDER" default:"inmemory"`
|
Provider string `envconfig:"GITNESS_LOCK_PROVIDER" default:"inmemory"`
|
||||||
|
@ -143,11 +128,4 @@ type Config struct {
|
||||||
// DefaultNamespace is when mutex doesn't specify custom namespace for their keys
|
// DefaultNamespace is when mutex doesn't specify custom namespace for their keys
|
||||||
DefaultNamespace string `envconfig:"GITNESS_LOCK_DEFAULT_NAMESPACE" default:"default"`
|
DefaultNamespace string `envconfig:"GITNESS_LOCK_DEFAULT_NAMESPACE" default:"default"`
|
||||||
}
|
}
|
||||||
|
|
||||||
Webhook struct {
|
|
||||||
MaxRetryCount int64 `envconfig:"GITNESS_WEBHOOK_MAX_RETRY_COUNT" default:"3"`
|
|
||||||
Concurrency int `envconfig:"GITNESS_WEBHOOK_CONCURRENCY" default:"4"`
|
|
||||||
AllowLoopback bool `envconfig:"GITNESS_WEBHOOK_ALLOW_LOOPBACK" default:"false"`
|
|
||||||
AllowPrivateNetwork bool `envconfig:"GITNESS_WEBHOOK_ALLOW_PRIVATE_NETWORK" default:"false"`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue