Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: refactor entitlements to be a safe object to use#14406

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 7 commits intomainfromstevenmasley/safe_entitlements
Aug 23, 2024

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedAug 22, 2024
edited
Loading

Previously, all usage of entitlements requires mutex usage on the
api struct directly. This prevents passing the entitlements to
a sub package. It also creates the possibility for misuse.

I am refactoring this because I want to place some IDP sync code into it's own package.
I'd prefer if the IDP code handled the entitlements (it's enterprise code).

Previously, all usage of entitlements requires mutex usage on theapi struct directly. This prevents passing the entitlements toa sub package. It also creates the possibility for misuse.
"github.com/coder/coder/v2/codersdk"
)

type Set struct {
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I implemented the methods as I saw them used. There might be a way to reduce the number of methods on this struct.

@EmyrkEmyrk marked this pull request as ready for reviewAugust 22, 2024 22:40
@EmyrkEmyrk requested a review fromjohnstcnAugust 22, 2024 22:40
return f, ok
}

func (l *Set) Enabled(feature codersdk.FeatureName) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Potential follow-up: we could replace this withf, ok := Features(name); ok && f.Enabled?

Emyrk reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

True. Because before we had access to the whole struct, our usage of it seemed a bit arbitrary at times. Sometimes we grab it and check entitled, most times just enabled.

I'm not trying to fix all our usage right now, but it would be good to audit at some times.

johnstcn reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

missing tests for the rest of the Entitlements methods

Emyrk reacted with thumbs up emoji
@johnstcn
Copy link
Member

LGTM pending some more tests, but approving pre-emptively.

@EmyrkEmyrk merged commitaf125c3 intomainAug 23, 2024
29 of 30 checks passed
@EmyrkEmyrk deleted the stevenmasley/safe_entitlements branchAugust 23, 2024 21:22
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 23, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Emyrk@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp