diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fc51337..d0ad1de 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -14,6 +14,12 @@ updates: - "andyone" reviewers: - "andyone" + groups: + all: + applies-to: version-updates + update-types: + - "minor" + - "patch" - package-ecosystem: "github-actions" directory: "/" diff --git a/.github/images/card.svg b/.github/images/card.svg new file mode 100644 index 0000000..6e915ec --- /dev/null +++ b/.github/images/card.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.github/images/license.svg b/.github/images/license.svg new file mode 100644 index 0000000..8990e77 --- /dev/null +++ b/.github/images/license.svg @@ -0,0 +1 @@ +license: Apache-2.0licenseApache-2.0 \ No newline at end of file diff --git a/Makefile b/Makefile index 78cf302..0e1b51a 100644 --- a/Makefile +++ b/Makefile @@ -1,39 +1,40 @@ ################################################################################ -# This Makefile generated by GoMakeGen 2.3.0 using next command: +# This Makefile generated by GoMakeGen 3.0.2 using next command: # gomakegen --mod . # # More info: https://kaos.sh/gomakegen ################################################################################ -export GO111MODULE=on - ifdef VERBOSE ## Print verbose information (Flag) VERBOSE_FLAG = -v endif -COMPAT ?= 1.18 +COMPAT ?= 1.19 MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD) ################################################################################ .DEFAULT_GOAL := help -.PHONY = fmt vet all clean deps update init vendor mod-init mod-update mod-download mod-vendor help +.PHONY = fmt vet all install uninstall clean deps update init vendor mod-init mod-update mod-download mod-vendor help ################################################################################ all: updown-badge-server ## Build all binaries updown-badge-server: - go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" updown-badge-server.go + @echo "Building updown-badge-server…" + @go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" updown-badge-server.go install: ## Install all binaries - cp updown-badge-server /usr/bin/updown-badge-server + @echo "Installing binaries…" + @cp updown-badge-server /usr/bin/updown-badge-server uninstall: ## Uninstall all binaries - rm -f /usr/bin/updown-badge-server + @echo "Removing installed binaries…" + @rm -f /usr/bin/updown-badge-server init: mod-init ## Initialize new module @@ -44,57 +45,70 @@ update: mod-update ## Update dependencies to the latest versions vendor: mod-vendor ## Make vendored copy of dependencies mod-init: + @echo "[1/2] Modules initialization…" ifdef MODULE_PATH ## Module path for initialization (String) - go mod init $(MODULE_PATH) + @go mod init $(MODULE_PATH) else - go mod init + @go mod init endif + @echo "[2/2] Dependencies cleanup…" ifdef COMPAT ## Compatible Go version (String) - go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT) + @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT) else - go mod tidy $(VERBOSE_FLAG) + @go mod tidy $(VERBOSE_FLAG) endif mod-update: + @echo "[1/4] Updating dependencies…" ifdef UPDATE_ALL ## Update all dependencies (Flag) - go get -u $(VERBOSE_FLAG) all + @go get -u $(VERBOSE_FLAG) all else - go get -u $(VERBOSE_FLAG) ./... + @go get -u $(VERBOSE_FLAG) ./... endif + @echo "[2/4] Stripping toolchain info…" + @grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || : + + @echo "[3/4] Dependencies cleanup…" ifdef COMPAT - go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) + @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) else - go mod tidy $(VERBOSE_FLAG) + @go mod tidy $(VERBOSE_FLAG) endif - test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : + @echo "[4/4] Updating vendored dependencies…" + @test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : mod-download: - go mod download + @echo "Downloading dependencies…" + @go mod download mod-vendor: - rm -rf vendor && go mod vendor $(VERBOSE_FLAG) + @echo "Vendoring dependencies…" + @rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : fmt: ## Format source code with gofmt - find . -name "*.go" -exec gofmt -s -w {} \; + @echo "Formatting sources…" + @find . -name "*.go" -exec gofmt -s -w {} \; vet: ## Runs 'go vet' over sources - go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./... + @echo "Running 'go vet' over sources…" + @go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./... clean: ## Remove generated files - rm -f updown-badge-server + @echo "Removing built binaries…" + @rm -f updown-badge-server help: ## Show this info @echo -e '\n\033[1mTargets:\033[0m\n' @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ - | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-21s\033[0m %s\n", $$1, $$2}' + | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-9s\033[0m %s\n", $$1, $$2}' @echo -e '\n\033[1mVariables:\033[0m\n' @grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \ | sed 's/ifdef //' \ - | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}' + | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-11s\033[0m %s\n", $$1, $$2}' @echo -e '' - @echo -e '\033[90mGenerated by GoMakeGen 2.3.0\033[0m\n' + @echo -e '\033[90mGenerated by GoMakeGen 3.0.2\033[0m\n' ################################################################################ diff --git a/README.md b/README.md index b958937..0fc2cff 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -

