-
Notifications
You must be signed in to change notification settings - Fork 48
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
base: main
Are you sure you want to change the base?
feat: add kubernetes_manifest interface #134
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Examples: | ||
RequirerSchema: | ||
unit: <empty> | ||
kubernetes_manifests: [ |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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!
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] |
There was a problem hiding this comment.
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
manifest_content: the content of the Kubernetes manifest file | ||
""" | ||
|
||
manifest_content: str |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, @PietroPasotti beat me to it :D
This adds the
kubernetes_manifest
interface, as used by the Resource Dispatcher charm.