Skip to content

Commit 20fb073

Browse files
authored
Merge pull request #108 from essentialkaos/develop
Version 0.1.0
2 parents 1f48d83 + 8810375 commit 20fb073

File tree

9 files changed

+91
-69
lines changed

9 files changed

+91
-69
lines changed

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ updates:
1414
- "andyone"
1515
reviewers:
1616
- "andyone"
17+
groups:
18+
all:
19+
applies-to: version-updates
20+
update-types:
21+
- "minor"
22+
- "patch"
1723

1824
- package-ecosystem: "github-actions"
1925
directory: "/"

.github/images/card.svg

+5
Loading

.github/images/license.svg

+1
Loading

Makefile

+39-25
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
################################################################################
22

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

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

10-
export GO111MODULE=on
11-
1210
ifdef VERBOSE ## Print verbose information (Flag)
1311
VERBOSE_FLAG = -v
1412
endif
1513

16-
COMPAT ?= 1.18
14+
COMPAT ?= 1.19
1715
MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
1816
GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD)
1917

2018
################################################################################
2119

2220
.DEFAULT_GOAL := help
23-
.PHONY = fmt vet all clean deps update init vendor mod-init mod-update mod-download mod-vendor help
21+
.PHONY = fmt vet all install uninstall clean deps update init vendor mod-init mod-update mod-download mod-vendor help
2422

2523
################################################################################
2624

2725
all: jira-reindex-runner ## Build all binaries
2826

2927
jira-reindex-runner:
30-
go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" jira-reindex-runner.go
28+
@echo "Building jira-reindex-runner…"
29+
@go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" jira-reindex-runner.go
3130

3231
install: ## Install all binaries
33-
cp jira-reindex-runner /usr/bin/jira-reindex-runner
32+
@echo "Installing binaries…"
33+
@cp jira-reindex-runner /usr/bin/jira-reindex-runner
3434

3535
uninstall: ## Uninstall all binaries
36-
rm -f /usr/bin/jira-reindex-runner
36+
@echo "Removing installed binaries…"
37+
@rm -f /usr/bin/jira-reindex-runner
3738

3839
init: mod-init ## Initialize new module
3940

@@ -44,57 +45,70 @@ update: mod-update ## Update dependencies to the latest versions
4445
vendor: mod-vendor ## Make vendored copy of dependencies
4546

4647
mod-init:
48+
@echo "[1/2] Modules initialization…"
4749
ifdef MODULE_PATH ## Module path for initialization (String)
48-
go mod init $(MODULE_PATH)
50+
@go mod init $(MODULE_PATH)
4951
else
50-
go mod init
52+
@go mod init
5153
endif
5254

55+
@echo "[2/2] Dependencies cleanup…"
5356
ifdef COMPAT ## Compatible Go version (String)
54-
go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
57+
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
5558
else
56-
go mod tidy $(VERBOSE_FLAG)
59+
@go mod tidy $(VERBOSE_FLAG)
5760
endif
5861

5962
mod-update:
63+
@echo "[1/4] Updating dependencies…"
6064
ifdef UPDATE_ALL ## Update all dependencies (Flag)
61-
go get -u $(VERBOSE_FLAG) all
65+
@go get -u $(VERBOSE_FLAG) all
6266
else
63-
go get -u $(VERBOSE_FLAG) ./...
67+
@go get -u $(VERBOSE_FLAG) ./...
6468
endif
6569

70+
@echo "[2/4] Stripping toolchain info…"
71+
@grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || :
72+
73+
@echo "[3/4] Dependencies cleanup…"
6674
ifdef COMPAT
67-
go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
75+
@go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
6876
else
69-
go mod tidy $(VERBOSE_FLAG)
77+
@go mod tidy $(VERBOSE_FLAG)
7078
endif
7179

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

7483
mod-download:
75-
go mod download
84+
@echo "Downloading dependencies…"
85+
@go mod download
7686

7787
mod-vendor:
78-
rm -rf vendor && go mod vendor $(VERBOSE_FLAG)
88+
@echo "Vendoring dependencies…"
89+
@rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :
7990

8091
fmt: ## Format source code with gofmt
81-
find . -name "*.go" -exec gofmt -s -w {} \;
92+
@echo "Formatting sources…"
93+
@find . -name "*.go" -exec gofmt -s -w {} \;
8294

8395
vet: ## Runs 'go vet' over sources
84-
go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./...
96+
@echo "Running 'go vet' over sources…"
97+
@go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./...
8598

8699
clean: ## Remove generated files
87-
rm -f jira-reindex-runner
100+
@echo "Removing built binaries…"
101+
@rm -f jira-reindex-runner
88102

