forked from keploy/keploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'keploy:main' into main
- Loading branch information
Showing
18 changed files
with
693 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
"go.keploy.io/server/v2/cli/provider" | ||
"go.keploy.io/server/v2/config" | ||
toolsSvc "go.keploy.io/server/v2/pkg/service/tools" | ||
"go.keploy.io/server/v2/utils" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func init() { | ||
Register("import", Import) | ||
} | ||
|
||
func Import(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command { | ||
|
||
var importCmd = &cobra.Command{ | ||
Use: "import", | ||
Short: "import postman collection to Keploy tests", | ||
Example: "keploy import", | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
disableAnsi, _ := (cmd.Flags().GetBool("disable-ansi")) | ||
provider.PrintLogo(disableAnsi) | ||
return cmd.Help() | ||
}, | ||
} | ||
var postmanCmd = &cobra.Command{ | ||
Use: "postman", | ||
Short: "import postman collection to Keploy tests", | ||
Example: "keploy import postman", | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
disableAnsi, _ := (cmd.Flags().GetBool("disable-ansi")) | ||
provider.PrintLogo(disableAnsi) | ||
path, _ := cmd.Flags().GetString("path") | ||
if path == "" { | ||
path = "output.json" | ||
} | ||
svc, err := serviceFactory.GetService(ctx, "import") | ||
if err != nil { | ||
utils.LogError(logger, err, "failed to get service") | ||
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.Import(ctx, path) | ||
if err != nil { | ||
utils.LogError(logger, err, "failed to import Postman collection") | ||
} | ||
return nil | ||
}, | ||
} | ||
importCmd.AddCommand(postmanCmd) | ||
|
||
for _, subCmd := range importCmd.Commands() { | ||
err := cmdConfigurator.AddFlags(subCmd) | ||
if err != nil { | ||
utils.LogError(logger, err, "failed to add flags to command", zap.String("command", subCmd.Name())) | ||
} | ||
} | ||
|
||
return importCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.