Skip to content

Commit

Permalink
outsourced passwd_encrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
peekjef72 committed Sep 29, 2024
1 parent 964ee3e commit fa735ff
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 177 deletions.
4 changes: 1 addition & 3 deletions .promu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ repository:
build:
binaries:
- name: httpapi_exporter
# path: httpapi_exporter
- name: passwd_encrypt
path: ./cmd/passwd_crypt
flags: -a -tags netgo,static
ldflags: |
-X github.com/prometheus/common/version.Version={{.Version}}
Expand All @@ -20,3 +17,4 @@ tarball:
files:
- LICENSE
- README.md
- passwd_encrypt
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch

<!--next-version-placeholder-->
## 0.3.9 / not release
- removed passwd_encrypt tool source code from httpapi_exporter: created a new stand-alone package [passwd_encrypt](https://github.com/peekjef72/passwd_encrypt). Passwd_encrypt is still installed when building and added to the released archiv.
- updated prometheus/exporter-toolkit to 0.13.0 (log => log/slog)
- renamed entrypoint /healthz to /health : response format depends on "accept" header (application/json, text/plain, text/html default)
- updated entrypoint /status, /loglevel /targets /config: response format depends on "accept" header (application/json, text/plain, text/html default)
- added cmd line --model_name to perform test with model and uri in dry-run mode
- added out format for passwd_encrypt that can be cut/pasted into config file.
- added InvalidLogin error cases: no cipher (auth_key not provided) or (invalid auth_key). For those cases if target is up, metrics for collectors status will return code 2; invalid_login
- added GET /loglevel to retrieve current level, add POST /loglevel[/level] to set loglevel to level directly
- added debug message for ba:qsic auth (auth_config.mode=basic) and bearer (auth_config.mode=token)
- added debug message for basic auth (auth_config.mode=basic) and bearer (auth_config.mode=token)
- loglevel link in landing page
- fixed typos

Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
GO := go
GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
PROMU := $(GOPATH)/bin/promu
PASSWD_ENCRYPT := $(GOPATH)/bin/passwd_encrypt
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)

PREFIX ?= $(shell pwd)
Expand All @@ -40,13 +41,15 @@ vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)

build: promu
build: promu passwd_encrypt
@echo ">> building binaries"
@$(PROMU) build --prefix $(PREFIX)

tarball: promu
tarball: promu passwd_encrypt
@echo ">> building release tarball"
@cp $(PASSWD_ENCRYPT) $(BIN_DIR)
@$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
@rm $(BIN_DIR)/passwd_encrypt

docker:
@echo ">> building docker image"
Expand All @@ -55,5 +58,7 @@ docker:
promu:
$(GO) install github.com/prometheus/promu@latest

passwd_encrypt:
$(GO) install github.com/peekjef72/passwd_encrypt@latest

.PHONY: all style format build test vet tarball docker promu
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ As examples 4 configurations for exporters are provided (see contribs):

```shell
go install github.com/prometheus/promu@latest
go install github.com/peekjef72/passwd_encrypt@latest

$GOBIN/promu build
```

or simply make.

```shell
make
```

this will build the exporter and a tool to crypt/decrypt ciphertext with a shared passphrase.

## Usage
Expand Down Expand Up @@ -56,6 +63,15 @@ kill -USR2 pid
```
Usefull if something is wrong and you want to have detailled log only for a small interval.

You can also set the loglevel using API endpoint /loglevel
* GET /loglevel : to retrieve the current level
* POST /loglevel : to cycle and increase the current loglevel
* POST /loglevel/\<level\> : to set level to \<level\>

## Reload

You can tell the exporter to reload its configuration by sending a signal HUP to the process or send a POST request to /reload endpoint.

## Exporter configuration

Exporter requires configuration to works:
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/go-resty/resty/v2"
"github.com/imdario/mergo"
"github.com/mitchellh/copystructure"
"github.com/peekjef72/httpapi_exporter/encrypt"
"github.com/peekjef72/passwd_encrypt/encrypt"
"golang.org/x/exp/slices"
)

Expand Down
86 changes: 0 additions & 86 deletions cmd/passwd_crypt/main.go

This file was deleted.

79 changes: 0 additions & 79 deletions encrypt/encrypt.go

This file was deleted.

7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/peekjef72/httpapi_exporter

go 1.22.0

toolchain go1.23.1
go 1.23.1

require (
github.com/imdario/mergo v0.3.16
Expand Down Expand Up @@ -42,10 +40,11 @@ require (
require (
github.com/Masterminds/sprig/v3 v3.3.0
github.com/alecthomas/kingpin/v2 v2.4.0
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30 // indirect
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/go-resty/resty/v2 v2.14.0
github.com/peekjef72/passwd_encrypt v0.0.0-20240929091637-a819ccf7499e
github.com/prometheus/procfs v0.15.1 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/sys v0.25.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjH
github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30 h1:t3eaIm0rUkzbrIewtiFmMK5RXHej2XnoXNhxVsAYUfg=
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs=
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b h1:mimo19zliBX/vSQ6PWWSL9lK8qwHozUj03+zLoEB8O0=
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
Expand Down Expand Up @@ -54,6 +56,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/peekjef72/passwd_encrypt v0.0.0-20240929091637-a819ccf7499e h1:CLWITFXrUOaKg2Tl8vQZxJrV8KnEkxo1kijO9kZn4sI=
github.com/peekjef72/passwd_encrypt v0.0.0-20240929091637-a819ccf7499e/go.mod h1:eWPKqB/RMGuCAwvQZC9/WPZZVY0n1tuZ42D1hVBTwWs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.20.0 h1:jBzTZ7B099Rg24tny+qngoynol8LtVYlA2bqx3vEloI=
Expand Down
2 changes: 1 addition & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
ttemplate "text/template"

"github.com/Masterminds/sprig/v3"
"github.com/peekjef72/httpapi_exporter/encrypt"
"github.com/peekjef72/passwd_encrypt/encrypt"
)

func convertToBytes(curval any, unit string) (int64, error) {
Expand Down

0 comments on commit fa735ff

Please sign in to comment.