feat: sync struct fields with upstream Casdoor and fix fmt.Errorf misuse#233
feat: sync struct fields with upstream Casdoor and fix fmt.Errorf misuse#233prochac wants to merge 2 commits intocasdoor:masterfrom
Conversation
Add new fields from upstream Casdoor to Application (Category, Type, Scopes, reverse proxy fields), Enforcer (ModelCfg), Group (ParentName, HaveChildren), Model (Description), Organization (AccountMenu, DcrPolicy), Provider (HttpHeaders, SslMode, EmailRegex, EnableProxy, EnablePkce), Record (Provider, Block), Session (ExclusiveSignin), Syncer (SSH/SSL fields), and Token (Resource). Remove fields deleted upstream: ProviderItem.AlertType, Record.StatusCode/ExtendedUser, Syncer.TablePrimaryKey. Replace fmt.Errorf with errors.New where no formatting is needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This pull request synchronizes the Casdoor SDK struct definitions with the upstream Casdoor repository to address issue #232 regarding SDK being out of sync. The changes include adding new fields across multiple entities, removing deprecated fields, and correcting the misuse of fmt.Errorf where no formatting is needed.
Changes:
- Added new fields to support upstream features including reverse proxy configuration (Application), SSH/SSL connection options (Syncer, Provider), resource indicators (Token), and various metadata fields across multiple entities
- Removed deprecated fields that were deleted upstream (ProviderItem.AlertType, Record.StatusCode/ExtendedUser, Syncer.TablePrimaryKey)
- Replaced
fmt.Errorfwitherrors.Newin util.go where no string formatting is performed
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| casdoorsdk/util.go | Replaced fmt.Errorf with errors.New for error messages without formatting at lines 101 and 179 |
| casdoorsdk/token.go | Added Resource field for RFC 8707 Resource Indicator support |
| casdoorsdk/syncer.go | Reorganized struct fields, added SSH/SSL configuration fields (SslMode, SshType, SshHost, SshPort, SshUser, SshPassword, Cert), removed TablePrimaryKey field |
| casdoorsdk/session.go | Added ExclusiveSignin field for exclusive signin functionality |
| casdoorsdk/record.go | Removed StatusCode and ExtendedUser fields, added Provider and Block fields, changed Object and Response to use mediumtext |
| casdoorsdk/provider.go | Added HttpHeaders, SslMode, EmailRegex, EnableProxy, and EnablePkce fields with deprecation note for DisableSsl |
| casdoorsdk/organization.go | Added AccountMenu and DcrPolicy fields |
| casdoorsdk/model.go | Added Description field |
| casdoorsdk/group.go | Added ParentName and HaveChildren fields for hierarchical group management |
| casdoorsdk/enforcer.go | Added ModelCfg map field for model configuration |
| casdoorsdk/application.go | Added Category, Type, and Scopes fields; added ScopeItem struct; added reverse proxy fields (Domain, OtherDomains, UpstreamHost, SslMode, SslCert); updated ProviderItem with CountryCodes and SignupGroup, removed AlertType |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| SessionId []string `json:"sessionId"` | ||
| SessionId []string `json:"sessionId"` | ||
| ExclusiveSignin bool `xorm:"-"` |
There was a problem hiding this comment.
The ExclusiveSignin field is missing a JSON struct tag. Based on the codebase convention where fields with xorm:"-" also include a json tag (see other examples in application.go, group.go, enforcer.go), this field should have json:"exclusiveSignin" added to maintain consistency with the API serialization.
| ExclusiveSignin bool `xorm:"-"` | |
| ExclusiveSignin bool `xorm:"-" json:"exclusiveSignin"` |
GetX methods now pass through owner/name IDs as-is when the name already contains a slash, instead of always prepending the client's default organization. modifyX methods now only set Owner when the caller left it empty, preserving explicitly set owners. This allows callers (like Terraform providers) to operate on resources in organizations other than the SDK client's configured default. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@prochac you should not modify the Go struct content. just paste the struct without modification from Casdoor |
You shouldn't leak the repository layer tags to SDK 😁 |
|
@prochac the current way makes the update more difficult in future. there will be unnescessary diff in git. copy-paste is simple |
Add new fields from upstream Casdoor to Application (Category, Type, Scopes, reverse proxy fields), Enforcer (ModelCfg), Group (ParentName, HaveChildren), Model (Description), Organization (AccountMenu, DcrPolicy), Provider (HttpHeaders, SslMode, EmailRegex, EnableProxy, EnablePkce), Record (Provider, Block), Session (ExclusiveSignin), Syncer (SSH/SSL fields), and Token (Resource).
Remove fields deleted upstream: ProviderItem.AlertType, Record.StatusCode/ExtendedUser, Syncer.TablePrimaryKey.
Replace fmt.Errorf with errors.New where no formatting is needed.
Fixes #232