Skip to content

Commit

Permalink
Merge pull request #118 from funbox/develop
Browse files Browse the repository at this point in the history
Version 0.25.1
  • Loading branch information
andyone authored Mar 6, 2024
2 parents 0af7396 + 3cff092 commit 560a76c
Show file tree
Hide file tree
Showing 20 changed files with 119 additions and 107 deletions.
53 changes: 27 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,28 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

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

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

strategy:
matrix:
go: [ '1.19.x', '1.20.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
run: make deps

- name: Run tests
working-directory: ${{env.SRC_DIR}}
run: make test

Aligo:
Expand All @@ -61,24 +53,20 @@ jobs:
needs: Go

steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.19.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: Download dependencies
working-directory: ${{env.SRC_DIR}}
run: make deps

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

Perfecto:
Expand All @@ -89,10 +77,10 @@ jobs:

steps:
- name: Code checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -102,3 +90,16 @@ jobs:
uses: essentialkaos/perfecto-action@v2
with:
files: common/init-exporter.spec

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

needs: Go

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

- name: Check spelling
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 @@ -15,14 +15,14 @@ jobs:

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

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
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"]
67 changes: 27 additions & 40 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ package cli

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2006-2021 FUNBOX //
// Copyright (c) 2006-2024 FUNBOX //
// //
// ////////////////////////////////////////////////////////////////////////////////// //

import (
"fmt"
"os"
"runtime"
"strings"

"github.com/essentialkaos/ek/v12/env"
"github.com/essentialkaos/ek/v12/fmtc"
Expand All @@ -22,6 +21,7 @@ import (
"github.com/essentialkaos/ek/v12/log"
"github.com/essentialkaos/ek/v12/options"
"github.com/essentialkaos/ek/v12/system"
"github.com/essentialkaos/ek/v12/terminal/tty"
"github.com/essentialkaos/ek/v12/usage"
"github.com/essentialkaos/ek/v12/usage/completion/bash"
"github.com/essentialkaos/ek/v12/usage/completion/fish"
Expand All @@ -43,7 +43,7 @@ import (
// App props
const (
APP = "init-exporter"
VER = "0.25.0"
VER = "0.25.1"
DESC = "Utility for exporting services described by Procfile to init system"
)

Expand All @@ -64,28 +64,32 @@ const (
OPT_GENERATE_MAN = "generate-man"
)

// Config properies
// Config properties
const (
MAIN_RUN_USER = "main:run-user"
MAIN_RUN_GROUP = "main:run-group"
MAIN_PREFIX = "main:prefix"
PROCFILE_VERSION1 = "procfile:version1"
PROCFILE_VERSION2 = "procfile:version2"
PATHS_WORKING_DIR = "paths:working-dir"
PATHS_HELPER_DIR = "paths:helper-dir"
PATHS_SYSTEMD_DIR = "paths:systemd-dir"
PATHS_UPSTART_DIR = "paths:upstart-dir"
MAIN_RUN_USER = "main:run-user"
MAIN_RUN_GROUP = "main:run-group"
MAIN_PREFIX = "main:prefix"

PROCFILE_VERSION1 = "procfile:version1"
PROCFILE_VERSION2 = "procfile:version2"

PATHS_WORKING_DIR = "paths:working-dir"
PATHS_HELPER_DIR = "paths:helper-dir"
PATHS_SYSTEMD_DIR = "paths:systemd-dir"
PATHS_UPSTART_DIR = "paths:upstart-dir"

DEFAULTS_NPROC = "defaults:nproc"
DEFAULTS_NOFILE = "defaults:nofile"
DEFAULTS_RESPAWN = "defaults:respawn"
DEFAULTS_RESPAWN_COUNT = "defaults:respawn-count"
DEFAULTS_RESPAWN_INTERVAL = "defaults:respawn-interval"
DEFAULTS_KILL_TIMEOUT = "defaults:kill-timeout"
LOG_ENABLED = "log:enabled"
LOG_DIR = "log:dir"
LOG_FILE = "log:file"
LOG_PERMS = "log:perms"
LOG_LEVEL = "log:level"

LOG_ENABLED = "log:enabled"
LOG_DIR = "log:dir"
LOG_FILE = "log:file"
LOG_PERMS = "log:perms"
LOG_LEVEL = "log:level"
)

const (
Expand Down Expand Up @@ -171,24 +175,7 @@ func Run(gitRev string, gomod []byte) {

// preConfigureUI preconfigures UI based on information about user terminal
func preConfigureUI() {
term := os.Getenv("TERM")

fmtc.DisableColors = true

if term != "" {
switch {
case strings.Contains(term, "xterm"),
strings.Contains(term, "color"),
term == "screen":
fmtc.DisableColors = false
}
}

if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" {
fmtc.DisableColors = true
}

if os.Getenv("NO_COLOR") != "" {
if !tty.IsTTY() {
fmtc.DisableColors = true
}
}
Expand Down Expand Up @@ -489,7 +476,7 @@ func printWarn(f string, a ...interface{}) {
fmtc.Fprintf(os.Stderr, "{y}"+f+"{!}\n", a...)
}

// printErrorAndExit prints error mesage and exit with exit code 1
// printErrorAndExit prints error message and exit with exit code 1
func printErrorAndExit(f string, a ...interface{}) {
printError(f, a...)
os.Exit(1)
Expand All @@ -503,11 +490,11 @@ func printCompletion() int {

switch options.GetS(OPT_COMPLETION) {
case "bash":
fmt.Printf(bash.Generate(info, "init-exporter"))
fmt.Print(bash.Generate(info, "init-exporter"))
case "fish":
fmt.Printf(fish.Generate(info, "init-exporter"))
fmt.Print(fish.Generate(info, "init-exporter"))
case "zsh":
fmt.Printf(zsh.Generate(info, optMap, "init-exporter"))
fmt.Print(zsh.Generate(info, optMap, "init-exporter"))
default:
return 1
}
Expand Down
20 changes: 19 additions & 1 deletion cli/support/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"
"os"
"runtime"
"runtime/debug"
"strings"

"github.com/essentialkaos/ek/v12/fmtc"
Expand Down Expand Up @@ -107,6 +108,23 @@ func showDepsInfo(gomod []byte) {
}
}

// extractGitRevFromBuildInfo extracts git SHA from embedded build info
func extractGitRevFromBuildInfo() string {
info, ok := debug.ReadBuildInfo()

if !ok {
return ""
}

for _, s := range info.Settings {
if s.Key == "vcs.revision" && len(s.Value) > 7 {
return s.Value[:7]
}
}

return ""
}

// getHashColorBullet return bullet with color from hash
func getHashColorBullet(v string) string {
if len(v) > 6 {
Expand All @@ -118,7 +136,7 @@ func getHashColorBullet(v string) string {

// printInfo formats and prints info record
func printInfo(size int, name, value string) {
name = name + ":"
name += ":"
size++

if value == "" {
Expand Down
15 changes: 7 additions & 8 deletions cli/support/support_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,24 @@ func showOSInfo() {
if err == nil {
fmtutil.Separator(false, "OS INFO")

printInfo(12, "Name", osInfo.Name)
printInfo(12, "Pretty Name", osInfo.PrettyName)
printInfo(12, "Version", osInfo.VersionID)
printInfo(12, "Name", osInfo.ColoredName())
printInfo(12, "Pretty Name", osInfo.ColoredPrettyName())
printInfo(12, "Version", osInfo.Version)
printInfo(12, "ID", osInfo.ID)
printInfo(12, "ID Like", osInfo.IDLike)
printInfo(12, "Version ID", osInfo.VersionID)
printInfo(12, "Version Code", osInfo.VersionCodename)
printInfo(12, "Platform ID", osInfo.PlatformID)
printInfo(12, "CPE", osInfo.CPEName)
}

systemInfo, err := system.GetSystemInfo()

if err != nil {
return
} else {
if osInfo == nil {
fmtutil.Separator(false, "SYSTEM INFO")
printInfo(12, "Name", systemInfo.OS)
}
} else if osInfo == nil {
fmtutil.Separator(false, "SYSTEM INFO")
printInfo(12, "Name", systemInfo.OS)
}

printInfo(12, "Arch", systemInfo.Arch)
Expand Down
8 changes: 6 additions & 2 deletions common/init-exporter.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Summary: Utility for exporting services described by Procfile to init system
Name: init-exporter
Version: 0.25.0
Version: 0.25.1
Release: 0%{?dist}
Group: Development/Tools
License: MIT
Expand All @@ -20,7 +20,7 @@ Source0: %{name}-%{version}.tar.gz

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

BuildRequires: golang >= 1.19
BuildRequires: golang >= 1.20

Provides: upstart-exporter = %{version}-%{release}
Provides: systemd-exporter = %{version}-%{release}
Expand Down Expand Up @@ -83,6 +83,10 @@ rm -rf %{buildroot}
################################################################################

%changelog
* Wed Mar 06 2024 Anton Novojilov <[email protected]> - 0.25.1-0
- Dependencies update
- Code refactoring

* Fri Mar 10 2023 Anton Novojilov <[email protected]> - 0.25.0-0
- Added verbose version output
- Dependencies update
Expand Down
2 changes: 1 addition & 1 deletion export/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package export

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2006-2023 FUNBOX //
// Copyright (c) 2006-2024 FUNBOX //
// //
// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down
2 changes: 1 addition & 1 deletion export/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package export

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2006-2023 FUNBOX //
// Copyright (c) 2006-2024 FUNBOX //
// //
// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down
2 changes: 1 addition & 1 deletion export/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package export

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2006-2023 FUNBOX //
// Copyright (c) 2006-2024 FUNBOX //
// //
// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down
2 changes: 1 addition & 1 deletion export/systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package export

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2006-2023 FUNBOX //
// Copyright (c) 2006-2024 FUNBOX //
// //
// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down
Loading

0 comments on commit 560a76c

Please sign in to comment.