-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
feat(ssh_tunnel): Create command & exceptions #22148
Conversation
…e/superset into ssh-create-command
@@ -71,6 +71,10 @@ def run(self) -> Model: | |||
database = DatabaseDAO.create(self._properties, commit=False) | |||
database.set_sqlalchemy_uri(database.sqlalchemy_uri) | |||
|
|||
# create ssh tunnel |
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.
Should we remove this comment block?
@@ -176,3 +176,8 @@ class DatabaseOfflineError(SupersetErrorException): | |||
|
|||
class InvalidParametersError(SupersetErrorsException): | |||
status = 422 | |||
|
|||
|
|||
class SSHTunnelCreateFailedError(CommandException): |
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 class should be in databases/ssh_tunnel/commands/exceptions.py
like the others.
class CreateSSHTunnelCommand(BaseCommand): | ||
def __init__(self, database_id: int, data: Dict[str, Any]): | ||
self._properties = data.copy() | ||
self._properties["database_id"] = database_id |
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.
Why not pulling it from the data
dict instead of having database_id
as a separated arg? I mean, even in the create_test.py
(dao and command) you have the database_id
as part of the properties of the tunnel.
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 removed it, i think the pattern is better since the database_id is the first class citizen
@@ -50,7 +53,7 @@ def session_with_data(session: Session) -> Iterator[Session]: | |||
session.rollback() | |||
|
|||
|
|||
def test_database_get_shh_tunnel(session_with_data: Session) -> None: | |||
def test_database_get_ssh_tunnel(session_with_data: Session) -> None: |
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.
Wondering what "changed" here because I see no difference 🤔 👀
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.
test_database_get_shh_tunnel
to test_database_get_ssh_tunnel
we misspelt ssh lol
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.
oh boy! yeah! hahaha trust me I had to read this like 10+ times to realize the mistake. kk thanks!
"password": "bar", | ||
} | ||
|
||
result = SSHTunnelDAO.create(properties, commit=True) |
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.
where is it getting the database_id
from?
Codecov Report
@@ Coverage Diff @@
## create-sshtunnelconfig-tbl #22148 +/- ##
==============================================================
- Coverage 66.97% 66.25% -0.72%
==============================================================
Files 1840 1839 -1
Lines 70062 70049 -13
Branches 7590 7571 -19
==============================================================
- Hits 46922 46413 -509
- Misses 21174 21677 +503
+ Partials 1966 1959 -7
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
return tunnel | ||
|
||
def validate(self) -> None: | ||
# check to make sure the server port is not localhost |
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.
can we fill in the validation for this?
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.
@eschutho going to implement an SSH_MANAGER class to handle this, was talking to @craig-rueda yesterday about the approach and we basically allow users define how the want manage this one their end.
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.
Ok, do we need this validation method then or can we remove it?
486ac2d
to
e5de217
Compare
e5de217
to
6e32b57
Compare
6e32b57
to
2b51126
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.
LGTM!
c00b151
to
1fbf7a0
Compare
1fbf7a0
to
630b0ad
Compare
…e/superset into ssh-create-command
merging to unblock following PRs
|
SUMMARY
Create a command to allow users to generate a
SSHTunnel
object to be saved once aDatabase
is being commited to the metastore.ADDITIONAL INFORMATION