storj/cmd/storagenode/root.go
Clement Sam f14fabc90a cmd/storagenode: add forget-satellite subcommand
This change adds a new forget-satellite sub-command to
the storagenode CLI which cleans up untrusted satellite
data.

Issue: https://github.com/storj/storj/issues/6068
Change-Id: Iafa109fdc98afdba7582f568a61c22222da65f02
2023-09-13 19:06:55 +00:00

70 lines
1.9 KiB
Go

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"github.com/spf13/cobra"
"go.uber.org/zap"
"storj.io/common/fpath"
"storj.io/private/cfgstruct"
"storj.io/storj/cmd/storagenode/internalcmd"
"storj.io/storj/storagenode"
)
// StorageNodeFlags defines storage node configuration.
type StorageNodeFlags struct {
EditConf bool `default:"false" help:"open config in default editor"`
storagenode.Config
Deprecated
}
// Factory contains default values for configuration flags.
type Factory struct {
Defaults cfgstruct.BindOpt
ConfDir string
IdentityDir string
UseColor bool
}
// newRootCmd creates a new root command.
func newRootCmd(setDefaults bool) (*cobra.Command, *Factory) {
cmd := &cobra.Command{
Use: "storagenode",
Short: "Storagenode",
}
factory := &Factory{}
if setDefaults {
defaultConfDir := fpath.ApplicationDir("storj", "storagenode")
defaultIdentityDir := fpath.ApplicationDir("storj", "identity", "storagenode")
cfgstruct.SetupFlag(zap.L(), cmd, &factory.ConfDir, "config-dir", defaultConfDir, "main directory for storagenode configuration")
cfgstruct.SetupFlag(zap.L(), cmd, &factory.IdentityDir, "identity-dir", defaultIdentityDir, "main directory for storagenode identity credentials")
cmd.PersistentFlags().BoolVar(&factory.UseColor, "color", false, "use color in user interface")
factory.Defaults = cfgstruct.DefaultsFlag(cmd)
}
cmd.AddCommand(
newConfigCmd(factory),
newSetupCmd(factory),
newDashboardCmd(factory),
newDiagCmd(factory),
newRunCmd(factory),
newNodeInfoCmd(factory),
newIssueAPIKeyCmd(factory),
newGracefulExitInitCmd(factory),
newGracefulExitStatusCmd(factory),
newForgetSatelliteCmd(factory),
// internal hidden commands
internalcmd.NewUsedSpaceFilewalkerCmd().Command,
internalcmd.NewGCFilewalkerCmd().Command,
)
return cmd, factory
}