From 902d4cb310f78abaf611d9e280c3304956b7723e Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Thu, 26 Sep 2024 15:44:21 +0200 Subject: [PATCH] Release 0.1.0 - add packaging via goreleaser - finaliza changelog for 0.1.0 - add debian changelog and copyright - add configuration for golangci-lint --- .gitignore | 5 +- .golangci.yml | 68 +++++++++++++++++++++++++ .goreleaser.yaml | 128 +++++++++++++++++++++++++++++++++++++++++++++++ cfg/command.cfg | 8 +-- debian/changelog | 5 ++ debian/copyright | 26 ++++++++++ 6 files changed, 232 insertions(+), 8 deletions(-) create mode 100644 .golangci.yml create mode 100644 .goreleaser.yaml create mode 100644 debian/changelog create mode 100644 debian/copyright diff --git a/.gitignore b/.gitignore index 749f198..e3109c4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.rej .*.swp /.idea/ +/debian/changelog.Debian.gz +/dist/ /matrix-host-notification -/matrix-service-notification -dist/ +/matrix-service-notification \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..6aeb42a --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,68 @@ +--- +run: + go: "1.23" + +output: + sort-results: true + +linters-settings: + goheader: + values: + const: + AUTHOR: Jan Dittberner + template: |- + Copyright {{ AUTHOR }} + SPDX-License-Identifier: GPL-3.0-or-later + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + goimports: + local-prefixes: git.dittberner.info/git/icinga2-matrix-notification + misspell: + locale: "US" + ignore-words: + - Icinga2 + +linters: + disable-all: false + enable: + - bodyclose + - containedctx + - contextcheck + - cyclop + - decorder + - errorlint + - exportloopref + - forbidigo + - forcetypeassert + - gocognit + - goconst + - gocritic + - gofmt + - goheader + - goimports + - mnd + - gosec + - lll + - makezero + - misspell + - nakedret + - nestif + - nlreturn + - nolintlint + - predeclared + - revive + - rowserrcheck + - sqlclosecheck + - wrapcheck + - wsl diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..b1f494a --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,128 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + - sh -c "gzip --best -n -c debian/changelog > debian/changelog.Debian.gz" + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + goarch: + - amd64 + - arm64 + id: matrix-host-notification + binary: matrix-host-notification + main: ./cmd/matrix-host-notification/main.go + - env: + - CGO_ENABLED=0 + goos: + - linux + goarch: + - amd64 + - arm64 + id: matrix-service-notification + binary: matrix-service-notification + main: ./cmd/matrix-service-notification/main.go + +archives: + - format: tar.gz + allow_different_binary_count: true + wrap_in_directory: true + # this name template makes the OS and Arch compatible with the results of `uname`. + builds: + - matrix-host-notification + - matrix-service-notification + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + files: + - cfg/* + - COPYING + - README.md + +checksum: + name_template: "checksums.txt" + +changelog: + sort: asc + +snapshot: + version_template: "{{ incpatch .Version }}-next" + +nfpms: + - package_name: icinga2-matrix-notification + builds: + - matrix-host-notification + - matrix-service-notification + file_name_template: "{{ .ProjectName }}_{{ .Version }}-1_{{ .Arch }}" + vendor: Jan Dittberner + maintainer: Jan Dittberner + description: |- + Icinga2 notification commands to send notifications to Matrix chat rooms + The icinga2-matrix-notification package contains notification commands to send + Icinga2 host and service status notifications to Matrix chat rooms. + . + The package contains configuration examples that need to be copied and adapted + for your Icinga 2 installation. + formats: + - deb + bindir: /usr/lib/nagios/plugins + section: utils + release: "1" + priority: optional + deb: + lintian_overrides: + - statically-linked-binary + - initial-upload-closes-no-bugs + recommends: + - icinga2 + contents: + - src: debian/changelog.Debian.gz + dst: /usr/share/doc/{{ .ProjectName }}/changelog.Debian.gz + file_info: + mode: 0644 + - src: debian/copyright + dst: /usr/share/doc/{{ .ProjectName }}/copyright + file_info: + mode: 0644 + - src: README.md + dst: /usr/share/doc/{{ .ProjectName }}/README.md + file_info: + mode: 0644 + - src: cfg/command.cfg + dst: /usr/share/doc/{{ .ProjectName }}/examples/cfg/command.cfg + file_info: + mode: 0644 + - src: cfg/services.cfg + dst: /usr/share/doc/{{ .ProjectName }}/examples/cfg/services.cfg + file_info: + mode: 0644 + - src: cfg/templates.cfg + dst: /usr/share/doc/{{ .ProjectName }}/examples/cfg/templates.cfg + file_info: + mode: 0644 + +release: + gitea: + owner: jan + name: "icinga2-matrix-notification" + +gitea_urls: + api: https://git.dittberner.info/api/v1 + download: https://git.dittberner.info \ No newline at end of file diff --git a/cfg/command.cfg b/cfg/command.cfg index 4ae895f..a251771 100644 --- a/cfg/command.cfg +++ b/cfg/command.cfg @@ -2,7 +2,7 @@ object NotificationCommand "matrix-host-notification" { import "plugin-notification-command" - command = [ SysconfDir + "/icinga2/scripts/matrix-host-notification" ] + command = [ PluginDir + "/matrix-host-notification" ] arguments += { "-4" = "$notification_address$" "-6" = "$notification_address6$" @@ -61,7 +61,7 @@ object NotificationCommand "matrix-host-notification" { object NotificationCommand "matrix-service-notification" { import "plugin-notification-command" - command = [ SysconfDir + "/icinga2/scripts/matrix-service-notification" ] + command = [ PluginDir + "/matrix-service-notification" ] arguments += { "-4" = { required = true @@ -99,10 +99,6 @@ object NotificationCommand "matrix-service-notification" { required = true value = "$notification_servicestate$" } - "-t" = { - required = true - value = "$notification_type$" - } "-u" = { required = true value = "$notification_servicedisplayname$" diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..7d622e5 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +icinga2-matrix-notification (0.1.0-1) unstable; urgency=medium + + * Initial release + + -- Jan Dittberner Thu, 26 Sep 2024 15:45:07 +0200 diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..26b1a1c --- /dev/null +++ b/debian/copyright @@ -0,0 +1,26 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Source: https://git.dittberner.info/jan/icinga2-matrix-notification +Upstream-Name: icinga2-matrix-notification +Upstream-Contact: Jan Dittberner + +Files: + * +Copyright: 2024 Jan Dittberner +License: GPL-3+ + +License: GPL-3+ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this package; if not, see <https://www.gnu.org/licenses/>. +Comment: + On Debian systems, the full text of the GNU General Public License + version 2 can be found in the file '/usr/share/common-licenses/GPL-2'. \ No newline at end of file