89103
help: ## Show this info
90104
@echo -e '\n\033[1mTargets:\033[0m\n'
91105
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
92-
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-21s\033[0m %s\n", $$1, $$2}'
106+
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-9s\033[0m %s\n", $$1, $$2}'
93107
@echo -e '\n\033[1mVariables:\033[0m\n'
94108
@grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \
95109
| sed 's/ifdef //' \
96-
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}'
110+
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-11s\033[0m %s\n", $$1, $$2}'
97111
@echo -e ''
98-
@echo -e '\033[90mGenerated by GoMakeGen 2.3.0\033[0m\n'
112+
@echo -e '\033[90mGenerated by GoMakeGen 3.0.2\033[0m\n'
99113

100114
################################################################################

README.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
<p align="center"><a href="#readme"><img src="https://gh.kaos.st/jira-reindex-runner.svg"/></a></p>
1+
<p align="center"><a href="#readme"><img src=".github/images/card.svg"/></a></p>
22

33
<p align="center">
4-
<a href="https://kaos.sh/w/jira-reindex-runner/ci"><img src="https://kaos.sh/w/jira-reindex-runner/ci.svg" alt="GitHub Actions CI Status" /></a>
5-
<a href="https://kaos.sh/r/jira-reindex-runner"><img src="https://kaos.sh/r/jira-reindex-runner.svg" alt="GoReportCard" /></a>
64
<a href="https://kaos.sh/b/jira-reindex-runner"><img src="https://kaos.sh/b/6eb7ec23-d693-4d48-bec2-a50adc82b432.svg" alt="Codebeat badge" /></a>
5+
<a href="https://kaos.sh/w/jira-reindex-runner/ci"><img src="https://kaos.sh/w/jira-reindex-runner/ci.svg" alt="GitHub Actions CI Status" /></a>
76
<a href="https://kaos.sh/w/jira-reindex-runner/codeql"><img src="https://kaos.sh/w/jira-reindex-runner/codeql.svg" alt="GitHub Actions CodeQL Status" /></a>
8-
<a href="#license"><img src="https://gh.kaos.st/apache2.svg"></a>
7+
<a href="#license"><img src=".github/images/license.svg"/></a>
98
</p>
109

11-
<p align="center"><a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#build-status">Build Status</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>
10+
<p align="center"><a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#ci-status">CI Status</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>
1211

1312
<br/>
1413

@@ -46,20 +45,20 @@ Using this endpoint, our app can check if re-index is required and run it.
4645

4746
#### From source
4847

49-
Make sure you have a working Go 1.19+ workspace ([instructions](https://go.dev/doc/install)), then:
48+
Make sure you have a working Go 1.21+ workspace ([instructions](https://go.dev/doc/install)), then:
5049

5150
```
52-
go install github.com/essentialkaos/jira-reindex-runner
51+
go install github.com/essentialkaos/jira-reindex-runner@latest
5352
```
5453

55-
#### From [ESSENTIAL KAOS Public Repository](https://pkgs.kaos.st)
54+
#### From [ESSENTIAL KAOS Public Repository](https://kaos.sh/kaos-repo)
5655

5756
```bash
58-
sudo yum install -y https://pkgs.kaos.st/kaos-repo-latest.el$(grep 'CPE_NAME' /etc/os-release | tr -d '"' | cut -d':' -f5).noarch.rpm
59-
sudo yum install jira-reindex-runner
57+
sudo dnf install -y https://pkgs.kaos.st/kaos-repo-latest.el$(grep 'CPE_NAME' /etc/os-release | tr -d '"' | cut -d':' -f5).noarch.rpm
58+
sudo dnf install jira-reindex-runner
6059
```
6160

62-
### Build Status
61+
### CI Status
6362

6463
| Branch | Status |
6564
|--------|----------|

app/cli.go renamed to app/app.go

+10-19
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/essentialkaos/ek/v12/options"
1919
"github.com/essentialkaos/ek/v12/support"
2020
"github.com/essentialkaos/ek/v12/support/deps"
21+
"github.com/essentialkaos/ek/v12/terminal"
2122
"github.com/essentialkaos/ek/v12/terminal/tty"
2223
"github.com/essentialkaos/ek/v12/usage"
2324
"github.com/essentialkaos/ek/v12/usage/completion/bash"
@@ -36,7 +37,7 @@ import (
3637
// Basic application info
3738
const (
3839
APP = "Jira Reindex Runner"
39-
VER = "0.0.6"
40+
VER = "0.1.0"
4041
DESC = "Tool for periodical running Jira re-index process"
4142
)
4243

@@ -81,24 +82,19 @@ var optMap = options.Map{
8182
OPT_GENERATE_MAN: {Type: options.BOOL},
8283
}
8384

84-
// useRawOutput is raw output flag (for cli command)
85-
var useRawOutput = false
86-
8785
// ////////////////////////////////////////////////////////////////////////////////// //
8886

8987
// Run is main application function
9088
func Run(gitRev string, gomod []byte) {
9189
preConfigureUI()
9290

93-
runtime.GOMAXPROCS(1)
91+
runtime.GOMAXPROCS(2)
9492

9593
_, errs := options.Parse(optMap)
9694

97-
if len(errs) != 0 {
98-
for _, err := range errs {
99-
printError(err.Error())
100-
}
101-
95+
if !errs.IsEmpty() {
96+
terminal.Error("Options parsing errors:")
97+
terminal.Error(errs.String())
10298
os.Exit(1)
10399
}
104100

@@ -183,10 +179,10 @@ func validateConfig() {
183179
})
184180

185181
if len(errs) != 0 {
186-
printError("Error while configuration file validation:")
182+
terminal.Error("Error while configuration file validation:")
187183

188184
for _, err := range errs {
189-
printError(" %v", err)
185+
terminal.Error(" %v", err)
190186
}
191187

192188
os.Exit(1)
@@ -195,7 +191,7 @@ func validateConfig() {
195191

196192
// setupLogger configures logger subsystems
197193
func setupLogger() {
198-
err := log.Set(knf.GetS(LOG_FILE), knf.GetM(LOG_PERMS, 644))
194+
err := log.Set(knf.GetS(LOG_FILE), knf.GetM(LOG_PERMS, 0644))
199195

200196
if err != nil {
201197
printErrorAndExit(err.Error())
@@ -213,14 +209,9 @@ func process() {
213209
os.Exit(runReindex())
214210
}
215211

216-
// printError prints error message to console
217-
func printError(f string, a ...interface{}) {
218-
fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...)
219-
}
220-
221212
// printErrorAndExit print error message and exit with exit code 1
222213
func printErrorAndExit(f string, a ...interface{}) {
223-
printError(f, a...)
214+
terminal.Error(f, a...)
224215
os.Exit(1)
225216
}
226217

0 commit comments

Comments
 (0)