// Code generated by Wire. DO NOT EDIT.

//go:build !wireinject && harness
// +build !wireinject,harness

package server

import (
	"context"
	"github.com/harness/gitness/events"
	"github.com/harness/gitness/gitrpc"
	server2 "github.com/harness/gitness/gitrpc/server"
	"github.com/harness/gitness/gitrpc/server/cron"
	"github.com/harness/gitness/harness/auth/authn"
	"github.com/harness/gitness/harness/auth/authz"
	"github.com/harness/gitness/harness/bootstrap"
	"github.com/harness/gitness/harness/client"
	"github.com/harness/gitness/harness/router"
	"github.com/harness/gitness/harness/services"
	events4 "github.com/harness/gitness/harness/services/events"
	"github.com/harness/gitness/harness/store"
	"github.com/harness/gitness/harness/types/check"
	check2 "github.com/harness/gitness/internal/api/controller/check"
	"github.com/harness/gitness/internal/api/controller/githook"
	"github.com/harness/gitness/internal/api/controller/principal"
	"github.com/harness/gitness/internal/api/controller/pullreq"
	"github.com/harness/gitness/internal/api/controller/repo"
	"github.com/harness/gitness/internal/api/controller/service"
	"github.com/harness/gitness/internal/api/controller/serviceaccount"
	"github.com/harness/gitness/internal/api/controller/space"
	"github.com/harness/gitness/internal/api/controller/user"
	webhook2 "github.com/harness/gitness/internal/api/controller/webhook"
	events3 "github.com/harness/gitness/internal/events/git"
	events2 "github.com/harness/gitness/internal/events/pullreq"
	router2 "github.com/harness/gitness/internal/router"
	"github.com/harness/gitness/internal/server"
	"github.com/harness/gitness/internal/services/codecomments"
	pullreq2 "github.com/harness/gitness/internal/services/pullreq"
	"github.com/harness/gitness/internal/services/webhook"
	"github.com/harness/gitness/internal/store/cache"
	"github.com/harness/gitness/internal/store/database"
	"github.com/harness/gitness/internal/url"
	"github.com/harness/gitness/lock"
	"github.com/harness/gitness/pubsub"
	"github.com/harness/gitness/types"
)

// Injectors from harness.wire.go:

