Make brew pass all audit tests.

This commit is contained in:
David Newhall II 2019-06-25 00:40:06 -07:00
parent c35266af2f
commit 077cab1cd2
2 changed files with 35 additions and 34 deletions

View File

@ -4,7 +4,7 @@
BINARY:=unifi-poller BINARY:=unifi-poller
URL:=https://github.com/davidnewhall/$(BINARY) URL:=https://github.com/davidnewhall/$(BINARY)
MAINT=David Newhall II <david at sleepers dot pro> MAINT=David Newhall II <david at sleepers dot pro>
DESC=This daemon polls a UniFi controller at a short interval and stores the collected measurements in an Influx Database. DESC=Polls a UniFi controller and stores metrics in InfluxDB
GOLANGCI_LINT_ARGS=--enable-all -D gochecknoglobals GOLANGCI_LINT_ARGS=--enable-all -D gochecknoglobals
DOCKER_REPO=golift DOCKER_REPO=golift
MD2ROFF_BIN=github.com/github/hub/md2roff-bin MD2ROFF_BIN=github.com/github/hub/md2roff-bin

View File

@ -1,13 +1,10 @@
# Homebrew Formula Template. Built by Makefile: `make fomula` # Homebrew Formula Template. Built by Makefile: `make fomula`
require "language/go"
class UnifiPoller < Formula class UnifiPoller < Formula
version "{{Version}}"
sha256 "{{SHA256}}"
url "{{URL}}/archive/v#{version}.tar.gz"
head "{{URL}}"
desc "{{Desc}}" desc "{{Desc}}"
homepage "{{URL}}" homepage "{{URL}}"
url "{{URL}}/archive/v{{Version}}.tar.gz"
sha256 "{{SHA256}}"
head "{{URL}}"
depends_on "go" => :build depends_on "go" => :build
depends_on "dep" depends_on "dep"
@ -20,16 +17,17 @@ class UnifiPoller < Formula
# to $GOPATH/src/github.com/davidnewhall/unifi-poller # to $GOPATH/src/github.com/davidnewhall/unifi-poller
bin_path.install Dir["*"] bin_path.install Dir["*"]
cd bin_path do cd bin_path do
system "dep", "ensure" system "dep", "ensure", "-vendor-only"
system "make", "install", "VERSION=#{version}", "PREFIX=#{prefix}", "ETC=#{etc}" system "make", "install", "VERSION=#{version}", "PREFIX=#{prefix}", "ETC=#{etc}"
# If this fails, the user gets a nice big warning about write permissions on their # If this fails, the user gets a nice big warning about write permissions on their
# #{var}/log folder. The alternative could be letting the app silently fail # #{var}/log folder. The alternative could be letting the app silently fail
# to start when it cannot write logs. This is better. Fix perms; reinstall. # to start when it cannot write logs. This is better. Fix perms; reinstall.
system "touch", "#{var}/log/unifi-poller.log" touch("#{var}/log/unifi-poller.log")
end end
end end
def caveats def caveats
s = <<-EOS <<-EOS
This application will not work until the config file has authentication This application will not work until the config file has authentication
information for a UniFi Controller and an Influx Database. Edit the config information for a UniFi Controller and an Influx Database. Edit the config
file at #{etc}/unifi-poller/up.conf then start the application with file at #{etc}/unifi-poller/up.conf then start the application with
@ -38,30 +36,33 @@ class UnifiPoller < Formula
EOS EOS
end end
def plist; <<-EOS plist_options :startup => true
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> def plist
<plist version="1.0"> <<-EOS
<dict> <?xml version="1.0" encoding="UTF-8"?>
<key>Label</key> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<string>#{plist_name}</string> <plist version="1.0">
<key>ProgramArguments</key> <dict>
<array> <key>Label</key>
<string>#{bin}/unifi-poller</string> <string>#{plist_name}</string>
<string>-c</string> <key>ProgramArguments</key>
<string>#{etc}/unifi-poller/up.conf</string> <array>
</array> <string>#{bin}/unifi-poller</string>
<key>RunAtLoad</key> <string>-c</string>
<true/> <string>#{etc}/unifi-poller/up.conf</string>
<key>KeepAlive</key> </array>
<true/> <key>RunAtLoad</key>
<key>StandardErrorPath</key> <true/>
<string>#{var}/log/unifi-poller.log</string> <key>KeepAlive</key>
<key>StandardOutPath</key> <true/>
<string>#{var}/log/unifi-poller.log</string> <key>StandardErrorPath</key>
</dict> <string>#{var}/log/unifi-poller.log</string>
</plist> <key>StandardOutPath</key>
EOS <string>#{var}/log/unifi-poller.log</string>
</dict>
</plist>
EOS
end end
test do test do