Skip to content

Commit

Permalink
Merge pull request #496 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 13.3.2
  • Loading branch information
andyone authored Aug 11, 2024
2 parents 4f53528 + 51b5425 commit c1cb0f8
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 29 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

### [13.3.2](https://kaos.sh/ek/13.3.2)

- `[support/apps]` Added support for Docker, Podman, and LXC
- `[rand]` Removed method `Int`
- `[rand]` Code refactoring

### [13.3.1](https://kaos.sh/ek/13.3.1)

- `[cache]` Added constants with duration
Expand Down
8 changes: 8 additions & 0 deletions cache/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ func (c Config) Validate() error {

// ////////////////////////////////////////////////////////////////////////////////// //

// func encodeItem(item any) ([]byte, error) {
// return nil, nil
// }

// func decodeItem() ([]byte, error) {
// return nil, nil
// }

// getItemPath returns path to cache item
func (c *Cache) getItemPath(key string, temporary bool) string {
if temporary {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/essentialkaos/ek/v13

go 1.18
go 1.21

require (
github.com/essentialkaos/check v1.4.0
github.com/essentialkaos/depsy v1.3.0
github.com/essentialkaos/go-linenoise/v3 v3.6.0
golang.org/x/crypto v0.25.0
golang.org/x/sys v0.22.0
golang.org/x/crypto v0.26.0
golang.org/x/sys v0.24.0
)

require (
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
14 changes: 4 additions & 10 deletions rand/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,29 @@ func String(length int) string {
return ""
}

rnd := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
symbolsLength := len(symbols)
result := make([]byte, length)

rand.Seed(time.Now().UTC().UnixNano())

for i := 0; i < length; i++ {
result[i] = symbols[rand.Intn(symbolsLength)]
result[i] = symbols[rnd.Intn(symbolsLength)]
}

return string(result)
}

// Int returns random int
func Int(n int) int {
rand.Seed(time.Now().UTC().UnixNano())
return rand.Intn(n)
}

// Slice returns slice with random chars
func Slice(length int) []string {
if length == 0 {
return []string{}
}

rnd := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
symbolsLength := len(symbols)
result := make([]string, length)

for i := 0; i < length; i++ {
result[i] = string(symbols[rand.Intn(symbolsLength)])
result[i] = string(symbols[rnd.Intn(symbolsLength)])
}

return result
Expand Down
11 changes: 0 additions & 11 deletions rand/rand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ func (s *RandSuite) TestString(c *C) {
c.Assert(len(String(-100)), Equals, 0)
}

func (s *RandSuite) TestInt(c *C) {
n := 1000
k := 0

for i := 0; i < 1000; i++ {
k += Int(n)
}

c.Assert(k/n, Not(Equals), n)
}

func (s *RandSuite) TestSlice(c *C) {
t1 := strings.Join(Slice(256), "")
t2 := strings.Join(Slice(256), "")
Expand Down
18 changes: 18 additions & 0 deletions support/apps/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,24 @@ func SVN() support.App {
return support.App{"svn", ver}
}

// Docker extracts version info from Docker command output
func Docker() support.App {
ver := extractField(execVersionCmd("docker", "--version"), 0, 2)
return support.App{"docker", ver}
}

// Podman extracts version info from Podman command output
func Podman() support.App {
ver := extractField(execVersionCmd("podman", "--version"), 0, 2)
return support.App{"podman", ver}
}

// LXC extracts version info from LXC command output
func LXC() support.App {
ver := extractField(execVersionCmd("lxc", "--version"), 0, 0)
return support.App{"lxc", ver}
}

// ////////////////////////////////////////////////////////////////////////////////// //

// execVersionCmd execs command and returns output as a string
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ package ek
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION is current ek package version
const VERSION = "13.3.1"
const VERSION = "13.3.2"

0 comments on commit c1cb0f8

Please sign in to comment.