Skip to content

Commit

Permalink
Merge pull request #69 from funbox/develop
Browse files Browse the repository at this point in the history
Version 0.12.1
  • Loading branch information
andyone authored Mar 6, 2024
2 parents aa32f5e + 47d90a2 commit c9da431
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 89 deletions.
50 changes: 26 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +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@v2
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: Build binaries
working-directory: ${{env.SRC_DIR}}
run: make all

Aligo:
Expand All @@ -60,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 @@ -88,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 @@ -101,3 +90,16 @@ jobs:
uses: essentialkaos/perfecto-action@v2
with:
files: common/init-exporter-converter.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"]
8 changes: 6 additions & 2 deletions common/init-exporter-converter.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Summary: Utility for converting init-exporter procfiles from v1 to v2 format
Name: init-exporter-converter
Version: 0.12.0
Version: 0.12.1
Release: 0%{?dist}
Group: Development/Tools
License: MIT
Expand All @@ -16,7 +16,7 @@ Source0: %{name}-%{version}.tar.gz

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

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

Provides: %{name} = %{version}-%{release}

Expand Down Expand Up @@ -60,6 +60,10 @@ rm -rf %{buildroot}
################################################################################

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

* Fri Mar 10 2023 Anton Novojilov <[email protected]> - 0.12.0-0
- Added verbose version output
- Dependencies update
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/funbox/init-exporter-converter
go 1.18

require (
github.com/essentialkaos/ek/v12 v12.62.0
github.com/essentialkaos/ek/v12 v12.102.0
github.com/essentialkaos/go-simpleyaml/v2 v2.1.4
github.com/funbox/init-exporter v0.24.1
github.com/funbox/init-exporter v0.25.1
)

require (
golang.org/x/sys v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
14 changes: 7 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk=
github.com/essentialkaos/ek/v12 v12.62.0 h1:A+pnMGbSz2apjEjlHU3EQ6Uqam85GTryVPhzcLfY8o4=
github.com/essentialkaos/ek/v12 v12.62.0/go.mod h1:9MlSuHpewu7OZ9tM9dLFHvoA8dflBIUPCA0Ctt97wRs=
github.com/essentialkaos/ek/v12 v12.102.0 h1:frHp1+iElQUg4CoscVQWuVFY1QZvU0fIqAaV2RtmeP0=
github.com/essentialkaos/ek/v12 v12.102.0/go.mod h1:T5RaDwmg6aso4vPfMp9OSk0R5YAjGtkinlxj2kDXUbo=
github.com/essentialkaos/go-simpleyaml/v2 v2.1.4 h1:B2bXdGWaQ6Xy3HTsO2DLBoNV7cbMW3KDmeeOKYLo9z0=
github.com/essentialkaos/go-simpleyaml/v2 v2.1.4/go.mod h1:pVQTleUBC8xBI9+HnTF38xWBZqANNrmMAzwmUemblJg=
github.com/funbox/init-exporter v0.24.1 h1:nQXX4nEq6oh+6Ok7nSRoP2WP97DU5vf84+ASEw3qg+8=
github.com/funbox/init-exporter v0.24.1/go.mod h1:/VrrNrdCYKcKZjoIPx6u0yra/M51tFPZ5v8GKV8eCz4=
github.com/funbox/init-exporter v0.25.1 h1:xmvgrPFUPInBsZRSSB8+mMciUtw78HFN0fCeMZuRyKo=
github.com/funbox/init-exporter v0.25.1/go.mod h1:r1uzN8W6j8P5awNYmWkQNA+EpIGEKdYrGA8IGVBleN4=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down
68 changes: 18 additions & 50 deletions init-exporter-converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"runtime"
"strings"

"github.com/essentialkaos/ek/v12/fmtc"
"github.com/essentialkaos/ek/v12/fsutil"
"github.com/essentialkaos/ek/v12/knf"
"github.com/essentialkaos/ek/v12/options"
"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 @@ -34,7 +32,7 @@ import (
// App props
const (
APP = "init-exporter-converter"
VER = "0.12.0"
VER = "0.12.1"
DESC = "Utility for converting procfiles from v1 to v2 format"
)

Expand All @@ -52,7 +50,7 @@ const (
OPT_GENERATE_MAN = "generate-man"
)

// Config properies
// Config properties
const (
MAIN_PREFIX = "main:prefix"
PATHS_WORKING_DIR = "paths:working-dir"
Expand Down Expand Up @@ -130,24 +128,7 @@ func main() {

// 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 @@ -237,7 +218,7 @@ func convert(file string) error {
}

if !options.GetB(OPT_IN_PLACE) {
fmt.Printf(yamlData)
fmt.Print(yamlData)
return nil
}

Expand Down Expand Up @@ -349,20 +330,15 @@ func validateYaml(data string) error {

// writeData writes procfile data to file
func writeData(file, data string) error {
return ioutil.WriteFile(file, []byte(data), 0644)
return os.WriteFile(file, []byte(data), 0644)
}

// printError prints error message to console
func printError(f string, a ...interface{}) {
fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...)
}

// printError prints warning message to console
func printWarn(f string, a ...interface{}) {
fmtc.Fprintf(os.Stderr, "{y}"+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 All @@ -376,11 +352,11 @@ func printCompletion() int {

switch options.GetS(OPT_COMPLETION) {
case "bash":
fmt.Printf(bash.Generate(info, "init-exporter-converter"))
fmt.Print(bash.Generate(info, "init-exporter-converter"))
case "fish":
fmt.Printf(fish.Generate(info, "init-exporter-converter"))
fmt.Print(fish.Generate(info, "init-exporter-converter"))
case "zsh":
fmt.Printf(zsh.Generate(info, optMap, "init-exporter-converter"))
fmt.Print(zsh.Generate(info, optMap, "init-exporter-converter"))
default:
return 1
}
Expand All @@ -390,12 +366,7 @@ func printCompletion() int {

// printMan prints man page
func printMan() {
fmt.Println(
man.Generate(
genUsage(),
genAbout(""),
),
)
fmt.Println(man.Generate(genUsage(), genAbout("")))
}

// genUsage generates usage info
Expand Down Expand Up @@ -426,16 +397,13 @@ func genUsage() *usage.Info {
// genAbout generates info about version
func genAbout(gitRev string) *usage.About {
about := &usage.About{
App: APP,
Version: VER,
Desc: DESC,
Year: 2006,
Owner: "FunBox",
License: "MIT License",
UpdateChecker: usage.UpdateChecker{
"funbox/init-exporter-converter",
update.GitHubChecker,
},
App: APP,
Version: VER,
Desc: DESC,
Year: 2006,
Owner: "FunBox",
License: "MIT License",
UpdateChecker: usage.UpdateChecker{"funbox/init-exporter-converter", update.GitHubChecker},

AppNameColorTag: "{*}" + colorTagApp,
VersionColorTag: colorTagVer,
Expand Down

0 comments on commit c9da431

Please sign in to comment.