Skip to content

Commit 76c212c

Browse files
authored
Merge pull request #59 from funbox/develop
Version 0.23.0
2 parents 3e9c055 + 29e5bde commit 76c212c

File tree

17 files changed

+362
-285
lines changed

17 files changed

+362
-285
lines changed

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
dist: xenial
2-
31
language: go
42

53
go:
6-
- 1.10.x
7-
- 1.11.x
8-
- 1.12.x
4+
- 1.13.x
5+
- 1.14.x
96
- tip
107

118
os:

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
################################################################################
22

3-
# This Makefile generated by GoMakeGen 1.1.2 using next command:
3+
# This Makefile generated by GoMakeGen 1.3.1 using next command:
44
# gomakegen .
55
#
66
# More info: https://kaos.sh/gomakegen
77

88
################################################################################
99

1010
.DEFAULT_GOAL := help
11-
.PHONY = fmt all clean git-config deps deps-test test gen-fuzz help
11+
.PHONY = fmt vet all clean git-config deps deps-test test gen-fuzz help
1212

1313
################################################################################
1414

@@ -27,12 +27,12 @@ git-config: ## Configure git redirects for stable import path services
2727
git config --global http.https://pkg.re.followRedirects true
2828

2929
deps: git-config ## Download dependencies
30-
go get -d -v pkg.re/essentialkaos/ek.v10
31-
go get -d -v pkg.re/essentialkaos/go-simpleyaml.v1
30+
go get -d -v pkg.re/essentialkaos/ek.v12
31+
go get -d -v pkg.re/essentialkaos/go-simpleyaml.v2
3232

3333
deps-test: git-config ## Download dependencies for tests
3434
go get -d -v pkg.re/check.v1
35-
go get -d -v pkg.re/essentialkaos/ek.v10
35+
go get -d -v pkg.re/essentialkaos/ek.v12
3636

3737
test: ## Run tests
3838
go test -covermode=count ./export ./procfile
@@ -44,6 +44,9 @@ gen-fuzz: ## Generate archives for fuzz testing
4444
fmt: ## Format source code with gofmt
4545
find . -name "*.go" -exec gofmt -s -w {} \;
4646

47+
vet: ## Runs go vet over sources
48+
go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./...
49+
4750
clean: ## Remove generated files
4851
rm -f init-exporter
4952

