octopush/internal/serverdeps/server_deps.go

50 lines
1.3 KiB
Go
Raw Normal View History

2022-09-10 20:20:49 +02:00
package serverdeps
2022-09-11 14:52:21 +02:00
import (
2022-09-12 09:52:44 +02:00
"git.front.kjuulh.io/kjuulh/kraken/internal/services/actions"
2022-09-11 22:56:54 +02:00
"git.front.kjuulh.io/kjuulh/kraken/internal/services/providers"
2022-09-11 14:52:21 +02:00
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
"go.uber.org/zap"
)
2022-09-10 20:20:49 +02:00
type ServerDeps struct {
2022-09-11 14:52:21 +02:00
logger *zap.Logger
storageConfig *storage.StorageConfig
2022-09-11 22:56:54 +02:00
gitCfg *providers.GitConfig
2022-09-10 20:20:49 +02:00
}
func NewServerDeps(logger *zap.Logger) *ServerDeps {
2022-09-11 14:52:21 +02:00
deps := &ServerDeps{
2022-09-12 09:52:44 +02:00
logger: logger.With(zap.Namespace("serverdeps")),
2022-09-10 20:20:49 +02:00
}
2022-09-11 14:52:21 +02:00
if storageCfg, err := storage.NewDefaultStorageConfig(); err != nil {
panic(err)
} else {
deps.storageConfig = storageCfg
}
2022-09-11 22:56:54 +02:00
deps.gitCfg = &providers.GitConfig{
AuthOption: providers.GIT_AUTH_SSH,
User: "git",
Password: "",
AccessToken: "",
SshPublicKeyFilePath: "/Users/kah/.ssh/id_ed25519",
SshPrivateKeyPassword: "",
}
2022-09-11 14:52:21 +02:00
return deps
}
func (deps *ServerDeps) GetStorageService() *storage.Service {
2022-09-12 09:52:44 +02:00
return storage.NewService(deps.logger.With(zap.Namespace("storage")), deps.storageConfig)
2022-09-11 22:56:54 +02:00
}
func (deps *ServerDeps) GetGitProvider() *providers.Git {
2022-09-12 09:52:44 +02:00
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")))
2022-09-10 20:20:49 +02:00
}