MCPcopy
hub / github.com/keploy/keploy / Sanitize

Function Sanitize

cli/sanitize.go:17–55  ·  view source on GitHub ↗
(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator)

Source from the content-addressed store, hash-verified

15}
16
17func Sanitize(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command {
18 var cmd = &cobra.Command{
19 Use: "sanitize",
20 Short: "sanitize the keploy testcases to remove the sensitive data",
21 Example: `keploy sanitize -t "test-set-id"`,
22 PreRunE: func(cmd *cobra.Command, _ []string) error {
23 return cmdConfigurator.Validate(ctx, cmd)
24 },
25 RunE: func(cmd *cobra.Command, _ []string) error {
26 svc, err := serviceFactory.GetService(ctx, cmd.Name())
27 if err != nil {
28 utils.LogError(logger, err, "failed to get service", zap.String("command", cmd.Name()))
29 return nil
30 }
31 var sanitizeService toolsSvc.Service
32 var ok bool
33 if sanitizeService, ok = svc.(toolsSvc.Service); !ok {
34 utils.LogError(logger, nil, "service doesn't satisfy tools service interface")
35 return nil
36 }
37
38 err = sanitizeService.Sanitize(ctx)
39 if err != nil {
40 utils.LogError(logger, err, "failed to sanitize test cases")
41 return nil
42 }
43
44 return nil
45 },
46 }
47
48 err := cmdConfigurator.AddFlags(cmd)
49 if err != nil {
50 utils.LogError(logger, err, "failed to add sanitize flags")
51 return nil
52 }
53
54 return cmd
55}

Callers

nothing calls this directly

Calls 7

SanitizeMethod · 0.95
LogErrorFunction · 0.92
NameMethod · 0.80
ValidateMethod · 0.65
GetServiceMethod · 0.65
AddFlagsMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected