Skip to content

Commit

Permalink
add manpage, ui module as well as github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
equinox0815 committed Oct 11, 2023
1 parent f3b591b commit c3c9fc7
Show file tree
Hide file tree
Showing 12 changed files with 534 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Go package

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Test
run: make test
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
release:
types: [created]

jobs:
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: ["386", amd64, arm64]
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
project_path: "./cmd/whawty-alerts"
binary_name: "whawty-alerts"
pre_command: export CGO_ENABLED=0
extra_files: AUTHORS LICENSE README.md doc/man/whawty-alerts.8
md5sum: false
sha256sum: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Go Report Card](https://goreportcard.com/badge/github.com/whawty/alerts)](https://goreportcard.com/report/github.com/whawty/alerts)

whawty.alerts is a simple daemon that handles notifications for monitoring alerts from the Prometheus Alertmanager. For Notifications
whawty.alerts is a simple daemon that handles notifications for monitoring alerts from the Prometheus Alertmanager. Notifications
can be sent via eMail as well as SMS. Unless most other solutions whawty.alerts tries to be of use without access to the internet.
This means sending eMails and SMS is not done using the API of some cloud provider but rather using local resources such as GSM modems
connected via USB.
Expand Down
74 changes: 74 additions & 0 deletions doc/man/whawty-alerts.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
'\" t
.\" Title: whawty-alerts
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" Date: 10/12/2023
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
.TH "WHAWTY\-ALERTS" "8" "10/12/2023" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
whawty-alerts \- the simple alert manager
.SH "SYNOPSIS"
.sp
\fBwhawty\-alerts\fR \fI[global options]\fR \fB<command>\fR \fI[command options]\fR \fI[arguments \&... ]\fR
.SH "DESCRIPTION"
.sp
\fBwhawty\-alerts\fR is a simple daemon that handles notifications for monitoring alerts from the Prometheus Alertmanager\&. Notifications can be sent via eMail as well as SMS\&. Unless most other solutions whawty\&.alerts tries to be of use without access to the internet\&. This means sending eMails and SMS is not done using the API of some cloud provider but rather using local resources such as GSM modems connected via USB\&.
.SH "GLOBAL OPTIONS"
.sp
The following global options can be passed to \fBwhawty\-alerts\fR\&.
.PP
\fB\-h | \-\-help\fR
.RS 4
Show help text and exit\&.
.RE
.PP
\fB\-v | \-\-version\fR
.RS 4
Print version information and exit\&.
.RE
.SH "COMMANDS"
.sp
Any of the following commands supports \fB\-h | \-\-help\fR as an option\&. This will print extra help information for the command\&. All these commands use the auth store directory as specified by the global store configuration file\&.
.SS "run \fI[options]\fR"
.sp
\&...tbd\&...
.SS "runsa"
.sp
This is basically the same as \fBrun\fR but expects all sockets to be passed via systemd socket activation\&. \fBwhawty\-alerts\fR will run the web\-api on all TCP sockets\&. All other socket types are ignored\&.
.SH "SIGNALS"
.sp
On HUP \fBwhawty\-alerts\fR tries to reload the configuration\&. I also runs a basic consistency check\&. If there is any error during that process the old configuration will be kept\&.
.SH "BUGS"
.sp
Most likely there are some bugs in \fBwhawty\-alerts\fR\&. If you find a bug, please let the developers know at http://github\&.com/whawty/alerts\&. Of course, pull requests are preferred\&.
.SH "SEE ALSO"
.sp
\fBpam\-whawty\fR(8)
.SH "AUTHORS"
.sp
Christian Pointner <equinox@spreadspace\&.org>
.SH "RESOURCES"
.sp
Main web site: http://github\&.com/whawty/alerts
89 changes: 89 additions & 0 deletions doc/man/whawty-alerts.8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
whawty-alerts(8)
================

NAME
----

whawty-alerts - the simple alert manager


SYNOPSIS
--------

*whawty-alerts* '[global options]' *<command>* '[command options]' '[arguments ... ]'


DESCRIPTION
-----------

*whawty-alerts* is a simple daemon that handles notifications for monitoring alerts from
the Prometheus Alertmanager. Notifications can be sent via eMail as well as SMS. Unless
most other solutions whawty.alerts tries to be of use without access to the internet.
This means sending eMails and SMS is not done using the API of some cloud provider but
rather using local resources such as GSM modems connected via USB.


GLOBAL OPTIONS
--------------

The following global options can be passed to *whawty-alerts*.

*-h | --help*::
Show help text and exit.

*-v | --version*::
Print version information and exit.


COMMANDS
--------

Any of the following commands supports *-h | --help* as an option. This will print
extra help information for the command. All these commands use the auth store directory
as specified by the global store configuration file.

run '[options]'
~~~~~~~~~~~~~~~

...tbd...

runsa
~~~~~

This is basically the same as *run* but expects all sockets to be passed via systemd
socket activation. *whawty-alerts* will run the web-api on all TCP sockets. All other
socket types are ignored.


SIGNALS
-------

On HUP *whawty-alerts* tries to reload the configuration. I also runs a basic
consistency check. If there is any error during that process the old configuration
will be kept.


BUGS
----

Most likely there are some bugs in *whawty-alerts*. If you find a bug, please let
the developers know at http://github.com/whawty/alerts. Of course, pull requests
are preferred.


SEE ALSO
--------

*pam-whawty*(8)


AUTHORS
-------

Christian Pointner <[email protected]>


RESOURCES
---------

Main web site: http://github.com/whawty/alerts
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ go 1.21.0
require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c // indirect
github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92 // indirect
github.com/urfave/cli v1.22.14 // indirect
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c h1:aqg5Vm5dwtvL+YgDpBcK1ITf3o96N/K7/wsRXQnUTEs=
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c/go.mod h1:owqhoLW1qZoYLZzLnBw+QkPP9WZnjlSWihhxAJC1+/M=
github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92 h1:OfRzdxCzDhp+rsKWXuOO2I/quKMJ/+TQwVbIP/gltZg=
github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92/go.mod h1:7/OT02F6S6I7v6WXb+IjhMuZEYfH/RJ5RwEWnEo5BMg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
Expand Down
40 changes: 40 additions & 0 deletions ui/assets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//go:build dev
// +build dev

//
// Copyright (c) 2023 whawty contributors (see AUTHORS file)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of whawty.alerts nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

package ui

import (
"net/http"
)

var Assets http.FileSystem = http.Dir("ui/assets")
14 changes: 14 additions & 0 deletions ui/assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>whawty alerts - admin interface</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="whawty alerts admin interface">
<meta name="author" content="Christian Pointner <[email protected]>">

</head>
<body>
<h1>Hello world</h1>
</body>
</html>
53 changes: 53 additions & 0 deletions ui/assets_generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//go:build ignore
// +build ignore

//
// Copyright (c) 2023 whawty contributors (see AUTHORS file)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of whawty.alerts nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

package main

import (
"log"
"net/http"

"github.com/shurcooL/vfsgen"
)

func main() {
assets := http.Dir("assets")
err := vfsgen.Generate(assets, vfsgen.Options{
PackageName: "ui",
BuildTags: "!dev",
VariableName: "Assets",
})
if err != nil {
log.Fatalln(err)
}
}
Loading

0 comments on commit c3c9fc7

Please sign in to comment.