Skip to content

Commit

Permalink
Merge pull request #113 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 1.0.3
  • Loading branch information
andyone authored Jun 22, 2024
2 parents 657e939 + fa09af8 commit e1122d9
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 115 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ updates:
- "andyone"
reviewers:
- "andyone"
groups:
all:
applies-to: version-updates
update-types:
- "minor"
- "patch"

- package-ecosystem: "github-actions"
directory: "/"
Expand Down
5 changes: 5 additions & 0 deletions .github/images/card.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .github/images/godoc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .github/images/license.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 38 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,52 @@ on:
branches: [master, develop]
pull_request:
branches: [master]
workflow_dispatch:
inputs:
force_run:
description: 'Force workflow run'
required: true
type: choice
options: [yes, no]

permissions:
actions: read
contents: read
statuses: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Go:
name: Go
runs-on: ubuntu-latest

env:
SRC_DIR: src/github.com/${{ github.repository }}

strategy:
matrix:
go: [ '1.17.x', '1.18.x' ]
go: [ '1.21.x', '1.22.x' ]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Checkout
uses: actions/checkout@v3
with:
path: ${{env.SRC_DIR}}

- name: Download dependencies
working-directory: ${{env.SRC_DIR}}
run: make deps

- name: Run tests
working-directory: ${{env.SRC_DIR}}
run: go test -covermode=count -coverprofile=cover.out

- name: Send coverage data
uses: essentialkaos/goveralls-action@v1
uses: essentialkaos/goveralls-action@v2
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: ${{env.SRC_DIR}}
profile: cover.out
parallel: true
flag-name: linux-${{ matrix.go }}
Expand All @@ -60,7 +63,7 @@ jobs:

steps:
- name: Finish parallel tests
uses: essentialkaos/goveralls-action@v1
uses: essentialkaos/goveralls-action@v2
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -72,23 +75,30 @@ jobs:

needs: Go

env:
SRC_DIR: src/github.com/${{ github.repository }}
GO111MODULE: auto

steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.17.x'

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
path: ${{env.SRC_DIR}}
go-version: '1.21.x'

- name: Check Golang sources with Aligo
uses: essentialkaos/aligo-action@v1
uses: essentialkaos/aligo-action@v2
with:
path: ${{env.SRC_DIR}}
files: .

Typos:
name: Typos
runs-on: ubuntu-latest

needs: Go

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check spelling
continue-on-error: true
uses: crate-ci/typos@master
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: go

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[files]
extend-exclude = ["go.sum"]
101 changes: 77 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,51 +1,104 @@
################################################################################

# This Makefile generated by GoMakeGen 1.6.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

.DEFAULT_GOAL := help
.PHONY = fmt vet deps deps-test test mod-init mod-update mod-download mod-vendor help
COMPAT ?= 1.19
MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD)

################################################################################

deps: mod-update ## Download dependencies
.DEFAULT_GOAL := help
.PHONY = fmt vet deps update test init vendor mod-init mod-update mod-download mod-vendor help

deps-test: deps ## Download dependencies for tests
################################################################################

test: ## Run tests
go test -covermode=count ./.
init: mod-init ## Initialize new module

mod-init: ## Initialize new module
go mod init
go mod tidy
deps: mod-download ## Download dependencies

mod-update: ## Update modules to their latest versions
go get -u
go mod tidy
update: mod-update ## Update dependencies to the latest versions

mod-download: ## Download modules to local cache
go mod download
vendor: mod-vendor ## Make vendored copy of dependencies

mod-vendor: ## Make vendored copy of dependencies
go mod vendor
test: ## Run tests
@echo "Starting tests…"
ifdef COVERAGE_FILE ## Save coverage data into file (String)
@go test $(VERBOSE_FLAG) -covermode=count -coverprofile=$(COVERAGE_FILE) ./.
else
@go test $(VERBOSE_FLAG) -covermode=count ./.
endif

mod-init:
@echo "[1/2] Modules initialization…"
ifdef MODULE_PATH ## Module path for initialization (String)
@go mod init $(MODULE_PATH)
else
@go mod init
endif

@echo "[2/2] Dependencies cleanup…"
ifdef COMPAT ## Compatible Go version (String)
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
else
@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
else
@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)
else
@go mod tidy $(VERBOSE_FLAG)
endif

@echo "[4/4] Updating vendored dependencies…"
@test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :

mod-download:
@echo "Downloading dependencies…"
@go mod download

mod-vendor:
@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 ./...
vet: ## Runs 'go vet' over sources
@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 ./...

help: ## Show this info
@echo -e '\n\033[1mSupported targets:\033[0m\n'
@echo -e '\n\033[1mTargets:\033[0m\n'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-14s\033[0m %s\n", $$1, $$2}'
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-6s\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%-13s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 1.6.0\033[0m\n'
@echo -e '\033[90mGenerated by GoMakeGen 3.0.2\033[0m\n'

################################################################################
27 changes: 6 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
<p align="center"><a href="#readme"><img src="https://gh.kaos.st/go-zabbix-jmx.svg"/></a></p>
<p align="center"><a href="#readme"><img src=".github/images/card.svg"/></a></p>

<p align="center">
<a href="https://kaos.sh/g/go-zabbix-jmx"><img src="https://gh.kaos.st/godoc.svg" alt="PkgGoDev" /></a>
<a href="https://kaos.sh/r/go-zabbix-jmx"><img src="https://kaos.sh/r/go-zabbix-jmx.svg" alt="GoReportCard" /></a>
<a href="https://kaos.sh/g/go-zabbix-jmx"><img src=".github/images/godoc.svg"/></a>
<a href="https://kaos.sh/w/go-zabbix-jmx/ci"><img src="https://kaos.sh/w/go-zabbix-jmx/ci.svg" alt="GitHub Actions CI Status" /></a>
<a href="https://kaos.sh/w/go-zabbix-jmx/codeql"><img src="https://kaos.sh/w/go-zabbix-jmx/codeql.svg" alt="GitHub Actions CodeQL Status" /></a>
<a href="https://kaos.sh/c/go-zabbix-jmx"><img src="https://kaos.sh/c/go-zabbix-jmx.svg" alt="Coverage Status" /></a>
<a href="https://kaos.sh/b/go-zabbix-jmx"><img src="https://kaos.sh/b/31cf4383-04c5-4ba4-85d2-85835e41d7fc.svg" alt="Codebeat badge" /></a>
<a href="#license"><img src="https://gh.kaos.st/apache2.svg"></a>
<a href="#license"><img src=".github/images/license.svg"/></a>
</p>

<p align="center"><a href="#installation">Installation</a> • <a href="#usage-example">Usage example</a> • <a href="#zabbix-jmx-get">zabbix-jmx-get</a> • <a href="#build-status">Build Status</a> • <a href="#license">License</a></p>
<p align="center"><a href="#usage-example">Usage example</a> • <a href="#zabbix-jmx-get">zabbix-jmx-get</a> • <a href="#ci-status">CI Status</a> • <a href="#license">License</a></p>

<br/>

`zabbix-jmx` is a Go package for retrieving and parsing data from Zabbix Java Gateway.

### Installation

Make sure you have a working Go 1.17+ workspace (_[instructions](https://golang.org/doc/install)_), then:

```
go get -d github.com/essentialkaos/go-zabbix-jmx
```

For update to the latest stable release, do:

```
go get -d -u github.com/essentialkaos/go-zabbix-jmx
```

### Usage example

```go
Expand Down Expand Up @@ -76,7 +61,7 @@ We also provide a command-line tool `zabbix-jmx-get` for retrieving data from Za
From sources:

```
go install github.com/essentialkaos/go-zabbix-jmx/cmd/zabbix-jmx-get
go install github.com/essentialkaos/go-zabbix-jmx/cmd/zabbix-jmx-get@latest
```

Prebuilt binaries:
Expand Down Expand Up @@ -109,7 +94,7 @@ $ zabbix-jmx-get -h 127.0.0.1 -p 10052 -H kfk-node1.domain.com -P 9093 'jmx["kaf
```

### Build Status
### CI Status

| Branch | Status |
|--------|--------|
Expand Down
2 changes: 1 addition & 1 deletion beans.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package jmx

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2022 ESSENTIAL KAOS //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
4 changes: 2 additions & 2 deletions cmd/zabbix-jmx-get/zabbix-jmx-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2022 ESSENTIAL KAOS //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down Expand Up @@ -208,7 +208,7 @@ func printError(f string, a ...interface{}) {
fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...)
}

// printErrorAndExit print error mesage and exit with exit code 1
// printErrorAndExit print error message and exit with exit code 1
func printErrorAndExit(f string, a ...interface{}) {
printError(f, a...)
os.Exit(1)
Expand Down
Loading

0 comments on commit e1122d9

Please sign in to comment.