Skip to content

Commit

Permalink
Merge pull request #463 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 12.120.0
  • Loading branch information
andyone authored Apr 29, 2024
2 parents a75bcaa + f7cf068 commit d4fd4ce
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 120 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Changelog

### 12.120.0

- `[knf]` Added methods `Alias` and `Config.Alias`
- `[knf]` Added property name validation for all getters
- `[sliceutil]` Added method `IsEqual`
- `[knf]` Code refactoring
- `[knf]` Added more tests

### 12.119.0

- `[initsystem]` Added [launchd](https://www.launchd.info) support
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ go get -u github.com/essentialkaos/ek/v12

* [aligo](https://kaos.sh/aligo) — Utility for checking and viewing Golang struct alignment info
* [artefactor](https://kaos.sh/artefactor) — Utility for downloading artefacts from GitHub
* [atlassian-cloud-backuper](https://kaos.sh/atlassian-cloud-backuper) — Tool for backuping Atlassian cloud services (_Jira and Confluence_)
* [Bastion](https://kaos.sh/bastion) — Utility for temporary disabling access to server
* [bibop](https://kaos.sh/bibop) — Utility for testing command-line tools
* [bop](https://kaos.sh/bop) — Utility for generating bibop tests for RPM packages
Expand All @@ -129,6 +130,7 @@ go get -u github.com/essentialkaos/ek/v12
* [path](https://kaos.sh/path) — Dead simple tool for working with paths
* [perfecto](https://kaos.sh/perfecto) — Tool for checking perfectly written RPM specs
* [RBInstall](https://kaos.sh/rbinstall) — Utility for installing prebuilt ruby to RBEnv
* [RDS](https://kaos.sh/rds) — Tool for Redis orchestration
* [Redis CLI Monitor](https://kaos.sh/redis-cli-monitor) — Tiny redis client for renamed MONITOR commands
* [Redis Latency Monitor](https://kaos.sh/redis-latency-monitor) — Tiny Redis client for latency measurement
* [Redis Monitor Top](https://kaos.sh/redis-monitor-top) — Tiny Redis client for aggregating stats from MONITOR flow
Expand Down
2 changes: 1 addition & 1 deletion ek.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION is current ek package version
const VERSION = "12.119.0"
const VERSION = "12.120.0"

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

Expand Down
42 changes: 42 additions & 0 deletions knf/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ func ExampleReload() {
}
}

func ExampleAlias() {
err := Global("/path/to/your/config.knf")

if err != nil {
fmt.Printf("Error: %v\n", err)
return
}

// Add alias for renamed property "user:username"
Alias("user:username", "user:name")

fmt.Printf("Value from config: %s\n", GetS("user:name"))
}

func ExampleGetS() {
err := Global("/path/to/your/config.knf")

Expand Down Expand Up @@ -373,6 +387,34 @@ func ExampleConfig_Reload() {
}
}

func ExampleConfig_Alias() {
cfg, err := Parse([]byte(`
[user]
username: john
uid: 512
is-admin: true
priority: 3.7
default-mode: 0644
timeout: 3m
created: 1654424130
timezone: Europe/Madrid
labels: system admin
`))

if err != nil {
fmt.Printf("Error: %v\n", err)
return
}

// Add alias for renamed property "user:username"
cfg.Alias("user:username", "user:name")

fmt.Printf("Value from config: %s\n", cfg.GetS("user:name"))

// Output:
// Value from config: john
}

func ExampleConfig_GetS() {
cfg, err := Parse([]byte(`
[user]
Expand Down
Loading

0 comments on commit d4fd4ce

Please sign in to comment.