-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathupdate.go
More file actions
51 lines (47 loc) · 1.39 KB
/
Copy pathupdate.go
File metadata and controls
51 lines (47 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package cli
import (
"context"
"os"
"github.com/spf13/cobra"
"go.keploy.io/server/v3/cli/provider"
"go.keploy.io/server/v3/config"
toolsSvc "go.keploy.io/server/v3/pkg/service/tools"
"go.keploy.io/server/v3/utils"
"go.uber.org/zap"
)
func init() {
Register("update", Update)
}
// Update retrieves the command to tools Keploy
func Update(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command {
var updateCmd = &cobra.Command{
Use: "update",
Short: "Update Keploy ",
Example: "keploy update",
RunE: func(cmd *cobra.Command, _ []string) error {
disableAnsi, _ := (cmd.Flags().GetBool("disable-ansi"))
provider.PrintLogo(os.Stdout, disableAnsi)
svc, err := serviceFactory.GetService(ctx, "update")
if err != nil {
utils.LogError(logger, err, "failed to get service", zap.String("command", cmd.Name()))
return nil
}
var tools toolsSvc.Service
var ok bool
if tools, ok = svc.(toolsSvc.Service); !ok {
utils.LogError(logger, nil, "service doesn't satisfy tools service interface")
return nil
}
err = tools.Update(ctx)
if err != nil {
utils.LogError(logger, err, "failed to update")
}
return nil
},
}
if err := cmdConfigurator.AddFlags(updateCmd); err != nil {
utils.LogError(logger, err, "failed to add update cmd flags")
return nil
}
return updateCmd
}