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

add kubeflow-dashboard-sidebar interface #83

Merged
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ To contribute a new interface specification, open a pull request containing:
- `charms.yaml` file consisting of a list of any `providers` and `requirers` known to adhere to the specification.
- a `interface_tests` directory in which you can put python files containing interface tests. Read more about interface tests [here](./README_INTERFACE_TESTS.md)
- under `docs/`, the json schemas generated from the pydantic schemas. You can use command `tox -e build-json-schemas` to generate them automatically. Do not edit those files manually.
- in this repo's root `README.md`, add the interface to the table, if applicable.

To quickly get started, see the [template interface](https://github.com/canonical/charm-relation-interfaces/tree/main/interfaces/__template__/v0) for a template of what to include and how it should be structured.

Expand Down Expand Up @@ -47,6 +48,7 @@ To quickly get started, see the [template interface](https://github.com/canonica
| Category | Interface | Status |
|---------------|:-----------------------------------------------------------------------------|:-------------------------------------------------------------------:|
| Metadata | [`k8s-service`](interfaces/k8s-service/v0/README.md) | ![Status: Draft](https://img.shields.io/badge/Status-Draft-orange) |
| Metadata | [`kubeflow-dashboard-sidebar`](interfaces/kubeflow_dashboard_sidebar/v0/README.md) | ![Status: Live](https://img.shields.io/badge/Status-Live-darkgreen) |

### Identity

Expand Down
56 changes: 56 additions & 0 deletions docs/json_schemas/kubeflow_dashboard_sidebar/v0/requirer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"title": "RequirerSchema",
"description": "Requirer schema for Ingress.",
"type": "object",
"properties": {
"unit": {
"$ref": "#/definitions/BaseModel"
},
"app": {
"title": "App",
"type": "array",
"items": {
"$ref": "#/definitions/SidebarItem"
}
}
},
"required": [
"app"
],
"definitions": {
"BaseModel": {
"title": "BaseModel",
"type": "object",
"properties": {}
},
"SidebarItem": {
"title": "SidebarItem",
"description": "Representation of a Kubeflow Dashboard sidebar entry.\n\nSee https://www.kubeflow.org/docs/components/central-dash/customizing-menu/ for more details.\n\nArgs:\n text: The text shown in the sidebar\n link: The relative link within the host (eg: /runs, not http://.../runs)\n type: A type of sidebar entry (typically, \"item\")\n icon: An icon for the link, from\n https://kevingleason.me/Polymer-Todo/bower_components/iron-icons/demo/index.html",
"type": "object",
"properties": {
"text": {
"title": "Text",
"type": "string"
},
"link": {
"title": "Link",
"type": "string"
},
"type": {
"title": "Type",
"type": "string"
},
"icon": {
"title": "Icon",
"type": "string"
}
},
"required": [
"text",
"link",
"type",
"icon"
]
}
}
}
48 changes: 48 additions & 0 deletions interfaces/kubeflow_dashboard_sidebar/v0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# `kubeflow-dashboard-sidebar/v0`

## Usage

This relation interface describes the expected behavior of any charm claiming to be able to provide
or consume the `kubeflow-dashboard-sidebar`. `kubeflow-dashboard-sidebar` is an interface for defining links in the format of Kubeflow Dashboard's sidebar.

## Behavior

### Provider

- Is expected to create a sidebar link in the dashboard UI for each link entry sent by the `requirer` over the relation

### Requirer

- Is expected to send zero or more sidebar items to the `provider` in the below-defined format.

## Relation Data

### Requirer

[\[JSON Schema\]](./schemas/requirer.json)

The requirer specifies zero or more sidebar items in the required format.

#### Example

```json
[
{
"text": "Some link text",
"link": "/some-relative-link",
"type": "item",
"icon": "assessment"
},
{
"text": "Some other link text",
"link": "/some-other-relative-link",
"type": "item",
"icon": "book"
}

]
```

### Provider

The `provider` sends no data on this interface.
4 changes: 4 additions & 0 deletions interfaces/kubeflow_dashboard_sidebar/v0/charms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
providers:
- name: kubeflow-dashboard
url: https://github.com/canonical/kubeflow-dashboard-operator
requirers: []
46 changes: 46 additions & 0 deletions interfaces/kubeflow_dashboard_sidebar/v0/schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2023 Canonical
# See LICENSE file for licensing details.
"""This file defines the schemas for the provider and requirer sides of the kubeflow-dashboard-sidebar interface.

Examples:
RequirerSchema:
unit: <empty>
app: [
{
"text": "some link text",
"link": "/some-link",
"type": "item",
"icon": "book"
}
]
"""
from typing import List
import yaml
from pydantic import BaseModel, AnyHttpUrl, validator

from interface_tester.schema_base import DataBagSchema


class SidebarItem(BaseModel):
"""Representation of a Kubeflow Dashboard sidebar entry.

See https://www.kubeflow.org/docs/components/central-dash/customizing-menu/ for more details.

Args:
text: The text shown in the sidebar
link: The relative link within the host (eg: /runs, not http://.../runs)
type: A type of sidebar entry (typically, "item")
icon: An icon for the link, from
https://kevingleason.me/Polymer-Todo/bower_components/iron-icons/demo/index.html
"""

text: str
link: str
type: str # noqa: A003
icon: str


class RequirerSchema(DataBagSchema):
"""Requirer schema for Ingress."""

app: List[SidebarItem]