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

class_generator - add object as field type #2073

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 0 additions & 16 deletions .github/in-solidarity.yml

This file was deleted.

3 changes: 3 additions & 0 deletions class_generator/class_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ def types_generator(key_dict: Dict[str, Any]) -> Dict[str, str]:
elif resource_type == "integer":
type_for_docstring = "int"

elif resource_type == "object":
type_for_docstring = "Dict[str, Any]"

if not type_from_dict_for_init:
type_from_dict_for_init = f"Optional[{type_for_docstring}] = None"

Expand Down
22 changes: 11 additions & 11 deletions class_generator/tests/manifests/APIServer/api_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md

from typing import Any, List, Optional
from typing import Any, Dict, List, Optional
from ocp_resources.resource import Resource


Expand All @@ -15,11 +15,11 @@ class APIServer(Resource):
def __init__(
self,
additional_cors_allowed_origins: Optional[List[Any]] = None,
audit: Optional[Any] = None,
client_ca: Optional[Any] = None,
encryption: Optional[Any] = None,
serving_certs: Optional[Any] = None,
tls_security_profile: Optional[Any] = None,
audit: Optional[Dict[str, Any]] = None,
client_ca: Optional[Dict[str, Any]] = None,
encryption: Optional[Dict[str, Any]] = None,
serving_certs: Optional[Dict[str, Any]] = None,
tls_security_profile: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> None:
"""
Expand All @@ -31,10 +31,10 @@ def __init__(
The values are regular expressions that correspond to the Golang
regular expression language.

audit(Any): audit specifies the settings for audit configuration to be applied to
audit(Dict[str, Any]): audit specifies the settings for audit configuration to be applied to
all OpenShift-provided API servers in the cluster.

client_ca(Any): clientCA references a ConfigMap containing a certificate bundle for
client_ca(Dict[str, Any]): clientCA references a ConfigMap containing a certificate bundle for
the signers that will be recognized for incoming client
certificates in addition to the operator managed signers. If this
is empty, then only operator managed signers are valid. You
Expand All @@ -43,14 +43,14 @@ def __init__(
openshift-config namespace and contain the following required
fields: - ConfigMap.Data["ca-bundle.crt"] - CA bundle.

encryption(Any): encryption allows the configuration of encryption of resources at the
encryption(Dict[str, Any]): encryption allows the configuration of encryption of resources at the
datastore layer.

serving_certs(Any): servingCert is the TLS cert info for serving secure traffic. If not
serving_certs(Dict[str, Any]): servingCert is the TLS cert info for serving secure traffic. If not
specified, operator managed certificates will be used for serving
secure traffic.

tls_security_profile(Any): tlsSecurityProfile specifies settings for TLS connections for
tls_security_profile(Dict[str, Any]): tlsSecurityProfile specifies settings for TLS connections for
externally exposed servers. If unset, a default (which may
change between releases) is chosen. Note that only Old,
Intermediate and Custom profiles are currently supported, and the
Expand Down
10 changes: 5 additions & 5 deletions class_generator/tests/manifests/ConfigMap/config_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md

from typing import Any, Optional
from typing import Any, Dict, Optional
from ocp_resources.resource import NamespacedResource


Expand All @@ -13,21 +13,21 @@ class ConfigMap(NamespacedResource):

def __init__(
self,
binary_data: Optional[Any] = None,
data: Optional[Any] = None,
binary_data: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
immutable: Optional[bool] = None,
**kwargs: Any,
) -> None:
"""
Args:
binary_data(Any): BinaryData contains the binary data. Each key must consist of
binary_data(Dict[str, Any]): BinaryData contains the binary data. Each key must consist of
alphanumeric characters, '-', '_' or '.'. BinaryData can contain
byte sequences that are not in the UTF-8 range. The keys stored in
BinaryData must not overlap with the ones in the Data field, this
is enforced during validation process. Using this field will
require 1.10+ apiserver and kubelet.

data(Any): Data contains the configuration data. Each key must consist of
data(Dict[str, Any]): Data contains the configuration data. Each key must consist of
alphanumeric characters, '-', '_' or '.'. Values with non-UTF-8
byte sequences must use the BinaryData field. The keys stored in
Data must not overlap with the keys in the BinaryData field, this
Expand Down
14 changes: 7 additions & 7 deletions class_generator/tests/manifests/DNS/dns_config_openshift_io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md

from typing import Any, Optional
from typing import Any, Dict, Optional
from ocp_resources.resource import Resource


Expand All @@ -15,9 +15,9 @@ class DNS(Resource):
def __init__(
self,
base_domain: Optional[str] = "",
platform: Optional[Any] = None,
private_zone: Optional[Any] = None,
public_zone: Optional[Any] = None,
platform: Optional[Dict[str, Any]] = None,
private_zone: Optional[Dict[str, Any]] = None,
public_zone: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> None:
"""
Expand All @@ -28,17 +28,17 @@ def __init__(
created for `cluster-api.openshift.example.com`. Once set, this
field cannot be changed.

platform(Any): platform holds configuration specific to the underlying infrastructure
platform(Dict[str, Any]): platform holds configuration specific to the underlying infrastructure
provider for DNS. When omitted, this means the user has no opinion
and the platform is left to choose reasonable defaults. These
defaults are subject to change over time.

private_zone(Any): privateZone is the location where all the DNS records that are only
private_zone(Dict[str, Any]): privateZone is the location where all the DNS records that are only
available internally to the cluster exist. If this field is nil,
no private records should be created. Once set, this field
cannot be changed.

public_zone(Any): publicZone is the location where all the DNS records that are publicly
public_zone(Dict[str, Any]): publicZone is the location where all the DNS records that are publicly
accessible to the internet exist. If this field is nil, no
public records should be created. Once set, this field cannot be
changed.
Expand Down
14 changes: 7 additions & 7 deletions class_generator/tests/manifests/DNS/dns_operator_openshift_io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md

from typing import Any, List, Optional
from typing import Any, Dict, List, Optional
from ocp_resources.resource import Resource


Expand All @@ -16,18 +16,18 @@ class DNS(Resource):

def __init__(
self,
cache: Optional[Any] = None,
cache: Optional[Dict[str, Any]] = None,
log_level: Optional[str] = "",
management_state: Optional[str] = "",
node_placement: Optional[Any] = None,
node_placement: Optional[Dict[str, Any]] = None,
operator_log_level: Optional[str] = "",
servers: Optional[List[Any]] = None,
upstream_resolvers: Optional[Any] = None,
upstream_resolvers: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> None:
"""
Args:
cache(Any): cache describes the caching configuration that applies to all server
cache(Dict[str, Any]): cache describes the caching configuration that applies to all server
blocks listed in the Corefile. This field allows a cluster admin
to optionally configure: * positiveTTL which is a duration for
which positive responses should be cached. * negativeTTL which is
Expand All @@ -48,7 +48,7 @@ def __init__(
management_state(str): managementState indicates whether the DNS operator should manage
cluster DNS

node_placement(Any): nodePlacement provides explicit control over the scheduling of DNS
node_placement(Dict[str, Any]): nodePlacement provides explicit control over the scheduling of DNS
pods. Generally, it is useful to run a DNS pod on every node so
that DNS queries are always handled by a local DNS pod instead of
going over the network to a DNS pod on another node. However,
Expand All @@ -75,7 +75,7 @@ def __init__(
routed to the Server with Zone "a.foo.com". If this field is
nil, no servers are created.

upstream_resolvers(Any): upstreamResolvers defines a schema for configuring CoreDNS to proxy
upstream_resolvers(Dict[str, Any]): upstreamResolvers defines a schema for configuring CoreDNS to proxy
DNS messages to upstream resolvers for the case of the default
(".") server If this field is not specified, the upstream used
will default to /etc/resolv.conf, with policy "sequential"
Expand Down
14 changes: 7 additions & 7 deletions class_generator/tests/manifests/Deployment/deployment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md

from typing import Any, Optional
from typing import Any, Dict, Optional
from ocp_resources.resource import NamespacedResource, MissingRequiredArgumentError


Expand All @@ -18,9 +18,9 @@ def __init__(
progress_deadline_seconds: Optional[int] = None,
replicas: Optional[int] = None,
revision_history_limit: Optional[int] = None,
selector: Optional[Any] = None,
strategy: Optional[Any] = None,
template: Optional[Any] = None,
selector: Optional[Dict[str, Any]] = None,
strategy: Optional[Dict[str, Any]] = None,
template: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> None:
"""
Expand All @@ -46,15 +46,15 @@ def __init__(
pointer to distinguish between explicit zero and not specified.
Defaults to 10.

selector(Any): A label selector is a label query over a set of resources. The result
selector(Dict[str, Any]): A label selector is a label query over a set of resources. The result
of matchLabels and matchExpressions are ANDed. An empty label
selector matches all objects. A null label selector matches no
objects.

strategy(Any): DeploymentStrategy describes how to replace existing pods with new
strategy(Dict[str, Any]): DeploymentStrategy describes how to replace existing pods with new
ones.

template(Any): PodTemplateSpec describes the data a pod should have when created from
template(Dict[str, Any]): PodTemplateSpec describes the data a pod should have when created from
a template

"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md

from typing import Any, List, Optional
from typing import Any, Dict, List, Optional
from ocp_resources.resource import Resource


Expand All @@ -14,15 +14,15 @@ class Image(Resource):

def __init__(
self,
additional_trusted_ca: Optional[Any] = None,
additional_trusted_ca: Optional[Dict[str, Any]] = None,
allowed_registries_for_import: Optional[List[Any]] = None,
external_registry_hostnames: Optional[List[Any]] = None,
registry_sources: Optional[Any] = None,
registry_sources: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> None:
"""
Args:
additional_trusted_ca(Any): additionalTrustedCA is a reference to a ConfigMap containing
additional_trusted_ca(Dict[str, Any]): additionalTrustedCA is a reference to a ConfigMap containing
additional CAs that should be trusted during imagestream import,
pod image pull, build image pull, and imageregistry pullthrough.
The namespace for this config map is openshift-config.
Expand All @@ -41,7 +41,7 @@ def __init__(
used in 'publicDockerImageRepository' field in ImageStreams. The
value must be in "hostname[:port]" format.

registry_sources(Any): registrySources contains configuration that determines how the
registry_sources(Dict[str, Any]): registrySources contains configuration that determines how the
container runtime should treat individual registries when
accessing images for builds+pods. (e.g. whether or not to allow
insecure access). It does not contain configuration for the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md

from typing import Any, List, Optional
from typing import Any, Dict, List, Optional
from ocp_resources.resource import Resource


Expand All @@ -20,7 +20,7 @@ def __init__(
docker_image_manifest: Optional[str] = "",
docker_image_manifest_media_type: Optional[str] = "",
docker_image_manifests: Optional[List[Any]] = None,
docker_image_metadata: Optional[Any] = None,
docker_image_metadata: Optional[Dict[str, Any]] = None,
docker_image_metadata_version: Optional[str] = "",
docker_image_reference: Optional[str] = "",
docker_image_signatures: Optional[List[Any]] = None,
Expand All @@ -46,7 +46,7 @@ def __init__(
image represents a manifest list. When this field is present, no
DockerImageLayers should be specified.

docker_image_metadata(Any): RawExtension is used to hold extensions in external versions. To use
docker_image_metadata(Dict[str, Any]): RawExtension is used to hold extensions in external versions. To use
this, make a field which has RawExtension as its type in your
external, versioned struct, and Object in your internal struct.
You also need to register your various plugin types. // Internal
Expand Down
14 changes: 7 additions & 7 deletions class_generator/tests/manifests/Machine/machine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md

from typing import Any, List, Optional
from typing import Any, Dict, List, Optional
from ocp_resources.resource import NamespacedResource


Expand All @@ -13,19 +13,19 @@ class Machine(NamespacedResource):

def __init__(
self,
lifecycle_hooks: Optional[Any] = None,
metadata: Optional[Any] = None,
lifecycle_hooks: Optional[Dict[str, Any]] = None,
metadata: Optional[Dict[str, Any]] = None,
provider_id: Optional[str] = "",
provider_spec: Optional[Any] = None,
provider_spec: Optional[Dict[str, Any]] = None,
taints: Optional[List[Any]] = None,
**kwargs: Any,
) -> None:
"""
Args:
lifecycle_hooks(Any): LifecycleHooks allow users to pause operations on the machine at
lifecycle_hooks(Dict[str, Any]): LifecycleHooks allow users to pause operations on the machine at
certain predefined points within the machine lifecycle.

metadata(Any): ObjectMeta will autopopulate the Node created. Use this to indicate
metadata(Dict[str, Any]): ObjectMeta will autopopulate the Node created. Use this to indicate
what labels, annotations, name prefix, etc., should be used when
creating the Node.

Expand All @@ -45,7 +45,7 @@ def __init__(
autoscaler that will be interfacing with cluster-api as generic
provider.

provider_spec(Any): ProviderSpec details Provider-specific configuration to use during
provider_spec(Dict[str, Any]): ProviderSpec details Provider-specific configuration to use during
node creation.

taints(List[Any]): The list of the taints to be applied to the corresponding Node in
Expand Down
Loading