2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-10-25 00:14:38 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-02-04 15:50:06 +00:00
|
|
|
"context"
|
|
|
|
"crypto/rand"
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
base58 "github.com/jbenet/go-base58"
|
2019-02-08 12:57:35 +00:00
|
|
|
"github.com/minio/cli"
|
|
|
|
minio "github.com/minio/minio/cmd"
|
2019-02-04 15:50:06 +00:00
|
|
|
"github.com/spf13/cobra"
|
2019-02-08 12:57:35 +00:00
|
|
|
"github.com/zeebo/errs"
|
2019-02-04 15:50:06 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
|
2019-06-25 19:25:31 +01:00
|
|
|
"storj.io/storj/cmd/internal/wizard"
|
2019-02-04 15:50:06 +00:00
|
|
|
"storj.io/storj/internal/fpath"
|
2019-07-08 15:45:20 +01:00
|
|
|
"storj.io/storj/internal/version"
|
2019-04-15 21:13:02 +01:00
|
|
|
libuplink "storj.io/storj/lib/uplink"
|
2019-02-04 15:50:06 +00:00
|
|
|
"storj.io/storj/pkg/cfgstruct"
|
|
|
|
"storj.io/storj/pkg/miniogw"
|
2018-10-25 00:14:38 +01:00
|
|
|
"storj.io/storj/pkg/process"
|
2019-02-04 15:50:06 +00:00
|
|
|
"storj.io/storj/pkg/storj"
|
2019-02-08 12:57:35 +00:00
|
|
|
"storj.io/storj/uplink"
|
2019-06-27 18:36:51 +01:00
|
|
|
"storj.io/storj/uplink/setup"
|
2019-02-04 15:50:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// GatewayFlags configuration flags
|
|
|
|
type GatewayFlags struct {
|
2019-05-08 17:52:57 +01:00
|
|
|
NonInteractive bool `help:"disable interactive mode" default:"false" setup:"true"`
|
2019-02-04 15:50:06 +00:00
|
|
|
|
2019-02-08 12:57:35 +00:00
|
|
|
Server miniogw.ServerConfig
|
|
|
|
Minio miniogw.MinioConfig
|
|
|
|
|
|
|
|
uplink.Config
|
2019-07-08 15:45:20 +01:00
|
|
|
|
|
|
|
Version version.Config
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2019-05-07 15:29:57 +01:00
|
|
|
// Error is the default gateway setup errs class
|
|
|
|
Error = errs.Class("gateway setup error")
|
2019-02-04 15:50:06 +00:00
|
|
|
// rootCmd represents the base gateway command when called without any subcommands
|
|
|
|
rootCmd = &cobra.Command{
|
|
|
|
Use: "gateway",
|
|
|
|
Short: "The Storj client-side S3 gateway",
|
|
|
|
Args: cobra.OnlyValidArgs,
|
|
|
|
}
|
|
|
|
setupCmd = &cobra.Command{
|
|
|
|
Use: "setup",
|
|
|
|
Short: "Create a gateway config file",
|
|
|
|
RunE: cmdSetup,
|
|
|
|
Annotations: map[string]string{"type": "setup"},
|
|
|
|
}
|
|
|
|
runCmd = &cobra.Command{
|
|
|
|
Use: "run",
|
|
|
|
Short: "Run the S3 gateway",
|
|
|
|
RunE: cmdRun,
|
|
|
|
}
|
|
|
|
|
|
|
|
setupCfg GatewayFlags
|
|
|
|
runCfg GatewayFlags
|
|
|
|
|
|
|
|
confDir string
|
|
|
|
identityDir string
|
2018-10-25 00:14:38 +01:00
|
|
|
)
|
|
|
|
|
2019-02-04 15:50:06 +00:00
|
|
|
func init() {
|
2019-03-12 12:51:06 +00:00
|
|
|
defaultConfDir := fpath.ApplicationDir("storj", "gateway")
|
|
|
|
defaultIdentityDir := fpath.ApplicationDir("storj", "identity", "gateway")
|
|
|
|
cfgstruct.SetupFlag(zap.L(), rootCmd, &confDir, "config-dir", defaultConfDir, "main directory for gateway configuration")
|
|
|
|
cfgstruct.SetupFlag(zap.L(), rootCmd, &identityDir, "identity-dir", defaultIdentityDir, "main directory for gateway identity credentials")
|
2019-04-19 19:17:30 +01:00
|
|
|
defaults := cfgstruct.DefaultsFlag(rootCmd)
|
2019-02-04 15:50:06 +00:00
|
|
|
|
|
|
|
rootCmd.AddCommand(runCmd)
|
|
|
|
rootCmd.AddCommand(setupCmd)
|
Command line flags features and cleanup (#2068)
* change BindSetup to be an option to Bind
* add process.Bind to allow composite structures
* hack fix for noprefix flags
* used tagged version of structs
Before this PR, some flags were created by calling `cfgstruct.Bind` and having their fields create a flag. Once the flags were parsed, `viper` was used to acquire all the values from them and config files, and the fields in the struct were set through the flag interface.
This doesn't work for slices of things on config structs very well, since it can only set strings, and for a string slice, it turns out that the implementation in `pflag` appends an entry rather than setting it.
This changes three things:
1. Only have a `Bind` call instead of `Bind` and `BindSetup`, and make `BindSetup` an option instead.
2. Add a `process.Bind` call that takes in a `*cobra.Cmd`, binds the struct to the command's flags, and keeps track of that struct in a global map keyed by the command.
3. Use `viper` to get the values and load them into the bound configuration structs instead of using the flags to propagate the changes.
In this way, we can support whatever rich configuration we want in the config yaml files, while still getting command like flags when important.
2019-05-29 18:56:22 +01:00
|
|
|
process.Bind(runCmd, &runCfg, defaults, cfgstruct.ConfDir(confDir), cfgstruct.IdentityDir(identityDir))
|
|
|
|
process.Bind(setupCmd, &setupCfg, defaults, cfgstruct.ConfDir(confDir), cfgstruct.IdentityDir(identityDir), cfgstruct.SetupMode())
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
|
|
|
setupDir, err := filepath.Abs(confDir)
|
|
|
|
if err != nil {
|
2019-06-07 17:14:40 +01:00
|
|
|
return Error.Wrap(err)
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
valid, _ := fpath.IsValidSetupDir(setupDir)
|
|
|
|
if !valid {
|
2019-06-07 17:14:40 +01:00
|
|
|
return Error.New("gateway configuration already exists (%v)", setupDir)
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = os.MkdirAll(setupDir, 0700)
|
|
|
|
if err != nil {
|
2019-06-07 17:14:40 +01:00
|
|
|
return Error.Wrap(err)
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
|
2019-03-22 09:01:49 +00:00
|
|
|
overrides := map[string]interface{}{}
|
2019-05-07 15:29:57 +01:00
|
|
|
|
2019-02-04 15:50:06 +00:00
|
|
|
accessKeyFlag := cmd.Flag("minio.access-key")
|
|
|
|
if !accessKeyFlag.Changed {
|
|
|
|
accessKey, err := generateKey()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-06-07 17:14:40 +01:00
|
|
|
|
2019-02-04 15:50:06 +00:00
|
|
|
overrides[accessKeyFlag.Name] = accessKey
|
|
|
|
}
|
2019-06-07 17:14:40 +01:00
|
|
|
|
2019-02-04 15:50:06 +00:00
|
|
|
secretKeyFlag := cmd.Flag("minio.secret-key")
|
|
|
|
if !secretKeyFlag.Changed {
|
|
|
|
secretKey, err := generateKey()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-06-07 17:14:40 +01:00
|
|
|
|
2019-02-04 15:50:06 +00:00
|
|
|
overrides[secretKeyFlag.Name] = secretKey
|
|
|
|
}
|
|
|
|
|
2019-06-07 17:14:40 +01:00
|
|
|
// override is required because the default value of Enc.KeyFilepath is ""
|
|
|
|
// and setting the value directly in setupCfg.Enc.KeyFiletpath will set the
|
|
|
|
// value in the config file but commented out.
|
|
|
|
encryptionKeyFilepath := setupCfg.Enc.KeyFilepath
|
|
|
|
if encryptionKeyFilepath == "" {
|
|
|
|
encryptionKeyFilepath = filepath.Join(setupDir, ".encryption.key")
|
|
|
|
overrides["enc.key-filepath"] = encryptionKeyFilepath
|
2019-05-07 15:29:57 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 17:14:40 +01:00
|
|
|
if setupCfg.NonInteractive {
|
|
|
|
return setupCfg.nonInteractive(cmd, setupDir, encryptionKeyFilepath, overrides)
|
|
|
|
}
|
|
|
|
|
|
|
|
return setupCfg.interactive(cmd, setupDir, encryptionKeyFilepath, overrides)
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func cmdRun(cmd *cobra.Command, args []string) (err error) {
|
|
|
|
address := runCfg.Server.Address
|
|
|
|
host, port, err := net.SplitHostPort(address)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if host == "" {
|
2019-04-05 13:09:16 +01:00
|
|
|
address = net.JoinHostPort("127.0.0.1", port)
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx := process.Ctx(cmd)
|
|
|
|
|
2019-05-08 17:52:57 +01:00
|
|
|
if err := process.InitMetrics(ctx, nil, ""); err != nil {
|
2019-02-04 15:50:06 +00:00
|
|
|
zap.S().Error("Failed to initialize telemetry batcher: ", err)
|
|
|
|
}
|
2019-04-03 20:13:39 +01:00
|
|
|
|
2019-07-08 15:45:20 +01:00
|
|
|
err = version.CheckProcessVersion(ctx, runCfg.Version, version.Build, "Gateway")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
zap.S().Infof("Starting Storj S3-compatible gateway!\n\n")
|
|
|
|
zap.S().Infof("Endpoint: %s\n", address)
|
|
|
|
zap.S().Infof("Access key: %s\n", runCfg.Minio.AccessKey)
|
|
|
|
zap.S().Infof("Secret key: %s\n", runCfg.Minio.SecretKey)
|
|
|
|
|
2019-05-10 12:17:58 +01:00
|
|
|
err = checkCfg(ctx)
|
2019-02-04 15:50:06 +00:00
|
|
|
if err != nil {
|
2019-07-08 15:45:20 +01:00
|
|
|
zap.S().Warn("Failed to contact Satellite. Perhaps your configuration is invalid?")
|
|
|
|
return err
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
|
2019-05-08 17:52:57 +01:00
|
|
|
return runCfg.Run(ctx)
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func generateKey() (key string, err error) {
|
|
|
|
var buf [20]byte
|
|
|
|
_, err = rand.Read(buf[:])
|
|
|
|
if err != nil {
|
2019-06-07 17:14:40 +01:00
|
|
|
return "", Error.Wrap(err)
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
return base58.Encode(buf[:]), nil
|
|
|
|
}
|
|
|
|
|
2019-05-10 12:17:58 +01:00
|
|
|
func checkCfg(ctx context.Context) (err error) {
|
|
|
|
proj, err := runCfg.openProject(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer func() { err = errs.Combine(err, proj.Close()) }()
|
|
|
|
|
2019-07-12 13:57:02 +01:00
|
|
|
_, err = proj.ListBuckets(ctx, &storj.BucketListOptions{Direction: storj.Forward})
|
2019-05-10 12:17:58 +01:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-02-08 12:57:35 +00:00
|
|
|
// Run starts a Minio Gateway given proper config
|
2019-05-08 17:52:57 +01:00
|
|
|
func (flags GatewayFlags) Run(ctx context.Context) (err error) {
|
2019-02-08 12:57:35 +00:00
|
|
|
err = minio.RegisterGatewayCommand(cli.Command{
|
|
|
|
Name: "storj",
|
|
|
|
Usage: "Storj",
|
|
|
|
Action: func(cliCtx *cli.Context) error {
|
2019-05-08 17:52:57 +01:00
|
|
|
return flags.action(ctx, cliCtx)
|
2019-02-08 12:57:35 +00:00
|
|
|
},
|
|
|
|
HideHelpCommand: true,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(jt): Surely there is a better way. This is so upsetting
|
|
|
|
err = os.Setenv("MINIO_ACCESS_KEY", flags.Minio.AccessKey)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = os.Setenv("MINIO_SECRET_KEY", flags.Minio.SecretKey)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
minio.Main([]string{"storj", "gateway", "storj",
|
|
|
|
"--address", flags.Server.Address, "--config-dir", flags.Minio.Dir, "--quiet"})
|
|
|
|
return errs.New("unexpected minio exit")
|
|
|
|
}
|
|
|
|
|
2019-05-08 17:52:57 +01:00
|
|
|
func (flags GatewayFlags) action(ctx context.Context, cliCtx *cli.Context) (err error) {
|
|
|
|
gw, err := flags.NewGateway(ctx)
|
2019-02-08 12:57:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
minio.StartGateway(cliCtx, miniogw.Logging(gw, zap.L()))
|
|
|
|
return errs.New("unexpected minio exit")
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewGateway creates a new minio Gateway
|
2019-05-08 17:52:57 +01:00
|
|
|
func (flags GatewayFlags) NewGateway(ctx context.Context) (gw minio.Gateway, err error) {
|
2019-06-28 06:18:24 +01:00
|
|
|
access, err := setup.LoadEncryptionAccess(ctx, flags.Enc)
|
2019-05-22 14:57:12 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-05-08 17:52:57 +01:00
|
|
|
|
|
|
|
project, err := flags.openProject(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return miniogw.NewStorjGateway(
|
|
|
|
project,
|
2019-06-28 06:18:24 +01:00
|
|
|
access,
|
2019-07-03 19:07:44 +01:00
|
|
|
storj.CipherSuite(flags.Enc.PathType),
|
|
|
|
flags.GetEncryptionParameters(),
|
2019-05-08 17:52:57 +01:00
|
|
|
flags.GetRedundancyScheme(),
|
|
|
|
flags.Client.SegmentSize,
|
|
|
|
), nil
|
|
|
|
}
|
|
|
|
|
2019-07-30 18:49:01 +01:00
|
|
|
func (flags *GatewayFlags) newUplink(ctx context.Context) (*libuplink.Uplink, error) {
|
|
|
|
// Transform the gateway config flags to the libuplink config object
|
|
|
|
libuplinkCfg := &libuplink.Config{}
|
|
|
|
libuplinkCfg.Volatile.MaxInlineSize = flags.Client.MaxInlineSize
|
|
|
|
libuplinkCfg.Volatile.MaxMemory = flags.RS.MaxBufferMem
|
|
|
|
libuplinkCfg.Volatile.PeerIDVersion = flags.TLS.PeerIDVersions
|
|
|
|
libuplinkCfg.Volatile.TLS = struct {
|
2019-04-15 21:13:02 +01:00
|
|
|
SkipPeerCAWhitelist bool
|
|
|
|
PeerCAWhitelistPath string
|
|
|
|
}{
|
|
|
|
SkipPeerCAWhitelist: !flags.TLS.UsePeerCAWhitelist,
|
|
|
|
PeerCAWhitelistPath: flags.TLS.PeerCAWhitelistPath,
|
|
|
|
}
|
|
|
|
|
2019-07-30 18:49:01 +01:00
|
|
|
libuplinkCfg.Volatile.DialTimeout = flags.Client.DialTimeout
|
|
|
|
libuplinkCfg.Volatile.RequestTimeout = flags.Client.RequestTimeout
|
|
|
|
|
|
|
|
return libuplink.NewUplink(ctx, libuplinkCfg)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (flags GatewayFlags) openProject(ctx context.Context) (*libuplink.Project, error) {
|
2019-05-22 14:57:12 +01:00
|
|
|
apiKey, err := libuplink.ParseAPIKey(flags.Client.APIKey)
|
2019-04-15 21:13:02 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-07-30 18:49:01 +01:00
|
|
|
uplk, err := flags.newUplink(ctx)
|
2019-05-22 14:57:12 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-06-24 03:06:14 +01:00
|
|
|
return uplk.OpenProject(ctx, flags.Client.SatelliteAddr, apiKey)
|
2019-02-04 15:50:06 +00:00
|
|
|
}
|
|
|
|
|
2019-06-07 17:14:40 +01:00
|
|
|
// interactive creates the configuration of the gateway interactively.
|
|
|
|
//
|
|
|
|
// encryptionKeyFilepath should be set to the filepath indicated by the user or
|
|
|
|
// or to a default path whose directory tree exists.
|
|
|
|
func (flags GatewayFlags) interactive(
|
|
|
|
cmd *cobra.Command, setupDir string, encryptionKeyFilepath string, overrides map[string]interface{},
|
|
|
|
) error {
|
2019-07-29 08:17:49 +01:00
|
|
|
ctx := process.Ctx(cmd)
|
|
|
|
|
2019-06-25 19:25:31 +01:00
|
|
|
satelliteAddress, err := wizard.PromptForSatellite(cmd)
|
2019-05-07 15:29:57 +01:00
|
|
|
if err != nil {
|
|
|
|
return Error.Wrap(err)
|
|
|
|
}
|
|
|
|
|
2019-07-29 08:17:49 +01:00
|
|
|
apiKeyString, err := wizard.PromptForAPIKey()
|
|
|
|
if err != nil {
|
|
|
|
return Error.Wrap(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
apiKey, err := libuplink.ParseAPIKey(apiKeyString)
|
|
|
|
if err != nil {
|
|
|
|
return Error.Wrap(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
passphrase, err := wizard.PromptForEncryptionPassphrase()
|
|
|
|
if err != nil {
|
|
|
|
return Error.Wrap(err)
|
|
|
|
}
|
|
|
|
|
2019-07-30 18:49:01 +01:00
|
|
|
uplk, err := flags.newUplink(ctx)
|
2019-07-29 08:17:49 +01:00
|
|
|
if err != nil {
|
|
|
|
return Error.Wrap(err)
|
|
|
|
}
|
|
|
|
defer func() { err = errs.Combine(err, uplk.Close()) }()
|
|
|
|
|
|
|
|
project, err := uplk.OpenProject(ctx, satelliteAddress, apiKey)
|
2019-05-07 15:29:57 +01:00
|
|
|
if err != nil {
|
|
|
|
return Error.Wrap(err)
|
|
|
|
}
|
2019-07-29 08:17:49 +01:00
|
|
|
defer func() { err = errs.Combine(err, project.Close()) }()
|
2019-05-07 15:29:57 +01:00
|
|
|
|
2019-07-29 08:17:49 +01:00
|
|
|
key, err := project.SaltedKeyFromPassphrase(ctx, passphrase)
|
2019-06-07 17:14:40 +01:00
|
|
|
if err != nil {
|
|
|
|
return Error.Wrap(err)
|
|
|
|
}
|
|
|
|
|
2019-07-29 08:17:49 +01:00
|
|
|
err = setup.SaveEncryptionKey(string(key[:]), encryptionKeyFilepath)
|
2019-05-07 15:29:57 +01:00
|
|
|
if err != nil {
|
|
|
|
return Error.Wrap(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
overrides["satellite-addr"] = satelliteAddress
|
2019-07-29 08:17:49 +01:00
|
|
|
overrides["api-key"] = apiKeyString
|
2019-06-25 18:29:52 +01:00
|
|
|
overrides["enc.key-filepath"] = encryptionKeyFilepath
|
2019-05-07 15:29:57 +01:00
|
|
|
|
|
|
|
err = process.SaveConfigWithAllDefaults(cmd.Flags(), filepath.Join(setupDir, "config.yaml"), overrides)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-06-07 17:14:40 +01:00
|
|
|
_, err = fmt.Printf(`
|
|
|
|
Your encryption key is saved to: %s
|
|
|
|
|
2019-05-07 15:29:57 +01:00
|
|
|
Your S3 Gateway is configured and ready to use!
|
|
|
|
|
|
|
|
Some things to try next:
|
|
|
|
|
|
|
|
* Run 'gateway --help' to see the operations that can be performed
|
|
|
|
|
|
|
|
* See https://github.com/storj/docs/blob/master/S3-Gateway.md#using-the-aws-s3-commandline-interface for some example commands
|
2019-06-07 17:14:40 +01:00
|
|
|
`, encryptionKeyFilepath)
|
2019-05-07 15:29:57 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-06-07 17:14:40 +01:00
|
|
|
// nonInteractive creates the configuration of the gateway non-interactively.
|
|
|
|
//
|
|
|
|
// encryptionKeyFilepath should be set to the filepath indicated by the user or
|
|
|
|
// or to a default path whose directory tree exists.
|
|
|
|
func (flags GatewayFlags) nonInteractive(
|
|
|
|
cmd *cobra.Command, setupDir string, encryptionKeyFilepath string, overrides map[string]interface{},
|
|
|
|
) error {
|
|
|
|
if setupCfg.Enc.EncryptionKey != "" {
|
2019-06-27 18:36:51 +01:00
|
|
|
err := setup.SaveEncryptionKey(setupCfg.Enc.EncryptionKey, encryptionKeyFilepath)
|
2019-06-07 17:14:40 +01:00
|
|
|
if err != nil {
|
|
|
|
return Error.Wrap(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
err := process.SaveConfigWithAllDefaults(cmd.Flags(), filepath.Join(setupDir, "config.yaml"), overrides)
|
|
|
|
if err != nil {
|
|
|
|
return Error.Wrap(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if setupCfg.Enc.EncryptionKey != "" {
|
|
|
|
_, _ = fmt.Printf("Your encryption key is saved to: %s\n", encryptionKeyFilepath)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:14:38 +01:00
|
|
|
func main() {
|
2019-02-04 15:50:06 +00:00
|
|
|
process.Exec(rootCmd)
|
2018-10-25 00:14:38 +01:00
|
|
|
}
|