Skip to content
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

Feature/explicit k8s resources #13

Merged
merged 22 commits into from
Aug 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c5aae3b
Excludes None/null YAML values in generated k8s specs
petermorrowdev Aug 4, 2024
14685a3
Fixes json type hints
petermorrowdev Aug 4, 2024
5af7134
Uses uv installer to speed up install
petermorrowdev Aug 4, 2024
8e08f0c
Includes missing common k8s structs
petermorrowdev Aug 4, 2024
8c71621
Upgrades k8s generated modules. Adding 1.30
petermorrowdev Aug 4, 2024
cc15404
Upgrades kubernetes submodule
petermorrowdev Aug 7, 2024
6e10945
Updates submodule
petermorrowdev Aug 18, 2024
9c1dc18
Code block highlights for pip install
petermorrowdev Aug 18, 2024
a9c8aee
Starts developing k8s resource model for
petermorrowdev Aug 18, 2024
fb9571c
Completes resource model codegen implementation
petermorrowdev Aug 19, 2024
c435029
Runs new resource model codegen implementation on all versions
petermorrowdev Aug 19, 2024
ed1e602
Modes codegen logic into gybe.codegen
petermorrowdev Aug 19, 2024
5affe76
Enforces transpiler returns list[K8sResource]
petermorrowdev Aug 20, 2024
7e6f137
More explicit comment
petermorrowdev Aug 24, 2024
6ff8c68
Sorts imports
petermorrowdev Aug 24, 2024
baeea18
Formatting
petermorrowdev Aug 24, 2024
6a62010
Decorates base classes with @dataclass.
petermorrowdev Aug 24, 2024
a052733
Expands ruff check to entire gybe module
petermorrowdev Aug 24, 2024
2abde3c
Fixes tests linter errors
petermorrowdev Aug 27, 2024
52d4ec3
Sets version to 0.3.2
petermorrowdev Aug 27, 2024
d07e3e9
Fixes codegen bug assigning K8sResource to all objects
petermorrowdev Aug 27, 2024
65af87b
Fixes backwards resource props check
petermorrowdev Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixes backwards resource props check
  • Loading branch information
petermorrowdev committed Aug 27, 2024

Verified

This commit was signed with the committer’s verified signature.
kianenigma Kian Paimani
commit 65af87b62866dd4f8655d331d55e1dfed0233299
2 changes: 1 addition & 1 deletion gybe/codegen/k8s_modules.py
Original file line number Diff line number Diff line change
@@ -148,7 +148,7 @@ def _model_def(
required: list[str],
resource_properties: dict[str, str],
) -> ast.ClassDef:
base_cls = 'K8sSpec' if len(resource_properties) > 0 else 'K8sResource'
base_cls = 'K8sSpec' if len(resource_properties) == 0 else 'K8sResource'
cdef = ast.parse('@dataclass\nclass ' + name + f'({base_cls}):\n pass').body[0]
if not isinstance(cdef, ast.ClassDef):
raise ValueError(f'{cdef} is not expected ast.ClassDef')
20 changes: 10 additions & 10 deletions gybe/k8s/v1_26/admissionregistration/v1.py
Original file line number Diff line number Diff line change
@@ -6,11 +6,11 @@
from typing import List, Optional

import gybe.k8s.v1_26.meta.v1
from gybe.k8s.types import JSONObj, K8sResource
from gybe.k8s.types import JSONObj, K8sSpec


@dataclass
class MutatingWebhook(K8sResource):
class MutatingWebhook(K8sSpec):
"""MutatingWebhook describes an admission webhook and the resources and operations it applies to.

Attributes
@@ -99,7 +99,7 @@ class MutatingWebhook(K8sResource):


@dataclass
class MutatingWebhookConfiguration(K8sResource):
class MutatingWebhookConfiguration(K8sSpec):
"""MutatingWebhookConfiguration describes the configuration of and admission webhook that accept or
reject and may change the object.

@@ -122,7 +122,7 @@ class MutatingWebhookConfiguration(K8sResource):


