Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ssorj committed Jun 12, 2024
1 parent 3d01b37 commit 5188443
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 3 deletions.
17 changes: 14 additions & 3 deletions config/resources.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -26,9 +40,6 @@ groups:
namespace: hello-world-west
spec:
linkAccess: default
metadata_properties:
- name: name
required: true
spec_properties:
- name: linkAccess
default: none
Expand Down
25 changes: 25 additions & 0 deletions input/resources/connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,31 @@ spec:
selector: app=backend
~~~

</section>

<section>

## Metadata properties

- <h3 id="name">name <span class="property-info">string, required</span></h3>

The name of the resource.

| | |
|-|-|
| Platforms | Kubernetes, Docker |


- <h3 id="namespace">namespace <span class="property-info">string, required</span></h3>

The namespace of the resource.

| | |
|-|-|
| Platforms | Kubernetes, Docker |
| See also | [Namespace concept]({{site_prefix}}/concepts/namespace.html), [Kubernetes namespaces]({{site_prefix}}) |


</section>

<section>
Expand Down
25 changes: 25 additions & 0 deletions input/resources/listener.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ spec:
host: backend
~~~

</section>

<section>

## Metadata properties

- <h3 id="name">name <span class="property-info">string, required</span></h3>

The name of the resource.

| | |
|-|-|
| Platforms | Kubernetes, Docker |


- <h3 id="namespace">namespace <span class="property-info">string, required</span></h3>

The namespace of the resource.

| | |
|-|-|
| Platforms | Kubernetes, Docker |
| See also | [Namespace concept]({{site_prefix}}/concepts/namespace.html), [Kubernetes namespaces]({{site_prefix}}) |


</section>

<section>
Expand Down
25 changes: 25 additions & 0 deletions input/resources/site.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,31 @@ spec:
linkAccess: default
~~~

</section>

<section>

## Metadata properties

- <h3 id="name">name <span class="property-info">string, required</span></h3>

The name of the resource.

| | |
|-|-|
| Platforms | Kubernetes, Docker |


- <h3 id="namespace">namespace <span class="property-info">string, required</span></h3>

The namespace of the resource.

| | |
|-|-|
| Platforms | Kubernetes, Docker |
| See also | [Namespace concept]({{site_prefix}}/concepts/namespace.html), [Kubernetes namespaces]({{site_prefix}}) |


</section>

<section>
Expand Down
21 changes: 21 additions & 0 deletions python/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ def append(line=""):

append("</section>")
append()
append("<section>")
append()
append("## Metadata properties")
append()

for prop in resource.metadata_properties:
generate_property(prop, append)

append("</section>")
append()

if resource.spec_properties:
append("<section>")
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5188443

Please sign in to comment.