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

Make private key path OS indendant #2393

Merged
merged 9 commits into from
Dec 2, 2024
Merged

Conversation

sebjulliand
Copy link
Collaborator

@sebjulliand sebjulliand commented Dec 2, 2024

Scenario

I use Code for i on several systems and I use VS Code settings synchronization so I my connection settings are shared across all my systems.

Since I may not be using the same OS and/or user name on these systems, the private key path set in the settings is different on all the systems, making it impossible to share that setting (the last path used will erase all the others because of VS Code synch).

Changes

This PR changes the connection private key path before it is stored to make it OS agnostic:

  • If the path starts with the user's hoe directory path, this part of the path is replaced by ~
  • The path is always stored with / as the path segment separator

When the private key path is displayed in the settings or retrieved to connect to an LPAR, it is transformed to a local path:

  • ~ is replaced with the current user home directory
  • / are converted back to \ when running on Windows

This is how it looks:

  • In the settings:
    image

  • Displayed/used on Linux
    image

  • Displayed/used on Windows
    image

This was tested on both Windows and Linux thanks to the settings synchronization. Each system used a different ed25519 private key. I created the connection from one system and I could connect from the other after the settings got synched.

A warning is displayed in the settings if the private key doesn't exist on the system.
image

How to test this PR

  1. Set a private key to connect to a system
  2. Check the user settings to see how it's stored
  3. Connect to the system

Checklist

  • have tested my change

@sebjulliand sebjulliand added the enhancement New feature or request label Dec 2, 2024
@sebjulliand sebjulliand self-assigned this Dec 2, 2024
Copy link
Contributor

github-actions bot commented Dec 2, 2024

👋 A new build is available for this PR based on 22ba1f4.

@sebjulliand sebjulliand requested a review from a team December 2, 2024 12:23
@worksofliam worksofliam self-assigned this Dec 2, 2024
@sebjulliand sebjulliand marked this pull request as ready for review December 2, 2024 12:38
Copy link
Contributor

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

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

Seems like just one log that needs to be removed and then it's good to go.

src/webviews/settings/index.ts Outdated Show resolved Hide resolved
Signed-off-by: Seb Julliand <[email protected]>
@sebjulliand
Copy link
Collaborator Author

@worksofliam back at you!

Copy link
Contributor

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

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

Very good @sebjulliand! Merge away :)

@sebjulliand sebjulliand merged commit c3fe88b into master Dec 2, 2024
1 check passed
@sebjulliand sebjulliand deleted the feature/privateKeyHome branch December 2, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants