diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..bb0e7f6 --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,81 @@ +- secret: + name: grafyaml-dockerhub + data: + username: opendevzuul + password: !encrypted/pkcs1-oaep + - bbW9hdHj1GzhXJky9VkO/FKqiwWJDvaJGn+z/rB/i4ssGu8keRiFCEXHBzzioDe9OWlux + aFNz1T3x7cUlWMEQ0ZDvD7GeQ9dRSo3lWctoS0P4iMClmZKjMDI+TSuLdVg2GlH6CtMiH + b0Flw5j4BsP2VtbN71KOs+J8ybLVYivdAJmDGVST4gBBI1vL5RHIMr98BEx7oGqcB+h/1 + FtRIWqCjWr+Jvj6C+rdGKiocb77sJyFfZ1X7H97o5TETQeYs118kBP0iWv5FksoflUQU0 + cckE6u0oDrPx/4ea3pqKPLD9/B8/vAX+WUd1y2jUnmUmZvnEeTxekjXFUTrCVLqZc1FTC + ZbbL/CQc/25QOI7sEeUigcYkPINhs6OsEe36gE2fKIjWEdVdunNOMxeQ/RS86OttzGlcP + x+ADrUTQjkuEnxZo2WTYL4kHuzPr3//DsPjLJBq8hoKXlT3fpdH5pHaiVBC3oIVCWfzSa + 1LfX7XL0eFIwEc99gAfbfhljE9P77ZWX2zD9reyNNH4VCI9u92RKF5+VZ5ResOdOA0z0r + sMYue1hqHYLLQq9O42t3PBfVMrS1V+GcJ8oWn+9sOll16kQw+wVpLmba/0Btdq0MSdWxc + itrO3WwA2kqDd6qtHYAd0c9BEx8HDt66Rl56AN30LBtPRTdhNc93QDDJlPvqZE= + +- job: + name: grafyaml-build-image + parent: opendev-build-docker-image + description: Build a Docker image of grafyaml + allowed-projects: opendev/grafyaml + timeout: 2700 + requires: + - python-builder-3.8-container-image + - python-base-3.8-container-image + provides: + - grafyaml-container-image + vars: &grafyaml_image_vars + docker_images: + - context: . + repository: opendevorg/grafyaml + tags: + &imagetag "{{ zuul.tag is defined | ternary([zuul.get('tag', '').split('.')[0], '.'.join(zuul.get('tag', '').split('.')[:2]), zuul.get('tag', '')], ['latest']) }}" + +- job: + name: grafyaml-upload-image + parent: opendev-upload-docker-image + description: Build the grafyaml Docker image and upload to Docker Hub. + timeout: 3600 + requires: + - python-builder-3.8-container-image + - python-base-3.8-container-image + provides: grafyaml-container-image + vars: *grafyaml_image_vars + secrets: + - name: docker_credentials + secret: grafyaml-dockerhub + pass-to-parent: true + +- job: + name: grafyaml-promote-image + parent: opendev-promote-docker-image + description: Promote previously uploaded Docker image. + vars: *grafyaml_image_vars + secrets: + - name: docker_credentials + secret: grafyaml-dockerhub + pass-to-parent: true + +- project: + vars: + release_python: python3 + check: + jobs: + - grafyaml-build-image + gate: + jobs: + - grafyaml-upload-image + promote: + jobs: + - grafyaml-promote-image + release: + jobs: + - upload-docker-image: + secrets: + name: docker_credentials + secret: grafyaml-dockerhub + pass-to-parent: true + vars: + <<: *grafyaml_image_vars + upload_docker_image_promote: false diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a239522 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# Copyright (c) 2020 Red Hat, Inc. +# Copyright (c) 2021 Acme Gating, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM docker.io/opendevorg/python-builder:3.8 as builder + +COPY . /tmp/src +RUN assemble + +FROM docker.io/opendevorg/python-base:3.8 + +COPY --from=builder /output/ /output +RUN /output/install-from-bindep + +# To use this image, you must supply GRAFANA_URL as an env var, and +# may optionally supply GRAFANA_APIKEY. +# Mount the dashboards at /grafana. + +ENTRYPOINT /usr/local/bin/grafana-dashboard --debug --grafana-url="${GRAFANA_URL}" ${GRAFANA_APIKEY:+--grafana-apikey "$GRAFANA_APIKEY"} update /grafana diff --git a/grafana_dashboards/schema/template/query.py b/grafana_dashboards/schema/template/query.py index 406fb3d..df458ec 100644 --- a/grafana_dashboards/schema/template/query.py +++ b/grafana_dashboards/schema/template/query.py @@ -28,8 +28,8 @@ class Query(Base): v.Required('includeAll', default=False): v.All(bool), v.Required('multi', default=False): v.All(bool), v.Required('query', default=''): v.All(str), - v.Required('refresh', default=1): \ - v.All(int, v.Range(min=0, max=2)), + v.Required('refresh', + default=1): v.All(int, v.Range(min=0, max=2)), v.Optional('datasource'): v.All(str), v.Optional('hide'): v.All(int, v.Range(min=0, max=2)), }