Module path changed from git.eeqj.de/sneak/vaultik to sneak.berlin/go/vaultik (vanity redirect). All imports, ldflags, Dockerfile, goreleaser config, and docs updated. App data/config directories now use plain "vaultik" instead of the reverse-DNS name. README: - New copy-pasteable quickstart at top: go install, config init, age keypair, config set for key + file:// destination, home backup - All command names in command details are code-quoted - config set/get gained sequence index support (age_recipients.0) so lists are settable from the CLI - Dockerfile build is CGO_ENABLED=0 to match the pure-Go build
43 lines
912 B
Go
43 lines
912 B
Go
package s3
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.uber.org/fx"
|
|
"sneak.berlin/go/vaultik/internal/config"
|
|
)
|
|
|
|
// Module exports S3 functionality as an fx module.
|
|
// It provides automatic dependency injection for the S3 client,
|
|
// configuring it based on the application's configuration settings.
|
|
var Module = fx.Module("s3",
|
|
fx.Provide(
|
|
provideClient,
|
|
),
|
|
)
|
|
|
|
func provideClient(lc fx.Lifecycle, cfg *config.Config) (*Client, error) {
|
|
ctx := context.Background()
|
|
|
|
client, err := NewClient(ctx, Config{
|
|
Endpoint: cfg.S3.Endpoint,
|
|
Bucket: cfg.S3.Bucket,
|
|
Prefix: cfg.S3.Prefix,
|
|
AccessKeyID: cfg.S3.AccessKeyID,
|
|
SecretAccessKey: cfg.S3.SecretAccessKey,
|
|
Region: cfg.S3.Region,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
lc.Append(fx.Hook{
|
|
OnStop: func(ctx context.Context) error {
|
|
// S3 client doesn't need explicit cleanup
|
|
return nil
|
|
},
|
|
})
|
|
|
|
return client, nil
|
|
}
|