Skip to content

Commit

Permalink
Merge branch 'main' into feature/contact-points
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemental authored Apr 18, 2024
2 parents e830725 + b64db9d commit 31afbec
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 43 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/353-docs-add-influxdb-flux-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- grafana_datasource - (docs) add influxdb v2 flux example
3 changes: 3 additions & 0 deletions changelogs/fragments/354-fix-find-grafana-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- fix find grafana versions python script comparation
3 changes: 3 additions & 0 deletions changelogs/fragments/355-rm-dashboard-message-argument.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
removed_features:
- removed deprecated `message` argument in `grafana_dashboard`
6 changes: 3 additions & 3 deletions hacking/check_fragment.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash

function fail() {
cat << EOF
cat <<EOF
Dear contributor,
Thank you for you Pull Request !
Expand All @@ -10,7 +10,7 @@ function fail() {
It will help your change be released faster !
Thank you !
EOF
exit 1
exit 1
}

FRAGMENTS=$(git fetch && git diff --name-only --diff-filter=ACMRT origin/main..HEAD | grep "changelogs")
Expand Down
31 changes: 16 additions & 15 deletions hacking/find_grafana_versions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

import json
import requests
Expand All @@ -7,32 +7,33 @@
def get_by_major(version):
if version.startswith("v"):
version = version[1:]
return (version[0], version, int(version.replace(".", "")))
return int(version.split(".")[0]), version, tuple(map(int, version.split(".")))


def get_grafana_releases():
r = requests.get(
"https://api.github.com/repos/grafana/grafana/releases?per_page=50",
"https://api.github.com/repos/grafana/grafana/releases?per_page=100",
headers={"Accept": "application/vnd.github.v3+json"},
)
if r.status_code != 200:
raise Exception("Failed to get releases from GitHub")
return r.json()


by_major = {}

if __name__ == "__main__":
releases = get_grafana_releases()
for item in releases:
if item.get("prerelease"):
by_major = {}

for release in releases:
if release.get("prerelease") or any(
char in release.get("tag_name") for char in "-+"
):
continue
major, version, as_int = get_by_major(item.get("tag_name"))
if major not in by_major.keys() or by_major[major]["as_int"] < as_int:
by_major[major] = {"version": version, "as_int": as_int}
latest_3_majors = sorted(list(by_major.keys()), reverse=True)[:3]

latest_releases = []
for idx in latest_3_majors:
latest_releases.append(by_major[idx]["version"])
major, version, as_tuple = get_by_major(release.get("tag_name"))
if major not in by_major.keys() or by_major[major]["as_tuple"] < as_tuple:
by_major[major] = {"version": version, "as_tuple": as_tuple}

latest_3_majors = sorted(list(by_major.keys()))[:3]
latest_releases = [by_major[idx]["version"] for idx in latest_3_majors]

print(json.dumps(latest_releases))
17 changes: 1 addition & 16 deletions plugins/modules/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@
description:
- Set a commit message for the version history.
- Only used when C(state) is C(present).
- C(message) alias is deprecated in Ansible 2.10, since it is used internally by Ansible Core Engine.
aliases: [ 'message' ]
type: str
extends_documentation_fragment:
- community.grafana.basic_auth
Expand Down Expand Up @@ -620,15 +618,7 @@ def main():
dashboard_id=dict(type="str"),
dashboard_revision=dict(type="str", default="1"),
overwrite=dict(type="bool", default=False),
commit_message=dict(
type="str",
aliases=["message"],
deprecated_aliases=[
dict(
name="message", version="2.0.0", collection_name="community.grafana"
)
],
),
commit_message=dict(type="str"),
)
module = AnsibleModule(
argument_spec=argument_spec,
Expand All @@ -647,11 +637,6 @@ def main():

module.params["url"] = clean_url(module.params["url"])

if "message" in module.params:
module.fail_json(
msg="'message' is reserved keyword, please change this parameter to 'commit_message'"
)

try:
if module.params["state"] == "present":
result = grafana_create_dashboard(module, module.params)
Expand Down
17 changes: 17 additions & 0 deletions plugins/modules/grafana_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,23 @@
time_interval: ">10s"
tls_ca_cert: "/etc/ssl/certs/ca.pem"
- name: Create influxdbv2 datasource using fluxql
community.grafana.grafana_datasource:
name: "datasource-influxdb-flux"
grafana_url: "https://grafana.company.com"
grafana_user: "admin"
grafana_password: "xxxxxx"
org_id: "1"
ds_type: "influxdb"
ds_url: "https://influx.company.com:8086"
additional_json_data:
version: "Flux"
organization: "organization"
defaultBucket: "bucket"
tlsSkipVerify: false
additional_secure_json_data:
token: "token"
- name: Create postgres datasource
community.grafana.grafana_datasource:
name: "datasource-postgres"
Expand Down
4 changes: 0 additions & 4 deletions tests/sanity/ignore-2.15.txt

This file was deleted.

4 changes: 0 additions & 4 deletions tests/sanity/ignore-2.16.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def run_command_ls():
def run_command_install_zip():
STDERR = ""
STDOUT = """
installing alexanderzobnin-grafana-zabbix @
installing alexanderzobnin-grafana-zabbix @
from: /home/grafana//alexanderzobnin-grafana-zabbix-v3.10.5-1-g2219691.zip
into: /var/lib/grafana/plugins
Expand Down

0 comments on commit 31afbec

Please sign in to comment.