@@ -52,6 +55,6 @@ help: ## Show this info
5255
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
5356
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-15s\033[0m %s\n", $$1, $$2}'
5457
@echo -e ''
55-
@echo -e '\033[90mGenerated by GoMakeGen 1.1.2\033[0m\n'
58+
@echo -e '\033[90mGenerated by GoMakeGen 1.3.1\033[0m\n'
5659

5760
################################################################################

README.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Before the initial install allows git to use redirects for [pkg.re](https://gith
2323
git config --global http.https://pkg.re.followRedirects true
2424
```
2525

26-
To build the init-exporter from scratch, make sure you have a working Go 1.10+ workspace ([instructions](https://golang.org/doc/install)), then:
26+
To build the init-exporter from scratch, make sure you have a working Go 1.13+ workspace ([instructions](https://golang.org/doc/install)), then:
2727

2828
```bash
2929
go get -d github.com/funbox/init-exporter
@@ -33,18 +33,11 @@ make all
3333
[sudo] make install
3434
```
3535

36-
#### From ESSENTIAL KAOS Public repo for RHEL6/CentOS6
36+
#### From [ESSENTIAL KAOS Public Repository](https://yum.kaos.st)
3737

38-
```
39-
[sudo] yum install -y https://yum.kaos.st/kaos-repo-latest.el6.noarch.rpm
40-
[sudo] yum install init-exporter
41-
```
42-
43-
#### From ESSENTIAL KAOS Public repo for RHEL7/CentOS7
44-
45-
```
46-
[sudo] yum install -y https://yum.kaos.st/kaos-repo-latest.el7.noarch.rpm
47-
[sudo] yum install init-exporter
38+
```bash
39+
sudo yum install -y https://yum.kaos.st/get/$(uname -r).rpm
40+
sudo yum install init-exporter
4841
```
4942

5043
### Configuration

cli/cli.go

Lines changed: 41 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package cli
44

55
// ////////////////////////////////////////////////////////////////////////////////// //
66
// //
7-
// Copyright (c) 2006-2019 FB GROUP LLC //
7+
// Copyright (c) 2006-2020 FB GROUP LLC //
88
// //
99
// ////////////////////////////////////////////////////////////////////////////////// //
1010

@@ -13,15 +13,19 @@ import (
1313
"os"
1414
"runtime"
1515

16-
"pkg.re/essentialkaos/ek.v10/env"
17-
"pkg.re/essentialkaos/ek.v10/fmtc"
18-
"pkg.re/essentialkaos/ek.v10/fsutil"
19-
"pkg.re/essentialkaos/ek.v10/knf"
20-
"pkg.re/essentialkaos/ek.v10/log"
21-
"pkg.re/essentialkaos/ek.v10/options"
22-
"pkg.re/essentialkaos/ek.v10/system"
23-
"pkg.re/essentialkaos/ek.v10/usage"
24-
"pkg.re/essentialkaos/ek.v10/usage/update"
16+
"pkg.re/essentialkaos/ek.v12/env"
17+
"pkg.re/essentialkaos/ek.v12/fmtc"
18+
"pkg.re/essentialkaos/ek.v12/fsutil"
19+
"pkg.re/essentialkaos/ek.v12/knf"
20+
"pkg.re/essentialkaos/ek.v12/log"
21+
"pkg.re/essentialkaos/ek.v12/options"
22+
"pkg.re/essentialkaos/ek.v12/system"
23+
"pkg.re/essentialkaos/ek.v12/usage"
24+
"pkg.re/essentialkaos/ek.v12/usage/update"
25+
26+
knfv "pkg.re/essentialkaos/ek.v12/knf/validators"
27+
knff "pkg.re/essentialkaos/ek.v12/knf/validators/fs"
28+
knfs "pkg.re/essentialkaos/ek.v12/knf/validators/system"
2529

2630
"github.com/funbox/init-exporter/export"
2731
"github.com/funbox/init-exporter/procfile"
@@ -32,7 +36,7 @@ import (
3236
// App props
3337
const (
3438
APP = "init-exporter"
35-
VER = "0.22.0"
39+
VER = "0.23.0"
3640
DESC = "Utility for exporting services described by Procfile to init system"
3741
)
3842

@@ -209,70 +213,37 @@ func loadConfig() {
209213

210214
// validateConfig validate config values
211215
func validateConfig() {
212-
var permsChecker = func(config *knf.Config, prop string, value interface{}) error {
213-
if !fsutil.CheckPerms(value.(string), config.GetS(prop)) {
214-
switch value.(string) {
215-
case "DRX":
216-
return fmt.Errorf("Property %s must be path to readable directory", prop)
217-
case "DWX":
218-
return fmt.Errorf("Property %s must be path to writable directory", prop)
219-
case "DRWX":
220-
return fmt.Errorf("Property %s must be path to writable/readable directory", prop)
221-
case "FR":
222-
return fmt.Errorf("Property %s must be path to readable file", prop)
223-
}
224-
}
225-
226-
return nil
227-
}
228-
229-
var userChecker = func(config *knf.Config, prop string, value interface{}) error {
230-
if !system.IsUserExist(knf.GetS(prop)) {
231-
return fmt.Errorf("Property %s contains user which not exist on this system", prop)
232-
}
233-
234-
return nil
235-
}
236-
237-
var groupChecker = func(config *knf.Config, prop string, value interface{}) error {
238-
if !system.IsGroupExist(knf.GetS(prop)) {
239-
return fmt.Errorf("Property %s contains group which not exist on this system", prop)
240-
}
241-
242-
return nil
243-
}
244-
245216
validators := []*knf.Validator{
246-
{MAIN_RUN_USER, knf.Empty, nil},
247-
{MAIN_RUN_GROUP, knf.Empty, nil},
248-
{PATHS_WORKING_DIR, knf.Empty, nil},
249-
{PATHS_HELPER_DIR, knf.Empty, nil},
250-
{PATHS_SYSTEMD_DIR, knf.Empty, nil},
251-
{PATHS_UPSTART_DIR, knf.Empty, nil},
252-
{DEFAULTS_NPROC, knf.Empty, nil},
253-
{DEFAULTS_NOFILE, knf.Empty, nil},
254-
{DEFAULTS_RESPAWN_COUNT, knf.Empty, nil},
255-
{DEFAULTS_RESPAWN_INTERVAL, knf.Empty, nil},
256-
{DEFAULTS_KILL_TIMEOUT, knf.Empty, nil},
257-
258-
{DEFAULTS_NPROC, knf.Less, 0},
259-
{DEFAULTS_NOFILE, knf.Less, 0},
260-
{DEFAULTS_RESPAWN_COUNT, knf.Less, 0},
261-
{DEFAULTS_RESPAWN_INTERVAL, knf.Less, 0},
262-
{DEFAULTS_KILL_TIMEOUT, knf.Less, 0},
263-
264-
{MAIN_RUN_USER, userChecker, nil},
265-
{MAIN_RUN_GROUP, groupChecker, nil},
266-
267-
{PATHS_WORKING_DIR, permsChecker, "DRWX"},
268-
{PATHS_HELPER_DIR, permsChecker, "DRWX"},
217+
{MAIN_RUN_USER, knfv.Empty, nil},
218+
{MAIN_RUN_GROUP, knfv.Empty, nil},
219+
{PATHS_WORKING_DIR, knfv.Empty, nil},
220+
{PATHS_HELPER_DIR, knfv.Empty, nil},
221+
{PATHS_SYSTEMD_DIR, knfv.Empty, nil},
222+
{PATHS_UPSTART_DIR, knfv.Empty, nil},
223+
{DEFAULTS_NPROC, knfv.Empty, nil},
224+
{DEFAULTS_NOFILE, knfv.Empty, nil},
225+
{DEFAULTS_RESPAWN_COUNT, knfv.Empty, nil},
226+
{DEFAULTS_RESPAWN_INTERVAL, knfv.Empty, nil},
227+
{DEFAULTS_KILL_TIMEOUT, knfv.Empty, nil},
228+
229+
{DEFAULTS_NPROC, knfv.Less, 0},
230+
{DEFAULTS_NOFILE, knfv.Less, 0},
231+
{DEFAULTS_RESPAWN_COUNT, knfv.Less, 0},
232+
{DEFAULTS_RESPAWN_INTERVAL, knfv.Less, 0},
233+
{DEFAULTS_KILL_TIMEOUT, knfv.Less, 0},
234+
235+
{MAIN_RUN_USER, knfs.User, nil},
236+
{MAIN_RUN_GROUP, knfs.Group, nil},
237+
238+
{PATHS_WORKING_DIR, knff.Perms, "DRWX"},
239+
{PATHS_HELPER_DIR, knff.Perms, "DRWX"},
269240
}
270241

271242
if knf.GetB(LOG_ENABLED, true) {
272243
validators = append(validators,
273-
&knf.Validator{LOG_DIR, knf.Empty, nil},
274-
&knf.Validator{LOG_FILE, knf.Empty, nil},
275-
&knf.Validator{LOG_DIR, permsChecker, "DWX"},
244+
&knf.Validator{LOG_DIR, knfv.Empty, nil},
245+
&knf.Validator{LOG_FILE, knfv.Empty, nil},
246+
&knf.Validator{LOG_DIR, knff.Perms, "DWX"},
276247
)
277248
}
278249

common/init-exporter.spec

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
Summary: Utility for exporting services described by Procfile to init system
4444
Name: init-exporter
45-
Version: 0.22.0
45+
Version: 0.23.0
4646
Release: 0%{?dist}
4747
Group: Development/Tools
4848
License: MIT
@@ -52,7 +52,7 @@ Source0: %{name}-%{version}.tar.gz
5252

5353
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
5454

55-
BuildRequires: golang >= 1.12
55+
BuildRequires: golang >= 1.14
5656

5757
Provides: upstart-exporter = %{version}-%{release}
5858
Provides: systemd-exporter = %{version}-%{release}
@@ -111,7 +111,15 @@ rm -rf %{buildroot}
111111
################################################################################
112112

113113
%changelog
114-
* Fri Jul 12 2019 Anton Novojilov <andy@essentialkaos.com> - 0.22.0-0
114+
* Fri Jan 24 2020 Anton Novojilov <andyone@fun-box.ru> - 0.23.0-0
115+
- Migrated to ek.v12
116+
- Migrated to go-simpleyaml.v12
117+
- Added support of required dependencies definition
118+
- Added option 'strong_dependencies' for strong dependencies configuration (for
119+
using 'Requires' instead of 'Wants' for systemd units)
120+
- Added option 'resources:cpu_affinity' for CPU affinity configuration
121+
122+
* Fri Jul 12 2019 Anton Novojilov <andyone@fun-box.ru> - 0.22.0-0
115123
- Added 'start_on_device' option for v2 procfile format
116124
- Dropped 'reload_signal' support for Upstart ≤ 1.10.0
117125
- Fixed 'reload_signal' support for Systemd

0 commit comments

Comments
 (0)