-
Notifications
You must be signed in to change notification settings - Fork 104
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
Adds interactive mode for info command #265
Conversation
fcda5ca
to
d58bca1
Compare
api/pkg/cli/cmd/info/info.go
Outdated
@@ -139,8 +139,68 @@ func (opts *options) run() error { | |||
} | |||
|
|||
hubClient := opts.cli.Hub() | |||
|
|||
// Get all Catalogs | |||
catalog, err := hubClient.GetCatalogsList() |
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 can be done when user has not passed catalog
if opt.from == "" {
get all catalogs
}
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 think in order to keep default catalog as tekton
as mentioned here we'll have to make an api call to get all catalogs, but it will be better to keep the catalog flag i.e. from
empty and make an api call first and get the catalogs list and if there is only one catalog then it won't ask for the catalog and select the catalog which is already there
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.
you can keep the from
flag empty but if user passes a catalog through the flag then you don't need to get all catalogs
.
use that catalog to fetch the resource, whether it exist or not.
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.
Yes make sense to get all the catalog if we keep the flag empty
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.
Updated the PR!
ab3ccd7
to
d701dea
Compare
d701dea
to
8171080
Compare
8171080
to
9a7ceeb
Compare
WDYT, To mention the |
9a7ceeb
to
110cfc2
Compare
110cfc2
to
0d5d7c5
Compare
api/pkg/cli/cmd/info/info.go
Outdated
if err != nil { | ||
return "", err | ||
} | ||
if len(ver) == 1 { |
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.
handle if no version
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.
If there is no version of the resource then it won't be a hub resource
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.e. while parsing the catalog I guess the resource won't be added in the db
if len(ver) == 1 { | ||
return ver[0], nil | ||
} else { | ||
latestVersion := ver[0] |
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.
We have a field in API response for latest version, better use that in case of versions array is not sorted
0d5d7c5
to
05a6721
Compare
api/pkg/cli/cmd/info/info.go
Outdated
if err != nil { | ||
return "", err | ||
} | ||
if len(resources) == 0 { |
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.
you can use switch
here :)
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.
Will there be any more cases ??
I mean there will be three cases like one with 0 resources, one with 1 resource and last with more than one, should we add switch ??
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 would say yes :) [0,1,default]
api/pkg/cli/hub/get_catalog.go
Outdated
} | ||
|
||
Catalog := data.Catalogs | ||
// // Get all catalog names |
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.
nit // Get all catalog names
@@ -172,11 +206,88 @@ func (opts *options) run() error { | |||
return printer.New(out).Tabbed(tmpl, tmplData) | |||
} | |||
|
|||
func (opts *options) AskCatalogName() (string, error) { |
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.
Line no 200-207 won't get be executed now right?
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 think yes it won't be executed but in that case we don't need to even check if the version is empty, should we remove the condition to check if the version is empty ??
- This patch interactively ask the users to select - Catalog first - Resources in the catalog selected - All Versions of the resource selected - If there is only one catalog or version then it will be auto-selected - User can also get the information of the resource if the user know the catalog name, resource name and version of the resource by `tkn hub info task <task-name> --version <version-number> --from catalog <catalog-name>` Signed-off-by: Puneet Punamiya <ppunamiy@redhat.com>
05a6721
to
e85d901
Compare
/approve |
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sm43 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
lgtm |
/lgtm |
This patch interactively ask the users to select
If there is only one catalog or version then
it will be auto-selected
User can also get the information of the resource
if the user know the catalog name, resource name
and version of the resource by
tkn hub info task <task-name> --version <version-number> --from catalog <catalog-name>
Signed-off-by: Puneet Punamiya ppunamiy@redhat.com
Changes
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.