From 518844324e92eb39934c5d0cb2bfdf88a73a2d78 Mon Sep 17 00:00:00 2001 From: Justin Ross Date: Wed, 12 Jun 2024 11:27:41 -0400 Subject: [PATCH] WIP --- config/resources.yaml | 17 ++++++++++++++--- input/resources/connector.md | 25 +++++++++++++++++++++++++ input/resources/listener.md | 25 +++++++++++++++++++++++++ input/resources/site.md | 25 +++++++++++++++++++++++++ python/resources.py | 21 +++++++++++++++++++++ 5 files changed, 110 insertions(+), 3 deletions(-) diff --git a/config/resources.yaml b/config/resources.yaml index 33afade..ceb5da9 100644 --- a/config/resources.yaml +++ b/config/resources.yaml @@ -1,3 +1,17 @@ +standard_metadata_properties: + - name: name + type: string + description: | + The name of the resource. + - name: namespace + type: string + description: | + The namespace of the resource. + links: + - name: Namespace concept + url: /concepts/namespace.html + - name: Kubernetes namespaces + url: "" groups: - name: Sites resources: @@ -26,9 +40,6 @@ groups: namespace: hello-world-west spec: linkAccess: default - metadata_properties: - - name: name - required: true spec_properties: - name: linkAccess default: none diff --git a/input/resources/connector.md b/input/resources/connector.md index c77b3ac..5edc688 100644 --- a/input/resources/connector.md +++ b/input/resources/connector.md @@ -44,6 +44,31 @@ spec: selector: app=backend ~~~ + + +
+ +## Metadata properties + +-

name string, required

+ + The name of the resource. + + | | | + |-|-| + | Platforms | Kubernetes, Docker | + + +-

namespace string, required

+ + The namespace of the resource. + + | | | + |-|-| + | Platforms | Kubernetes, Docker | + | See also | [Namespace concept]({{site_prefix}}/concepts/namespace.html), [Kubernetes namespaces]({{site_prefix}}) | + +
diff --git a/input/resources/listener.md b/input/resources/listener.md index 93bc1b3..cfb1d7f 100644 --- a/input/resources/listener.md +++ b/input/resources/listener.md @@ -45,6 +45,31 @@ spec: host: backend ~~~ +
+ +
+ +## Metadata properties + +-

name string, required

+ + The name of the resource. + + | | | + |-|-| + | Platforms | Kubernetes, Docker | + + +-

namespace string, required

+ + The namespace of the resource. + + | | | + |-|-| + | Platforms | Kubernetes, Docker | + | See also | [Namespace concept]({{site_prefix}}/concepts/namespace.html), [Kubernetes namespaces]({{site_prefix}}) | + +
diff --git a/input/resources/site.md b/input/resources/site.md index 13e7400..7b30cdb 100644 --- a/input/resources/site.md +++ b/input/resources/site.md @@ -52,6 +52,31 @@ spec: linkAccess: default ~~~ +
+ +
+ +## Metadata properties + +-

name string, required

+ + The name of the resource. + + | | | + |-|-| + | Platforms | Kubernetes, Docker | + + +-

namespace string, required

+ + The namespace of the resource. + + | | | + |-|-| + | Platforms | Kubernetes, Docker | + | See also | [Namespace concept]({{site_prefix}}/concepts/namespace.html), [Kubernetes namespaces]({{site_prefix}}) | + +
diff --git a/python/resources.py b/python/resources.py index ca38747..9e72641 100644 --- a/python/resources.py +++ b/python/resources.py @@ -106,6 +106,16 @@ def append(line=""): append("
") append() + append("
") + append() + append("## Metadata properties") + append() + + for prop in resource.metadata_properties: + generate_property(prop, append) + + append("
") + append() if resource.spec_properties: append("
") @@ -260,6 +270,13 @@ class Resource(ModelObject): def __init__(self, model, group, data): super().__init__(model, group, data) + self.metadata_properties = list() + + for property_data in self.model.data.get("standard_metadata_properties", []): + prop = Property(self.model, self, property_data, "metadata") + + self.metadata_properties.append(prop) + self.spec_properties = list() self.spec_properties_by_name = dict() @@ -306,6 +323,10 @@ def __init__(self, model, resource, data, group): @property def required(self): + # XXX + if self.group == "metadata": + return True + schema = self.model.get_schema(self.object) required_names = schema["properties"][self.group].get("required", []) default = self.name in required_names