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

Add support for backup, import by regex, interactive push #8

Closed
wants to merge 3 commits into from

Conversation

ivaivalous
Copy link

  • Consul configuration can be backed up before changes are applied when using push
  • Interactive mode has been added allowing the user to choose what keys to apply, one by one
  • A regular expression can be used to push all keys that match it. This can be used together with interactive push

 - Listing keys in push is now possible using a regular expression;
 - Add interactive mode for updating configuration;
 - Add backup creation prior to import
 - Template validation can now be skipped for restoring backups
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 84.882% when pulling 122b01c on push-regex into 4c686d3 on master.

@simeon-aladjem
Copy link

Coverage is still down 0.6% :(

@ivaivalous ivaivalous force-pushed the push-regex branch 2 times, most recently from f4b7af9 to 9f5fef5 Compare March 22, 2017 11:03
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 85.698% when pulling f5507f8 on push-regex into 4c686d3 on master.

@ivaivalous ivaivalous force-pushed the push-regex branch 2 times, most recently from a3405db to b8ee247 Compare March 22, 2017 14:26
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 85.698% when pulling 58b0c8e on push-regex into 4c686d3 on master.

Copy link
Owner

@VMitov VMitov left a comment

Choose a reason for hiding this comment

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

I'm not really happy with so much unrelated changes in one commit (mainly the first one). This makes the review process very hard and not that efficient. Also being in one pull request means that nothing can be merged even if only one change is not approved.
Also - test should be in the same commit as changes.

@@ -149,3 +150,9 @@ func toString(s interface{}) (string, bool) {
return "", false
}
}

func getRegex(key string) (isRegex bool, expression *regexp.Regexp) {
Copy link
Owner

Choose a reason for hiding this comment

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

The order of the return parameters should be the other way around.

@@ -18,7 +18,9 @@ var fetchCmd = &cobra.Command{
config := viper.GetStringMap("storage.config")
format := viper.GetString("format")

return fetchRun(storage, config, format)
cfg, err := fetchRun(storage, config, format)
fmt.Println(*cfg)
Copy link
Owner

Choose a reason for hiding this comment

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

For consistency all the printing is done in the *Run function. Can we move this print there?

return err
}

backup, err := cmd.Flags().GetBool("backup")
Copy link
Owner

Choose a reason for hiding this comment

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

There is a backup functionality (fetch). Having it in two places is obsolete. If you want it here you should expose a way to select filename and basically everything fetch exposes.

cmd/push.go Outdated
@@ -43,50 +61,154 @@ var pushCmd = &cobra.Command{
return err
}

return pushRun(template, format, key, sourcesList, storage, config, force, !plain)
pushConf := &pushConfig{
Copy link
Owner

Choose a reason for hiding this comment

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

I don't like the config struct. Can we make it so it has Run receiver? I guess we should migrate all the Run functions as receivers to a type.

"You will be able to confirm the list before applying it.\n\n")

return changeset.Refine(func(a interface{}) bool {
b := a.(diff.KVChange)
Copy link
Owner

Choose a reason for hiding this comment

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

You can't assume it is KVChange, different storage can have different way of showing diff - e.g. db storage.

@@ -49,3 +49,8 @@ func (c BuildConfig) Build() ([]byte, error) {

return cfgStr, nil
}

// BuildNoValidation creates the config based on a non-validated input file.
func (c BuildConfig) BuildNoValidation() ([]byte, error) {
Copy link
Owner

Choose a reason for hiding this comment

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

What's that about?

cmd/push.go Outdated
@@ -61,6 +63,8 @@ var pushCmd = &cobra.Command{
return err
}

plain = usePlain(plain)
Copy link
Owner

Choose a reason for hiding this comment

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

This function is confusing like that. I think it is better if you make it to be usePretty(plain).

@ivaivalous
Copy link
Author

Closing PR - requested changes to be handled in a separate branch/PR.

@ivaivalous ivaivalous closed this Mar 27, 2017
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.

None yet

4 participants