-
-
Notifications
You must be signed in to change notification settings - Fork 379
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
PranshuSrivastava
wants to merge
21
commits into
main
Choose a base branch
from
autogen-config
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b33abac
fix: work in progress
PranshuSrivastava eb5d035
feat: auto gen config file if it does not exist
PranshuSrivastava ee03efc
fix: fix ci errors
PranshuSrivastava bbc901e
Merge branch 'main' into autogen-config
PranshuSrivastava 941c9c6
Merge branch 'main' into autogen-config
PranshuSrivastava 2787589
Merge branch 'main' into autogen-config
PranshuSrivastava 83a4595
chore: checking the pipeline
PranshuSrivastava dde140f
chore: fix merge conflicts and checking failing test
PranshuSrivastava 22dab02
Merge branch 'autogen-config' of https://github.com/keploy/keploy int…
PranshuSrivastava feb811d
chore: fix merge conflicts and checking failing test
PranshuSrivastava cc1829e
Merge branch 'main' into autogen-config
PranshuSrivastava 45a86af
fix: trimming /keploy from the path
PranshuSrivastava b9f5816
fix: updated checking location
PranshuSrivastava 9b79de1
fix: removed unnecessary changes
PranshuSrivastava e844206
Merge branch 'main' into autogen-config
PranshuSrivastava 877a158
fix: made changes according to the comments
PranshuSrivastava cec6389
fix: changing local variables instead of the actual config
PranshuSrivastava 1b2684e
Merge branch 'main' into autogen-config
Sarthak160 7107851
Merge branch 'main' into autogen-config
PranshuSrivastava 3f6ce5e
fix: making deep copy of the config variable
PranshuSrivastava 980b739
fix: linting issues and node on docker failing
PranshuSrivastava File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ package provider | |
import ( | ||
"context" | ||
"errors" | ||
"strings" | ||
|
||
"go.keploy.io/server/v2/config" | ||
"go.keploy.io/server/v2/pkg/core" | ||
|
@@ -20,6 +21,7 @@ import ( | |
"go.keploy.io/server/v2/pkg/service/tools" | ||
"go.keploy.io/server/v2/utils" | ||
"go.uber.org/zap" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type ServiceProvider struct { | ||
|
@@ -84,6 +86,45 @@ func (n *ServiceProvider) GetService(ctx context.Context, cmd string) (interface | |
return tools.NewTools(n.logger, tel), nil | ||
// TODO: add case for mock | ||
case "record", "test", "mock", "normalize": | ||
// 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) | ||
config := &config.Config{ | ||
Path: n.cfg.Path, | ||
AppID: n.cfg.AppID, | ||
ReRecord: n.cfg.ReRecord, | ||
Command: n.cfg.Command, | ||
Port: n.cfg.Port, | ||
DNSPort: n.cfg.DNSPort, | ||
ProxyPort: n.cfg.ProxyPort, | ||
Debug: n.cfg.Debug, | ||
DisableTele: n.cfg.DisableTele, | ||
DisableANSI: n.cfg.DisableANSI, | ||
InDocker: n.cfg.InDocker, | ||
ContainerName: n.cfg.ContainerName, | ||
NetworkName: n.cfg.NetworkName, | ||
BuildDelay: n.cfg.BuildDelay, | ||
Test: n.cfg.Test, | ||
Record: n.cfg.Record, | ||
Normalize: n.cfg.Normalize, | ||
ConfigPath: n.cfg.ConfigPath, | ||
BypassRules: n.cfg.BypassRules, | ||
EnableTesting: n.cfg.EnableTesting, | ||
GenerateGithubActions: n.cfg.GenerateGithubActions, | ||
KeployContainer: n.cfg.KeployContainer, | ||
KeployNetwork: n.cfg.KeployNetwork, | ||
CommandType: n.cfg.CommandType, | ||
} | ||
config.Path = strings.TrimSuffix(config.Path, "/keploy") | ||
yamlData, err := yaml.Marshal(config) | ||
if err != nil { | ||
n.logger.Debug("failed to marshal the config") | ||
} | ||
err = toolsService.CreateConfig(ctx, "keploy.yml", string(yamlData)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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..? |
||
if err != nil { | ||
n.logger.Debug("failed to create the config file", zap.Error(err)) | ||
} | ||
} | ||
commonServices := n.GetCommonServices(*n.cfg) | ||
if cmd == "record" { | ||
return record.New(n.logger, commonServices.YamlTestDB, commonServices.YamlMockDb, tel, commonServices.Instrumentation, *n.cfg), nil | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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..?
There was a problem hiding this comment.
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.