-
Notifications
You must be signed in to change notification settings - Fork 386
Fix polaris CLI support for updating catalog properties and hitting real Polaris services #404
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
Changes from all commits
59ef275
59c2d9a
6eca851
927dffc
1d11373
d1d45e1
aed4a8c
adb0898
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
| # under the License. | ||
| # | ||
| from dataclasses import dataclass | ||
| from typing import Dict, Optional | ||
| from typing import Dict, Optional, List | ||
|
|
||
| from pydantic import StrictStr | ||
|
|
||
|
|
@@ -46,6 +46,8 @@ class CatalogRolesCommand(Command): | |
| catalog_role_name: str | ||
| principal_role_name: str | ||
| properties: Optional[Dict[str, StrictStr]] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i.e. could you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My thinking for preserving And similarly
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. My initial hesitation was just having two properties that do the same thing. Lets keep this, but I think we should reject the "invalid" inputs then: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, this test case in test_cli_parsing.py covers the rejection of |
||
| set_properties: Dict[str, StrictStr] | ||
| remove_properties: List[str] | ||
|
|
||
| def validate(self): | ||
| if not self.catalog_name: | ||
|
|
@@ -77,9 +79,20 @@ def execute(self, api: PolarisDefaultApi) -> None: | |
| print(catalog_role.to_json()) | ||
| elif self.catalog_roles_subcommand == Subcommands.UPDATE: | ||
| catalog_role = api.get_catalog_role(self.catalog_name, self.catalog_role_name) | ||
| new_properties = catalog_role.properties or {} | ||
|
|
||
| # Add or update all entries specified in set_properties | ||
| if self.set_properties: | ||
| new_properties = {**new_properties, **self.set_properties} | ||
|
|
||
| # Remove all keys specified in remove_properties | ||
| if self.remove_properties: | ||
| for to_remove in self.remove_properties: | ||
| new_properties.pop(to_remove, None) | ||
|
|
||
| request = UpdateCatalogRoleRequest( | ||
| current_entity_version=catalog_role.entity_version, | ||
| properties=self.properties | ||
| properties=new_properties | ||
| ) | ||
| api.update_catalog_role(self.catalog_name, self.catalog_role_name, request) | ||
| elif self.catalog_roles_subcommand == Subcommands.GRANT: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.