Add proper Version Handling to Identity, Gateway and Uplink Binary (#2471)
This commit is contained in:
parent
524eb24c83
commit
ccef5eee46
@ -20,6 +20,7 @@ import (
|
||||
|
||||
"storj.io/storj/cmd/internal/wizard"
|
||||
"storj.io/storj/internal/fpath"
|
||||
"storj.io/storj/internal/version"
|
||||
libuplink "storj.io/storj/lib/uplink"
|
||||
"storj.io/storj/pkg/cfgstruct"
|
||||
"storj.io/storj/pkg/miniogw"
|
||||
@ -37,6 +38,8 @@ type GatewayFlags struct {
|
||||
Minio miniogw.MinioConfig
|
||||
|
||||
uplink.Config
|
||||
|
||||
Version version.Config
|
||||
}
|
||||
|
||||
var (
|
||||
@ -144,21 +147,26 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) {
|
||||
address = net.JoinHostPort("127.0.0.1", port)
|
||||
}
|
||||
|
||||
fmt.Printf("Starting Storj S3-compatible gateway!\n\n")
|
||||
fmt.Printf("Endpoint: %s\n", address)
|
||||
fmt.Printf("Access key: %s\n", runCfg.Minio.AccessKey)
|
||||
fmt.Printf("Secret key: %s\n", runCfg.Minio.SecretKey)
|
||||
|
||||
ctx := process.Ctx(cmd)
|
||||
|
||||
if err := process.InitMetrics(ctx, nil, ""); err != nil {
|
||||
zap.S().Error("Failed to initialize telemetry batcher: ", err)
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
err = checkCfg(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to contact Satellite.\n"+
|
||||
"Perhaps your configuration is invalid?\n%s", err)
|
||||
zap.S().Warn("Failed to contact Satellite. Perhaps your configuration is invalid?")
|
||||
return err
|
||||
}
|
||||
|
||||
return runCfg.Run(ctx)
|
||||
|
@ -57,7 +57,9 @@ var (
|
||||
ParentKeyPath string `help:"path to the parent authority's private key"`
|
||||
Signer certificates.CertClientConfig
|
||||
// TODO: ideally the default is the latest version; can't interpolate struct tags
|
||||
Version uint `default:"0" help:"identity version to use when creating an identity or CA"`
|
||||
IdentityVersion uint `default:"0" help:"identity version to use when creating an identity or CA"`
|
||||
|
||||
Version version.Config
|
||||
}
|
||||
|
||||
identityDir, configDir string
|
||||
@ -84,7 +86,7 @@ func serviceDirectory(serviceName string) string {
|
||||
func cmdNewService(cmd *cobra.Command, args []string) error {
|
||||
ctx := process.Ctx(cmd)
|
||||
|
||||
err := version.CheckProcessVersion(ctx, version.Config{}, version.Build, "Identity")
|
||||
err := version.CheckProcessVersion(ctx, config.Version, version.Build, "Identity")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -103,7 +105,7 @@ func cmdNewService(cmd *cobra.Command, args []string) error {
|
||||
Concurrency: config.Concurrency,
|
||||
ParentCertPath: config.ParentCertPath,
|
||||
ParentKeyPath: config.ParentKeyPath,
|
||||
VersionNumber: config.Version,
|
||||
VersionNumber: config.IdentityVersion,
|
||||
}
|
||||
|
||||
status, err := caConfig.Status()
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/storj/internal/fpath"
|
||||
"storj.io/storj/internal/version"
|
||||
libuplink "storj.io/storj/lib/uplink"
|
||||
"storj.io/storj/pkg/cfgstruct"
|
||||
"storj.io/storj/pkg/process"
|
||||
@ -27,6 +28,8 @@ import (
|
||||
type UplinkFlags struct {
|
||||
NonInteractive bool `help:"disable interactive mode" default:"false" setup:"true"`
|
||||
uplink.Config
|
||||
|
||||
Version version.Config
|
||||
}
|
||||
|
||||
var (
|
||||
@ -91,6 +94,11 @@ func (cliCfg *UplinkFlags) NewUplink(ctx context.Context) (*libuplink.Uplink, er
|
||||
|
||||
// GetProject returns a *libuplink.Project for interacting with a specific project
|
||||
func (cliCfg *UplinkFlags) GetProject(ctx context.Context) (*libuplink.Project, error) {
|
||||
err := version.CheckProcessVersion(ctx, cliCfg.Version, version.Build, "Uplink")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiKey, err := libuplink.ParseAPIKey(cliCfg.Client.APIKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -337,7 +337,6 @@ func cleanup(cmd *cobra.Command) {
|
||||
|
||||
err = workErr
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Fatal error: %v\n", err)
|
||||
logger.Sugar().Debugf("Fatal error: %+v", err)
|
||||
_ = logger.Sync()
|
||||
os.Exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user