@dataclass
class MutatingWebhookConfigurationList(K8sResource):
class MutatingWebhookConfigurationList(K8sSpec):
"""MutatingWebhookConfigurationList is a list of MutatingWebhookConfiguration.

Attributes
@@ -144,7 +144,7 @@ class MutatingWebhookConfigurationList(K8sResource):


@dataclass
class RuleWithOperations(K8sResource):
class RuleWithOperations(K8sSpec):
"""RuleWithOperations is a tuple of Operations and Resources. It is recommended to make sure that all the
tuple expansions are valid.

@@ -179,7 +179,7 @@ class RuleWithOperations(K8sResource):


@dataclass
class ServiceReference(K8sResource):
class ServiceReference(K8sSpec):
"""ServiceReference holds a reference to Service.legacy.k8s.io
Attributes:
name: `name` is the name of the service. Required
@@ -197,7 +197,7 @@ class ServiceReference(K8sResource):


@dataclass
class ValidatingWebhook(K8sResource):
class ValidatingWebhook(K8sSpec):
"""ValidatingWebhook describes an admission webhook and the resources and operations it applies to.

Attributes
@@ -274,7 +274,7 @@ class ValidatingWebhook(K8sResource):


@dataclass
class ValidatingWebhookConfiguration(K8sResource):
class ValidatingWebhookConfiguration(K8sSpec):
"""ValidatingWebhookConfiguration describes the configuration of and admission webhook that accept or
reject and object without changing it.

@@ -297,7 +297,7 @@ class ValidatingWebhookConfiguration(K8sResource):


@dataclass
class ValidatingWebhookConfigurationList(K8sResource):
class ValidatingWebhookConfigurationList(K8sSpec):
"""ValidatingWebhookConfigurationList is a list of ValidatingWebhookConfiguration.

Attributes
@@ -319,7 +319,7 @@ class ValidatingWebhookConfigurationList(K8sResource):


@dataclass
class WebhookClientConfig(K8sResource):
class WebhookClientConfig(K8sSpec):
"""WebhookClientConfig contains the information to make a TLS connection with the webhook
Attributes:
caBundle: `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server
24 changes: 12 additions & 12 deletions gybe/k8s/v1_26/admissionregistration/v1alpha1.py
Original file line number Diff line number Diff line change
@@ -6,11 +6,11 @@
from typing import List, Optional

import gybe.k8s.v1_26.meta.v1
from gybe.k8s.types import JSONObj, K8sResource
from gybe.k8s.types import JSONObj, K8sSpec


@dataclass
class MatchResources(K8sResource):
class MatchResources(K8sSpec):
"""MatchResources decides whether to run the admission control policy on an object based on whether it
meets the match criteria. The exclude rules take precedence over include rules (if a resource matches
both, it is excluded)
@@ -64,7 +64,7 @@ class MatchResources(K8sResource):


@dataclass
class NamedRuleWithOperations(K8sResource):
class NamedRuleWithOperations(K8sSpec):
"""NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.

Attributes
@@ -101,7 +101,7 @@ class NamedRuleWithOperations(K8sResource):


@dataclass
class ParamKind(K8sResource):
class ParamKind(K8sSpec):
"""ParamKind is a tuple of Group Kind and Version.

Attributes
@@ -117,7 +117,7 @@ class ParamKind(K8sResource):


@dataclass
class ParamRef(K8sResource):
class ParamRef(K8sSpec):
"""ParamRef references a parameter resource
Attributes:
name: Name of the resource being referenced.
@@ -130,7 +130,7 @@ class ParamRef(K8sResource):


@dataclass
class ValidatingAdmissionPolicy(K8sResource):
class ValidatingAdmissionPolicy(K8sSpec):
"""ValidatingAdmissionPolicy describes the definition of an admission validation policy that accepts or
rejects an object without changing it.

@@ -153,7 +153,7 @@ class ValidatingAdmissionPolicy(K8sResource):


@dataclass
class ValidatingAdmissionPolicyBinding(K8sResource):
class ValidatingAdmissionPolicyBinding(K8sSpec):
"""ValidatingAdmissionPolicyBinding binds the ValidatingAdmissionPolicy with paramerized resources.
ValidatingAdmissionPolicyBinding and parameter CRDs together define how cluster administrators
configure policies for clusters.
@@ -177,7 +177,7 @@ class ValidatingAdmissionPolicyBinding(K8sResource):


@dataclass
class ValidatingAdmissionPolicyBindingList(K8sResource):
class ValidatingAdmissionPolicyBindingList(K8sSpec):
"""ValidatingAdmissionPolicyBindingList is a list of ValidatingAdmissionPolicyBinding.

