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

fix(cli): retain config changes on re-login #2388

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

walsm232
Copy link
Contributor

@walsm232 walsm232 commented Aug 5, 2024

Fixes: #2363

@walsm232 walsm232 requested a review from a team as a code owner August 5, 2024 18:35
Copy link

netlify bot commented Aug 5, 2024

Deploy Preview for docs-kargo-akuity-io ready!

Name Link
🔨 Latest commit b069f66
🔍 Latest deploy log https://app.netlify.com/sites/docs-kargo-akuity-io/deploys/66b25a7259ee3c0008c25843
😎 Deploy Preview https://deploy-preview-2388.kargo.akuity.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@walsm232 walsm232 force-pushed the walsm232/cli-login-config branch from 47f762c to 2f412a9 Compare August 5, 2024 18:41
@walsm232 walsm232 changed the title enhancement(cli): retain config changes on re-login fix(cli): retain config changes on re-login Aug 5, 2024
Comment on lines 180 to 187
// Merge new settings with the existing configuration
o.Config.APIAddress = o.ServerAddress
o.Config.BearerToken = bearerToken
o.Config.RefreshToken = refreshToken
o.Config.InsecureSkipTLSVerify = o.InsecureTLS
Copy link
Member

Choose a reason for hiding this comment

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

This looks very close, but I think that if the server we're logging into isn't the same as the one we were previously logged into, then we don't want to merge because we will want to lose any other server-specific settings in the config file at that point, e.g. default project.

Could we conditionally merge or start with a new config from scratch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I think I see what you mean, I will adjust this now and hopefully fix it if I am understanding correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adjusted the PR now

Copy link
Member

Choose a reason for hiding this comment

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

Looks great! Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Actually... my apologies... this works, but something like the following pseudocode may be more efficient and easier to read and maintain:

if not same server:
  cfg = new config
cfg.apiAddress = apiAddress
cfg.bearerToken = bearerToken
# etc...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, that would definitely be easier to read. I've updated PR now, hopefully it makes sense - let me know if you think there's any comment(s) needed on it or if it's self-explanatory

Signed-off-by: Michael Walsh <walshmichael310@gmail.com>
@walsm232 walsm232 force-pushed the walsm232/cli-login-config branch from f3ac23a to b069f66 Compare August 6, 2024 17:16
Copy link
Member

@krancour krancour left a comment

Choose a reason for hiding this comment

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

LGTM @walsm232. Solid first contribution to the project. Thank you!

@krancour krancour enabled auto-merge August 6, 2024 21:01
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 47.64%. Comparing base (a01f049) to head (b069f66).
Report is 2 commits behind head on main.

Files Patch % Lines
internal/cli/cmd/login/login.go 0.00% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2388   +/-   ##
=======================================
  Coverage   47.63%   47.64%           
=======================================
  Files         244      244           
  Lines       17396    17395    -1     
=======================================
  Hits         8287     8287           
+ Misses       8698     8697    -1     
  Partials      411      411           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@krancour krancour added this pull request to the merge queue Aug 6, 2024
Merged via the queue into akuity:main with commit ad7f79c Aug 6, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

avoid unnecessary cli config changes on re-login
2 participants