func initSystem(ctx context.Context, config *types.Config) (*system, error) {
	principalUID := check.ProvidePrincipalUIDCheck()
	typesConfig, err := ProvideHarnessConfig()
	if err != nil {
		return nil, err
	}
	serviceJWTProvider, err := client.ProvideServiceJWTProvider(typesConfig)
	if err != nil {
		return nil, err
	}
	acl, err := client.ProvideACL(ctx, serviceJWTProvider, typesConfig)
	if err != nil {
		return nil, err
	}
	authorizer := authz.ProvideAuthorizer(ctx, typesConfig, config, acl)
	db, err := database.ProvideDatabase(ctx, config)
	if err != nil {
		return nil, err
	}
	principalUIDTransformation := store.ProvidePrincipalUIDTransformation()
	principalStore := database.ProvidePrincipalStore(db, principalUIDTransformation)
	tokenStore := database.ProvideTokenStore(db)
	controller := user.NewController(principalUID, authorizer, principalStore, tokenStore)
	serviceController := service.NewController(principalUID, authorizer, principalStore)
	bootstrapBootstrap := bootstrap.ProvideBootstrap(config, controller, serviceController)
	tokenClient, err := client.ProvideTokenClient(serviceJWTProvider, typesConfig)
	if err != nil {
		return nil, err
	}
	userClient, err := client.ProvideUserClient(serviceJWTProvider, typesConfig)
	if err != nil {
		return nil, err
	}
	serviceAccountClient, err := client.ProvideServiceAccountClient(serviceJWTProvider, typesConfig)
	if err != nil {
		return nil, err
	}
	pathTransformation := store.ProvidePathTransformation()
	pathStore := database.ProvidePathStore(db, pathTransformation)
	pathCache := cache.ProvidePathCache(pathStore, pathTransformation)
	spaceStore := database.ProvideSpaceStore(db, pathCache)
	repoStore := database.ProvideRepoStore(db, pathCache)
	serviceaccountController := serviceaccount.NewController(principalUID, authorizer, principalStore, spaceStore, repoStore, tokenStore)
	provider, err := url.ProvideURLProvider(config)
	if err != nil {
		return nil, err
	}
	pathUID := check.ProvidePathUIDCheck()
	gitrpcConfig, err := ProvideGitRPCClientConfig()
	if err != nil {
		return nil, err
	}
	gitrpcInterface, err := gitrpc.ProvideClient(gitrpcConfig)
	if err != nil {
		return nil, err
	}
	repoController := repo.ProvideController(config, db, provider, pathUID, authorizer, pathStore, repoStore, spaceStore, principalStore, gitrpcInterface)
	spaceController := space.ProvideController(db, provider, pathUID, authorizer, pathStore, spaceStore, repoStore, principalStore, repoController)
	accountClient, err := client.ProvideAccountClient(serviceJWTProvider, typesConfig)
	if err != nil {
		return nil, err
	}
	authenticator, err := authn.ProvideAuthenticator(controller, tokenClient, userClient, typesConfig, serviceAccountClient, serviceaccountController, serviceController, spaceController, accountClient)
	if err != nil {
		return nil, err
	}
	principalController := principal.NewController(principalStore)
	principalInfoView := database.ProvidePrincipalInfoView(db)
	principalInfoCache := cache.ProvidePrincipalInfoCache(principalInfoView)
	pullReqStore := database.ProvidePullReqStore(db, principalInfoCache)
	pullReqActivityStore := database.ProvidePullReqActivityStore(db, principalInfoCache)
	codeCommentView := database.ProvideCodeCommentView(db)
	pullReqReviewStore := database.ProvidePullReqReviewStore(db)
	pullReqReviewerStore := database.ProvidePullReqReviewerStore(db, principalInfoCache)
	eventsConfig, err := ProvideEventsConfig()
	if err != nil {
		return nil, err
	}
	universalClient, err := ProvideRedis(config)
	if err != nil {
		return nil, err
	}
	eventsSystem, err := events.ProvideSystem(eventsConfig, universalClient)
	if err != nil {
		return nil, err
	}
	reporter, err := events2.ProvideReporter(eventsSystem)
	if err != nil {
		return nil, err
	}
	lockConfig := lock.ProvideConfig(config)
	mutexManager := lock.ProvideMutexManager(lockConfig, universalClient)
	migrator := codecomments.ProvideMigrator(gitrpcInterface)
	pullreqController := pullreq.ProvideController(db, provider, authorizer, pullReqStore, pullReqActivityStore, codeCommentView, pullReqReviewStore, pullReqReviewerStore, repoStore, principalStore, gitrpcInterface, reporter, mutexManager, migrator)
	webhookConfig, err := ProvideWebhookConfig()
	if err != nil {
		return nil, err
	}
	webhookStore := database.ProvideWebhookStore(db)
	webhookExecutionStore := database.ProvideWebhookExecutionStore(db)
	readerFactory, err := events3.ProvideReaderFactory(eventsSystem)
	if err != nil {
		return nil, err
	}
	eventsReaderFactory, err := events2.ProvideReaderFactory(eventsSystem)
	if err != nil {
		return nil, err
	}
	webhookService, err := webhook.ProvideService(ctx, webhookConfig, readerFactory, eventsReaderFactory, webhookStore, webhookExecutionStore, repoStore, pullReqStore, provider, principalStore, gitrpcInterface)
	if err != nil {
		return nil, err
	}
	webhookController := webhook2.ProvideController(webhookConfig, db, authorizer, webhookStore, webhookExecutionStore, repoStore, webhookService)
	eventsReporter, err := events3.ProvideReporter(eventsSystem)
	if err != nil {
		return nil, err
	}
	githookController := githook.ProvideController(db, authorizer, principalStore, repoStore, eventsReporter)
	checkStore := database.ProvideCheckStore(db, principalInfoCache)
	checkController := check2.ProvideController(db, authorizer, checkStore, repoStore, gitrpcInterface)
	apiHandler := router.ProvideAPIHandler(config, authenticator, accountClient, controller, principalController, spaceController, repoController, pullreqController, webhookController, githookController, checkController)
	gitHandler := router.ProvideGitHandler(config, provider, repoStore, authenticator, authorizer, gitrpcInterface)
	webHandler := router2.ProvideWebHandler(config)
	routerRouter := router2.ProvideRouter(config, apiHandler, gitHandler, webHandler)
	serverServer := server.ProvideServer(config, routerRouter)
	serverConfig, err := ProvideGitRPCServerConfig()
	if err != nil {
		return nil, err
	}
	server3, err := server2.ProvideServer(serverConfig)
	if err != nil {
		return nil, err
	}
	manager := cron.ProvideManager(serverConfig)
	repoGitInfoView := database.ProvideRepoGitInfoView(db)
	repoGitInfoCache := cache.ProvideRepoGitInfoCache(repoGitInfoView)
	pubsubConfig := pubsub.ProvideConfig(config)
	pubSub := pubsub.ProvidePubSub(pubsubConfig, universalClient)
	pullreqService, err := pullreq2.ProvideService(ctx, config, readerFactory, eventsReaderFactory, reporter, gitrpcInterface, db, repoGitInfoCache, principalInfoCache, repoStore, pullReqStore, pullReqActivityStore, codeCommentView, migrator, pubSub)
	if err != nil {
		return nil, err
	}
	eventsService, err := events4.ProvideEventService(ctx, typesConfig, spaceController, config)
	if err != nil {
		return nil, err
	}
	servicesServices, err := services.ProvideServices(ctx, webhookService, pullreqService, eventsService)
	if err != nil {
		return nil, err
	}
	serverSystem := newSystem(bootstrapBootstrap, serverServer, server3, manager, servicesServices)
	return serverSystem, nil
}
