Implement plugin discovery source CRUD command for context aware CLI#950
Conversation
cca655a to
59eeab4
Compare
59eeab4 to
1bda275
Compare
|
Sorry if it's too late, but would Also see my comment: #947 (comment) |
zjs
left a comment
There was a problem hiding this comment.
Looks good. Left a couple of nit-picky comments.
(Note that this was a pretty cursory review as I ran out of time. If there's anywhere you'd like me to take a more careful look at, just let me know!)
1bda275 to
186f284
Compare
As discussed in #947, I have updated the noun to |
186f284 to
fd31bd0
Compare
imikushin
left a comment
There was a problem hiding this comment.
A few comments to make code simpler and more testable.
Also, please add unit tests for all new functionality.
| discoverySources := cfg.ClientOptions.CLI.DiscoverySources | ||
|
|
||
| newDiscoverySources := []configv1alpha1.PluginDiscovery{} | ||
| found := false | ||
| for _, ds := range discoverySources { | ||
| if checkDiscoveryName(ds, discoveryName) { | ||
| found = true | ||
| ds = configv1alpha1.PluginDiscovery{} | ||
| switch strings.ToLower(discoverySourceType) { | ||
| case common.DiscoveryTypeLocal: | ||
| ds.Local = createLocalDiscoverySource(discoveryName, uri) | ||
| case common.DiscoveryTypeOCI: | ||
| ds.OCI = createOCIDiscoverySource(discoveryName, uri) | ||
| default: | ||
| return errors.Errorf("discovery source type '%s' is not yet supported", discoverySourceType) | ||
| } | ||
| } | ||
| newDiscoverySources = append(newDiscoverySources, ds) | ||
| } | ||
| if !found { | ||
| return discoveryNoExistError | ||
| } | ||
|
|
||
| cfg.ClientOptions.CLI.DiscoverySources = newDiscoverySources |
There was a problem hiding this comment.
The whole block should be a separate function (that is easily unit testable):
newDiscoverySources, err := updateDiscoverySources(cfg.ClientOptions.CLI.DiscoverySources, discoveryName, discoverySourceType, uri)
if err != nil {
return err
}
cfg.ClientOptions.CLI.DiscoverySources = newDiscoverySourcesThere was a problem hiding this comment.
This one hasn't been addressed :(
Please refactor consistent with deleteDiscoverySource() and addDiscoverySource()
There was a problem hiding this comment.
done. Refactored and added unit tests
fac141c to
b2fe37f
Compare
vuil
left a comment
There was a problem hiding this comment.
Lgtm. Just a nit on the doc.
imikushin
left a comment
There was a problem hiding this comment.
A couple comments still un-addressed. Otherwise looks good!
b2fe37f to
444ae70
Compare
- Implements `tanzu plugin source add/list/update/delete` commands - Currently, supported discovery types are oci and local - Add newly added noun, flag to cli-wordlist.yml file Signed-off-by: Anuj Chaudhari <anujc@vmware.com>
444ae70 to
87abe10
Compare
…mware-tanzu#950) * Implement plugin discovery source CRUD command - Implements `tanzu plugin source add/list/update/delete` commands - Currently, supported discovery types are oci and local - Add newly added noun, flag to cli-wordlist.yml file * Update cobra docs for the commands
What this PR does / why we need it
tanzu plugin source add/list/update/deletecommandsWhich issue(s) this PR fixes
Fixes #947
Describe testing done for PR
Release note
PR Checklist
Additional information
Special notes for your reviewer