octopush/internal/serverdeps/server_deps.go
2022-09-12 09:52:44 +02:00

50 lines
1.3 KiB
Go

package serverdeps
import (
"git.front.kjuulh.io/kjuulh/kraken/internal/services/actions"
"git.front.kjuulh.io/kjuulh/kraken/internal/services/providers"
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
"go.uber.org/zap"
)
type ServerDeps struct {
logger *zap.Logger
storageConfig *storage.StorageConfig
gitCfg *providers.GitConfig
}
func NewServerDeps(logger *zap.Logger) *ServerDeps {
deps := &ServerDeps{
logger: logger.With(zap.Namespace("serverdeps")),
}
if storageCfg, err := storage.NewDefaultStorageConfig(); err != nil {
panic(err)
} else {
deps.storageConfig = storageCfg
}
deps.gitCfg = &providers.GitConfig{
AuthOption: providers.GIT_AUTH_SSH,
User: "git",
Password: "",
AccessToken: "",
SshPublicKeyFilePath: "/Users/kah/.ssh/id_ed25519",
SshPrivateKeyPassword: "",
}
return deps
}
func (deps *ServerDeps) GetStorageService() *storage.Service {
return storage.NewService(deps.logger.With(zap.Namespace("storage")), deps.storageConfig)
}
func (deps *ServerDeps) GetGitProvider() *providers.Git {
return providers.NewGit(deps.logger.With(zap.Namespace("gitProvider")), deps.gitCfg)
}
func (deps *ServerDeps) GetAction() *actions.Action {
return actions.NewAction(deps.logger.With(zap.Namespace("action")))
}