-
Notifications
You must be signed in to change notification settings - Fork 102
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
Upgrade command #659
Merged
Merged
Upgrade command #659
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3982e17
PoC of upgrade command
alenkacz 6e6dbea
Format
alenkacz 8df8e82
Fix
alenkacz 7d56475
Fix formatting
alenkacz f6dda6f
Merge branch 'master' into av/upgrade-command
alenkacz 4e95683
Fixed
alenkacz 2d833de
Merge branch 'master' into av/upgrade-command
alenkacz 51a37e7
Add tests for kudo client
alenkacz fd2b476
Merge
alenkacz b31a61b
Format
alenkacz 5919ca4
Upgrade unit tests
alenkacz 21e2c59
Formatting
alenkacz 9c97ddd
Missing file
alenkacz b9db50b
Review feedback
alenkacz c9b0471
Parameters merge patch in progress
alenkacz dca018b
Params
alenkacz 96840ab
Formats
alenkacz ca00001
Missing file
alenkacz 77d5b48
PR comments
alenkacz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package install | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// GetParameterMap takes a slice of parameter strings, parses parameters into a map of keys and values | ||
func GetParameterMap(raw []string) (map[string]string, error) { | ||
var errs []string | ||
parameters := make(map[string]string) | ||
|
||
for _, a := range raw { | ||
key, value, err := parseParameter(a) | ||
if err != nil { | ||
errs = append(errs, *err) | ||
continue | ||
} | ||
parameters[key] = value | ||
} | ||
|
||
if errs != nil { | ||
return nil, errors.New(strings.Join(errs, ", ")) | ||
} | ||
|
||
return parameters, nil | ||
} | ||
|
||
// parseParameter does all the parsing logic for an instance of a parameter provided to the command line | ||
// it expects `=` as a delimiter as in key=value. It separates keys from values as a return. Any unexpected param will result in a | ||
// detailed error message. | ||
func parseParameter(raw string) (key string, param string, err *string) { | ||
|
||
var errMsg string | ||
s := strings.SplitN(raw, "=", 2) | ||
if len(s) < 2 { | ||
errMsg = fmt.Sprintf("parameter not set: %+v", raw) | ||
} else if s[0] == "" { | ||
errMsg = fmt.Sprintf("parameter name can not be empty: %+v", raw) | ||
} else if s[1] == "" { | ||
errMsg = fmt.Sprintf("parameter value can not be empty: %+v", raw) | ||
} | ||
if errMsg != "" { | ||
return "", "", &errMsg | ||
} | ||
return s[0], s[1], nil | ||
} |
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
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.
these tests disappeared... shouldn't they move to
params_test.go
?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.
it got moved to params_test. Oh wait, I did not push that, LOL :D