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

feat: add kubernetes_manifest interface #134

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

NohaIhab
Copy link

This adds the kubernetes_manifest interface, as used by the Resource Dispatcher charm.

Copy link

@DnPlas DnPlas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @NohaIhab. Could we get approval from @simskij as well?

Examples:
RequirerSchema:
unit: <empty>
kubernetes_manifests: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this kuberntes_manifest, or app? I think this level is talking about whether we're writing in unit or app space.

And then the next level down would be any named attribute inside data (so I think manifest_content)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we changing this file intentionally? This looks like something that got formatted accidentally

manifest_content: the content of the Kubernetes manifest file
"""

manifest_content: str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, you can put the field description in... the field description!

Suggested change
manifest_content: str
manifest_content: str = pydantic.Field(..., description="The content of the kubernetes manifest file.")

as it's technically not an arg.

class RequirerSchema(DataBagSchema):
"""The schema for the requirer side of kubernetes_manifest interface."""

kubernetes_manifests: List[KubernetesManifest]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're supposed to have an 'unit' and/or an 'app' in here:
https://github.com/canonical/charm-relation-interfaces/blob/main/interfaces/ingress/v2/schema.py#L58

it needs to read:

class MyAppDatabag(BaseModel):
    kubernetes_manifests: List[KubernetesManifest]

class RequirerSchema(DataBagSchema):
    app: MyAppDatabag

the requirer schema represents "the requirer's side", which includes app and unit databags with their own schemas.

it's easier to think about it if you map it to show-relation's output
image

manifest_content: the content of the Kubernetes manifest file
"""

manifest_content: str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I look at the example above in the docstring, this is not a string but a dictionary containing all sorts of data.

@@ -53,4 +46,4 @@ class KubernetesManifest(BaseModel):
class RequirerSchema(DataBagSchema):
"""The schema for the requirer side of kubernetes_manifest interface."""

app: List[KubernetesManifest]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're still missing something here. Before, we had data of:

data = {
  'unit': {},  # <-- this comes from the [DataBagSchema](https://github.com/canonical/pytest-interface-tester/blob/50cd08647af9a8e1f904ed922a754460cd2027ce/interface_tester/schema_base.py#L10)
  'app': [manifest1, manifest2, ...]  # <-- this comes from your schema.py
}

Now, we have

data = {
  'unit': {},  # <-- this comes from the [DataBagSchema](https://github.com/canonical/pytest-interface-tester/blob/50cd08647af9a8e1f904ed922a754460cd2027ce/interface_tester/schema_base.py#L10)
  'app': {},  # <-- this comes from the [DataBagSchema](https://github.com/canonical/pytest-interface-tester/blob/50cd08647af9a8e1f904ed922a754460cd2027ce/interface_tester/schema_base.py#L10)
  'kubernetes_manifests: [manifest1, manifest2, ...]
}

This gets a little clearer imo if we paste the requirer.json into a json schema viewer (paste to the right hand side, then click "generate json from schema"). Note we get 3 attributes.

What I think we need here is one more class in the hierarchy. See the tracing example for what I mean (and you can paste their .json into the renderer to see the difference)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants