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

Upsert provider access tokens instead of Create and Delete #2486

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Mar 4, 2024

Summary

For OAuth flow provider enrollments we used to delete and recreate the
provider access token in order to be able to list the new token based on
CreatedAt. For the case where we pass a PAT, we would just error out
in case the token was already created.

Let's just upsert in both cases and instead of CreatedAt let's look at
UpdatedAt.

This will be useful for tests.

Fixes: #2411

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Manual testing with both PAT enrollment and OAuth flow.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • [N/A] Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • [N/A] Checked that related changes are merged.

For OAuth flow provider enrollments we used to delete and recreate the
provider access token in order to be able to list the new token based on
CreatedAt. For the case where we pass a PAT, we would just error out
in case the token was already created.

Let's just upsert in both cases and instead of CreatedAt let's look at
UpdatedAt.

This will be useful for tests.

Fixes: stacklok#2411
@jhrozek jhrozek requested a review from a team as a code owner March 4, 2024 22:16
@coveralls
Copy link

Coverage Status

coverage: 39.333% (+0.02%) from 39.316%
when pulling 574eb3a on jhrozek:upsert_provider_token
into e68fcce on stacklok:main.

@JAORMX JAORMX merged commit aa7c815 into stacklok:main Mar 5, 2024
21 checks passed
Vyom-Yadav pushed a commit to Vyom-Yadav/minder that referenced this pull request Mar 5, 2024
…2486)

For OAuth flow provider enrollments we used to delete and recreate the
provider access token in order to be able to list the new token based on
CreatedAt. For the case where we pass a PAT, we would just error out
in case the token was already created.

Let's just upsert in both cases and instead of CreatedAt let's look at
UpdatedAt.

This will be useful for tests.

Fixes: stacklok#2411
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for updating the provider token upon enrolment
3 participants