Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: autogenerate config if it doesn't already exist at the path #1773

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

PranshuSrivastava
Copy link
Member

Related Issue

It would be good to autogenerate a config file for the user if it doesn't already exist

Closes: #1737

Describe the changes you've made

Checking if the config file exists or not, and if it doesn't create one with the flags and parameters provided in the command

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Copy link
Member

@charankamarapu charankamarapu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIx the github actions

@PranshuSrivastava PranshuSrivastava force-pushed the autogen-config branch 7 times, most recently from 5113cd4 to cee0035 Compare May 13, 2024 17:49
Copy link
Member

@charankamarapu charankamarapu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the comments and resolve the pipeline failures

@@ -69,9 +69,6 @@ sudo -E env PATH=$PATH ./../../keployv2 test -c 'npm start' --delay 10 --generat

sudo -E env PATH=$PATH ./../../keployv2 test -c 'npm start' --delay 10 --testsets test-set-0 --generateGithubActions=false

# Generate the keploy-config file.
sudo ./../../keployv2 config --generate

# Update the global noise to ts.
config_file="./keploy.yml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will these filters appended to the config if you are not generating them ahead..?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in our case the config file would have already been generated when we are running keploy in the record and the test mode. So this command is not needed now, we can just edit the same keploy config file.

@@ -294,7 +294,7 @@ func (c *CmdConfigurator) ValidateFlags(ctx context.Context, cmd *cobra.Command)
utils.LogError(c.logger, err, errMsg)
return errors.New(errMsg)
}
c.logger.Info("config file not found; proceeding with flags only")
c.logger.Info("config file not found; creating one and proceeding with flags for now.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "for now" from the sentence. and mention that you are creating config file from the flag that are used.

@@ -83,7 +85,21 @@ func (n *ServiceProvider) GetService(ctx context.Context, cmd string) (interface
case "config", "update":
return tools.NewTools(n.logger, tel), nil
// TODO: add case for mock
case "record", "test", "mock", "normalize":
case "record", "test", "mock":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the normalize removed from switch case..?

// Check if the config file exists on the path or not and if it does not, we create it.
if !utils.CheckFileExists("keploy.yml") {
toolsService := tools.NewTools(n.logger, tel)
n.cfg.Path = strings.TrimSuffix(n.cfg.Path, "/keploy")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a local variable rather an trimming and attaching to config object..?

if err != nil {
n.logger.Debug("failed to marshal the config")
}
err = toolsService.CreateConfig(ctx, "keploy.yml", string(yamlData))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a screenshot by using 3 flags like selected test-sets etc and generate the config file..?

@Sarthak160
Copy link
Member

@PranshuSrivastava , Is this ready for merge ? as we need this in VsCode Extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature]: auto create config file for users
3 participants