-
Notifications
You must be signed in to change notification settings - Fork 67
Add Grafana resources #1121
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 Grafana resources #1121
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from ocp_resources.resource import NamespacedResource | ||
|
|
||
|
|
||
| class Grafana(NamespacedResource): | ||
| """ | ||
| Grafana Resource. API Reference: | ||
| https://github.com/grafana-operator/grafana-operator/blob/master/documentation/api.md | ||
| """ | ||
|
|
||
| api_group = NamespacedResource.ApiGroup.INTEGREATLY_ORG | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| from ocp_resources.resource import NamespacedResource | ||
|
|
||
|
|
||
| class GrafanaDashboard(NamespacedResource): | ||
| """ | ||
| GrafanaDashboard Resource. API Reference: | ||
| https://github.com/grafana-operator/grafana-operator/blob/master/documentation/api.md | ||
| """ | ||
|
|
||
| api_group = NamespacedResource.ApiGroup.INTEGREATLY_ORG | ||
|
|
||
| def __init__( | ||
| self, | ||
| name=None, | ||
| namespace=None, | ||
| label=None, | ||
| configmap_name=None, | ||
| configmap_key=None, | ||
| data_sources=None, | ||
| yaml_file=None, | ||
| **kwargs | ||
| ): | ||
| """ | ||
|
|
||
| Args: | ||
| name (str): Resource name | ||
| namespace (str): Resource namespace | ||
| label (dict): Resource labels (Used by Grafana to identify GrafanaDashboards) | ||
| configmap_name (str): Name of ConfigMap containing dashboard JSON | ||
| configmap_key (str): Key in ConfigMap referencing dashboard JSON | ||
| data_sources (list): List of data sources | ||
| yaml_file (str): yaml file for the resource (in lieu of other arguments) | ||
|
|
||
| Example: | ||
| GrafanaDashboard( | ||
| name="dashboard", | ||
| namespace="grafana", | ||
| label={"app": "grafana"}, | ||
| configmap_name="my_dashboard_configmap", | ||
| configmap_key="dashboard_1", | ||
| data_sources=[{"inputName": "DS_PROMETHEUS", "datasourceName": "Prometheus"}] | ||
| ) | ||
|
|
||
| """ | ||
| super().__init__(name=name, namespace=namespace, yaml_file=yaml_file, **kwargs) | ||
| self.label = label | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of those required? Please add verification for required args under |
||
| self.configmap_name = configmap_name | ||
| self.configmap_key = configmap_key | ||
| self.data_sources = data_sources | ||
|
|
||
| def to_dict(self): | ||
| super().to_dict() | ||
| if not self.yaml_file: | ||
| self.res.update( | ||
| { | ||
| "metadata": { | ||
| "labels": self.label, | ||
| }, | ||
| "spec": { | ||
| "json": "", | ||
| "configMapRef": { | ||
| "name": self.configmap_name, | ||
| "key": self.configmap_key, | ||
| }, | ||
| "datasources": self.data_sources, | ||
| }, | ||
| } | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from ocp_resources.resource import NamespacedResource | ||
|
|
||
|
|
||
| class GrafanaDataSource(NamespacedResource): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty class without to_dict implement required is not allowed. |
||
| """ | ||
| GrafanaDataSource Resource. API Reference: | ||
| https://github.com/grafana-operator/grafana-operator/blob/master/documentation/api.md | ||
| """ | ||
|
|
||
| api_group = NamespacedResource.ApiGroup.INTEGREATLY_ORG | ||
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.
Empty class without to_dict implement required is not allowed.
Please introduce to_dict().