Skip to content

Commit

Permalink
feat: in CI flag (keploy#2050)
Browse files Browse the repository at this point in the history
* in ci flag

Signed-off-by: Yash <[email protected]>
---------

Signed-off-by: Yash <[email protected]>
  • Loading branch information
khareyash05 authored Jul 10, 2024
1 parent b319698 commit 191bc2f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
3 changes: 2 additions & 1 deletion cli/provider/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ func (c *CmdConfigurator) AddFlags(cmd *cobra.Command) error {
var err error
cmd.Flags().SetNormalizeFunc(aliasNormalizeFunc)
switch cmd.Name() {

case "update":
return nil
case "normalize":
Expand Down Expand Up @@ -216,6 +215,7 @@ func (c *CmdConfigurator) AddFlags(cmd *cobra.Command) error {
cmd.Flags().Uint64P("app-id", "a", c.cfg.AppID, "A unique name for the user's application")
cmd.Flags().String("app-name", c.cfg.AppName, "Name of the user's application")
cmd.Flags().Bool("generate-github-actions", c.cfg.GenerateGithubActions, "Generate Github Actions workflow file")
cmd.Flags().Bool("in-ci", c.cfg.InCi, "is CI Running or not")
err = cmd.Flags().MarkHidden("port")
if err != nil {
errMsg := "failed to mark port as hidden flag"
Expand Down Expand Up @@ -322,6 +322,7 @@ func aliasNormalizeFunc(_ *pflag.FlagSet, name string) pflag.NormalizedName {
"keployNetwork": "keploy-network",
"recordTimer": "record-timer",
"urlMethods": "url-methods",
"inCi": "in-ci",
}

if newName, ok := flagNameMapping[name]; ok {
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Config struct {
KeployContainer string `json:"keployContainer" yaml:"keployContainer" mapstructure:"keployContainer"`
KeployNetwork string `json:"keployNetwork" yaml:"keployNetwork" mapstructure:"keployNetwork"`
CommandType string `json:"cmdType" yaml:"cmdType" mapstructure:"cmdType"`
InCi bool `json:"inCi" yaml:"inCi" mapstructure:"inCi"`
}

type UtGen struct {
Expand Down
37 changes: 19 additions & 18 deletions pkg/service/orchestrator/rerecord.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,26 +149,27 @@ func (o *Orchestrator) ReRecord(ctx context.Context) error {
}

stopReason = "Re-recorded all the selected testsets successfully"
o.logger.Info("Re-record was successfull. Do you want to remove the older testsets? (y/n)", zap.Any("testsets", SelectedTests))
reader := bufio.NewReader(os.Stdin)
input, err := reader.ReadString('\n')
if err != nil {
o.logger.Warn("Failed to read input. The older testsets will be kept.")
return nil
}

if input == "y\n" || input == "Y\n" {
for _, testSet := range SelectedTests {
err := o.replay.DeleteTestSet(ctx, testSet)
if err != nil {
o.logger.Warn("Failed to delete the testset", zap.String("testset", testSet))
if !o.config.InCi {
o.logger.Info("Re-record was successfull. Do you want to remove the older testsets? (y/n)", zap.Any("testsets", SelectedTests))
reader := bufio.NewReader(os.Stdin)
input, err := reader.ReadString('\n')
if err != nil {
o.logger.Warn("Failed to read input. The older testsets will be kept.")
return nil
}
if input == "y\n" || input == "Y\n" {
for _, testSet := range SelectedTests {
err := o.replay.DeleteTestSet(ctx, testSet)
if err != nil {
o.logger.Warn("Failed to delete the testset", zap.String("testset", testSet))
}
}
o.logger.Info("Deleted the older testsets successfully")
} else if input == "n\n" || input == "N\n" {
o.logger.Info("skipping the deletion of older testsets")
} else {
o.logger.Warn("Invalid input. The older testsets will be kept.")
}
o.logger.Info("Deleted the older testsets successfully")
} else if input == "n\n" || input == "N\n" {
o.logger.Info("skipping the deletion of older testsets")
} else {
o.logger.Warn("Invalid input. The older testsets will be kept.")
}
return nil
}
Expand Down

0 comments on commit 191bc2f

Please sign in to comment.