-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
🐙 octavia-cli: add command to list existing sources, destinations and connections #9642
🐙 octavia-cli: add command to list existing sources, destinations and connections #9642
Conversation
@lmossman I tried to continue to improve inheritances goodies to avoid repeating shared logic between all the listing commands. |
453bcaf
to
9533e93
Compare
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.
Looks good to me overall! Left a few small comments but none of them are blocking, so feel free to merge when you are ready
"""Compute column width for display purposes: | ||
Find largest column size, add a padding of two characters. |
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 method description should be updated to reflect the new implementation
def compute_columns_width(data: List[List[str]], padding: int = 2) -> List[int]: | ||
"""Compute column width for display purposes: | ||
Find largest column size, add a padding of two characters. | ||
Returns: |
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.
Returns: | |
Args: |
class Sources(WorkspaceListing): | ||
api = source_api.SourceApi | ||
fields_to_display = ["name", "sourceName", "sourceId"] | ||
list_field_in_response = "sources" | ||
list_function_name = "list_sources_for_workspace" | ||
|
||
|
||
class Destinations(WorkspaceListing): | ||
api = destination_api.DestinationApi | ||
fields_to_display = ["name", "destinationName", "destinationId"] | ||
list_field_in_response = "destinations" | ||
list_function_name = "list_destinations_for_workspace" | ||
|
||
|
||
class Connections(WorkspaceListing): | ||
api = connection_api.ConnectionApi | ||
fields_to_display = ["name", "connectionId", "status", "sourceId", "destinationId"] | ||
list_field_in_response = "connections" | ||
list_function_name = "list_connections_for_workspace" |
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.
The fact that these inherit from a WorkspaceListing made me think: would it make sense to group these commands under a workspace
keyword? I.e. the commands would look like
octavia list workspace sources
octavia list workspace destinations
octavia list workspace connections
octavia list connectors sources
octavia list connectors destinations
Do you think this would make it more clear what the difference between these commands are to the user? Or would we just end up with a ton of workspace
commands, making the commands unnecessarily long?
I'll leave it up to you to make the final decision here; I don't feel super strongly either way, but just thought I would offer this suggestion in case you liked it
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 like this, looks tidier and will keep the same command "depth" for list
subcommands.
37ae4e3
to
88bfbb2
Compare
Thank you @lmossman for your review and suggestions! |
What
How
ConnectorDefinitions
class in aBaseListing
class hosted inlistings.py
module.ConnectorDefinitions
.SourcesConnectorsDefinitions
,DestinationsConnectorsDefinitions
,Sources
,Destinations
inherit fromBaseListing
.list sources
andlist destinations
commands.Recommended reading order
octavia-cli/octavia_cli/list/listings.py
octavia-cli/octavia_cli/list/commands.py
octavia-cli/octavia_cli/list/formatting.py
octavia-cli/unit_tests/test_list/test_listings.py
octavia-cli/unit_tests/test_list/test_commands.py
octavia-cli/unit_tests/test_list/test_formatting.py
🚨 User Impact 🚨
Two new commands:
octavia list sources
andoctavia list destinations