-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate off deprecated trait profile/status attributes #57
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,9 @@ import ( | |
| ) | ||
|
|
||
| var ( | ||
| _ connectorbuilder.ResourceSyncer = (*userResourceType)(nil) | ||
| _ connectorbuilder.AccountManagerLimited = (*userResourceType)(nil) | ||
| _ connectorbuilder.ResourceDeleterLimited = (*userResourceType)(nil) | ||
| _ connectorbuilder.ResourceSyncer = (*userResourceType)(nil) | ||
| _ connectorbuilder.AccountManagerLimited = (*userResourceType)(nil) | ||
| _ connectorbuilder.ResourceDeleterLimited = (*userResourceType)(nil) | ||
| ) | ||
|
|
||
| const userRoleProfileKey = "user_role" | ||
|
|
@@ -65,16 +65,16 @@ func userResource(ctx context.Context, user *linear.User, parentResourceID *v2.R | |
| } | ||
|
|
||
| userTraitOptions := []sdkResource.UserTraitOption{ | ||
| sdkResource.WithUserProfile(profile), | ||
| sdkResource.WithEmail(user.Email, true), | ||
| sdkResource.WithStatus(v2.UserTrait_Status_STATUS_ENABLED), | ||
| } | ||
|
|
||
| ret, err := sdkResource.NewUserResource( | ||
| user.Name, | ||
| resourceTypeUser, | ||
| user.ID, | ||
| userTraitOptions, | ||
| sdkResource.WithResourceProfile(profile), | ||
| sdkResource.WithResourceStatus(v2.Status_RESOURCE_STATUS_ENABLED, ""), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: The profile/status emission path changed shape here (trait-level → resource-level), but |
||
| sdkResource.WithParentResourceID(parentResourceID), | ||
| ) | ||
| if err != nil { | ||
|
|
@@ -125,11 +125,7 @@ func (o *userResourceType) Entitlements(_ context.Context, _ *v2.Resource, _ *pa | |
|
|
||
| func (o *userResourceType) Grants(ctx context.Context, resource *v2.Resource, pt *pagination.Token) ([]*v2.Grant, string, annotations.Annotations, error) { | ||
| var rv []*v2.Grant | ||
| userTrait, err := sdkResource.GetUserTrait(resource) | ||
| if err != nil { | ||
| return nil, "", nil, fmt.Errorf("list-grants: Failed to get user trait from user: %w", err) | ||
| } | ||
| userProfile := userTrait.GetProfile() | ||
| userProfile := sdkResource.GetProfile(resource) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: The read path for the role profile key moved from the user trait to the resource, which is the one place this refactor could silently regress (Grants would fail with "user role was not present on profile"). |
||
| userRole, present := sdkResource.GetProfileStringValue(userProfile, userRoleProfileKey) | ||
| if !present { | ||
| return nil, "", nil, fmt.Errorf("list-grants: user role was not present on profile") | ||
|
|
||
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.
🟡 Suggestion: Now that the profile moved to
WithResourceProfile, this slice is always empty — the local variable is dead scaffolding. Passingnildirectly toresource.NewRoleResource(...)is clearer. Same applies toproject.go:40andteam.go:43.