Skip to content

feat: Add role schema#549

Open
leecalcote wants to merge 2 commits intomasterfrom
schemas/role
Open

feat: Add role schema#549
leecalcote wants to merge 2 commits intomasterfrom
schemas/role

Conversation

@leecalcote
Copy link
Copy Markdown
Member

@leecalcote leecalcote commented Jan 12, 2026

Signed-off-by: Lee Calcote lee.calcote@layer5.io

The following Golang structs present in the remote provider server/models/roles.go are missing in explicit definition in this PR:

  • TeamMemberWithRole
  • UserWithRole
  • Preference
  • UsersPage
  • TeamMembersPage
  • UserID
  • RoleID

The following helper functions present in the remote provider server/models/roles.go are not included in this PR:

// String is not required by pop and may be deleted
func (a Roles) String() string {
	ja, _ := json.Marshal(a)
	return string(ja)
}

Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @leecalcote, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request establishes the foundational components for a robust role-based access control system. It defines the necessary data structures and API endpoints to manage roles for users, organizations, and teams, enabling granular permission management and integration with keychains. This feature significantly enhances the system's security and administrative capabilities.

Highlights

  • New Role Management Capabilities: Introduces comprehensive schema and models for managing user roles, organization roles, and team roles within the system, laying the groundwork for granular access control.
  • API Definition for Roles: Adds a new OpenAPI specification (api.yml) defining endpoints for role assignment, creation, retrieval, updates, and associating keychains with roles, enhancing the system's administrative interface.
  • Go Data Models: Implements Go structs (role.go) for various role-related entities, such as 'Role', 'OrganizationWithUserRoles', 'TeamWithUserRoles', and 'UserRoleUpdateRequest', facilitating robust backend data handling.
  • Dependency Updates: Includes new Go module dependencies (github.com/gobuffalo/nulls, github.com/jmoiron/sqlx, github.com/lib/pq, github.com/mattn/go-sqlite3) to support database interactions and null value handling for the new role models.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@leecalcote leecalcote changed the title feat: Add role schema and models feat: Add role schema Jan 12, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new schema definitions and Go models for roles. The changes are a good step forward, but there is a systematic issue in the new OpenAPI specification files (api.yml and role.yaml) that needs to be addressed. Currently, $ref is used with sibling properties, which is not compliant with the OpenAPI 3.0 specification. This causes the Go code generator (oapi-codegen) to produce duplicated, inlined structs instead of reusing defined types, which undermines the goal of schema reusability and makes the generated code harder to maintain. I've left comments with suggestions on how to fix this using the allOf keyword. After correcting the YAML files, please remember to regenerate the Go models to reflect these changes.

- roles
properties:
page:
$ref: "../../v1alpha1/core/api.yml#/components/schemas/number"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

In OpenAPI 3.0, a $ref cannot have sibling properties. This causes oapi-codegen to inline the schema instead of reusing the defined type, leading to code duplication and maintenance issues in the generated Go models. To fix this, you should wrap the $ref in an allOf block when you need to add other properties like x-order.

This issue is present in multiple places in this file (e.g., within RolesPage, RolesKeychainsMapping, UserRoleUpdateRequest, OrganizationWithUserRoles, TeamWithUserRoles). Please apply this allOf fix consistently throughout the file.

          allOf:
            - $ref: "../../v1alpha1/core/api.yml#/components/schemas/number"

- updated_at
properties:
id:
$ref: ../../v1alpha1/core/api.yml#/components/schemas/uuid
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Similar to the issues in api.yml, using $ref with sibling properties is not compliant with OpenAPI 3.0. This will cause the code generator to inline the schema instead of reusing it. Please wrap the $ref in an allOf block. This change should be applied to all properties in this file that use $ref with siblings (id, created_at, updated_at, deleted_at).

    allOf:
      - $ref: ../../v1alpha1/core/api.yml#/components/schemas/uuid

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 12, 2026

@leecalcote I've opened a new pull request, #550, to work on those changes. Once the pull request is ready, I'll request review from you.

- Introduced a new file `helpers.go` in the `models/v1beta1/role` package.
- Implemented the `EventCategory` method to return the category as "role".
- Added a `String` method for JSON representation of the `Role` struct.
- Created `ValidateCreate` and `ValidateUpdate` methods for role validation, returning empty validation errors.

Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
@hortison
Copy link
Copy Markdown
Contributor

@copilot Follow the naming convention in meshery/schemas README.md use camelCase for property names.

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 13, 2026

@hortison I've opened a new pull request, #551, to work on those changes. Once the pull request is ready, I'll request review from you.

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.

3 participants