Skip to content
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

Connector type list #1641

Merged
merged 4 commits into from
Jul 14, 2022
Merged

Connector type list #1641

merged 4 commits into from
Jul 14, 2022

Conversation

jackdelahunt
Copy link
Contributor

@jackdelahunt jackdelahunt commented Jul 13, 2022

Verification Steps

  1. rhoas connector type list
  2. rhoas connector type list --output=yaml
  3. rhoas connector type list --limit=5
  4. rhoas connector type list --search=Amazon%
  5. rhoas connector type list --limit=15 --page=2

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Other (please specify)

@jackdelahunt jackdelahunt changed the base branch from main to connectors-v2 July 14, 2022 10:52
@jackdelahunt jackdelahunt force-pushed the connector-type-list branch from 05b1d2f to baf97d7 Compare July 14, 2022 11:03
@jackdelahunt jackdelahunt changed the title WIP Connector type list Connector type list Jul 14, 2022
@jackdelahunt jackdelahunt requested a review from wtrocki July 14, 2022 11:16
@@ -36,6 +37,8 @@ func NewConnectorsCommand(f *factory.Factory) *cobra.Command {
use.NewUseCommand(f),
start.NewStartCommand(f),
stop.NewStopCommand(f),
connector_type.NewTypeCommand(f),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong naming format :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to type being a reserved word in go. I just went with connector_type instead.


if err != nil {
switch httpRes.StatusCode {
case http.StatusUnauthorized:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is antipattern. We should not use status codes for validation. We should use error codes.
See kafka create for example


flags := connectorcmdutil.NewFlagSet(cmd, f)
flags.AddOutput(&opts.outputFormat)
flags.IntVar(&opts.limit, "limit", 150, f.Localizer.MustLocalize("connector.type.list.flag.page.description"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use build package limits here as in other implementations

flags.AddOutput(&opts.outputFormat)
flags.IntVar(&opts.limit, "limit", 150, f.Localizer.MustLocalize("connector.type.list.flag.page.description"))
flags.StringVar(&opts.search, "search", DefaultSearch, f.Localizer.MustLocalize("connector.type.list.flag.search.description"))
flags.IntVar(&opts.page, "page", 1, f.Localizer.MustLocalize("connector.type.list.flag.page.description"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is pagination starting from 0? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik 1 is the start and when passing 0 it just gives the same output as 1 anyway

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That is common pattern

Copy link
Collaborator

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works. Minor stuff reported

@wtrocki wtrocki merged commit 56f69b6 into connectors-v2 Jul 14, 2022
@wtrocki wtrocki deleted the connector-type-list branch July 14, 2022 14:58
@wtrocki
Copy link
Collaborator

wtrocki commented Jul 14, 2022

Can be fixed on separate PR

wtrocki pushed a commit that referenced this pull request Jul 18, 2022
wtrocki pushed a commit that referenced this pull request Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants