Conversation
Codecov Report
@@ Coverage Diff @@
## master #2347 +/- ##
==========================================
- Coverage 60.52% 60.51% -0.01%
==========================================
Files 128 128
Lines 26366 26401 +35
==========================================
+ Hits 15958 15977 +19
- Misses 9005 9017 +12
- Partials 1403 1407 +4 |
|
Ping @aluzzardi @dongluochen @aaronlehmann :) |
| // ParseCmd parses the Generic Resource command line argument | ||
| // and returns a list of *api.GenericResource | ||
| func ParseCmd(cmd string) ([]*api.GenericResource, error) { | ||
| if strings.Contains(cmd, "\n") { |
There was a problem hiding this comment.
Seems like a strange thing to check for - I don't know of any CLI arguments where this would be an issue, or where we explicitly check for it. But it shouldn't hurt.
api/genericresource/parse.go
Outdated
| // and returns a list of *api.GenericResource | ||
| func ParseCmd(cmd string) ([]*api.GenericResource, error) { | ||
| if strings.Contains(cmd, "\n") { | ||
| return nil, newParseError("unexpected '\n' character") |
There was a problem hiding this comment.
You'll want to use backticks instead of double quotes to avoid putting an actual newline inside the erorr stirng.
api/genericresource/parse.go
Outdated
| if len(kva) != 2 { | ||
| return nil, newParseError("incorrect term %s, missing '=' or malformed expr", term) | ||
| return nil, newParseError("incorrect term %s, missing"+ | ||
| "'=' or malformed expression", term) |
There was a problem hiding this comment.
There's a missing space between missing and =.
api/genericresource/parse.go
Outdated
| if u < 0 { | ||
| return nil, newParseError("cannot ask for negative resource %s", key) | ||
| return nil, newParseError("cannot ask for"+ | ||
| "negative resource %s", k) |
There was a problem hiding this comment.
Missing space between for and negative.
| func Parse(cmd string) ([]*api.GenericResource, error) { | ||
| var rs []*api.GenericResource | ||
| func namedResourceVal(res string) (int64, error) { | ||
| return strconv.ParseInt(res, 10, 64) |
There was a problem hiding this comment.
If this parses as an integer, wouldn't it be a discrete resource, not a named resource as the function name suggests?
api/genericresource/parse.go
Outdated
| } | ||
|
|
||
| return nil, newParseError("could not parse expression '%s'", term) | ||
| return nil, newParseError("malformed expression '%s=%s'", k, v) |
There was a problem hiding this comment.
Seems like the only possible error condition is a mix of numeric and non-numeric values. The error message should make this clear.
api/genericresource/parse.go
Outdated
|
|
||
| var rs []*api.GenericResource | ||
| for k, v := range tokens { | ||
| if len(v) == 1 { |
There was a problem hiding this comment.
How about calling a function here that checks that len(v) == 1 and namedResourceVal does not return an error? It would slightly simplify the control flow.
f9a8e2c to
73b6493
Compare
|
@aaronlehmann fixed ! |
|
@aluzzardi PTAL :) |
|
@aaronlehmann is it possible to merge this PR :) ? |
|
@aaronlehmann is it possible to merge this PR :) ?
I don't have merge access anymore. @stevvooe could you please merge it?
|
|
ping @stevvooe :) |
anshulpundir
left a comment
There was a problem hiding this comment.
@RenaudWasTaken some nits.
| return strconv.ParseInt(res, 10, 64) | ||
| } | ||
|
|
||
| func allNamedResources(res []string) bool { |
| // Parse parses the GenericResource resources given by the arguments | ||
| func Parse(cmd string) ([]*api.GenericResource, error) { | ||
| var rs []*api.GenericResource | ||
| func discreteResourceVal(res string) (int64, error) { |
There was a problem hiding this comment.
nit: I'd suggest adding a comment. thx!
| return rs, nil | ||
| } | ||
|
|
||
| func isDiscreteResource(values []string) (int64, bool) { |
73b6493 to
370d333
Compare
|
@anshulpundir done |
Signed-off-by: Renaud Gaubert <[email protected]>
Signed-off-by: Renaud Gaubert <[email protected]>
Signed-off-by: Renaud Gaubert <[email protected]>
Signed-off-by: Renaud Gaubert <[email protected]>
370d333 to
c7b06ee
Compare
|
@anshulpundir CI is green can we finally merge this PR :) ? |
Upgrade swarmkit dependency. Changes: moby/swarmkit@ce5f7b8a (HEAD -> master, origin/master, origin/HEAD) Merge pull request moby/swarmkit#2411 from crunchywelch/2401-arm64_support moby/swarmkit@b0856099 Merge pull request moby/swarmkit#2423 from thaJeztah/new-misty-handle moby/swarmkit@2bd294fc Update Misty's GitHub handle moby/swarmkit@0769c605 Comments for orphaned state/task reaper. (moby/swarmkit#2421) moby/swarmkit@de950a7e Generic resource cli (moby/swarmkit#2347) moby/swarmkit@312be598 Provide custom gRPC dialer to override default proxy dialer (moby/swarmkit#2419) moby/swarmkit@4f12bf79 Merge pull request moby/swarmkit#2415 from cheyang/master moby/swarmkit@8f9f7dc1 add pid limits moby/swarmkit@da5ee2a6 Merge pull request moby/swarmkit#2409 from dperny/workaround-attachments moby/swarmkit@0c7b2fc2 Delete node attachments when node is removed moby/swarmkit@9d702763 normalize "aarch64" architectures to "arm64" moby/swarmkit@28f91d8...ce5f7b8 Signed-off-by: Marcus Martins <[email protected]>
* Generic resource now uses csv format Signed-off-by: Renaud Gaubert <[email protected]> * Tested new input format Signed-off-by: Renaud Gaubert <[email protected]> * Updated Generic resource design to use new CLI format Signed-off-by: Renaud Gaubert <[email protected]> * Updated swarmctl and swarmd to use the new Generic resource CLI format Signed-off-by: Renaud Gaubert <[email protected]>
Signed-off-by: Renaud Gaubert [email protected]
What I did:
Changed the CLI format of Generic Resources as suggested by @thaJeztah in docker/cli/pull/429
From
--generic-resources "apple=2;orange={blue,red,green}"To
--generic-resources "apple=2,orange=blue,orange=red,orange=green"This new format albeit a bit more verbose is the CSV format and is already used for
--mountHow to verify it:
ping @aaronlehmann