-
Notifications
You must be signed in to change notification settings - Fork 99
APPSRE-13008: added typed queries for clusterrolebinding #5315
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
Open
mehfuz
wants to merge
6
commits into
app-sre:master
Choose a base branch
from
mehfuz:APPSRE-13008
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
reconcile/gql_definitions/common/app_interface_clusterrole.gql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # qenerate: plugin=pydantic_v2 | ||
| query AppInterfaceClusterRoles { | ||
| clusterRoles: roles_v1 { | ||
| name | ||
| users { | ||
| org_username | ||
| github_username | ||
| } | ||
| bots { | ||
| openshift_serviceaccount | ||
| } | ||
| access { | ||
| cluster { | ||
| name | ||
| auth { | ||
| service | ||
| } | ||
| } | ||
| clusterRole | ||
| } | ||
| expirationDate | ||
| } | ||
| } | ||
104 changes: 104 additions & 0 deletions
104
reconcile/gql_definitions/common/app_interface_clusterrole.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| """ | ||
| Generated by qenerate plugin=pydantic_v2. DO NOT MODIFY MANUALLY! | ||
| """ | ||
| from collections.abc import Callable # noqa: F401 # pylint: disable=W0611 | ||
| from datetime import datetime # noqa: F401 # pylint: disable=W0611 | ||
| from enum import Enum # noqa: F401 # pylint: disable=W0611 | ||
| from typing import ( # noqa: F401 # pylint: disable=W0611 | ||
| Any, | ||
| Optional, | ||
| Union, | ||
| ) | ||
|
|
||
| from pydantic import ( # noqa: F401 # pylint: disable=W0611 | ||
| BaseModel, | ||
| ConfigDict, | ||
| Field, | ||
| Json, | ||
| ) | ||
|
|
||
|
|
||
| DEFINITION = """ | ||
| query AppInterfaceClusterRoles { | ||
| clusterRoles: roles_v1 { | ||
| name | ||
| users { | ||
| org_username | ||
| github_username | ||
| } | ||
| bots { | ||
| openshift_serviceaccount | ||
| } | ||
| access { | ||
| cluster { | ||
| name | ||
| auth { | ||
| service | ||
| } | ||
| } | ||
| clusterRole | ||
| } | ||
| expirationDate | ||
| } | ||
| } | ||
| """ | ||
|
|
||
|
|
||
| class ConfiguredBaseModel(BaseModel): | ||
| model_config = ConfigDict( | ||
| extra='forbid' | ||
| ) | ||
|
|
||
|
|
||
| class UserV1(ConfiguredBaseModel): | ||
| org_username: str = Field(..., alias="org_username") | ||
| github_username: str = Field(..., alias="github_username") | ||
|
|
||
|
|
||
| class BotV1(ConfiguredBaseModel): | ||
| openshift_serviceaccount: Optional[str] = Field(..., alias="openshift_serviceaccount") | ||
|
|
||
|
|
||
| class ClusterAuthV1(ConfiguredBaseModel): | ||
| service: str = Field(..., alias="service") | ||
|
|
||
|
|
||
| class ClusterV1(ConfiguredBaseModel): | ||
| name: str = Field(..., alias="name") | ||
| auth: list[ClusterAuthV1] = Field(..., alias="auth") | ||
|
|
||
|
|
||
| class AccessV1(ConfiguredBaseModel): | ||
| cluster: Optional[ClusterV1] = Field(..., alias="cluster") | ||
| cluster_role: Optional[str] = Field(..., alias="clusterRole") | ||
|
|
||
|
|
||
| class RoleV1(ConfiguredBaseModel): | ||
| name: str = Field(..., alias="name") | ||
| users: list[UserV1] = Field(..., alias="users") | ||
| bots: list[BotV1] = Field(..., alias="bots") | ||
| access: Optional[list[AccessV1]] = Field(..., alias="access") | ||
| expiration_date: Optional[str] = Field(..., alias="expirationDate") | ||
|
|
||
|
|
||
| class AppInterfaceClusterRolesQueryData(ConfiguredBaseModel): | ||
| cluster_roles: Optional[list[RoleV1]] = Field(..., alias="clusterRoles") | ||
|
|
||
|
|
||
| def query(query_func: Callable, **kwargs: Any) -> AppInterfaceClusterRolesQueryData: | ||
| """ | ||
| This is a convenience function which queries and parses the data into | ||
| concrete types. It should be compatible with most GQL clients. | ||
| You do not have to use it to consume the generated data classes. | ||
| Alternatively, you can also mime and alternate the behavior | ||
| of this function in the caller. | ||
|
|
||
| Parameters: | ||
| query_func (Callable): Function which queries your GQL Server | ||
| kwargs: optional arguments that will be passed to the query function | ||
|
|
||
| Returns: | ||
| AppInterfaceClusterRolesQueryData: queried data parsed into generated classes | ||
| """ | ||
| raw_data: dict[Any, Any] = query_func(DEFINITION, **kwargs) | ||
| return AppInterfaceClusterRolesQueryData(**raw_data) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Fix indentation: