MCPcopy
hub / github.com/keploy/keploy / Download

Function Download

cli/contract.go:79–109  ·  view source on GitHub ↗
(ctx context.Context, logger *zap.Logger, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator)

Source from the content-addressed store, hash-verified

77}
78
79func Download(ctx context.Context, logger *zap.Logger, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command {
80 var cmd = &cobra.Command{
81 Use: "download",
82 Short: "Download contract for specified services",
83 Example: `keploy contract download --service="email,notify" --path /local/path`,
84 PreRunE: func(cmd *cobra.Command, _ []string) error {
85 return cmdConfigurator.Validate(ctx, cmd)
86 },
87 RunE: func(cmd *cobra.Command, _ []string) error {
88 svc, err := serviceFactory.GetService(ctx, "contract")
89 if err != nil {
90 utils.LogError(logger, err, "failed to get service", zap.String("command", cmd.Name()))
91 return nil
92 }
93 var contract contractSvc.Service
94 var ok bool
95 if contract, ok = svc.(contractSvc.Service); !ok {
96 utils.LogError(logger, nil, "service doesn't satisfy contract service interface")
97 return nil
98 }
99 err = contract.Download(ctx, true)
100
101 if err != nil {
102 utils.LogError(logger, err, "failed to download contract")
103 }
104 return nil
105 },
106 }
107
108 return cmd
109}
110
111func Validate(ctx context.Context, logger *zap.Logger, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command {
112 var cmd = &cobra.Command{

Callers 1

ContractFunction · 0.85

Calls 6

DownloadMethod · 0.95
LogErrorFunction · 0.92
NameMethod · 0.80
ValidateMethod · 0.65
GetServiceMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected