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

Refactor utils command to follow Complete/Validate/Run pattern #1264

Merged
merged 17 commits into from
Feb 4, 2019

Conversation

metacosm
Copy link
Contributor

Was the change discussed in an issue?

fixes #1194

How to test changes?

Play with odo utils commands.

@codeclimate
Copy link

codeclimate bot commented Jan 31, 2019

Code Climate has analyzed commit f9e6912 and detected 9 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2
Style 7

View more on Code Climate.

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@codecov
Copy link

codecov bot commented Jan 31, 2019

Codecov Report

Merging #1264 into master will decrease coverage by 0.12%.
The diff coverage is 50.63%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1264      +/-   ##
==========================================
- Coverage    42.8%   42.67%   -0.13%     
==========================================
  Files          38       40       +2     
  Lines        4841     4907      +66     
==========================================
+ Hits         2072     2094      +22     
- Misses       2564     2608      +44     
  Partials      205      205
Impacted Files Coverage Δ
pkg/odo/cli/utils/utils.go 0% <0%> (ø)
pkg/util/util.go 64.78% <100%> (+1.37%) ⬆️
pkg/odo/cli/utils/terminal.go 7.14% <7.14%> (ø)
pkg/config/config.go 67.17% <93.75%> (+2.88%) ⬆️
pkg/component/watch.go 67.92% <0%> (-2.52%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f2be30...f9e6912. Read the comment docs.

@geoand
Copy link
Contributor

geoand commented Feb 1, 2019

I haven't really ever used odo utils so I'm probably not the best person to review :(

var (
// records information on supported parameters
supportedParameterDescriptions = map[string]string{
"UpdateNotification": "Controls if an update notification is shown or not (true or false)",
Copy link
Contributor

@anmolbabu anmolbabu Feb 1, 2019

Choose a reason for hiding this comment

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

Can these configurables be string constants?
I see them being referred in more than 1 places which might be prone to bugs
So, this then converts to map[string_alias]string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me see what I can do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted constants.

@@ -141,29 +142,31 @@ func (c *ConfigInfo) writeToFile() error {
// SetConfiguration modifies Odo configurations in the config file
// as of now being used for nameprefix, timeout, updatenotification
func (c *ConfigInfo) SetConfiguration(parameter string, value string) error {
// processing values according to the parameter names
switch parameter {
if p, ok := asSupportedParameter(parameter); ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

I tend to feel config or configurable would be apt instead of parameter?

Copy link
Contributor

Choose a reason for hiding this comment

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

but from what i see in git diff view, its been like that for some time now in which case please ignore my comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually have more ideas on how to refactor things here but I don't think it was appropriate to do these changes in this PR (I've deleted code that I spent a couple of hours on with some of these changes I had in mind and decided against pushing further).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This actually ties to the constant question: ideally, the values in OdoSettings would be structs, possibly implementing Validatable that I added not long ago (though, they might need something more like a Convertible interface), each struct having a name and type along with some validation / conversion logic.

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

Copy link
Contributor

@anmolbabu anmolbabu left a comment

Choose a reason for hiding this comment

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

LGTM...
Works for me

})
It("should be checking to see if timeout is the same as the constant", func() {
configOutput := runCmd("odo utils config view|grep Timeout")
configOutput := runCmd("odo utils config view|grep " + config.TimeoutSetting)
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using terminal specific command like grep. regular expression would be an alternate choice and can be run on any terminal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't create these tests, they've been like this for a while, not going to change them now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, will track this change in #1129 then.

Copy link
Contributor

@amitkrout amitkrout left a comment

Choose a reason for hiding this comment

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

Major command odo utils config set ... is missed as part of this pr. Would you please add scenario for odo utils config set ... in integration test too.

$ ./odo utils -h
Utilities for terminal commands and modifying Odo configurations

Usage:
  odo utils [command]

[…]

   # Set a configuration value
   odo utils config set UpdateNotification false
   odo utils config set NamePrefix "app"
   odo utils config set Timeout 20
	
  # For viewing the current configuration
   odo utils config view
  
[…]

Copy link
Contributor

@surajnarwade surajnarwade left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@metacosm
Copy link
Contributor Author

metacosm commented Feb 4, 2019

Major command odo utils config set ... is missed as part of this pr. Would you please add scenario for odo utils config set ... in integration test too.

$ ./odo utils -h
Utilities for terminal commands and modifying Odo configurations

Usage:
  odo utils [command]

[…]

   # Set a configuration value
   odo utils config set UpdateNotification false
   odo utils config set NamePrefix "app"
   odo utils config set Timeout 20
	
  # For viewing the current configuration
   odo utils config view
  
[…]

Actually, set is covered: https://github.com/redhat-developer/odo/blob/master/tests/e2e/e2e_test.go#L92-L99

Copy link
Contributor

@amitkrout amitkrout left a comment

Choose a reason for hiding this comment

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

LGTM

Actually, set is covered: https://github.com/redhat-developer/odo/blob/master/tests/e2e/e2e_test.go#L92-L99

Cool!!!
My bad, could not recognize it. Thanks for the reference

@AppVeyorBot
Copy link

@metacosm metacosm merged commit 12f7c62 into redhat-developer:master Feb 4, 2019
@metacosm metacosm deleted the 1194 branch February 4, 2019 15:44
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.

Refactor utils command to follow complete-validate-run pattern
6 participants