Attributes
@@ -199,7 +199,7 @@ class ValidatingAdmissionPolicyBindingList(K8sResource):


@dataclass
class ValidatingAdmissionPolicyBindingSpec(K8sResource):
class ValidatingAdmissionPolicyBindingSpec(K8sSpec):
"""ValidatingAdmissionPolicyBindingSpec is the specification of the ValidatingAdmissionPolicyBinding.

Attributes
@@ -228,7 +228,7 @@ class ValidatingAdmissionPolicyBindingSpec(K8sResource):


@dataclass
class ValidatingAdmissionPolicyList(K8sResource):
class ValidatingAdmissionPolicyList(K8sSpec):
"""ValidatingAdmissionPolicyList is a list of ValidatingAdmissionPolicy.

Attributes
@@ -250,7 +250,7 @@ class ValidatingAdmissionPolicyList(K8sResource):


@dataclass
class ValidatingAdmissionPolicySpec(K8sResource):
class ValidatingAdmissionPolicySpec(K8sSpec):
"""ValidatingAdmissionPolicySpec is the specification of the desired behavior of the AdmissionPolicy.

Attributes
@@ -281,7 +281,7 @@ class ValidatingAdmissionPolicySpec(K8sResource):


@dataclass
class Validation(K8sResource):
class Validation(K8sSpec):
"""Validation specifies the CEL expression which is used to apply the validation.

Attributes
34 changes: 17 additions & 17 deletions gybe/k8s/v1_26/apiextensions/v1.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@


@dataclass
class CustomResourceColumnDefinition(K8sResource):
class CustomResourceColumnDefinition(K8sSpec):
"""CustomResourceColumnDefinition specifies a column for server side printing.

Attributes
@@ -39,7 +39,7 @@ class CustomResourceColumnDefinition(K8sResource):


@dataclass
class CustomResourceConversion(K8sResource):
class CustomResourceConversion(K8sSpec):
"""CustomResourceConversion describes how to convert different versions of a CR.

Attributes
@@ -59,7 +59,7 @@ class CustomResourceConversion(K8sResource):


@dataclass
class CustomResourceDefinition(K8sSpec):
class CustomResourceDefinition(K8sResource):
"""CustomResourceDefinition represents a resource that should be exposed on the API server. Its name
MUST be in the format <.spec.name>.<.spec.group>.

@@ -84,7 +84,7 @@ class CustomResourceDefinition(K8sSpec):


@dataclass
class CustomResourceDefinitionCondition(K8sResource):
class CustomResourceDefinitionCondition(K8sSpec):
"""CustomResourceDefinitionCondition contains details for the current condition of this pod.

Attributes
@@ -106,7 +106,7 @@ class CustomResourceDefinitionCondition(K8sResource):


@dataclass
class CustomResourceDefinitionList(K8sResource):
class CustomResourceDefinitionList(K8sSpec):
"""CustomResourceDefinitionList is a list of CustomResourceDefinition objects.

Attributes
@@ -128,7 +128,7 @@ class CustomResourceDefinitionList(K8sResource):


@dataclass
class CustomResourceDefinitionNames(K8sResource):
class CustomResourceDefinitionNames(K8sSpec):
"""CustomResourceDefinitionNames indicates the names to serve this CustomResourceDefinition
Attributes:
categories: categories is a list of grouped resources this custom resource belongs to (e.g. 'all').
@@ -156,7 +156,7 @@ class CustomResourceDefinitionNames(K8sResource):


@dataclass
class CustomResourceDefinitionSpec(K8sResource):
class CustomResourceDefinitionSpec(K8sSpec):
"""CustomResourceDefinitionSpec describes how a user wants their resource to appear
Attributes:
conversion: conversion defines conversion settings for the CRD.
@@ -192,7 +192,7 @@ class CustomResourceDefinitionSpec(K8sResource):


@dataclass
class CustomResourceDefinitionStatus(K8sResource):
class CustomResourceDefinitionStatus(K8sSpec):
"""CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition
Attributes:
acceptedNames: acceptedNames are the names that are actually being used to serve discovery. They may
@@ -212,7 +212,7 @@ class CustomResourceDefinitionStatus(K8sResource):


