Migrate off deprecated trait profile/status attributes - #13
Conversation
baton-sdk v0.20.6 moved `profile`, `status`, and `created_at` off the trait
messages onto attributes on `Resource`, deprecating the trait-level options and
getters. staticcheck flags every remaining call with `SA1019`, so `verify / lint`
is red on `main`.
This migrates the connector to the resource-level API:
- `With{User,Group,Role,App}Profile` -> `WithResourceProfile`
- `WithStatus` / `WithDetailedStatus` -> `WithResourceStatus`
- `WithCreatedAt` / `WithSecretCreatedAt` -> `WithResourceCreatedAt`
- trait `GetProfile()` / `GetStatus()` reads -> the equivalent read on the resource
The option type changes from a `*TraitOption` to a `ResourceOption`, so the calls
move out of the trait slice and into the variadic tail of the `New*Resource` call.
The two status enums are numerically identical, so the values map 1:1. Non-deprecated
trait data (login, aliases, emails, secret type/expiry) is untouched.
No behavioural change intended: the deprecated options already populated the
resource-level fields. `golangci-lint run ./...` reports 0 issues after this
change, and the package tests pass.
| resource, err := rs.NewUserResource(user.Name, userResourceType, user.ID, userTraits) | ||
| resource, err := rs.NewUserResource(user.Name, userResourceType, user.ID, userTraits, | ||
| rs.WithResourceProfile(profile), | ||
| rs.WithResourceStatus(v2.Status_ResourceStatus(userStatus), "")) |
There was a problem hiding this comment.
🟡 Suggestion: userStatus (line 36) is still typed as the deprecated trait enum v2.UserTrait_Status_Status and converted here. The values do line up 1:1 (UNSPECIFIED/ENABLED/DISABLED/DELETED = 0/1/2/3 in both enums), so this is correct today, but it's an unchecked cross-enum conversion that would silently produce the wrong status if the enums ever diverge. Declaring userStatus as v2.Status_ResourceStatus with v2.Status_RESOURCE_STATUS_DISABLED / ..._ENABLED drops both the cast and the last reference to the deprecated type.
| roleTraitOptions := []rs.RoleTraitOption{ | ||
| rs.WithRoleProfile(profile), | ||
| } | ||
| roleTraitOptions := []rs.RoleTraitOption{} |
There was a problem hiding this comment.
🟡 Suggestion: now that the profile option moved out, this empty slice literal only exists to fill the roleTraitOpts parameter. Passing nil directly (rs.NewRoleResource(role, roleResourceType, role, nil, rs.WithResourceProfile(profile))) is equivalent — WithRoleTrait() with no options still creates the role trait — and drops the variable entirely.
Connector PR Review: Migrate off deprecated trait profile/status attributesBlocking Issues: 0 | Suggestions: 2 | Threads Resolved: 0 Review SummaryScanned the full PR diff (2 files, Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agents |
baton-sdk v0.20.6 moved
profile,status, andcreated_atoff the traitmessages onto attributes on
Resource, deprecating the trait-level options andgetters. staticcheck flags every remaining call with
SA1019, soverify / lintis red on
main.This migrates the connector to the resource-level API:
With{User,Group,Role,App}Profile->WithResourceProfileWithStatus/WithDetailedStatus->WithResourceStatusWithCreatedAt/WithSecretCreatedAt->WithResourceCreatedAtGetProfile()/GetStatus()reads -> the equivalent read on the resourceThe option type changes from a
*TraitOptionto aResourceOption, so the callsmove out of the trait slice and into the variadic tail of the
New*Resourcecall.The two status enums are numerically identical, so the values map 1:1. Non-deprecated
trait data (login, aliases, emails, secret type/expiry) is untouched.
No behavioural change intended: the deprecated options already populated the
resource-level fields.
golangci-lint run ./...reports 0 issues after thischange, and the package tests pass.