Merge pull request #10557 from tariq1890/cli-ctx-add
use ctx object from cliContext instead of a creating a new one
This commit is contained in:
commit
dd2a24cf0e
@ -87,7 +87,8 @@ var configCommand = &cli.Command{
|
|||||||
Name: "default",
|
Name: "default",
|
||||||
Usage: "See the output of the default config",
|
Usage: "See the output of the default config",
|
||||||
Action: func(cliContext *cli.Context) error {
|
Action: func(cliContext *cli.Context) error {
|
||||||
return outputConfig(context.Background(), defaultConfig())
|
ctx := cliContext.Context
|
||||||
|
return outputConfig(ctx, defaultConfig())
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -95,7 +96,7 @@ var configCommand = &cli.Command{
|
|||||||
Usage: "See the output of the final main config with imported in subconfig files",
|
Usage: "See the output of the final main config with imported in subconfig files",
|
||||||
Action: func(cliContext *cli.Context) error {
|
Action: func(cliContext *cli.Context) error {
|
||||||
config := defaultConfig()
|
config := defaultConfig()
|
||||||
ctx := context.Background()
|
ctx := cliContext.Context
|
||||||
if err := srvconfig.LoadConfig(ctx, cliContext.String("config"), config); err != nil && !os.IsNotExist(err) {
|
if err := srvconfig.LoadConfig(ctx, cliContext.String("config"), config); err != nil && !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -108,7 +109,7 @@ var configCommand = &cli.Command{
|
|||||||
Usage: "Migrate the current configuration file to the latest version (does not migrate subconfig files)",
|
Usage: "Migrate the current configuration file to the latest version (does not migrate subconfig files)",
|
||||||
Action: func(cliContext *cli.Context) error {
|
Action: func(cliContext *cli.Context) error {
|
||||||
config := defaultConfig()
|
config := defaultConfig()
|
||||||
ctx := context.Background()
|
ctx := cliContext.Context
|
||||||
if err := srvconfig.LoadConfig(ctx, cliContext.String("config"), config); err != nil && !os.IsNotExist(err) {
|
if err := srvconfig.LoadConfig(ctx, cliContext.String("config"), config); err != nil && !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ can be used and modified as necessary as a custom configuration.`
|
|||||||
start = time.Now()
|
start = time.Now()
|
||||||
signals = make(chan os.Signal, 2048)
|
signals = make(chan os.Signal, 2048)
|
||||||
serverC = make(chan *server.Server, 1)
|
serverC = make(chan *server.Server, 1)
|
||||||
ctx, cancel = context.WithCancel(context.Background())
|
ctx, cancel = context.WithCancel(cliContext.Context)
|
||||||
config = defaultConfig()
|
config = defaultConfig()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ var publishCommand = &cli.Command{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: func(cliContext *cli.Context) error {
|
Action: func(cliContext *cli.Context) error {
|
||||||
ctx := namespaces.WithNamespace(context.Background(), cliContext.String("namespace"))
|
ctx := namespaces.WithNamespace(cliContext.Context, cliContext.String("namespace"))
|
||||||
topic := cliContext.String("topic")
|
topic := cliContext.String("topic")
|
||||||
if topic == "" {
|
if topic == "" {
|
||||||
return fmt.Errorf("topic required to publish event: %w", errdefs.ErrInvalidArgument)
|
return fmt.Errorf("topic required to publish event: %w", errdefs.ErrInvalidArgument)
|
||||||
|
@ -35,7 +35,7 @@ import (
|
|||||||
// defined.
|
// defined.
|
||||||
func AppContext(cliContext *cli.Context) (context.Context, context.CancelFunc) {
|
func AppContext(cliContext *cli.Context) (context.Context, context.CancelFunc) {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = cliContext.Context
|
||||||
timeout = cliContext.Duration("timeout")
|
timeout = cliContext.Duration("timeout")
|
||||||
namespace = cliContext.String("namespace")
|
namespace = cliContext.String("namespace")
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
|
Loading…
Reference in New Issue
Block a user