@dataclass
class CustomResourceDefinitionVersion(K8sResource):
class CustomResourceDefinitionVersion(K8sSpec):
"""CustomResourceDefinitionVersion describes a version for CRD.

Attributes
@@ -249,7 +249,7 @@ class CustomResourceDefinitionVersion(K8sResource):


@dataclass
class CustomResourceSubresourceScale(K8sResource):
class CustomResourceSubresourceScale(K8sSpec):
"""CustomResourceSubresourceScale defines how to serve the scale subresource for CustomResources.

Attributes
@@ -276,7 +276,7 @@ class CustomResourceSubresourceScale(K8sResource):


@dataclass
class CustomResourceSubresources(K8sResource):
class CustomResourceSubresources(K8sSpec):
"""CustomResourceSubresources defines the status and scale subresources for CustomResources.

Attributes
@@ -295,7 +295,7 @@ class CustomResourceSubresources(K8sResource):


@dataclass
class CustomResourceValidation(K8sResource):
class CustomResourceValidation(K8sSpec):
"""CustomResourceValidation is a list of validation methods for CustomResources.

Attributes
@@ -308,7 +308,7 @@ class CustomResourceValidation(K8sResource):


@dataclass
class ExternalDocumentation(K8sResource):
class ExternalDocumentation(K8sSpec):
"""ExternalDocumentation allows referencing an external resource for extended documentation.

Attributes
@@ -323,7 +323,7 @@ class ExternalDocumentation(K8sResource):


@dataclass
class ServiceReference(K8sResource):
class ServiceReference(K8sSpec):
"""ServiceReference holds a reference to Service.legacy.k8s.io
Attributes:
name: name is the name of the service. Required
@@ -341,7 +341,7 @@ class ServiceReference(K8sResource):


@dataclass
class ValidationRule(K8sResource):
class ValidationRule(K8sSpec):
"""ValidationRule describes a validation rule written in the CEL expression language.

Attributes
@@ -396,7 +396,7 @@ class ValidationRule(K8sResource):


@dataclass
class WebhookClientConfig(K8sResource):
class WebhookClientConfig(K8sSpec):
"""WebhookClientConfig contains the information to make a TLS connection with the webhook.

Attributes
@@ -426,7 +426,7 @@ class WebhookClientConfig(K8sResource):


@dataclass
class WebhookConversion(K8sResource):
class WebhookConversion(K8sSpec):
"""WebhookConversion describes how to call a conversion webhook
Attributes:
clientConfig: clientConfig is the instructions for how to call the webhook if strategy is `Webhook`.
10 changes: 5 additions & 5 deletions gybe/k8s/v1_26/apiserverinternal/v1alpha1.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@


@dataclass
class ServerStorageVersion(K8sResource):
class ServerStorageVersion(K8sSpec):
"""An API server instance reports the version it can decode and the version it encodes objects to when
persisting objects in the backend.

@@ -30,7 +30,7 @@ class ServerStorageVersion(K8sResource):


@dataclass
class StorageVersion(K8sSpec):
class StorageVersion(K8sResource):
"""Storage version of a specific resource.

Attributes
@@ -55,7 +55,7 @@ class StorageVersion(K8sSpec):


@dataclass
class StorageVersionCondition(K8sResource):
class StorageVersionCondition(K8sSpec):
"""Describes the state of the storageVersion at a certain point.

Attributes
@@ -79,7 +79,7 @@ class StorageVersionCondition(K8sResource):


@dataclass
class StorageVersionList(K8sResource):
class StorageVersionList(K8sSpec):
"""A list of StorageVersions.

Attributes
@@ -101,7 +101,7 @@ class StorageVersionList(K8sResource):


@dataclass
class StorageVersionStatus(K8sResource):
class StorageVersionStatus(K8sSpec):
"""API server instances report the versions they can decode and the version they encode objects to when
persisting objects in the backend.

Loading
Loading