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

minikube config get/set/unset cmd #545

Merged
merged 1 commit into from
Sep 7, 2016
Merged

Conversation

r2d4
Copy link
Contributor

@r2d4 r2d4 commented Sep 2, 2016

This introduces the minikube config get/set/unset command. At a basic level, it allows a more user friendly interface for setting minikube config values, but it also allows us to run validations and callbacks before and after the values have been set.

This will allow us to validate settings to catch them before minikube gets incorrectly configured and might help us prevent some problems before they happen. Right now there are only some basic validations, drivers and CIDR but in the future we could have more complex ones if we have interdependent settings.

There are also callbacks that can give some output to the user. Right now there is only the "requires restart" message so that users know they will have to recreate their VM before their driver changes for instance.

In the future we could use this to set more complex settings like enabling addons or something. Let me know what you guys think.

(theres still a bit of work and cleanup to do before merging, but I wanted to get a first draft out before I go any further)

@r2d4 r2d4 force-pushed the config-set branch 3 times, most recently from a706f54 to 4da0b0e Compare September 2, 2016 17:09

// A generous cidr regex
// validates general format, but will allow some invalid values of the form xxx.xxx.xxx.xxx/xx
const CIDRregex = `^([0-9]{1,3}\.){3}[0-9]{1,3}(\/[0-9]|[1-2][0-9]3[0-2])?$`
Copy link
Contributor

Choose a reason for hiding this comment

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

Switch this to net.ParseCIDR

@r2d4 r2d4 force-pushed the config-set branch 2 times, most recently from 818ba3e to a06ea20 Compare September 2, 2016 21:25
}
glog.Errorf("Could not open file %s: %s", constants.ConfigFile, err)
}
var m map[string]interface{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be the MinikubeConfig type alias you defined above? (same for line 89)

@dlorenc
Copy link
Contributor

dlorenc commented Sep 4, 2016

This is looking really good. Just a few nits, and you'll need to add copyright headers to fix travis.

@r2d4 r2d4 force-pushed the config-set branch 2 times, most recently from 9ff9d79 to 2b662e0 Compare September 5, 2016 00:37
@codecov-io
Copy link

codecov-io commented Sep 5, 2016

Current coverage is 32.05% (diff: 27.74%)

Merging #545 into master will decrease coverage by 0.34%

@@             master       #545   diff @@
==========================================
  Files            38         44     +6   
  Lines          1676       1828   +152   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits            543        586    +43   
- Misses         1020       1125   +105   
- Partials        113        117     +4   

Powered by Codecov. Last update 430894c...a8dbc18

@dlorenc
Copy link
Contributor

dlorenc commented Sep 6, 2016

@minikube-bot test this please

1 similar comment
@dlorenc
Copy link
Contributor

dlorenc commented Sep 6, 2016

@minikube-bot test this please

@r2d4 r2d4 changed the title [WIP] minikube config get/set/unset cmd minikube config get/set/unset cmd Sep 6, 2016
@r2d4
Copy link
Contributor Author

r2d4 commented Sep 6, 2016

@dlorenc integration tests are passing now. I was setting a logging config property in the integration test which made the output unexpected.


// Reads in the JSON minikube config
func ReadConfig() MinikubeConfig {
f, err := os.Open(constants.ConfigFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, one last nit. It looks like the error handling in this function is a bit off. glog.Errorf doesn't return anything, it just logs the error. It looks like you could end up returning an unitialized map here if Open throws an error, or decode throws an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same below in WriteConfig.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, propagated those errors all the way through

This introduces the minikube config get/set/unset command. At a basic level, it allows a more user friendly interface for setting minikube config values, but it also allows us to run validations and callbacks before and after the values have been set.
@dlorenc
Copy link
Contributor

dlorenc commented Sep 7, 2016

LGTM

@dlorenc dlorenc merged commit 12dfb47 into kubernetes:master Sep 7, 2016
@r2d4 r2d4 deleted the config-set branch September 7, 2016 03:34
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