+

GitHub Actions CI Status Codebeat badge GitHub Actions CodeQL Status - +

Installation • Badges • Build Status • Contributing • License

diff --git a/common/updown-badge-server.knf b/common/updown-badge-server.knf index 369fe82..2cc86da 100644 --- a/common/updown-badge-server.knf +++ b/common/updown-badge-server.knf @@ -42,8 +42,8 @@ # Path to log file file: {log:dir}/updown-badge-server.log - # Log permissions - perms: 600 + # Log file mode + mode: 0600 # Default log level (debug/info/warn/error/crit) level: info diff --git a/common/updown-badge-server.service b/common/updown-badge-server.service index e7abe8a..3e1d51f 100644 --- a/common/updown-badge-server.service +++ b/common/updown-badge-server.service @@ -5,11 +5,14 @@ Requires=network.target remote-fs.target After=network.target remote-fs.target [Service] -User=updownbs -ExecStart=/usr/bin/updown-badge-server -ExecReload=kill -HUP $MAINPID -StandardError=syslog -SyslogIdentifier=updown-badge-server +Type=simple +User=updown +EnvironmentFile=/etc/sysconfig/updown-badge-server +ExecStart=/usr/bin/updown-badge-server -c /etc/updown-badge-server.knf +ExecReload=/bin/kill -s HUP $MAINPID +ExecStop=/bin/kill -s TERM $MAINPID +StandardError=file:/var/log/updown-badge-server/startup.log +PrivateTmp=true [Install] WantedBy=multi-user.target diff --git a/common/updown-badge-server.spec b/common/updown-badge-server.spec index ad4f9b0..c18d30f 100644 --- a/common/updown-badge-server.spec +++ b/common/updown-badge-server.spec @@ -14,7 +14,7 @@ Summary: Service for generating badges for updown.io checks Name: updown-badge-server -Version: 1.3.1 +Version: 1.3.2 Release: 0%{?dist} Group: Applications/System License: Apache License, Version 2.0 @@ -43,13 +43,15 @@ Service for generating badges for updown.io checks. %{crc_check} %setup -q - -%build if [[ ! -d "%{name}/vendor" ]] ; then - echo "This package requires vendored dependencies" + echo -e "----\nThis package requires vendored dependencies\n----" + exit 1 +elif [[ -f "%{name}/%{name}" ]] ; then + echo -e "----\nSources must not contain precompiled binaries\n----" exit 1 fi +%build pushd %{name} go build %{name}.go cp LICENSE .. @@ -98,6 +100,10 @@ exit 0 ################################################################################ %changelog +* Mon Jun 24 2024 Anton Novojilov - 1.3.2-0 +- Code refactoring +- Dependencies update + * Sat Mar 30 2024 Anton Novojilov - 1.3.1-0 - Improved support information gathering - Code refactoring diff --git a/daemon/daemon.go b/daemon/daemon.go index 4478424..90b3c4c 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -21,6 +21,7 @@ import ( "github.com/essentialkaos/ek/v12/signal" "github.com/essentialkaos/ek/v12/support" "github.com/essentialkaos/ek/v12/support/deps" + "github.com/essentialkaos/ek/v12/terminal" "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/usage" @@ -41,7 +42,7 @@ import ( // Basic service info const ( APP = "UpDownBadgeServer" - VER = "1.3.1" + VER = "1.3.2" DESC = "Service for generating badges for updown.io checks" ) @@ -78,7 +79,7 @@ const ( SERVER_REDIRECT = "server:redirect" LOG_DIR = "log:dir" LOG_FILE = "log:file" - LOG_PERMS = "log:perms" + LOG_MODE = "log:mode" LOG_LEVEL = "log:level" ) @@ -109,11 +110,9 @@ func Run(gomod []byte) { _, errs := options.Parse(optMap) - if len(errs) != 0 { - for _, err := range errs { - log.Crit(err.Error()) - } - + if !errs.IsEmpty() { + terminal.Error("Options parsing errors:") + terminal.Error(errs.String()) os.Exit(1) } @@ -236,7 +235,7 @@ func registerSignalHandlers() { // setupLogger configures logger subsystems func setupLogger() { - err := log.Set(knf.GetS(LOG_FILE), knf.GetM(LOG_PERMS, 0644)) + err := log.Set(knf.GetS(LOG_FILE), knf.GetM(LOG_MODE, 0644)) if err != nil { log.Crit(err.Error()) diff --git a/go.mod b/go.mod index 7090ba1..0930249 100644 --- a/go.mod +++ b/go.mod @@ -3,17 +3,17 @@ module github.com/essentialkaos/updown-badge-server go 1.18 require ( - github.com/essentialkaos/ek/v12 v12.113.1 - github.com/essentialkaos/go-badge v1.3.3 - github.com/valyala/fasthttp v1.52.0 + github.com/essentialkaos/ek/v12 v12.127.0 + github.com/essentialkaos/go-badge v1.3.4 + github.com/valyala/fasthttp v1.55.0 ) require ( github.com/andybalholm/brotli v1.1.0 // indirect - github.com/essentialkaos/depsy v1.1.0 // indirect + github.com/essentialkaos/depsy v1.3.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/klauspost/compress v1.17.7 // indirect + github.com/klauspost/compress v1.17.9 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - golang.org/x/image v0.15.0 // indirect - golang.org/x/sys v0.18.0 // indirect + golang.org/x/image v0.17.0 // indirect + golang.org/x/sys v0.21.0 // indirect ) diff --git a/go.sum b/go.sum index 4531e0e..7dc68ab 100644 --- a/go.sum +++ b/go.sum @@ -1,24 +1,24 @@ github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= -github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI= -github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= -github.com/essentialkaos/ek/v12 v12.113.1 h1:3opV9dwRpIQq1fqg5mkaSEt6ogECL4VLzrH/829qeYg= -github.com/essentialkaos/ek/v12 v12.113.1/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= -github.com/essentialkaos/go-badge v1.3.3 h1:mp2UyD8FpAUiYunHJ/lRfbNTSJNgMqb1+gRV0dDHZZk= -github.com/essentialkaos/go-badge v1.3.3/go.mod h1:3BFjchqLk51N66eG5zrOugKKFS00nh2H2tnKm2Hyw9o= +github.com/essentialkaos/depsy v1.3.0 h1:CN7bRgBU2jGTHSkg/Sh38eDUn7cvmaTp2sxFt2HpFeU= +github.com/essentialkaos/depsy v1.3.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= +github.com/essentialkaos/ek/v12 v12.127.0 h1:fU5A+QbIZ7NTq1K5jGVwAWwuLtBUhsIKuRWYT78hE+Q= +github.com/essentialkaos/ek/v12 v12.127.0/go.mod h1:71IJ7m82hgjrvWnhL+z0vIhguxz47/rfVma5/CeI5Fw= +github.com/essentialkaos/go-badge v1.3.4 h1:nQPlfc0F7YbcpnZa+gaiAQy5VMGiojfQeJb+D34gLKI= +github.com/essentialkaos/go-badge v1.3.4/go.mod h1:AAHR0QTa5yMNAY/dNA4e6jJbPBZvpD2qowyiFz1Gb04= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.52.0 h1:wqBQpxH71XW0e2g+Og4dzQM8pk34aFYlA1Ga8db7gU0= -github.com/valyala/fasthttp v1.52.0/go.mod h1:hf5C4QnVMkNXMspnsUlfM3WitlgYflyhHYoKol/szxQ= -golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8= -golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +github.com/valyala/fasthttp v1.55.0 h1:Zkefzgt6a7+bVKHnu/YaYSOPfNYNisSVBo/unVCf8k8= +github.com/valyala/fasthttp v1.55.0/go.mod h1:NkY9JtkrpPKmgwV3HTaS2HWaJss9RSIsRVfcxxoHiOM= +golang.org/x/image v0.17.0 h1:nTRVVdajgB8zCMZVsViyzhnMKPwYeroEERRC64JuLco= +golang.org/x/image v0.17.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=