-
Notifications
You must be signed in to change notification settings - Fork 243
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
Conversation
Code Climate has analyzed commit f9e6912 and detected 9 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
✅ odo build 1314 completed and artifacts can be found here (for commit 0bb0e94986 by @metacosm) |
✅ odo build 1319 completed and artifacts can be found here (for commit 65b605f3d8 by @metacosm) |
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
I haven't really ever used |
pkg/config/config.go
Outdated
var ( | ||
// records information on supported parameters | ||
supportedParameterDescriptions = map[string]string{ | ||
"UpdateNotification": "Controls if an update notification is shown or not (true or false)", |
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.
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
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.
Let me see what I can do.
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.
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 { |
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.
I tend to feel config or configurable would be apt instead of parameter?
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.
but from what i see in git diff view, its been like that for some time now in which case please ignore my comment
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.
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).
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.
This actually ties to the constant question: ideally, the values in OdoSettings
would be struct
s, 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.
✅ odo build 1347 completed and artifacts can be found here (for commit ad8812ac84 by @metacosm) |
✅ odo build 1351 completed and artifacts can be found here (for commit e0be71991c by @metacosm) |
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.
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) |
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.
Avoid using terminal specific command like grep
. regular expression would be an alternate choice and can be run on any terminal.
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.
I didn't create these tests, they've been like this for a while, not going to change them now.
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.
Ok, will track this change in #1129 then.
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.
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
[…]
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.
LGTM 🎉
Might be more refactoring opportunities.
Actually, |
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.
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
✅ odo build 1386 completed and artifacts can be found here (for commit f498b0bb8f by @metacosm) |
Was the change discussed in an issue?
fixes #1194
How to test changes?
Play with
odo utils
commands.