mirror of
https://github.com/bitmagnet-io/bitmagnet.git
synced 2026-08-02 01:13:44 -04:00
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package config
|
|
|
|
import (
|
|
"github.com/bitmagnet-io/bitmagnet/internal/config"
|
|
"github.com/bitmagnet-io/bitmagnet/internal/config/lookup"
|
|
"github.com/bitmagnet-io/bitmagnet/internal/config/resolver"
|
|
"github.com/bitmagnet-io/bitmagnet/internal/plugin/builder"
|
|
"github.com/bitmagnet-io/bitmagnet/internal/ref"
|
|
"github.com/bitmagnet-io/bitmagnet/pkg/fs"
|
|
"github.com/bitmagnet-io/bitmagnet/pkg/i18n"
|
|
"github.com/bitmagnet-io/bitmagnet/pkg/plugin"
|
|
"github.com/spf13/afero"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
type deps struct {
|
|
fx.In
|
|
}
|
|
|
|
var (
|
|
Ref = ref.Root.MustSub("config")
|
|
RefActivation = Ref.MustSub("plugin_activation")
|
|
|
|
Plugin = builder.NewPlugin(
|
|
Ref,
|
|
builder.WithDescription[deps]("Provides configuration functionality"),
|
|
builder.WithActivation[deps](plugin.ActivationAlways),
|
|
builder.WithFxOption[deps](
|
|
fx.Provide(
|
|
lookup.NewFromEnv,
|
|
resolver.New,
|
|
func(provider fs.Provider) config.FS {
|
|
return afero.Afero{
|
|
Fs: afero.NewBasePathFs(provider.FSData(), lookup.SubpathPersisted),
|
|
}
|
|
},
|
|
fx.Private,
|
|
),
|
|
fx.Provide(
|
|
config.New,
|
|
),
|
|
),
|
|
builder.WithI18nMessage[deps](
|
|
RefActivation,
|
|
"description for plugin activation param",
|
|
i18n.WithOther("Activation"),
|
|
),
|
|
)
|
|
)
|