-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
fix: fix warning in ssh tunnel #22912
Merged
AAfghahi
merged 2 commits into
master
from
aafghahi/sc-65705/fix-is-assigned-a-value-but-never-used-warnings
Jan 31, 2023
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@AAfghahi It might be worth adding a conditional check to skip cases where no ssh tunnel info exists and consolidating the omit to a single check like:
This way if additional fields get added at some point that also need to be filtered you can just add to the array of fields passed to omit without having more if blocks to differentiate between the AuthType. omit will work fine getting attributes that may or may not exist on trimmedState.ssh_tunnel so we can just keep a single array of sensitive attributes
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.
omit
handlesundefined
andnull
values (will return an empty object) already. About the conditionals, we need the properties to be removed individually so there's always a login method available in the tunnel, i.e, we shouldn't delete them all at once. The use case for this action is:If you select login method === password -> remove any private_key & private_key_password from the tunnel object we send in the payload to the API and vice versa.
That way the tunnel always has only 1 login method and not the two of them which will cause issues later when trying to connect because you won't know which method to use.
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.
Eric's method of making sure that there is no issue around null and undefined makes me a bit more comfortable, personally.
Instead of omitting, could we use a
pick
here instead? @Antonio-RiveroMartnez is there a place where we define what columns the object should have? Are they the same btwn the two login methods?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.
Sure you could use pick.
superset-frontend/src/views/CRUD/data/database/types.ts
has theSSHTunnelObject
type definition.You would have to pick
id
,server_address
,server_port
,username
, and finally thepassword
ORprivate_key
&private_key_password
depending on your selected login method. More typing and prone to more changes if we add more properties in the tunnel definition later on, but totally doable 👍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 would we pick
password
/private_key
/private_key_password
aren't those the ones we don't want included?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 tunnel must have a login method, only one between
password
orprivate_key
. If you selectpassword
as login method, you remove theprivate_key
, and vice versa. So, before with the omit, iflogin method === password
youomit
theprivate_key
and if you selectlogin method === private_key
youomit
thepassword
, that way your tunnel has only 1 login credentials (the one that you selected)Now, you want to use
pick
, in that case if you selectlogin method === password
you need topick
the common properties and include thepassword
, otherwise there's no login credentials associated to the tunnel. Same if you selectlogin method === private_key
, you need to pick the common properties and include theprivate_key
credentials.The goal for this action is to make sure your selected login method is the only one in the tunnel. That can be done by excluding the other method (
omit
) or by adding just the selected credentials to the common properties (pick
)