Compare commits

...

229 commits

Author SHA1 Message Date
dependabot[bot] b9733f03ad build(deps): bump actions/checkout from 4.1.4 to 4.1.6
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.4 to 4.1.6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](0ad4b8fada...a5ac7e51b4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-01 14:57:38 +02:00
dependabot[bot] 6ecc5c810f build(deps): bump cachix/install-nix-action from 26 to 27
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 26 to 27.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](8887e596b4...ba0dd844c9)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-01 14:57:10 +02:00
dependabot[bot] 248c6fdd03 build(deps): bump github/codeql-action from 3.25.4 to 3.25.7
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.4 to 3.25.7.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ccf74c9479...f079b84933)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-01 14:56:54 +02:00
Stephen Kitt abea773f16 Update references to bketelsen/crypt
Since https://github.com/spf13/viper/pull/1218 crypt is provided by
https://github.com/sagikazarmark/crypt

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-05-29 16:02:38 +02:00
dependabot[bot] f17acb4fd4 build(deps): bump golangci/golangci-lint-action from 4.0.0 to 6.0.1
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 4.0.0 to 6.0.1.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](3cfe3a4abb...a4f60bb28d)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-12 15:56:31 +02:00
dependabot[bot] 8e285a5880 build(deps): bump github/codeql-action from 3.25.2 to 3.25.4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.2 to 3.25.4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](8f596b4ae3...ccf74c9479)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-12 15:56:15 +02:00
dependabot[bot] 40176207a5 build(deps): bump actions/setup-go from 5.0.0 to 5.0.1
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](0c52d547c9...cdcb360436)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-12 15:55:51 +02:00
dependabot[bot] b67e814385 build(deps): bump github.com/pelletier/go-toml/v2 from 2.2.1 to 2.2.2
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.2.1 to 2.2.2.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.2.1...v2.2.2)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-12 15:55:34 +02:00
dependabot[bot] 4a182c767b build(deps): bump actions/dependency-review-action from 4.2.5 to 4.3.2
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.2.5 to 4.3.2.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](5bbc3ba658...0c155c5e85)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-12 15:55:19 +02:00
dependabot[bot] 45a0e1214a build(deps): bump mheap/github-action-required-labels
Bumps [mheap/github-action-required-labels](https://github.com/mheap/github-action-required-labels) from 5.4.0 to 5.4.1.
- [Release notes](https://github.com/mheap/github-action-required-labels/releases)
- [Commits](132879b972...5847eef682)

---
updated-dependencies:
- dependency-name: mheap/github-action-required-labels
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-12 15:55:03 +02:00
dependabot[bot] ea35b92596 build(deps): bump github/codeql-action from 3.25.1 to 3.25.2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.1 to 3.25.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](c7f9125735...8f596b4ae3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-25 01:40:21 -03:00
dependabot[bot] 3d32668ee5 build(deps): bump actions/checkout from 4.1.3 to 4.1.4
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.3 to 4.1.4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](1d96c772d1...0ad4b8fada)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-25 01:40:07 -03:00
dependabot[bot] d539b7a246 build(deps): bump actions/checkout from 4.1.2 to 4.1.3
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.2 to 4.1.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](9bb56186c3...1d96c772d1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-19 17:37:57 -03:00
dependabot[bot] 33920bee87 build(deps): bump golang.org/x/net from 0.22.0 to 0.23.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.22.0 to 0.23.0.
- [Commits](https://github.com/golang/net/compare/v0.22.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-19 15:06:28 -03:00
dependabot[bot] ec459a1935 build(deps): bump github/codeql-action from 3.24.9 to 3.25.1
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.9 to 3.25.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](1b1aada464...c7f9125735)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-19 15:06:00 -03:00
dependabot[bot] bd3d203553 build(deps): bump github.com/pelletier/go-toml/v2 from 2.2.0 to 2.2.1
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.2.0...v2.2.1)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-19 15:05:24 -03:00
dependabot[bot] ad27eabd6a build(deps): bump actions/dependency-review-action from 4.2.4 to 4.2.5
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.2.4 to 4.2.5.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](733dd5d4a5...5bbc3ba658)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-19 15:04:59 -03:00
sandeep 2e9148610a
fix #1700: update tests to use local viper instance (#1791)
* fix:test to use local viper instance

* fix linting

* fix typo

* remove unsed function
2024-04-07 13:09:02 +02:00
dependabot[bot] 947eb59667 build(deps): bump github.com/pelletier/go-toml/v2 from 2.1.1 to 2.2.0
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.1.1 to 2.2.0.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.1.1...v2.2.0)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-25 13:47:24 +01:00
Mark Sagi-Kazar 06c8eab75b feat: drop Go 1.19 support
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2024-03-25 13:39:13 +01:00
Mark Sagi-Kazar 8b5a9ae620 chore: upgrade crypt
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2024-03-25 13:39:13 +01:00
dependabot[bot] e7b623d3fa build(deps): bump actions/dependency-review-action from 4.1.3 to 4.2.4
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.1.3 to 4.2.4.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](9129d7d40b...733dd5d4a5)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-25 13:18:21 +01:00
dependabot[bot] 6cf94c6469 build(deps): bump actions/checkout from 4.1.1 to 4.1.2
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.1 to 4.1.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](b4ffde65f4...9bb56186c3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-25 13:15:07 +01:00
dependabot[bot] 2fdb281f15 build(deps): bump mheap/github-action-required-labels
Bumps [mheap/github-action-required-labels](https://github.com/mheap/github-action-required-labels) from 5.3.0 to 5.4.0.
- [Release notes](https://github.com/mheap/github-action-required-labels/releases)
- [Commits](80a96a4863...132879b972)

---
updated-dependencies:
- dependency-name: mheap/github-action-required-labels
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-25 13:14:41 +01:00
dependabot[bot] d2d8cb1844 build(deps): bump github/codeql-action from 3.24.6 to 3.24.9
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.6 to 3.24.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](8a470fddaf...1b1aada464)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-25 13:14:32 +01:00
dependabot[bot] 8ac644165c build(deps): bump actions/dependency-review-action from 4.1.0 to 4.1.3
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.1.0 to 4.1.3.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](80f10bf419...9129d7d40b)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-11 18:43:24 +01:00
dependabot[bot] dac344c3b7 build(deps): bump cachix/install-nix-action from 25 to 26
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 25 to 26.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](6004951b18...8887e596b4)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-11 18:42:56 +01:00
dependabot[bot] e2eefdafab build(deps): bump github/codeql-action from 3.24.5 to 3.24.6
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.5 to 3.24.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](47b3d888fe...8a470fddaf)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-04 13:16:42 +01:00
dependabot[bot] f1d14ce9d7 build(deps): bump github.com/stretchr/testify from 1.8.4 to 1.9.0
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.4 to 1.9.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.4...v1.9.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-04 13:16:28 +01:00
dependabot[bot] 5870123c5f build(deps): bump github/codeql-action from 3.24.3 to 3.24.5
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.3 to 3.24.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](379614612a...47b3d888fe)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-28 01:09:58 +01:00
dependabot[bot] 1f0aed7935 build(deps): bump github.com/sagikazarmark/crypt from 0.17.0 to 0.18.0
Bumps [github.com/sagikazarmark/crypt](https://github.com/sagikazarmark/crypt) from 0.17.0 to 0.18.0.
- [Commits](https://github.com/sagikazarmark/crypt/compare/v0.17.0...v0.18.0)

---
updated-dependencies:
- dependency-name: github.com/sagikazarmark/crypt
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-28 01:09:33 +01:00
dependabot[bot] 24d6fd3379 build(deps): bump github/codeql-action from 3.24.1 to 3.24.3
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.1 to 3.24.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](e675ced7a7...379614612a)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-16 00:45:05 +01:00
Mark Sagi-Kazar 030b77a720 fix: lint violations
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2024-02-15 14:19:50 +01:00
Mark Sagi-Kazar 6c6bd7c0b5 chore: add Go 1.22 support
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2024-02-15 14:19:50 +01:00
dependabot[bot] a38f9750dc build(deps): bump mheap/github-action-required-labels
Bumps [mheap/github-action-required-labels](https://github.com/mheap/github-action-required-labels) from 5.2.0 to 5.3.0.
- [Release notes](https://github.com/mheap/github-action-required-labels/releases)
- [Commits](cc7a79fadb...80a96a4863)

---
updated-dependencies:
- dependency-name: mheap/github-action-required-labels
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-15 12:00:29 +01:00
dependabot[bot] 233bae8183 build(deps): bump golangci/golangci-lint-action from 3.7.0 to 4.0.0
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.7.0 to 4.0.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](3a91952989...3cfe3a4abb)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-15 12:00:11 +01:00
dependabot[bot] b28713100e build(deps): bump actions/dependency-review-action from 4.0.0 to 4.1.0
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](4901385134...80f10bf419)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-15 11:59:51 +01:00
tobb10001 c4c81fd795 readme: update link to go modules documentation 2024-02-15 11:55:56 +01:00
dependabot[bot] c9d7f6517c build(deps): bump github/codeql-action from 3.24.0 to 3.24.1
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.0 to 3.24.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](e8893c57a1...e675ced7a7)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-15 11:55:00 +01:00
dependabot[bot] 8f34134e70 build(deps): bump github/codeql-action from 3.23.2 to 3.24.0
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.23.2 to 3.24.0.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](b7bf0a3ed3...e8893c57a1)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-05 19:37:23 +01:00
dependabot[bot] 0e82215118 build(deps): bump cachix/install-nix-action from 24 to 25
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 24 to 25.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](7ac1ec2549...6004951b18)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-30 10:35:49 +01:00
dependabot[bot] bc0e4e85f4 build(deps): bump actions/dependency-review-action from 3.1.5 to 4.0.0
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 3.1.5 to 4.0.0.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](c74b580d73...4901385134)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-30 10:35:36 +01:00
dependabot[bot] b633fc0aa1 build(deps): bump github/codeql-action from 3.23.0 to 3.23.2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.23.0 to 3.23.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](e5f05b81d5...b7bf0a3ed3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-30 10:35:20 +01:00
dependabot[bot] eda842880e build(deps): bump mheap/github-action-required-labels
Bumps [mheap/github-action-required-labels](https://github.com/mheap/github-action-required-labels) from 5.1.0 to 5.2.0.
- [Release notes](https://github.com/mheap/github-action-required-labels/releases)
- [Commits](4e9ef4ce8c...cc7a79fadb)

---
updated-dependencies:
- dependency-name: mheap/github-action-required-labels
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-30 10:35:06 +01:00
dependabot[bot] c44f929787 build(deps): bump actions/dependency-review-action from 3.1.4 to 3.1.5
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 3.1.4 to 3.1.5.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](01bc87099b...c74b580d73)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-09 12:16:53 +01:00
dependabot[bot] d9cf5cffdc build(deps): bump github/codeql-action from 3.22.11 to 3.23.0
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.22.11 to 3.23.0.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](b374143c11...e5f05b81d5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-09 12:16:38 +01:00
dependabot[bot] e36638d878 build(deps): bump golang.org/x/crypto from 0.16.0 to 0.17.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.16.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-19 22:08:07 +01:00
Mark Sagi-Kazar 473a3dfc7f fix!: hide struct binding behind a feature flag
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-12-18 19:36:22 +01:00
dependabot[bot] 0b0a1104ba build(deps): bump github.com/pelletier/go-toml/v2 from 2.1.0 to 2.1.1
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.1.0 to 2.1.1.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.1.0...v2.1.1)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-15 14:09:38 +01:00
dependabot[bot] fcda1149d6 build(deps): bump github/codeql-action from 2.22.9 to 3.22.11
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.22.9 to 3.22.11.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](c0d1daa7f7...b374143c11)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-15 13:41:45 +01:00
dependabot[bot] 9154b900c3 build(deps): bump actions/setup-go from 4.1.0 to 5.0.0
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4.1.0 to 5.0.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](93397bea11...0c52d547c9)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-08 14:48:22 +01:00
dependabot[bot] 08e4a00949 build(deps): bump github/codeql-action from 2.22.8 to 2.22.9
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.22.8 to 2.22.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](407ffafae6...c0d1daa7f7)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-08 14:48:15 +01:00
Filip Krakowski fb6eb1e8e9 fix: merge missing struct keys inside UnmarshalExact 2023-12-08 14:44:05 +01:00
Mark Sagi-Kazar f5fcb4a104 chore: update crypt
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-12-06 21:48:41 +07:00
linuxsong f7363633d1
fix isPathShadowedInFlatMap type cast bug (#1585)
* fix isPathShadowedInFlatMap type cast bug

* Add "IsPathShadowedInFlatMap" method unit test

* fix: typo

* add an unit test for flag shadow

---------

Co-authored-by: Márk Sági-Kazár <sagikazarmark@users.noreply.github.com>
2023-12-06 14:41:36 +01:00
Oleksandr Redko 36a38682ba Review changes 2023-12-06 19:07:50 +07:00
Oleksandr Redko f0c4ccd6cd fix: gocritic lint issues 2023-12-06 19:07:50 +07:00
Oleksandr Redko 3a23b80b11 ci: enable test shuffle; fix tests 2023-12-06 19:03:14 +07:00
Mark Sagi-Kazar 73dfb94c57 feat: make Unmarshal work with AutomaticEnv
Co-authored-by: Filip Krakowski <krakowski@hhu.de>
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-12-06 18:44:04 +07:00
Mark Sagi-Kazar 6ea31ae4ca refactor: move all settings code to a getter
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-12-06 18:44:04 +07:00
Oleksandr Redko c4dcd31f68 fix: godot lint issues 2023-11-30 21:20:53 +07:00
Ville Skyttä 4c9b2a26ae Note Get* behavior on parse failure
Even though it's kind of evident as these functions don't return an
error, it can still come as a surprise.
2023-11-30 15:21:42 +07:00
Mark Sagi-Kazar a4a551fd2a chore: update dependencies
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-11-30 00:37:44 +07:00
Mark Sagi-Kazar 464cdab72a refactor: drop fsonitfy wrapper
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-11-30 00:24:02 +07:00
dependabot[bot] 6db0ab274d build(deps): bump github.com/fsnotify/fsnotify from 1.6.0 to 1.7.0
Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/fsnotify/fsnotify/releases)
- [Changelog](https://github.com/fsnotify/fsnotify/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fsnotify/fsnotify/compare/v1.6.0...v1.7.0)

---
updated-dependencies:
- dependency-name: github.com/fsnotify/fsnotify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 23:52:50 +07:00
maxim-konovalov 1c764910bb add info about multiple hosts for remote config 2023-11-29 23:47:27 +07:00
dependabot[bot] 7a9716be0b build(deps): bump github.com/spf13/cast from 1.5.1 to 1.6.0
Bumps [github.com/spf13/cast](https://github.com/spf13/cast) from 1.5.1 to 1.6.0.
- [Release notes](https://github.com/spf13/cast/releases)
- [Commits](https://github.com/spf13/cast/compare/v1.5.1...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cast
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 23:38:31 +07:00
dependabot[bot] cd3d41c170 build(deps): bump github.com/nats-io/nkeys from 0.4.5 to 0.4.6
Bumps [github.com/nats-io/nkeys](https://github.com/nats-io/nkeys) from 0.4.5 to 0.4.6.
- [Release notes](https://github.com/nats-io/nkeys/releases)
- [Changelog](https://github.com/nats-io/nkeys/blob/main/.goreleaser.yml)
- [Commits](https://github.com/nats-io/nkeys/compare/v0.4.5...v0.4.6)

---
updated-dependencies:
- dependency-name: github.com/nats-io/nkeys
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 21:43:32 +07:00
dependabot[bot] ece813c99a build(deps): bump cachix/install-nix-action from 23 to 24
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 23 to 24.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](6a9a9e84a1...7ac1ec2549)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 21:43:00 +07:00
dependabot[bot] a831a3736f build(deps): bump actions/dependency-review-action from 3.1.0 to 3.1.4
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 3.1.0 to 3.1.4.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](6c5ccdad46...01bc87099b)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 21:42:34 +07:00
dependabot[bot] 291a41f167 build(deps): bump github.com/spf13/afero from 1.10.0 to 1.11.0
Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/spf13/afero/releases)
- [Commits](https://github.com/spf13/afero/compare/v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/afero
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 21:42:03 +07:00
dependabot[bot] 1a4fa6c906 build(deps): bump github/codeql-action from 2.22.3 to 2.22.8
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.22.3 to 2.22.8.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](0116bc2df5...407ffafae6)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 21:34:01 +07:00
dependabot[bot] be8a2e81aa build(deps): bump actions/github-script from 6.4.1 to 7.0.1
Bumps [actions/github-script](https://github.com/actions/github-script) from 6.4.1 to 7.0.1.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](d7906e4ad0...60a0d83039)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 21:33:31 +07:00
dependabot[bot] e9f2018b22 build(deps): bump actions/checkout from 4.1.0 to 4.1.1
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](8ade135a41...b4ffde65f4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 21:32:32 +07:00
Oleksandr Redko b5daec6e7b test: Replace ifs with asserts to simplify tests 2023-10-14 02:12:35 +02:00
dependabot[bot] b6610e7702 build(deps): bump golang.org/x/net from 0.15.0 to 0.17.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.15.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.15.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-14 02:11:19 +02:00
dependabot[bot] 4b59dd6386 build(deps): bump github/codeql-action from 2.21.9 to 2.22.3
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.9 to 2.22.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ddccb87388...0116bc2df5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-14 02:10:56 +02:00
Oleksandr Redko dd9a341aec Rename 2023-10-06 15:06:37 +02:00
Oleksandr Redko 1d75c512ef chore: rename files according enabled build tags 2023-10-06 15:06:37 +02:00
Ville Skyttä f62f86a84b refactor: make use of strings.Cut 2023-10-06 14:22:22 +02:00
Étienne BERSAC 94632fa21e chore: Use pip3 explicitly to install yamllint
Distribution stends to skip unversionned pip for compatibility issues.
Also, yamllint requires Python 3.8+.

Signed-off-by: Étienne BERSAC <etienne.bersac@dalibo.com>
2023-10-06 14:12:00 +02:00
Étienne BERSAC 3f6cadcbeb chore: Fix copy-paste error for yamllint target
Signed-off-by: Étienne BERSAC <etienne.bersac@dalibo.com>
2023-10-06 14:12:00 +02:00
yhliyr 287507c0b5 docs: add set subset KV example 2023-10-06 14:09:32 +02:00
Mark Sagi-Kazar f1cb2262bb chore(deps): update crypt
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-10-05 22:52:58 +02:00
Oleksandr Redko c292b55050 test: refactor asserts 2023-10-05 00:58:18 +02:00
Oleksandr Redko 3d006fe361 refactor: replace interface{} with any 2023-10-01 17:04:26 +02:00
dependabot[bot] 8a6dc5d43c build(deps): bump github/codeql-action from 2.21.8 to 2.21.9
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.8 to 2.21.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](6a28655e3d...ddccb87388)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-01 15:39:02 +02:00
Oleksandr Redko 96c5c0083f chore: remove deprecated build tags 2023-09-25 13:19:04 +02:00
dependabot[bot] 44911d2cac build(deps): bump github/codeql-action from 2.21.7 to 2.21.8
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.7 to 2.21.8.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](04daf014b5...6a28655e3d)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-25 12:34:26 +02:00
dependabot[bot] a6f8e227bb build(deps): bump github.com/spf13/afero from 1.9.5 to 1.10.0
Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.9.5 to 1.10.0.
- [Release notes](https://github.com/spf13/afero/releases)
- [Commits](https://github.com/spf13/afero/compare/v1.9.5...v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/afero
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-25 12:34:09 +02:00
dependabot[bot] a9437f2500 build(deps): bump actions/checkout from 4.0.0 to 4.1.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](3df4ab11eb...8ade135a41)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-25 12:33:39 +02:00
Mark Sagi-Kazar cae55fefc9 fix: result order by upgrading locafero
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-16 14:01:33 +02:00
Mark Sagi-Kazar f2e0e48e6b fix: compile error
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-16 14:01:33 +02:00
Mark Sagi-Kazar db5aafac4d feat: enable finder tag builds
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-16 14:01:33 +02:00
Mark Sagi-Kazar abbfd91119 feat: replace io fs finder with afero finder
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-16 14:01:33 +02:00
Mark Sagi-Kazar cfa8fd9b4f feat: use new finder library
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-16 14:01:33 +02:00
Oleksandr Redko 6fdfebc843 Fix tests on Windows 2023-09-16 13:48:38 +02:00
Oleksandr Redko 4aeec5882c Remove usages of deprecated io/ioutil; simplify tests 2023-09-16 13:48:38 +02:00
dependabot[bot] f683416bfb build(deps): bump github/codeql-action from 2.21.6 to 2.21.7
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.6 to 2.21.7.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](701f152f28...04daf014b5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-16 13:47:30 +02:00
dependabot[bot] 336e9f0a93 build(deps): bump github/codeql-action from 2.21.5 to 2.21.6
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.5 to 2.21.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](00e563ead9...701f152f28)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-13 23:05:26 +02:00
Mark Sagi-Kazar 58b177a8c0 fix: lint violations
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-13 16:24:59 +02:00
Mark Sagi-Kazar 2672f3e4d3 refactor: drop unused jww code
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-13 16:24:59 +02:00
Mark Sagi-Kazar 0c5594ae7a feat: deprecate logger interface
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-13 16:24:59 +02:00
Mark Sagi-Kazar d16deb4b93 feat: add slog support
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-13 16:24:59 +02:00
Mark Sagi-Kazar d4c2f2ef40 feat!: bump minimum Go version to 1.19
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-12 00:17:53 +02:00
dependabot[bot] c78218cb99 build(deps): bump actions/dependency-review-action from 3.0.8 to 3.1.0
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 3.0.8 to 3.1.0.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](f6fff72a32...6c5ccdad46)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-09 07:55:48 +02:00
John Hooks 1e811d1f02 Add NATS support 2023-09-08 15:32:50 +02:00
Mark Sagi-Kazar d5c5c83bfc ci: add Go 1.21 to the test matrix
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-08 15:30:13 +02:00
Mark Sagi-Kazar b425370376 chore(deps): update crypt
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-08 15:29:58 +02:00
dependabot[bot] 27914f862f build(deps): bump cachix/install-nix-action from 22 to 23
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 22 to 23.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](6ed004b9cc...6a9a9e84a1)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-08 14:23:57 +02:00
dependabot[bot] 3718c2ec5a build(deps): bump github.com/subosito/gotenv from 1.4.2 to 1.6.0
Bumps [github.com/subosito/gotenv](https://github.com/subosito/gotenv) from 1.4.2 to 1.6.0.
- [Changelog](https://github.com/subosito/gotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/subosito/gotenv/compare/v1.4.2...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/subosito/gotenv
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-08 14:23:33 +02:00
Oleksandr Redko 13dbfcafff test: remove testutil.Setenv as not needed from Go 1.17 2023-09-07 13:33:21 +02:00
Oleksandr Redko a0696bbc97 docs: fix typos in comments 2023-09-07 13:32:51 +02:00
dependabot[bot] c63105849f build(deps): bump actions/setup-go from 4.0.1 to 4.1.0
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4.0.1 to 4.1.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](fac708d667...93397bea11)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-07 12:53:14 +02:00
dependabot[bot] 2bd8c8e48d build(deps): bump golangci/golangci-lint-action from 3.6.0 to 3.7.0
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.6.0 to 3.7.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](639cd343e1...3a91952989)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-07 12:27:58 +02:00
dependabot[bot] 0195f11e50 build(deps): bump actions/dependency-review-action from 3.0.6 to 3.0.8
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 3.0.6 to 3.0.8.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](1360a344cc...f6fff72a32)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-07 12:27:42 +02:00
dependabot[bot] 64661d4342 build(deps): bump github.com/pelletier/go-toml/v2 from 2.0.9 to 2.1.0
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.9 to 2.1.0.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.9...v2.1.0)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-07 12:27:28 +02:00
dependabot[bot] 59cd02f67b build(deps): bump github/codeql-action from 2.21.2 to 2.21.5
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.2 to 2.21.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](0ba4244466...00e563ead9)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-07 12:27:14 +02:00
dependabot[bot] 7b2db61200 build(deps): bump actions/checkout from 3.5.3 to 4.0.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 4.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](c85c95e3d7...3df4ab11eb)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-07 12:27:00 +02:00
Andres Taylor 24cfadcf0f Add Vitess to list of projects using Viper
Signed-off-by: Andres Taylor <andres@planetscale.com>
2023-09-07 12:26:29 +02:00
StepSecurity Bot b77f4c1928 [StepSecurity] ci: Harden GitHub Actions
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
2023-08-04 11:38:34 +02:00
guangwu cb9b2bffc2
fix: code optimization (#1557)
* fix: code optimization

* fix: golangci-lint
2023-07-27 20:56:32 +02:00
Mark Sagi-Kazar c5102bdba0 chore: upgrade crypt
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-07-21 16:13:01 +02:00
dependabot[bot] 706ccb68a4 build(deps): bump github.com/pelletier/go-toml/v2 from 2.0.8 to 2.0.9
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.8 to 2.0.9.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.8...v2.0.9)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-15 12:35:25 +02:00
dependabot[bot] 097e0d888f build(deps): bump cachix/install-nix-action from 21 to 22
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 21 to 22.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](4b933aa7eb...6ed004b9cc)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-29 06:50:12 +02:00
Mark Sagi-Kazar 961c39613b ci: add misc release note label
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-06-29 06:26:02 +02:00
Mark Sagi-Kazar bb60a768c5 chore: improve dev env
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-06-29 06:26:02 +02:00
Mark Sagi-Kazar bec1fce61d ci: update golangci-lint
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-06-29 06:26:02 +02:00
Mark Sagi-Kazar 76acbbdbb2 feat: drop support for Go 1.17
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-06-29 05:58:30 +02:00
Baruch Odem 731a91be43 feat: add func GetEnvPrefix 2023-06-29 05:37:45 +02:00
Mark Sagi-Kazar 31af6d09c2 ci: rename yml to yaml
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-06-29 05:37:25 +02:00
Mark Sagi-Kazar 74c53b7580 chore: update pr checks
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-06-29 05:37:25 +02:00
Mark Sagi-Kazar 351365dbe1 chore: add local development environment using nix
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-06-29 05:37:25 +02:00
dependabot[bot] a362607d5f build(deps): bump github.com/stretchr/testify from 1.8.3 to 1.8.4
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.3 to 1.8.4.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.3...v1.8.4)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-28 18:59:50 +02:00
dependabot[bot] 5f51413ed2 build(deps): bump mheap/github-action-required-labels from 4 to 5
Bumps [mheap/github-action-required-labels](https://github.com/mheap/github-action-required-labels) from 4 to 5.
- [Release notes](https://github.com/mheap/github-action-required-labels/releases)
- [Commits](https://github.com/mheap/github-action-required-labels/compare/v4...v5)

---
updated-dependencies:
- dependency-name: mheap/github-action-required-labels
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-28 18:59:38 +02:00
goldeneggg 0520e750b5 swap the order of actions/checkout@v3 and actions/setup-go@v4 2023-06-04 02:35:38 +02:00
andig 21a7fd828e
Allow ConfigParseError to unwrap (#1433)
* Allow ConfigParseError to unwrap

* wip

* Avoid pointer type
2023-05-30 12:07:27 +02:00
Márk Sági-Kazár 53cdb5253a chore: improve log messages 2023-05-29 15:43:38 +02:00
Quentin Burgess 24ece16a9a drop std' logger in favor of jww one 2023-05-29 15:43:38 +02:00
Quentin Burgess 98b1b9fd42 add:viper: allow to disable internal log messages 2023-05-29 15:43:38 +02:00
VOrishirne 2ee16310d0 extend viper's pflag binding to stringToInt pflag 2023-05-29 15:34:52 +02:00
Ben Potter 86520578dc docs: Coder uses Viper 2023-05-29 15:32:18 +02:00
dependabot[bot] b850f3448f build(deps): bump github.com/pelletier/go-toml/v2 from 2.0.7 to 2.0.8
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.7 to 2.0.8.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.7...v2.0.8)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-29 15:16:39 +02:00
Cédric Fabianski 23b123aba9 doc: add bearer/bearer as projects using Viper 2023-05-29 15:16:28 +02:00
Deleplace a0fed9f570 Update main image to better handle dark background 2023-05-29 14:52:14 +02:00
dependabot[bot] 143e3bc9d9 build(deps): bump github.com/stretchr/testify from 1.8.2 to 1.8.3
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.2 to 1.8.3.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.2...v1.8.3)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-29 14:50:48 +02:00
dependabot[bot] 9bfa0ccd19 build(deps): bump github.com/spf13/cast from 1.5.0 to 1.5.1
Bumps [github.com/spf13/cast](https://github.com/spf13/cast) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/spf13/cast/releases)
- [Commits](https://github.com/spf13/cast/compare/v1.5.0...v1.5.1)

---
updated-dependencies:
- dependency-name: github.com/spf13/cast
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-29 14:50:32 +02:00
dependabot[bot] 9aa0336962 build(deps): bump github.com/sagikazarmark/crypt from 0.9.0 to 0.10.0
Bumps [github.com/sagikazarmark/crypt](https://github.com/sagikazarmark/crypt) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/sagikazarmark/crypt/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: github.com/sagikazarmark/crypt
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-27 00:13:40 +02:00
Azanul Haque f74916adfa ADD Meshery to projects 2023-04-19 10:29:14 +02:00
dependabot[bot] adc3a873f0 build(deps): bump github.com/spf13/afero from 1.9.3 to 1.9.5
Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.9.3 to 1.9.5.
- [Release notes](https://github.com/spf13/afero/releases)
- [Commits](https://github.com/spf13/afero/compare/v1.9.3...v1.9.5)

---
updated-dependencies:
- dependency-name: github.com/spf13/afero
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-07 19:39:06 +00:00
Mark Sagi-Kazar 995db99714 test: fix test to actually assert something
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-04-06 11:12:29 +02:00
Mark Sagi-Kazar 8d1fb59230 chore: update linter
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-04-06 11:12:29 +02:00
Mark Sagi-Kazar 59fe4dbc92 ci: add Go 1.20 to build matrix
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-04-06 11:12:29 +02:00
dependabot[bot] e2cc9031b5 build(deps): bump github.com/stretchr/testify from 1.8.1 to 1.8.2
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.1 to 1.8.2.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.1...v1.8.2)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-06 08:52:37 +00:00
dependabot[bot] ff77ba015e build(deps): bump github.com/pelletier/go-toml/v2 from 2.0.6 to 2.0.7
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.6 to 2.0.7.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.6...v2.0.7)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-06 08:52:08 +00:00
dependabot[bot] 6393b67401 build(deps): bump golang.org/x/net from 0.4.0 to 0.7.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.4.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.4.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-06 08:51:38 +00:00
dependabot[bot] 28997ba8e9 build(deps): bump actions/setup-go from 3 to 4
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-06 08:51:00 +00:00
dependabot[bot] 1663811850 build(deps): bump mheap/github-action-required-labels from 3 to 4
Bumps [mheap/github-action-required-labels](https://github.com/mheap/github-action-required-labels) from 3 to 4.
- [Release notes](https://github.com/mheap/github-action-required-labels/releases)
- [Commits](https://github.com/mheap/github-action-required-labels/compare/v3...v4)

---
updated-dependencies:
- dependency-name: mheap/github-action-required-labels
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-06 08:50:42 +00:00
Márk Sági-Kazár 34d6318c0b chore: fix typo 2023-03-31 13:08:16 +02:00
Yoofi Quansah c6ba8f4702 fix: fix typo 2023-03-31 13:08:16 +02:00
TaylorOno 3970ad177e Preserve envPrefix in Sub 2023-02-25 22:17:36 +01:00
TaylorOno 3f4449054d Sub inerits from automaticEnvApplied and envKeyReplacer
parents are tracked so sub(x).sub(y).GetString(z) looks up x.y.z
2023-02-25 22:17:36 +01:00
Dawid Urbański c898f59d33
fix: time.Duration slice type conversion (#1498)
* fix DurationSlice

* Fix typo

---------

Co-authored-by: Márk Sági-Kazár <sagikazarmark@users.noreply.github.com>
2023-02-05 18:30:05 +01:00
glebik000 5182412574
Add DocBlock to WatchConfig (#1467)
* Add DocBlock to WatchConfig

Added a small description of the WatchConfig().
So that you can understand in the ide why you could use it.

* Update viper.go

* update viper.go

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Co-authored-by: Márk Sági-Kazár <sagikazarmark@users.noreply.github.com>
Co-authored-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-01-19 16:38:18 +01:00
Astone 0755477020 feat: add multiple endpoints support for remote 2023-01-19 16:34:22 +01:00
dependabot[bot] a7ad8cfcc4 build(deps): bump github.com/sagikazarmark/crypt from 0.8.0 to 0.9.0
Bumps [github.com/sagikazarmark/crypt](https://github.com/sagikazarmark/crypt) from 0.8.0 to 0.9.0.
- [Release notes](https://github.com/sagikazarmark/crypt/releases)
- [Commits](https://github.com/sagikazarmark/crypt/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: github.com/sagikazarmark/crypt
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-19 15:27:42 +00:00
dependabot[bot] 63630c2fcd build(deps): bump github.com/subosito/gotenv from 1.4.1 to 1.4.2
Bumps [github.com/subosito/gotenv](https://github.com/subosito/gotenv) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/subosito/gotenv/releases)
- [Changelog](https://github.com/subosito/gotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/subosito/gotenv/compare/v1.4.1...v1.4.2)

---
updated-dependencies:
- dependency-name: github.com/subosito/gotenv
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-19 15:20:14 +00:00
Mark Sagi-Kazar 996ab10214 ci: update golangci-lint
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-01-19 16:18:37 +01:00
Mark Sagi-Kazar 982460e8e1 feat!: drop Go 1.16 support
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-01-19 16:18:37 +01:00
Mark Sagi-Kazar 2f5cb62e1f ci: cleanup tags
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-01-19 16:02:48 +01:00
Mark Sagi-Kazar 77fc1c3084 feat!: drop toml v1 support
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-01-19 16:02:48 +01:00
Mark Sagi-Kazar e42b933dbe feat!: drop yaml v2 support
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-01-19 16:02:48 +01:00
dependabot[bot] 9e46b7652f build(deps): bump mheap/github-action-required-labels from 2 to 3
Bumps [mheap/github-action-required-labels](https://github.com/mheap/github-action-required-labels) from 2 to 3.
- [Release notes](https://github.com/mheap/github-action-required-labels/releases)
- [Commits](https://github.com/mheap/github-action-required-labels/compare/v2...v3)

---
updated-dependencies:
- dependency-name: mheap/github-action-required-labels
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-18 23:27:40 +00:00
Adam Williams ce73936440 Provide a link to explain what a 12-factor app is 2023-01-08 23:39:46 +01:00
Ahra Cho 9da88d94fa Update badge route 2022-12-26 21:01:12 +01:00
dependabot[bot] ab1367a4d9 build(deps): bump github.com/pelletier/go-toml/v2 from 2.0.5 to 2.0.6
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.5 to 2.0.6.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.5...v2.0.6)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-14 12:41:13 +00:00
dependabot[bot] 41d75b2770 build(deps): bump github.com/magiconair/properties from 1.8.6 to 1.8.7
Bumps [github.com/magiconair/properties](https://github.com/magiconair/properties) from 1.8.6 to 1.8.7.
- [Release notes](https://github.com/magiconair/properties/releases)
- [Changelog](https://github.com/magiconair/properties/blob/main/CHANGELOG.md)
- [Commits](https://github.com/magiconair/properties/compare/v1.8.6...v1.8.7)

---
updated-dependencies:
- dependency-name: github.com/magiconair/properties
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-08 19:12:13 +00:00
dependabot[bot] 38b5494903 build(deps): bump github.com/spf13/afero from 1.9.2 to 1.9.3
Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.9.2 to 1.9.3.
- [Release notes](https://github.com/spf13/afero/releases)
- [Commits](https://github.com/spf13/afero/compare/v1.9.2...v1.9.3)

---
updated-dependencies:
- dependency-name: github.com/spf13/afero
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-08 19:11:54 +00:00
Mark Sagi-Kazar b89e554a96 chore: update crypt
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-11-06 14:19:33 +01:00
Mark Sagi-Kazar db9f89ac41 chore: disable watch on appengine
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-11-06 03:22:10 +01:00
Mark Sagi-Kazar 4b8d14881e refactor: use new Has fsnotify method for event matching
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-11-04 05:39:26 +01:00
Mark Sagi-Kazar 2e99a57324 refactor: rename watch file to unsupported
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-11-04 03:17:49 +01:00
Mark Sagi-Kazar dcb7f30f39 feat: fix compilation for all platforms unsupported by fsnotify
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-11-04 03:17:49 +01:00
Mark Sagi-Kazar 2e04739b68 ci: drop dedicated wasm build
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-11-04 03:17:49 +01:00
Mark Sagi-Kazar b2234f214f ci: add build for aix
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-11-04 03:17:49 +01:00
Mark Sagi-Kazar 52009d3493 feat: disable watcher on aix
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-11-04 03:17:49 +01:00
dependabot[bot] b274f639e0 build(deps): bump github.com/fsnotify/fsnotify from 1.5.4 to 1.6.0
Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.5.4 to 1.6.0.
- [Release notes](https://github.com/fsnotify/fsnotify/releases)
- [Changelog](https://github.com/fsnotify/fsnotify/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fsnotify/fsnotify/compare/v1.5.4...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/fsnotify/fsnotify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-03 17:20:38 +01:00
dependabot[bot] 7c62cfdbac build(deps): bump github.com/stretchr/testify from 1.8.0 to 1.8.1
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.0...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-03 17:19:37 +01:00
dependabot[bot] f1d2c470bf build(deps): bump github.com/sagikazarmark/crypt from 0.6.0 to 0.7.0
Bumps [github.com/sagikazarmark/crypt](https://github.com/sagikazarmark/crypt) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/sagikazarmark/crypt/releases)
- [Commits](https://github.com/sagikazarmark/crypt/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: github.com/sagikazarmark/crypt
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-27 21:07:24 +00:00
dependabot[bot] 419fd86e49 build(deps): bump github.com/spf13/afero from 1.8.2 to 1.9.2
Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.8.2 to 1.9.2.
- [Release notes](https://github.com/spf13/afero/releases)
- [Commits](https://github.com/spf13/afero/compare/v1.8.2...v1.9.2)

---
updated-dependencies:
- dependency-name: github.com/spf13/afero
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-06 14:46:54 +02:00
Mark Sagi-Kazar 91aa484d1d chore: drop support for Go 1.15
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-09-06 14:28:48 +02:00
Mark Sagi-Kazar 57cc9a000f test: fix ini tests
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-09-06 11:57:54 +02:00
dependabot[bot] 8030d5b976 build(deps): bump gopkg.in/ini.v1 from 1.66.4 to 1.67.0
Bumps [gopkg.in/ini.v1](https://github.com/go-ini/ini) from 1.66.4 to 1.67.0.
- [Release notes](https://github.com/go-ini/ini/releases)
- [Commits](https://github.com/go-ini/ini/compare/v1.66.4...v1.67.0)

---
updated-dependencies:
- dependency-name: gopkg.in/ini.v1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-06 11:57:54 +02:00
Brad P. Crochet 312417a0c5 Add a DebugTo convenience funtion
One might want to write the debug information somewhere other than
Stdout. This patch adss a DebugTo function and method, that accepts
an io.Writer. It changes the original Debug implementation to call
this new function with a default of os.Stdout, which maintains
backward compatibility.

Signed-off-by: Brad P. Crochet <brad@redhat.com>
2022-09-06 11:14:22 +02:00
Christian Banse 202060b3a2 Adds support for uint16 with GetUint16
We have encountered numerous places where it is convenient to have viper return a `uint16` value, especially in combination with the new `netip` package  that represents a port correctly as `uint16` rather than just an `int`. cobra already supports this, but we need a conversion from the existing `GetUint` method in viper.
2022-09-04 03:07:23 +02:00
Mark Sagi-Kazar 97591f0083 build: fix lint violations
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-09-03 19:07:15 +02:00
Mark Sagi-Kazar 9af8daeeab ci: upgrade golangci-lint
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-09-03 19:07:15 +02:00
Mark Sagi-Kazar 7b4f2b27cd ci: add Go 1.19 to CI
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-09-03 19:07:15 +02:00
Mark Sagi-Kazar 601ec815ba test: fix toml tests
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-09-03 17:33:50 +02:00
dependabot[bot] d7f4832bd3 build(deps): bump github.com/pelletier/go-toml/v2 from 2.0.2 to 2.0.5
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.2 to 2.0.5.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.2...v2.0.5)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-03 17:33:50 +02:00
dependabot[bot] c2f42f3060 build(deps): bump github.com/subosito/gotenv from 1.4.0 to 1.4.1
Bumps [github.com/subosito/gotenv](https://github.com/subosito/gotenv) from 1.4.0 to 1.4.1.
- [Release notes](https://github.com/subosito/gotenv/releases)
- [Changelog](https://github.com/subosito/gotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/subosito/gotenv/compare/v1.4.0...v1.4.1)

---
updated-dependencies:
- dependency-name: github.com/subosito/gotenv
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-03 13:54:00 +02:00
Andrew Richardson 5247643f02 Recurse into arrays when converting keys to lowercase
Fixes #1386

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
2022-07-12 18:10:05 +02:00
Kevin Franklin Kim 98c63ede11 feat: check providers and log error 2022-07-10 13:48:18 +02:00
Kevin Franklin Kim 1bc0a5ac7a add etcd3 to supported providers 2022-07-10 13:48:18 +02:00
Sungyun Hur a4e4f65a0c Update README.md 2022-07-10 12:51:24 +02:00
dependabot[bot] d55cd57115 build(deps): bump github.com/stretchr/testify from 1.7.4 to 1.8.0
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.4 to 1.8.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.4...v1.8.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-10 12:35:00 +02:00
dependabot[bot] 0add84cdf2 build(deps): bump mheap/github-action-required-labels from 1 to 2
Bumps [mheap/github-action-required-labels](https://github.com/mheap/github-action-required-labels) from 1 to 2.
- [Release notes](https://github.com/mheap/github-action-required-labels/releases)
- [Commits](https://github.com/mheap/github-action-required-labels/compare/v1...v2)

---
updated-dependencies:
- dependency-name: mheap/github-action-required-labels
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-21 20:15:53 +02:00
dependabot[bot] 501b966b5d build(deps): bump github.com/stretchr/testify from 1.7.3 to 1.7.4
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.3 to 1.7.4.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.3...v1.7.4)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-21 20:15:04 +02:00
dependabot[bot] bd03e926b9 build(deps): bump github.com/stretchr/testify from 1.7.2 to 1.7.3
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.2 to 1.7.3.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.2...v1.7.3)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-20 20:02:32 +02:00
mjmaisey b1b8b3d4d4 Fix go-staticcheck failures (ST1005)
Fix to example code, which fails static checks related to acceptable formats of error strings if used.
2022-06-16 21:19:37 +02:00
dependabot[bot] 2b83d46130 build(deps): bump github.com/pelletier/go-toml/v2 from 2.0.1 to 2.0.2
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.1 to 2.0.2.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.1...v2.0.2)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-09 19:50:27 +02:00
dependabot[bot] 22b9573a99 build(deps): bump github.com/subosito/gotenv from 1.3.0 to 1.4.0
Bumps [github.com/subosito/gotenv](https://github.com/subosito/gotenv) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/subosito/gotenv/releases)
- [Changelog](https://github.com/subosito/gotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/subosito/gotenv/compare/v1.3.0...v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/subosito/gotenv
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-07 20:44:09 +02:00
dependabot[bot] 32d4cbb62f build(deps): bump github.com/stretchr/testify from 1.7.1 to 1.7.2
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.1 to 1.7.2.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.1...v1.7.2)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-07 13:01:18 +02:00
Mark Sagi-Kazar 4322cf20e9 feat: make toml2 the default
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-05-26 17:48:00 +02:00
Mark Sagi-Kazar 8d0299919d feat: make yaml3 the default
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-05-26 17:27:50 +02:00
Mark Sagi-Kazar 7c35aa91d2 chore(deps): update yaml3
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-05-26 17:27:50 +02:00
Mark Sagi-Kazar 433821fa47 feat: add etcd3 support to remote
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-05-26 17:01:59 +02:00
Mark Sagi-Kazar 2080d43fa5 chore: update crypt
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-05-26 17:01:59 +02:00
Wade Carpenter da55858fff chore: fix Error log calls in mergeMaps
The logger interface uses k,v pairs, but it was being called with a
format string, here.

Changed to use k,v pairs.

I didn't find any other instances of this problem.
2022-05-26 16:01:47 +02:00
Michael Wilson f50ce904a9 Add in MustBindEnv.
Adds in a MustBindEnv function which will panic if BindEnv fails.
2022-05-26 15:53:50 +02:00
dependabot[bot] 3b836e5088 build(deps): bump github.com/subosito/gotenv from 1.2.0 to 1.3.0
Bumps [github.com/subosito/gotenv](https://github.com/subosito/gotenv) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/subosito/gotenv/releases)
- [Changelog](https://github.com/subosito/gotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/subosito/gotenv/compare/v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/subosito/gotenv
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-26 15:47:59 +02:00
dependabot[bot] 5d65186f1e build(deps): bump github.com/pelletier/go-toml/v2 from 2.0.0 to 2.0.1
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.0 to 2.0.1.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-12 15:36:00 +02:00
dependabot[bot] 9f85518c5d build(deps): bump github.com/spf13/cast from 1.4.1 to 1.5.0
Bumps [github.com/spf13/cast](https://github.com/spf13/cast) from 1.4.1 to 1.5.0.
- [Release notes](https://github.com/spf13/cast/releases)
- [Commits](https://github.com/spf13/cast/compare/v1.4.1...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cast
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-12 11:46:19 +02:00
dependabot[bot] ffad330c91 build(deps): bump github.com/fsnotify/fsnotify from 1.5.1 to 1.5.4
Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.5.1 to 1.5.4.
- [Release notes](https://github.com/fsnotify/fsnotify/releases)
- [Changelog](https://github.com/fsnotify/fsnotify/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fsnotify/fsnotify/compare/v1.5.1...v1.5.4)

---
updated-dependencies:
- dependency-name: github.com/fsnotify/fsnotify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 19:31:41 +02:00
dependabot[bot] 5f023c7e56 build(deps): bump github.com/pelletier/go-toml from 1.9.4 to 1.9.5
Bumps [github.com/pelletier/go-toml](https://github.com/pelletier/go-toml) from 1.9.4 to 1.9.5.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Commits](https://github.com/pelletier/go-toml/compare/v1.9.4...v1.9.5)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 19:29:38 +02:00
dependabot[bot] 55a46638f2 build(deps): bump github.com/mitchellh/mapstructure from 1.4.3 to 1.5.0
Bumps [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) from 1.4.3 to 1.5.0.
- [Release notes](https://github.com/mitchellh/mapstructure/releases)
- [Changelog](https://github.com/mitchellh/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mitchellh/mapstructure/compare/v1.4.3...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/mitchellh/mapstructure
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 16:55:51 +02:00
dependabot[bot] 4eb3e0bc2f build(deps): bump github.com/pelletier/go-toml/v2
Bumps [github.com/pelletier/go-toml/v2](https://github.com/pelletier/go-toml) from 2.0.0-beta.8 to 2.0.0.
- [Release notes](https://github.com/pelletier/go-toml/releases)
- [Changelog](https://github.com/pelletier/go-toml/blob/v2/.goreleaser.yaml)
- [Commits](https://github.com/pelletier/go-toml/compare/v2.0.0-beta.8...v2.0.0)

---
updated-dependencies:
- dependency-name: github.com/pelletier/go-toml/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 12:13:36 +02:00
dependabot[bot] 81089eeca9 build(deps): bump github/codeql-action from 1 to 2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-27 03:35:43 +02:00
Mark Sagi-Kazar 5243f253fc
chore: rename files to yaml
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-04-14 01:05:39 +02:00
72 changed files with 2516 additions and 2830 deletions

View file

@ -11,5 +11,8 @@ trim_trailing_whitespace = true
[*.go]
indent_style = tab
[{Makefile, *.mk}]
[{Makefile,*.mk}]
indent_style = tab
[*.nix]
indent_size = 2

4
.envrc Normal file
View file

@ -0,0 +1,4 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
fi
use flake . --impure

BIN
.github/logo.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

@ -11,8 +11,20 @@ jobs:
steps:
- name: Check minimum labels
uses: mheap/github-action-required-labels@v1
uses: mheap/github-action-required-labels@5847eef68201219cf0a4643ea7be61e77837bbce # v5.4.1
with:
mode: minimum
count: 1
labels: "release-note/ignore, kind/feature, release-note/new-feature, kind/enhancement, release-note/enhancement, kind/bug, release-note/bug-fix, release-note/breaking-change, release-note/deprecation, area/dependencies, release-note/dependency-update"
labels: |
release-note/ignore
kind/feature
release-note/new-feature
kind/enhancement
release-note/enhancement
kind/bug
release-note/bug-fix
release-note/breaking-change
release-note/deprecation
area/dependencies
release-note/dependency-update
release-note/misc

115
.github/workflows/ci.yaml vendored Normal file
View file

@ -0,0 +1,115 @@
name: CI
on:
push:
branches: [master]
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: js
goarch: wasm
- goos: aix
goarch: ppc64
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Set up Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: "1.22"
- name: Build
run: go build .
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
# Fail fast is disabled because there are Go version specific features and tests
# that should be able to fail independently.
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: ["1.20", "1.21", "1.22"]
tags: ["", "finder", "viper_bind_struct"]
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Set up Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: ${{ matrix.go }}
- name: Test
run: go test -race -v -tags '${{ matrix.tags }}' -shuffle=on ./...
if: runner.os != 'Windows'
- name: Test (without race detector)
run: go test -v -tags '${{ matrix.tags }}' -shuffle=on ./...
if: runner.os == 'Windows'
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Set up Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: "1.22"
- name: Lint
uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1
with:
version: v1.56.1
dev:
name: Developer environment
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Set up Nix
uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b # v27
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Check
run: nix flake check --impure
- name: Dev shell
run: nix develop --impure
dependency-review:
name: Dependency review
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Dependency Review
uses: actions/dependency-review-action@0c155c5e8556a497adf53f2c18edabf945ed8e70 # v4.3.2

View file

@ -1,59 +0,0 @@
name: CI
on:
push:
branches:
- master
pull_request:
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
# Fail fast is disabled because there are Go version specific features and tests
# that should be able to fail independently.
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: ['1.15', '1.16', '1.17', '1.18']
tags: ['', 'viper_yaml3', 'viper_toml2']
env:
GOFLAGS: -mod=readonly
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Checkout code
uses: actions/checkout@v3
- name: Test
run: go test -race -tags '${{ matrix.tags }}' -v ./...
if: runner.os != 'Windows'
- name: Test (without race detector)
run: go test -tags '${{ matrix.tags }}' -v ./...
if: runner.os == 'Windows'
lint:
name: Lint
runs-on: ubuntu-latest
env:
GOFLAGS: -mod=readonly
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: Checkout code
uses: actions/checkout@v3
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2

View file

@ -39,11 +39,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@ -68,5 +68,5 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7

View file

@ -6,7 +6,7 @@ jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |

View file

@ -6,7 +6,7 @@ jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |

View file

@ -1,26 +0,0 @@
name: WASM
on:
push:
branches:
- master
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
GOFLAGS: -mod=readonly
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.17'
- name: Checkout code
uses: actions/checkout@v3
- name: Ensure Viper compiles for WASM
run: GOOS=js GOARCH=wasm go build .

3
.gitignore vendored
View file

@ -1,4 +1,7 @@
/.devenv/
/.direnv/
/.idea/
/.pre-commit-config.yaml
/bin/
/build/
/var/

View file

@ -7,6 +7,16 @@ linters-settings:
- standard
- default
- prefix(github.com/spf13/viper)
gocritic:
# Enable multiple checks by tags. See "Tags" section in https://github.com/go-critic/go-critic#usage.
enabled-tags:
- diagnostic
- experimental
- opinionated
- style
disabled-checks:
- importShadow
- unnamedResult
golint:
min-confidence: 0
goimports:
@ -16,13 +26,14 @@ linters:
disable-all: true
enable:
- bodyclose
- deadcode
- dogsled
- dupl
- durationcheck
- exhaustive
- exportloopref
- gci
- gocritic
- godot
- gofmt
- gofumpt
- goimports
@ -43,14 +54,12 @@ linters:
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- tparallel
- typecheck
- unconvert
- unparam
- unused
- varcheck
- wastedassign
- whitespace
@ -65,9 +74,7 @@ linters:
# - gochecknoinits
# - gocognit
# - goconst
# - gocritic
# - gocyclo
# - godot
# - gosec
# - gosimple
# - ifshort
@ -83,6 +90,11 @@ linters:
# - goheader
# - gomodguard
# deprecated
# - deadcode
# - structcheck
# - varcheck
# don't enable:
# - asciicheck
# - funlen

2
.yamlignore Normal file
View file

@ -0,0 +1,2 @@
# TODO: FIXME
/.github/

6
.yamllint.yaml Normal file
View file

@ -0,0 +1,6 @@
ignore-from-file: [.gitignore, .yamlignore]
extends: default
rules:
line-length: disable

View file

@ -15,8 +15,8 @@ TEST_FORMAT = short-verbose
endif
# Dependency versions
GOTESTSUM_VERSION = 1.8.0
GOLANGCI_VERSION = 1.45.2
GOTESTSUM_VERSION = 1.9.0
GOLANGCI_VERSION = 1.53.3
# Add the ability to override some variables
# Use with care
@ -29,11 +29,6 @@ clear: ## Clear the working area and the project
.PHONY: check
check: test lint ## Run tests and linters
bin/gotestsum: bin/gotestsum-${GOTESTSUM_VERSION}
@ln -sf gotestsum-${GOTESTSUM_VERSION} bin/gotestsum
bin/gotestsum-${GOTESTSUM_VERSION}:
@mkdir -p bin
curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum-${GOTESTSUM_VERSION} && chmod +x ./bin/gotestsum-${GOTESTSUM_VERSION}
TEST_PKGS ?= ./...
.PHONY: test
@ -44,20 +39,36 @@ test: bin/gotestsum ## Run tests
@mkdir -p ${BUILD_DIR}
bin/gotestsum --no-summary=skipped --junitfile ${BUILD_DIR}/coverage.xml --format ${TEST_FORMAT} -- -race -coverprofile=${BUILD_DIR}/coverage.txt -covermode=atomic $(filter-out -v,${GOARGS}) $(if ${TEST_PKGS},${TEST_PKGS},./...)
bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION}
@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
bin/golangci-lint-${GOLANGCI_VERSION}:
@mkdir -p bin
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ./bin/ v${GOLANGCI_VERSION}
@mv bin/golangci-lint "$@"
.PHONY: lint
lint: bin/golangci-lint ## Run linter
bin/golangci-lint run
lint: lint-go lint-yaml
lint: ## Run linters
.PHONY: fix
fix: bin/golangci-lint ## Fix lint violations
bin/golangci-lint run --fix
.PHONY: lint-go
lint-go:
golangci-lint run $(if ${CI},--out-format github-actions,)
.PHONY: lint-yaml
lint-yaml:
yamllint $(if ${CI},-f github,) --no-warnings .
.PHONY: fmt
fmt: ## Format code
golangci-lint run --fix
deps: bin/golangci-lint bin/gotestsum yamllint
deps: ## Install dependencies
bin/gotestsum:
@mkdir -p bin
curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum && chmod +x ./bin/gotestsum
bin/golangci-lint:
@mkdir -p bin
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- v${GOLANGCI_VERSION}
.PHONY: yamllint
yamllint:
pip3 install --user yamllint
# Add custom targets here
-include custom.mk

View file

@ -8,10 +8,10 @@
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/avelino/awesome-go#configuration)
[![run on repl.it](https://repl.it/badge/github/sagikazarmark/Viper-example)](https://repl.it/@sagikazarmark/Viper-example#main.go)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/spf13/viper/CI?style=flat-square)](https://github.com/spf13/viper/actions?query=workflow%3ACI)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/spf13/viper/ci.yaml?branch=master&style=flat-square)](https://github.com/spf13/viper/actions?query=workflow%3ACI)
[![Join the chat at https://gitter.im/spf13/viper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/spf13/viper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Go Report Card](https://goreportcard.com/badge/github.com/spf13/viper?style=flat-square)](https://goreportcard.com/report/github.com/spf13/viper)
![Go Version](https://img.shields.io/badge/go%20version-%3E=1.15-61CFDD.svg?style=flat-square)
![Go Version](https://img.shields.io/badge/go%20version-%3E=1.20-61CFDD.svg?style=flat-square)
[![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/spf13/viper)](https://pkg.go.dev/mod/github.com/spf13/viper)
**Go configuration with fangs!**
@ -27,6 +27,10 @@ Many Go projects are built using Viper including:
* [doctl](https://github.com/digitalocean/doctl)
* [Clairctl](https://github.com/jgsqware/clairctl)
* [Mercure](https://mercure.rocks)
* [Meshery](https://github.com/meshery/meshery)
* [Bearer](https://github.com/bearer/bearer)
* [Coder](https://github.com/coder/coder)
* [Vitess](https://vitess.io/)
## Install
@ -35,13 +39,13 @@ Many Go projects are built using Viper including:
go get github.com/spf13/viper
```
**Note:** Viper uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.
**Note:** Viper uses [Go Modules](https://go.dev/wiki/Modules) to manage dependencies.
## What is Viper?
Viper is a complete configuration solution for Go applications including 12-Factor apps. It is designed
to work within an application, and can handle all types of configuration needs
Viper is a complete configuration solution for Go applications including [12-Factor apps](https://12factor.net/#the_twelve_factors).
It is designed to work within an application, and can handle all types of configuration needs
and formats. It supports:
* setting defaults
@ -119,7 +123,7 @@ viper.AddConfigPath("$HOME/.appname") // call multiple times to add many search
viper.AddConfigPath(".") // optionally look for config in the working directory
err := viper.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
panic(fmt.Errorf("Fatal error config file: %w \n", err))
panic(fmt.Errorf("fatal error config file: %w", err))
}
```
@ -137,7 +141,7 @@ if err := viper.ReadInConfig(); err != nil {
// Config file found and successfully parsed
```
*NOTE [since 1.6]:* You can also have a file without an extension and specify the format programmaticaly. For those configuration files that lie in the home of the user without any extension like `.bashrc`
*NOTE [since 1.6]:* You can also have a file without an extension and specify the format programmatically. For those configuration files that lie in the home of the user without any extension like `.bashrc`
### Writing Config Files
@ -218,6 +222,7 @@ These could be from a command line flag, or from your own application logic.
```go
viper.Set("Verbose", true)
viper.Set("LogFile", LogFile)
viper.Set("host.port", 5899) // set subset
```
### Registering and Using Aliases
@ -413,7 +418,9 @@ in a Key/Value store such as etcd or Consul. These values take precedence over
default values, but are overridden by configuration values retrieved from disk,
flags, or environment variables.
Viper uses [crypt](https://github.com/bketelsen/crypt) to retrieve
Viper supports multiple hosts. To use, pass a list of endpoints separated by `;`. For example `http://127.0.0.1:4001;http://127.0.0.1:4002`.
Viper uses [crypt](https://github.com/sagikazarmark/crypt) to retrieve
configuration from the K/V store, which means that you can store your
configuration values encrypted and have them automatically decrypted if you have
the correct gpg keyring. Encryption is optional.
@ -425,7 +432,7 @@ independently of it.
K/V store. `crypt` defaults to etcd on http://127.0.0.1:4001.
```bash
$ go get github.com/bketelsen/crypt/bin/crypt
$ go get github.com/sagikazarmark/crypt/bin/crypt
$ crypt set -plaintext /config/hugo.json /Users/hugo/settings/config.json
```
@ -447,6 +454,13 @@ viper.SetConfigType("json") // because there is no file extension in a stream of
err := viper.ReadRemoteConfig()
```
#### etcd3
```go
viper.AddRemoteProvider("etcd3", "http://127.0.0.1:4001","/config/hugo.json")
viper.SetConfigType("json") // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop", "env", "dotenv"
err := viper.ReadRemoteConfig()
```
#### Consul
You need to set a key to Consul key/value storage with JSON value containing your desired config.
For example, create a Consul key/value store key `MY_CONSUL_KEY` with value:
@ -477,6 +491,15 @@ err := viper.ReadRemoteConfig()
Of course, you're allowed to use `SecureRemoteProvider` also
#### NATS
```go
viper.AddRemoteProvider("nats", "nats://127.0.0.1:4222", "myapp.config")
viper.SetConfigType("json")
err := viper.ReadRemoteConfig()
```
### Remote Key/Value Store Example - Encrypted
```go
@ -524,24 +547,27 @@ go func(){
In Viper, there are a few ways to get a value depending on the values type.
The following functions and methods exist:
* `Get(key string) : interface{}`
* `Get(key string) : any`
* `GetBool(key string) : bool`
* `GetFloat64(key string) : float64`
* `GetInt(key string) : int`
* `GetIntSlice(key string) : []int`
* `GetString(key string) : string`
* `GetStringMap(key string) : map[string]interface{}`
* `GetStringMap(key string) : map[string]any`
* `GetStringMapString(key string) : map[string]string`
* `GetStringSlice(key string) : []string`
* `GetTime(key string) : time.Time`
* `GetDuration(key string) : time.Duration`
* `IsSet(key string) : bool`
* `AllSettings() : map[string]interface{}`
* `AllSettings() : map[string]any`
One important thing to recognize is that each Get function will return a zero
value if its not found. To check if a given key exists, the `IsSet()` method
has been provided.
The zero value will also be returned if the value is set, but fails to parse
as the requested type.
Example:
```go
viper.GetString("logfile") // case-insensitive Setting & Getting
@ -594,7 +620,7 @@ configuration level.
Viper can access array indices by using numbers in the path. For example:
```json
```jsonc
{
"host": {
"address": "localhost",
@ -622,7 +648,7 @@ GetInt("host.ports.1") // returns 6029
Lastly, if there exists a key that matches the delimited key path, its value
will be returned instead. E.g.
```json
```jsonc
{
"datastore.metric.host": "0.0.0.0",
"host": {
@ -699,8 +725,8 @@ etc.
There are two methods to do this:
* `Unmarshal(rawVal interface{}) : error`
* `UnmarshalKey(key string, rawVal interface{}) : error`
* `Unmarshal(rawVal any) : error`
* `UnmarshalKey(key string, rawVal any) : error`
Example:
@ -725,9 +751,9 @@ you have to change the delimiter:
```go
v := viper.NewWithOptions(viper.KeyDelimiter("::"))
v.SetDefault("chart::values", map[string]interface{}{
"ingress": map[string]interface{}{
"annotations": map[string]interface{}{
v.SetDefault("chart::values", map[string]any{
"ingress": map[string]any{
"annotations": map[string]any{
"traefik.frontend.rule.type": "PathPrefix",
"traefik.ingress.kubernetes.io/ssl-redirect": "true",
},
@ -736,7 +762,7 @@ v.SetDefault("chart::values", map[string]interface{}{
type config struct {
Chart struct{
Values map[string]interface{}
Values map[string]any
}
}
@ -872,3 +898,31 @@ No, you will need to synchronize access to the viper yourself (for example by us
## Troubleshooting
See [TROUBLESHOOTING.md](TROUBLESHOOTING.md).
## Development
**For an optimal developer experience, it is recommended to install [Nix](https://nixos.org/download.html) and [direnv](https://direnv.net/docs/installation.html).**
_Alternatively, install [Go](https://go.dev/dl/) on your computer then run `make deps` to install the rest of the dependencies._
Run the test suite:
```shell
make test
```
Run linters:
```shell
make lint # pass -j option to run them in parallel
```
Some linter violations can automatically be fixed:
```shell
make fmt
```
## License
The project is licensed under the [MIT License](LICENSE).

View file

@ -15,10 +15,10 @@ cannot find package "github.com/hashicorp/hcl/tree/hcl1" in any of:
```
As the error message suggests, Go tries to look up dependencies in `GOPATH` mode (as it's commonly called) from the `GOPATH`.
Viper opted to use [Go Modules](https://github.com/golang/go/wiki/Modules) to manage its dependencies. While in many cases the two methods are interchangeable, once a dependency releases new (major) versions, `GOPATH` mode is no longer able to decide which version to use, so it'll either use one that's already present or pick a version (usually the `master` branch).
Viper opted to use [Go Modules](https://go.dev/wiki/Modules) to manage its dependencies. While in many cases the two methods are interchangeable, once a dependency releases new (major) versions, `GOPATH` mode is no longer able to decide which version to use, so it'll either use one that's already present or pick a version (usually the `master` branch).
The solution is easy: switch to using Go Modules.
Please refer to the [wiki](https://github.com/golang/go/wiki/Modules) on how to do that.
Please refer to the [wiki](https://go.dev/wiki/Modules) on how to do that.
**tl;dr* `export GO111MODULE=on`

View file

@ -1,11 +0,0 @@
//go:build viper_logger
// +build viper_logger
package viper
// WithLogger sets a custom logger.
func WithLogger(l Logger) Option {
return optionFunc(func(v *Viper) {
v.logger = l
})
}

View file

@ -1,5 +1,4 @@
//go:build !go1.16 || !finder
// +build !go1.16 !finder
//go:build !finder
package viper
@ -44,7 +43,7 @@ func (v *Viper) searchInPath(in string) (filename string) {
return ""
}
// Check if file Exists
// exists checks if file exists.
func exists(fs afero.Fs, path string) (bool, error) {
stat, err := fs.Stat(path)
if err == nil {

38
file_finder.go Normal file
View file

@ -0,0 +1,38 @@
//go:build finder
package viper
import (
"fmt"
"github.com/sagikazarmark/locafero"
)
// Search all configPaths for any config file.
// Returns the first path that exists (and is a config file).
func (v *Viper) findConfigFile() (string, error) {
var names []string
if v.configType != "" {
names = locafero.NameWithOptionalExtensions(v.configName, SupportedExts...)
} else {
names = locafero.NameWithExtensions(v.configName, SupportedExts...)
}
finder := locafero.Finder{
Paths: v.configPaths,
Names: names,
Type: locafero.FileTypeFile,
}
results, err := finder.Find(v.fs)
if err != nil {
return "", err
}
if len(results) == 0 {
return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)}
}
return results[0], nil
}

View file

@ -30,8 +30,8 @@ func (p pflagValueSet) VisitAll(fn func(flag FlagValue)) {
})
}
// pflagValue is a wrapper aroung *pflag.flag
// that implements FlagValue
// pflagValue is a wrapper around *pflag.flag
// that implements FlagValue.
type pflagValue struct {
flag *pflag.Flag
}

View file

@ -5,9 +5,11 @@ import (
"github.com/spf13/pflag"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestBindFlagValueSet(t *testing.T) {
Reset()
flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError)
testValues := map[string]*string{
@ -29,9 +31,7 @@ func TestBindFlagValueSet(t *testing.T) {
flagValueSet := pflagValueSet{flagSet}
err := BindFlagValues(flagValueSet)
if err != nil {
t.Fatalf("error binding flag set, %v", err)
}
require.NoError(t, err, "error binding flag set")
flagSet.VisitAll(func(flag *pflag.Flag) {
flag.Value.Set(mutatedTestValues[flag.Name])
@ -39,7 +39,7 @@ func TestBindFlagValueSet(t *testing.T) {
})
for name, expected := range mutatedTestValues {
assert.Equal(t, Get(name), expected)
assert.Equal(t, expected, Get(name))
}
}

273
flake.lock Normal file
View file

@ -0,0 +1,273 @@
{
"nodes": {
"devenv": {
"inputs": {
"flake-compat": "flake-compat",
"nix": "nix",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1707817777,
"narHash": "sha256-vHyIs1OULQ3/91wD6xOiuayfI71JXALGA5KLnDKAcy0=",
"owner": "cachix",
"repo": "devenv",
"rev": "5a30b9e5ac7c6167e61b1f4193d5130bb9f8defa",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1706830856,
"narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"devenv",
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"lowdown-src": {
"flake": false,
"locked": {
"lastModified": 1633514407,
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
"owner": "kristapsdz",
"repo": "lowdown",
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
"type": "github"
},
"original": {
"owner": "kristapsdz",
"repo": "lowdown",
"type": "github"
}
},
"nix": {
"inputs": {
"lowdown-src": "lowdown-src",
"nixpkgs": [
"devenv",
"nixpkgs"
],
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
"lastModified": 1676545802,
"narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=",
"owner": "domenkozar",
"repo": "nix",
"rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f",
"type": "github"
},
"original": {
"owner": "domenkozar",
"ref": "relaxed-flakes",
"repo": "nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1678875422,
"narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1706550542,
"narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "97b17f32362e475016f942bbdfda4a4a72a8a652",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-regression": {
"locked": {
"lastModified": 1643052045,
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1707939175,
"narHash": "sha256-D1xan0lgxbmXDyzVqXTiSYHLmAMrMRdD+alKzEO/p3w=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f7e8132daca31b1e3859ac0fb49741754375ac3d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": [
"devenv",
"flake-compat"
],
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"devenv",
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1704725188,
"narHash": "sha256-qq8NbkhRZF1vVYQFt1s8Mbgo8knj+83+QlL5LBnYGpI=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "ea96f0c05924341c551a797aaba8126334c505d2",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_2"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

57
flake.nix Normal file
View file

@ -0,0 +1,57 @@
{
description = "Viper";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
devenv.url = "github:cachix/devenv";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devenv.flakeModule
];
systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }: rec {
devenv.shells = {
default = {
languages = {
go.enable = true;
go.package = pkgs.go_1_22;
};
pre-commit.hooks = {
nixpkgs-fmt.enable = true;
yamllint.enable = true;
};
packages = with pkgs; [
gnumake
golangci-lint
yamllint
];
scripts = {
versions.exec = ''
go version
golangci-lint version
'';
};
enterShell = ''
versions
'';
# https://github.com/cachix/devenv/issues/528#issuecomment-1556108767
containers = pkgs.lib.mkForce { };
};
ci = devenv.shells.default;
};
};
};
}

65
fs.go
View file

@ -1,65 +0,0 @@
//go:build go1.16 && finder
// +build go1.16,finder
package viper
import (
"errors"
"io/fs"
"path"
)
type finder struct {
paths []string
fileNames []string
extensions []string
withoutExtension bool
}
func (f finder) Find(fsys fs.FS) (string, error) {
for _, searchPath := range f.paths {
for _, fileName := range f.fileNames {
for _, extension := range f.extensions {
filePath := path.Join(searchPath, fileName+"."+extension)
ok, err := fileExists(fsys, filePath)
if err != nil {
return "", err
}
if ok {
return filePath, nil
}
}
if f.withoutExtension {
filePath := path.Join(searchPath, fileName)
ok, err := fileExists(fsys, filePath)
if err != nil {
return "", err
}
if ok {
return filePath, nil
}
}
}
}
return "", nil
}
func fileExists(fsys fs.FS, filePath string) (bool, error) {
fileInfo, err := fs.Stat(fsys, filePath)
if err == nil {
return !fileInfo.IsDir(), nil
}
if errors.Is(err, fs.ErrNotExist) {
return false, nil
}
return false, err
}

View file

@ -1,100 +0,0 @@
//go:build go1.16 && finder
// +build go1.16,finder
package viper
import (
"io/fs"
"testing"
"testing/fstest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestFinder(t *testing.T) {
t.Parallel()
fsys := fstest.MapFS{
"home/user/.config": &fstest.MapFile{},
"home/user/config.json": &fstest.MapFile{},
"home/user/config.yaml": &fstest.MapFile{},
"home/user/data.json": &fstest.MapFile{},
"etc/config/.config": &fstest.MapFile{},
"etc/config/a_random_file.txt": &fstest.MapFile{},
"etc/config/config.json": &fstest.MapFile{},
"etc/config/config.yaml": &fstest.MapFile{},
"etc/config/config.xml": &fstest.MapFile{},
}
testCases := []struct {
name string
fsys func() fs.FS
finder finder
result string
}{
{
name: "find file",
fsys: func() fs.FS { return fsys },
finder: finder{
paths: []string{"etc/config"},
fileNames: []string{"config"},
extensions: []string{"json"},
},
result: "etc/config/config.json",
},
{
name: "file not found",
fsys: func() fs.FS { return fsys },
finder: finder{
paths: []string{"var/config"},
fileNames: []string{"config"},
extensions: []string{"json"},
},
result: "",
},
{
name: "empty search params",
fsys: func() fs.FS { return fsys },
finder: finder{},
result: "",
},
{
name: "precedence",
fsys: func() fs.FS { return fsys },
finder: finder{
paths: []string{"var/config", "home/user", "etc/config"},
fileNames: []string{"aconfig", "config"},
extensions: []string{"zml", "xml", "json"},
},
result: "home/user/config.json",
},
{
name: "without extension",
fsys: func() fs.FS { return fsys },
finder: finder{
paths: []string{"var/config", "home/user", "etc/config"},
fileNames: []string{".config"},
extensions: []string{"zml", "xml", "json"},
withoutExtension: true,
},
result: "home/user/.config",
},
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
fsys := testCase.fsys()
result, err := testCase.finder.Find(fsys)
require.NoError(t, err)
assert.Equal(t, testCase.result, result)
})
}
}

118
go.mod
View file

@ -1,65 +1,93 @@
module github.com/spf13/viper
go 1.17
go 1.20
require (
github.com/fsnotify/fsnotify v1.5.1
github.com/fsnotify/fsnotify v1.7.0
github.com/hashicorp/hcl v1.0.0
github.com/magiconair/properties v1.8.6
github.com/mitchellh/mapstructure v1.4.3
github.com/pelletier/go-toml v1.9.4
github.com/pelletier/go-toml/v2 v2.0.0-beta.8
github.com/sagikazarmark/crypt v0.5.0
github.com/spf13/afero v1.8.2
github.com/spf13/cast v1.4.1
github.com/spf13/jwalterweatherman v1.1.0
github.com/magiconair/properties v1.8.7
github.com/mitchellh/mapstructure v1.5.0
github.com/pelletier/go-toml/v2 v2.2.2
github.com/sagikazarmark/crypt v0.19.0
github.com/sagikazarmark/locafero v0.4.0
github.com/sagikazarmark/slog-shim v0.1.0
github.com/spf13/afero v1.11.0
github.com/spf13/cast v1.6.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.1
github.com/subosito/gotenv v1.2.0
gopkg.in/ini.v1 v1.66.4
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
github.com/stretchr/testify v1.9.0
github.com/subosito/gotenv v1.6.0
gopkg.in/ini.v1 v1.67.0
gopkg.in/yaml.v3 v3.0.1
)
require (
cloud.google.com/go v0.100.2 // indirect
cloud.google.com/go/compute v1.5.0 // indirect
cloud.google.com/go/firestore v1.6.1 // indirect
github.com/armon/go-metrics v0.3.10 // indirect
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/firestore v1.15.0 // indirect
cloud.google.com/go/longrunning v0.5.5 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/googleapis/gax-go/v2 v2.3.0 // indirect
github.com/hashicorp/consul/api v1.12.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/hashicorp/consul/api v1.28.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.2.0 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/serf v0.9.7 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.etcd.io/etcd/api/v3 v3.5.2 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.2 // indirect
go.etcd.io/etcd/client/v2 v2.305.2 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/api v0.74.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac // indirect
google.golang.org/grpc v1.45.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
github.com/nats-io/nats.go v1.34.0 // indirect
github.com/nats-io/nkeys v0.4.7 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
go.etcd.io/etcd/api/v3 v3.5.12 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect
go.etcd.io/etcd/client/v2 v2.305.12 // indirect
go.etcd.io/etcd/client/v3 v3.5.12 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.171.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)

748
go.sum

File diff suppressed because it is too large Load diff

View file

@ -5,9 +5,9 @@ import (
)
// Decoder decodes the contents of b into v.
// It's primarily used for decoding contents of a file into a map[string]interface{}.
// It's primarily used for decoding contents of a file into a map[string]any.
type Decoder interface {
Decode(b []byte, v map[string]interface{}) error
Decode(b []byte, v map[string]any) error
}
const (
@ -48,7 +48,7 @@ func (e *DecoderRegistry) RegisterDecoder(format string, enc Decoder) error {
}
// Decode calls the underlying Decoder based on the format.
func (e *DecoderRegistry) Decode(format string, b []byte, v map[string]interface{}) error {
func (e *DecoderRegistry) Decode(format string, b []byte, v map[string]any) error {
e.mu.RLock()
decoder, ok := e.decoders[format]
e.mu.RUnlock()

View file

@ -1,15 +1,17 @@
package encoding
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type decoder struct {
v map[string]interface{}
v map[string]any
}
func (d decoder) Decode(_ []byte, v map[string]interface{}) error {
func (d decoder) Decode(_ []byte, v map[string]any) error {
for key, value := range d.v {
v[key] = value
}
@ -22,23 +24,17 @@ func TestDecoderRegistry_RegisterDecoder(t *testing.T) {
registry := NewDecoderRegistry()
err := registry.RegisterDecoder("myformat", decoder{})
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
})
t.Run("AlreadyRegistered", func(t *testing.T) {
registry := NewDecoderRegistry()
err := registry.RegisterDecoder("myformat", decoder{})
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
err = registry.RegisterDecoder("myformat", decoder{})
if err != ErrDecoderFormatAlreadyRegistered {
t.Fatalf("expected ErrDecoderFormatAlreadyRegistered, got: %v", err)
}
assert.ErrorIs(t, err, ErrDecoderFormatAlreadyRegistered)
})
}
@ -46,36 +42,28 @@ func TestDecoderRegistry_Decode(t *testing.T) {
t.Run("OK", func(t *testing.T) {
registry := NewDecoderRegistry()
decoder := decoder{
v: map[string]interface{}{
v: map[string]any{
"key": "value",
},
}
err := registry.RegisterDecoder("myformat", decoder)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
v := map[string]interface{}{}
v := map[string]any{}
err = registry.Decode("myformat", []byte("key: value"), v)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if !reflect.DeepEqual(decoder.v, v) {
t.Fatalf("decoded value does not match the expected one\nactual: %+v\nexpected: %+v", v, decoder.v)
}
assert.Equal(t, decoder.v, v)
})
t.Run("DecoderNotFound", func(t *testing.T) {
registry := NewDecoderRegistry()
v := map[string]interface{}{}
v := map[string]any{}
err := registry.Decode("myformat", nil, v)
if err != ErrDecoderNotFound {
t.Fatalf("expected ErrDecoderNotFound, got: %v", err)
}
assert.ErrorIs(t, err, ErrDecoderNotFound)
})
}

View file

@ -15,8 +15,8 @@ const keyDelimiter = "_"
// (commonly called as dotenv format).
type Codec struct{}
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
flattened := map[string]interface{}{}
func (Codec) Encode(v map[string]any) ([]byte, error) {
flattened := map[string]any{}
flattened = flattenAndMergeMap(flattened, v, "", keyDelimiter)
@ -40,7 +40,7 @@ func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
return buf.Bytes(), nil
}
func (Codec) Decode(b []byte, v map[string]interface{}) error {
func (Codec) Decode(b []byte, v map[string]any) error {
var buf bytes.Buffer
_, err := buf.Write(b)

View file

@ -1,21 +1,23 @@
package dotenv
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// original form of the data
// original form of the data.
const original = `# key-value pair
KEY=value
`
// encoded form of the data
// encoded form of the data.
const encoded = `KEY=value
`
// Viper's internal representation
var data = map[string]interface{}{
// data is Viper's internal representation.
var data = map[string]any{
"KEY": "value",
}
@ -23,40 +25,30 @@ func TestCodec_Encode(t *testing.T) {
codec := Codec{}
b, err := codec.Encode(data)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if encoded != string(b) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", string(b), encoded)
}
assert.Equal(t, encoded, string(b))
}
func TestCodec_Decode(t *testing.T) {
t.Run("OK", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(original), v)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if !reflect.DeepEqual(data, v) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", v, data)
}
assert.Equal(t, data, v)
})
t.Run("InvalidData", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(`invalid data`), v)
if err == nil {
t.Fatal("expected decoding to fail")
}
require.Error(t, err)
t.Logf("decoding failed as expected: %s", err)
})

View file

@ -7,27 +7,27 @@ import (
)
// flattenAndMergeMap recursively flattens the given map into a new map
// Code is based on the function with the same name in tha main package.
// TODO: move it to a common place
func flattenAndMergeMap(shadow map[string]interface{}, m map[string]interface{}, prefix string, delimiter string) map[string]interface{} {
// Code is based on the function with the same name in the main package.
// TODO: move it to a common place.
func flattenAndMergeMap(shadow, m map[string]any, prefix, delimiter string) map[string]any {
if shadow != nil && prefix != "" && shadow[prefix] != nil {
// prefix is shadowed => nothing more to flatten
return shadow
}
if shadow == nil {
shadow = make(map[string]interface{})
shadow = make(map[string]any)
}
var m2 map[string]interface{}
var m2 map[string]any
if prefix != "" {
prefix += delimiter
}
for k, val := range m {
fullKey := prefix + k
switch val.(type) {
case map[string]interface{}:
m2 = val.(map[string]interface{})
case map[interface{}]interface{}:
switch val := val.(type) {
case map[string]any:
m2 = val
case map[any]any:
m2 = cast.ToStringMap(val)
default:
// immediate value

View file

@ -5,9 +5,9 @@ import (
)
// Encoder encodes the contents of v into a byte representation.
// It's primarily used for encoding a map[string]interface{} into a file format.
// It's primarily used for encoding a map[string]any into a file format.
type Encoder interface {
Encode(v map[string]interface{}) ([]byte, error)
Encode(v map[string]any) ([]byte, error)
}
const (
@ -47,7 +47,7 @@ func (e *EncoderRegistry) RegisterEncoder(format string, enc Encoder) error {
return nil
}
func (e *EncoderRegistry) Encode(format string, v map[string]interface{}) ([]byte, error) {
func (e *EncoderRegistry) Encode(format string, v map[string]any) ([]byte, error) {
e.mu.RLock()
encoder, ok := e.encoders[format]
e.mu.RUnlock()

View file

@ -2,13 +2,16 @@ package encoding
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type encoder struct {
b []byte
}
func (e encoder) Encode(_ map[string]interface{}) ([]byte, error) {
func (e encoder) Encode(_ map[string]any) ([]byte, error) {
return e.b, nil
}
@ -17,23 +20,17 @@ func TestEncoderRegistry_RegisterEncoder(t *testing.T) {
registry := NewEncoderRegistry()
err := registry.RegisterEncoder("myformat", encoder{})
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
})
t.Run("AlreadyRegistered", func(t *testing.T) {
registry := NewEncoderRegistry()
err := registry.RegisterEncoder("myformat", encoder{})
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
err = registry.RegisterEncoder("myformat", encoder{})
if err != ErrEncoderFormatAlreadyRegistered {
t.Fatalf("expected ErrEncoderFormatAlreadyRegistered, got: %v", err)
}
assert.ErrorIs(t, err, ErrEncoderFormatAlreadyRegistered)
})
}
@ -45,26 +42,18 @@ func TestEncoderRegistry_Decode(t *testing.T) {
}
err := registry.RegisterEncoder("myformat", encoder)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
b, err := registry.Encode("myformat", map[string]interface{}{"key": "value"})
if err != nil {
t.Fatal(err)
}
b, err := registry.Encode("myformat", map[string]any{"key": "value"})
require.NoError(t, err)
if string(b) != "key: value" {
t.Fatalf("expected 'key: value', got: %#v", string(b))
}
assert.Equal(t, "key: value", string(b))
})
t.Run("EncoderNotFound", func(t *testing.T) {
registry := NewEncoderRegistry()
_, err := registry.Encode("myformat", map[string]interface{}{"key": "value"})
if err != ErrEncoderNotFound {
t.Fatalf("expected ErrEncoderNotFound, got: %v", err)
}
_, err := registry.Encode("myformat", map[string]any{"key": "value"})
assert.ErrorIs(t, err, ErrEncoderNotFound)
})
}

View file

@ -12,7 +12,7 @@ import (
// TODO: add printer config to the codec?
type Codec struct{}
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
func (Codec) Encode(v map[string]any) ([]byte, error) {
b, err := json.Marshal(v)
if err != nil {
return nil, err
@ -35,6 +35,6 @@ func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
return buf.Bytes(), nil
}
func (Codec) Decode(b []byte, v map[string]interface{}) error {
func (Codec) Decode(b []byte, v map[string]any) error {
return hcl.Unmarshal(b, &v)
}

View file

@ -1,11 +1,13 @@
package hcl
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// original form of the data
// original form of the data.
const original = `# key-value pair
"key" = "value"
@ -26,7 +28,7 @@ nested map
"list" = ["item1", "item2", "item3"]
}`
// encoded form of the data
// encoded form of the data.
const encoded = `"key" = "value"
"list" = ["item1", "item2", "item3"]
@ -41,28 +43,28 @@ const encoded = `"key" = "value"
"list" = ["item1", "item2", "item3"]
}`
// decoded form of the data
// decoded form of the data.
//
// in case of HCL it's slightly different from Viper's internal representation
// (eg. map is decoded into a list of maps)
var decoded = map[string]interface{}{
// In case of HCL it's slightly different from Viper's internal representation
// (e.g. map is decoded into a list of maps).
var decoded = map[string]any{
"key": "value",
"list": []interface{}{
"list": []any{
"item1",
"item2",
"item3",
},
"map": []map[string]interface{}{
"map": []map[string]any{
{
"key": "value",
},
},
"nested_map": []map[string]interface{}{
"nested_map": []map[string]any{
{
"map": []map[string]interface{}{
"map": []map[string]any{
{
"key": "value",
"list": []interface{}{
"list": []any{
"item1",
"item2",
"item3",
@ -73,21 +75,21 @@ var decoded = map[string]interface{}{
},
}
// Viper's internal representation
var data = map[string]interface{}{
// data is Viper's internal representation.
var data = map[string]any{
"key": "value",
"list": []interface{}{
"list": []any{
"item1",
"item2",
"item3",
},
"map": map[string]interface{}{
"map": map[string]any{
"key": "value",
},
"nested_map": map[string]interface{}{
"map": map[string]interface{}{
"nested_map": map[string]any{
"map": map[string]any{
"key": "value",
"list": []interface{}{
"list": []any{
"item1",
"item2",
"item3",
@ -100,40 +102,30 @@ func TestCodec_Encode(t *testing.T) {
codec := Codec{}
b, err := codec.Encode(data)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if encoded != string(b) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", string(b), encoded)
}
assert.Equal(t, encoded, string(b))
}
func TestCodec_Decode(t *testing.T) {
t.Run("OK", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(original), v)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if !reflect.DeepEqual(decoded, v) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", v, decoded)
}
assert.Equal(t, decoded, v)
})
t.Run("InvalidData", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(`invalid data`), v)
if err == nil {
t.Fatal("expected decoding to fail")
}
require.Error(t, err)
t.Logf("decoding failed as expected: %s", err)
})

View file

@ -19,11 +19,11 @@ type Codec struct {
LoadOptions LoadOptions
}
func (c Codec) Encode(v map[string]interface{}) ([]byte, error) {
func (c Codec) Encode(v map[string]any) ([]byte, error) {
cfg := ini.Empty()
ini.PrettyFormat = false
flattened := map[string]interface{}{}
flattened := map[string]any{}
flattened = flattenAndMergeMap(flattened, v, "", c.keyDelimiter())
@ -62,7 +62,7 @@ func (c Codec) Encode(v map[string]interface{}) ([]byte, error) {
return buf.Bytes(), nil
}
func (c Codec) Decode(b []byte, v map[string]interface{}) error {
func (c Codec) Decode(b []byte, v map[string]any) error {
cfg := ini.Empty(c.LoadOptions)
err := cfg.Append(b)

View file

@ -1,11 +1,13 @@
package ini
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// original form of the data
// original form of the data.
const original = `; key-value pair
key=value ; key-value pair
@ -15,31 +17,30 @@ key=%(key)s
`
// encoded form of the data
// encoded form of the data.
const encoded = `key=value
[map]
key=value
`
// decoded form of the data
// decoded form of the data.
//
// in case of INI it's slightly different from Viper's internal representation
// (eg. top level keys land in a section called default)
var decoded = map[string]interface{}{
"DEFAULT": map[string]interface{}{
// In case of INI it's slightly different from Viper's internal representation
// (e.g. top level keys land in a section called default).
var decoded = map[string]any{
"DEFAULT": map[string]any{
"key": "value",
},
"map": map[string]interface{}{
"map": map[string]any{
"key": "value",
},
}
// Viper's internal representation
var data = map[string]interface{}{
// data is Viper's internal representation.
var data = map[string]any{
"key": "value",
"map": map[string]interface{}{
"map": map[string]any{
"key": "value",
},
}
@ -49,35 +50,27 @@ func TestCodec_Encode(t *testing.T) {
codec := Codec{}
b, err := codec.Encode(data)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if encoded != string(b) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", string(b), encoded)
}
assert.Equal(t, encoded, string(b))
})
t.Run("Default", func(t *testing.T) {
codec := Codec{}
data := map[string]interface{}{
"default": map[string]interface{}{
data := map[string]any{
"default": map[string]any{
"key": "value",
},
"map": map[string]interface{}{
"map": map[string]any{
"key": "value",
},
}
b, err := codec.Encode(data)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if encoded != string(b) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", string(b), encoded)
}
assert.Equal(t, encoded, string(b))
})
}
@ -85,27 +78,21 @@ func TestCodec_Decode(t *testing.T) {
t.Run("OK", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(original), v)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if !reflect.DeepEqual(decoded, v) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", v, decoded)
}
assert.Equal(t, decoded, v)
})
t.Run("InvalidData", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(`invalid data`), v)
if err == nil {
t.Fatal("expected decoding to fail")
}
require.Error(t, err)
t.Logf("decoding failed as expected: %s", err)
})

View file

@ -15,22 +15,22 @@ import (
// In case intermediate keys do not exist, or map to a non-map value,
// a new map is created and inserted, and the search continues from there:
// the initial map "m" may be modified!
func deepSearch(m map[string]interface{}, path []string) map[string]interface{} {
func deepSearch(m map[string]any, path []string) map[string]any {
for _, k := range path {
m2, ok := m[k]
if !ok {
// intermediate key does not exist
// => create it and continue from there
m3 := make(map[string]interface{})
m3 := make(map[string]any)
m[k] = m3
m = m3
continue
}
m3, ok := m2.(map[string]interface{})
m3, ok := m2.(map[string]any)
if !ok {
// intermediate key is a value
// => replace with a new map
m3 = make(map[string]interface{})
m3 = make(map[string]any)
m[k] = m3
}
// continue search from here
@ -40,27 +40,27 @@ func deepSearch(m map[string]interface{}, path []string) map[string]interface{}
}
// flattenAndMergeMap recursively flattens the given map into a new map
// Code is based on the function with the same name in tha main package.
// TODO: move it to a common place
func flattenAndMergeMap(shadow map[string]interface{}, m map[string]interface{}, prefix string, delimiter string) map[string]interface{} {
// Code is based on the function with the same name in the main package.
// TODO: move it to a common place.
func flattenAndMergeMap(shadow, m map[string]any, prefix, delimiter string) map[string]any {
if shadow != nil && prefix != "" && shadow[prefix] != nil {
// prefix is shadowed => nothing more to flatten
return shadow
}
if shadow == nil {
shadow = make(map[string]interface{})
shadow = make(map[string]any)
}
var m2 map[string]interface{}
var m2 map[string]any
if prefix != "" {
prefix += delimiter
}
for k, val := range m {
fullKey := prefix + k
switch val.(type) {
case map[string]interface{}:
m2 = val.(map[string]interface{})
case map[interface{}]interface{}:
switch val := val.(type) {
case map[string]any:
m2 = val
case map[any]any:
m2 = cast.ToStringMap(val)
default:
// immediate value

View file

@ -20,12 +20,12 @@ type Codec struct {
Properties *properties.Properties
}
func (c *Codec) Encode(v map[string]interface{}) ([]byte, error) {
func (c *Codec) Encode(v map[string]any) ([]byte, error) {
if c.Properties == nil {
c.Properties = properties.NewProperties()
}
flattened := map[string]interface{}{}
flattened := map[string]any{}
flattened = flattenAndMergeMap(flattened, v, "", c.keyDelimiter())
@ -54,7 +54,7 @@ func (c *Codec) Encode(v map[string]interface{}) ([]byte, error) {
return buf.Bytes(), nil
}
func (c *Codec) Decode(b []byte, v map[string]interface{}) error {
func (c *Codec) Decode(b []byte, v map[string]any) error {
var err error
c.Properties, err = properties.Load(b, properties.UTF8)
if err != nil {

View file

@ -1,25 +1,27 @@
package javaproperties
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// original form of the data
// original form of the data.
const original = `#key-value pair
key = value
map.key = value
`
// encoded form of the data
// encoded form of the data.
const encoded = `key = value
map.key = value
`
// Viper's internal representation
var data = map[string]interface{}{
// data is Viper's internal representation.
var data = map[string]any{
"key": "value",
"map": map[string]interface{}{
"map": map[string]any{
"key": "value",
},
}
@ -28,29 +30,21 @@ func TestCodec_Encode(t *testing.T) {
codec := Codec{}
b, err := codec.Encode(data)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if encoded != string(b) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", string(b), encoded)
}
assert.Equal(t, encoded, string(b))
}
func TestCodec_Decode(t *testing.T) {
t.Run("OK", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(original), v)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if !reflect.DeepEqual(data, v) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", v, data)
}
assert.Equal(t, data, v)
})
t.Run("InvalidData", func(t *testing.T) {
@ -58,32 +52,24 @@ func TestCodec_Decode(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
codec.Decode([]byte(``), v)
if len(v) > 0 {
t.Fatalf("expected map to be empty when data is invalid\nactual: %#v", v)
}
assert.Empty(t, v)
})
}
func TestCodec_DecodeEncode(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(original), v)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
b, err := codec.Encode(data)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if original != string(b) {
t.Fatalf("encoded value does not match the original\nactual: %#v\nexpected: %#v", string(b), original)
}
assert.Equal(t, original, string(b))
}

View file

@ -15,22 +15,22 @@ import (
// In case intermediate keys do not exist, or map to a non-map value,
// a new map is created and inserted, and the search continues from there:
// the initial map "m" may be modified!
func deepSearch(m map[string]interface{}, path []string) map[string]interface{} {
func deepSearch(m map[string]any, path []string) map[string]any {
for _, k := range path {
m2, ok := m[k]
if !ok {
// intermediate key does not exist
// => create it and continue from there
m3 := make(map[string]interface{})
m3 := make(map[string]any)
m[k] = m3
m = m3
continue
}
m3, ok := m2.(map[string]interface{})
m3, ok := m2.(map[string]any)
if !ok {
// intermediate key is a value
// => replace with a new map
m3 = make(map[string]interface{})
m3 = make(map[string]any)
m[k] = m3
}
// continue search from here
@ -40,27 +40,27 @@ func deepSearch(m map[string]interface{}, path []string) map[string]interface{}
}
// flattenAndMergeMap recursively flattens the given map into a new map
// Code is based on the function with the same name in tha main package.
// TODO: move it to a common place
func flattenAndMergeMap(shadow map[string]interface{}, m map[string]interface{}, prefix string, delimiter string) map[string]interface{} {
// Code is based on the function with the same name in the main package.
// TODO: move it to a common place.
func flattenAndMergeMap(shadow, m map[string]any, prefix, delimiter string) map[string]any {
if shadow != nil && prefix != "" && shadow[prefix] != nil {
// prefix is shadowed => nothing more to flatten
return shadow
}
if shadow == nil {
shadow = make(map[string]interface{})
shadow = make(map[string]any)
}
var m2 map[string]interface{}
var m2 map[string]any
if prefix != "" {
prefix += delimiter
}
for k, val := range m {
fullKey := prefix + k
switch val.(type) {
case map[string]interface{}:
m2 = val.(map[string]interface{})
case map[interface{}]interface{}:
switch val := val.(type) {
case map[string]any:
m2 = val
case map[any]any:
m2 = cast.ToStringMap(val)
default:
// immediate value

View file

@ -7,11 +7,11 @@ import (
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for JSON encoding.
type Codec struct{}
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
func (Codec) Encode(v map[string]any) ([]byte, error) {
// TODO: expose prefix and indent in the Codec as setting?
return json.MarshalIndent(v, "", " ")
}
func (Codec) Decode(b []byte, v map[string]interface{}) error {
func (Codec) Decode(b []byte, v map[string]any) error {
return json.Unmarshal(b, &v)
}

View file

@ -1,11 +1,13 @@
package json
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// encoded form of the data
// encoded form of the data.
const encoded = `{
"key": "value",
"list": [
@ -28,21 +30,21 @@ const encoded = `{
}
}`
// Viper's internal representation
var data = map[string]interface{}{
// data is Viper's internal representation.
var data = map[string]any{
"key": "value",
"list": []interface{}{
"list": []any{
"item1",
"item2",
"item3",
},
"map": map[string]interface{}{
"map": map[string]any{
"key": "value",
},
"nested_map": map[string]interface{}{
"map": map[string]interface{}{
"nested_map": map[string]any{
"map": map[string]any{
"key": "value",
"list": []interface{}{
"list": []any{
"item1",
"item2",
"item3",
@ -55,40 +57,30 @@ func TestCodec_Encode(t *testing.T) {
codec := Codec{}
b, err := codec.Encode(data)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if encoded != string(b) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", string(b), encoded)
}
assert.Equal(t, encoded, string(b))
}
func TestCodec_Decode(t *testing.T) {
t.Run("OK", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(encoded), v)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if !reflect.DeepEqual(data, v) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", v, data)
}
assert.Equal(t, data, v)
})
t.Run("InvalidData", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(`invalid data`), v)
if err == nil {
t.Fatal("expected decoding to fail")
}
require.Error(t, err)
t.Logf("decoding failed as expected: %s", err)
})

View file

@ -1,39 +1,16 @@
//go:build !viper_toml2
// +build !viper_toml2
package toml
import (
"github.com/pelletier/go-toml"
"github.com/pelletier/go-toml/v2"
)
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for TOML encoding.
type Codec struct{}
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
t, err := toml.TreeFromMap(v)
if err != nil {
return nil, err
}
s, err := t.ToTomlString()
if err != nil {
return nil, err
}
return []byte(s), nil
func (Codec) Encode(v map[string]any) ([]byte, error) {
return toml.Marshal(v)
}
func (Codec) Decode(b []byte, v map[string]interface{}) error {
tree, err := toml.LoadBytes(b)
if err != nil {
return err
}
tmap := tree.ToMap()
for key, value := range tmap {
v[key] = value
}
return nil
func (Codec) Decode(b []byte, v map[string]any) error {
return toml.Unmarshal(b, &v)
}

View file

@ -1,19 +0,0 @@
//go:build viper_toml2
// +build viper_toml2
package toml
import (
"github.com/pelletier/go-toml/v2"
)
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for TOML encoding.
type Codec struct{}
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
return toml.Marshal(v)
}
func (Codec) Decode(b []byte, v map[string]interface{}) error {
return toml.Unmarshal(b, &v)
}

View file

@ -1,109 +0,0 @@
//go:build viper_toml2
// +build viper_toml2
package toml
import (
"reflect"
"testing"
)
// original form of the data
const original = `# key-value pair
key = "value"
list = ["item1", "item2", "item3"]
[map]
key = "value"
# nested
# map
[nested_map]
[nested_map.map]
key = "value"
list = [
"item1",
"item2",
"item3",
]
`
// encoded form of the data
const encoded = `key = 'value'
list = ['item1', 'item2', 'item3']
[map]
key = 'value'
[nested_map]
[nested_map.map]
key = 'value'
list = ['item1', 'item2', 'item3']
`
// Viper's internal representation
var data = map[string]interface{}{
"key": "value",
"list": []interface{}{
"item1",
"item2",
"item3",
},
"map": map[string]interface{}{
"key": "value",
},
"nested_map": map[string]interface{}{
"map": map[string]interface{}{
"key": "value",
"list": []interface{}{
"item1",
"item2",
"item3",
},
},
},
}
func TestCodec_Encode(t *testing.T) {
codec := Codec{}
b, err := codec.Encode(data)
if err != nil {
t.Fatal(err)
}
if encoded != string(b) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", string(b), encoded)
}
}
func TestCodec_Decode(t *testing.T) {
t.Run("OK", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
err := codec.Decode([]byte(original), v)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(data, v) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", v, data)
}
})
t.Run("InvalidData", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
err := codec.Decode([]byte(`invalid data`), v)
if err == nil {
t.Fatal("expected decoding to fail")
}
t.Logf("decoding failed as expected: %s", err)
})
}

View file

@ -1,14 +1,13 @@
//go:build !viper_toml2
// +build !viper_toml2
package toml
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// original form of the data
// original form of the data.
const original = `# key-value pair
key = "value"
list = ["item1", "item2", "item3"]
@ -28,35 +27,34 @@ list = [
]
`
// encoded form of the data
const encoded = `key = "value"
list = ["item1", "item2", "item3"]
// encoded form of the data.
const encoded = `key = 'value'
list = ['item1', 'item2', 'item3']
[map]
key = "value"
key = 'value'
[nested_map]
[nested_map.map]
key = "value"
list = ["item1", "item2", "item3"]
[nested_map.map]
key = 'value'
list = ['item1', 'item2', 'item3']
`
// Viper's internal representation
var data = map[string]interface{}{
// data is Viper's internal representation.
var data = map[string]any{
"key": "value",
"list": []interface{}{
"list": []any{
"item1",
"item2",
"item3",
},
"map": map[string]interface{}{
"map": map[string]any{
"key": "value",
},
"nested_map": map[string]interface{}{
"map": map[string]interface{}{
"nested_map": map[string]any{
"map": map[string]any{
"key": "value",
"list": []interface{}{
"list": []any{
"item1",
"item2",
"item3",
@ -69,40 +67,30 @@ func TestCodec_Encode(t *testing.T) {
codec := Codec{}
b, err := codec.Encode(data)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if encoded != string(b) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", string(b), encoded)
}
assert.Equal(t, encoded, string(b))
}
func TestCodec_Decode(t *testing.T) {
t.Run("OK", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(original), v)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if !reflect.DeepEqual(data, v) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", v, data)
}
assert.Equal(t, data, v)
})
t.Run("InvalidData", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(`invalid data`), v)
if err == nil {
t.Fatal("expected decoding to fail")
}
require.Error(t, err)
t.Logf("decoding failed as expected: %s", err)
})

View file

@ -1,14 +1,14 @@
package yaml
// import "gopkg.in/yaml.v2"
import "gopkg.in/yaml.v3"
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for YAML encoding.
type Codec struct{}
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
func (Codec) Encode(v map[string]any) ([]byte, error) {
return yaml.Marshal(v)
}
func (Codec) Decode(b []byte, v map[string]interface{}) error {
func (Codec) Decode(b []byte, v map[string]any) error {
return yaml.Unmarshal(b, &v)
}

View file

@ -1,48 +1,127 @@
package yaml
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// original form of the data.
const original = `# key-value pair
key: value
list:
- item1
- item2
- item3
map:
key: value
# nested
# map
nested_map:
map:
key: value
list:
- item1
- item2
- item3
`
// encoded form of the data.
const encoded = `key: value
list:
- item1
- item2
- item3
map:
key: value
nested_map:
map:
key: value
list:
- item1
- item2
- item3
`
// decoded form of the data.
//
// In case of YAML it's slightly different from Viper's internal representation
// (e.g. map is decoded into a map with interface key).
var decoded = map[string]any{
"key": "value",
"list": []any{
"item1",
"item2",
"item3",
},
"map": map[string]any{
"key": "value",
},
"nested_map": map[string]any{
"map": map[string]any{
"key": "value",
"list": []any{
"item1",
"item2",
"item3",
},
},
},
}
// data is Viper's internal representation.
var data = map[string]any{
"key": "value",
"list": []any{
"item1",
"item2",
"item3",
},
"map": map[string]any{
"key": "value",
},
"nested_map": map[string]any{
"map": map[string]any{
"key": "value",
"list": []any{
"item1",
"item2",
"item3",
},
},
},
}
func TestCodec_Encode(t *testing.T) {
codec := Codec{}
b, err := codec.Encode(data)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if encoded != string(b) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", string(b), encoded)
}
assert.Equal(t, encoded, string(b))
}
func TestCodec_Decode(t *testing.T) {
t.Run("OK", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(original), v)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
if !reflect.DeepEqual(decoded, v) {
t.Fatalf("decoded value does not match the expected one\nactual: %#v\nexpected: %#v", v, decoded)
}
assert.Equal(t, decoded, v)
})
t.Run("InvalidData", func(t *testing.T) {
codec := Codec{}
v := map[string]interface{}{}
v := map[string]any{}
err := codec.Decode([]byte(`invalid data`), v)
if err == nil {
t.Fatal("expected decoding to fail")
}
require.Error(t, err)
t.Logf("decoding failed as expected: %s", err)
})

View file

@ -1,14 +0,0 @@
//go:build !viper_yaml3
// +build !viper_yaml3
package yaml
import yamlv2 "gopkg.in/yaml.v2"
var yaml = struct {
Marshal func(in interface{}) (out []byte, err error)
Unmarshal func(in []byte, out interface{}) (err error)
}{
Marshal: yamlv2.Marshal,
Unmarshal: yamlv2.Unmarshal,
}

View file

@ -1,91 +0,0 @@
//go:build !viper_yaml3
// +build !viper_yaml3
package yaml
// original form of the data
const original = `# key-value pair
key: value
list:
- item1
- item2
- item3
map:
key: value
# nested
# map
nested_map:
map:
key: value
list:
- item1
- item2
- item3
`
// encoded form of the data
const encoded = `key: value
list:
- item1
- item2
- item3
map:
key: value
nested_map:
map:
key: value
list:
- item1
- item2
- item3
`
// decoded form of the data
//
// in case of YAML it's slightly different from Viper's internal representation
// (eg. map is decoded into a map with interface key)
var decoded = map[string]interface{}{
"key": "value",
"list": []interface{}{
"item1",
"item2",
"item3",
},
"map": map[interface{}]interface{}{
"key": "value",
},
"nested_map": map[interface{}]interface{}{
"map": map[interface{}]interface{}{
"key": "value",
"list": []interface{}{
"item1",
"item2",
"item3",
},
},
},
}
// Viper's internal representation
var data = map[string]interface{}{
"key": "value",
"list": []interface{}{
"item1",
"item2",
"item3",
},
"map": map[string]interface{}{
"key": "value",
},
"nested_map": map[string]interface{}{
"map": map[string]interface{}{
"key": "value",
"list": []interface{}{
"item1",
"item2",
"item3",
},
},
},
}

View file

@ -1,14 +0,0 @@
//go:build viper_yaml3
// +build viper_yaml3
package yaml
import yamlv3 "gopkg.in/yaml.v3"
var yaml = struct {
Marshal func(in interface{}) (out []byte, err error)
Unmarshal func(in []byte, out interface{}) (err error)
}{
Marshal: yamlv3.Marshal,
Unmarshal: yamlv3.Unmarshal,
}

View file

@ -1,91 +0,0 @@
//go:build viper_yaml3
// +build viper_yaml3
package yaml
// original form of the data
const original = `# key-value pair
key: value
list:
- item1
- item2
- item3
map:
key: value
# nested
# map
nested_map:
map:
key: value
list:
- item1
- item2
- item3
`
// encoded form of the data
const encoded = `key: value
list:
- item1
- item2
- item3
map:
key: value
nested_map:
map:
key: value
list:
- item1
- item2
- item3
`
// decoded form of the data
//
// in case of YAML it's slightly different from Viper's internal representation
// (eg. map is decoded into a map with interface key)
var decoded = map[string]interface{}{
"key": "value",
"list": []interface{}{
"item1",
"item2",
"item3",
},
"map": map[string]interface{}{
"key": "value",
},
"nested_map": map[string]interface{}{
"map": map[string]interface{}{
"key": "value",
"list": []interface{}{
"item1",
"item2",
"item3",
},
},
},
}
// Viper's internal representation
var data = map[string]interface{}{
"key": "value",
"list": []interface{}{
"item1",
"item2",
"item3",
},
"map": map[string]interface{}{
"key": "value",
},
"nested_map": map[string]interface{}{
"map": map[string]interface{}{
"key": "value",
"list": []interface{}{
"item1",
"item2",
"item3",
},
},
},
}

View file

@ -0,0 +1,5 @@
//go:build viper_bind_struct
package features
const BindStruct = true

View file

@ -0,0 +1,5 @@
//go:build !viper_bind_struct
package features
const BindStruct = false

View file

@ -1,40 +0,0 @@
//go:build !go1.17
// +build !go1.17
package testutil
import (
"os"
"testing"
)
// Based on https://github.com/frankban/quicktest/blob/577841610793d24f99e31cc2c0ef3a541fefd7c7/patch.go#L34-L64
// Licensed under the MIT license
// Copyright (c) 2017 Canonical Ltd.
// Setenv sets an environment variable to a temporary value for the
// duration of the test.
//
// At the end of the test (see "Deferred execution" in the package docs), the
// environment variable is returned to its original value.
func Setenv(t *testing.T, name, val string) {
setenv(t, name, val, true)
}
// setenv sets or unsets an environment variable to a temporary value for the
// duration of the test
func setenv(t *testing.T, name, val string, valOK bool) {
oldVal, oldOK := os.LookupEnv(name)
if valOK {
os.Setenv(name, val)
} else {
os.Unsetenv(name)
}
t.Cleanup(func() {
if oldOK {
os.Setenv(name, oldVal)
} else {
os.Unsetenv(name)
}
})
}

View file

@ -1,18 +0,0 @@
//go:build go1.17
// +build go1.17
package testutil
import (
"testing"
)
// Setenv sets an environment variable to a temporary value for the
// duration of the test.
//
// This shim can be removed once support for Go <1.17 is dropped.
func Setenv(t *testing.T, name, val string) {
t.Helper()
t.Setenv(name, val)
}

View file

@ -1,77 +1,68 @@
package viper
import (
"fmt"
"context"
jww "github.com/spf13/jwalterweatherman"
slog "github.com/sagikazarmark/slog-shim"
)
// Logger is a unified interface for various logging use cases and practices, including:
// - leveled logging
// - structured logging
// - leveled logging
// - structured logging
//
// Deprecated: use `log/slog` instead.
type Logger interface {
// Trace logs a Trace event.
//
// Even more fine-grained information than Debug events.
// Loggers not supporting this level should fall back to Debug.
Trace(msg string, keyvals ...interface{})
Trace(msg string, keyvals ...any)
// Debug logs a Debug event.
//
// A verbose series of information events.
// They are useful when debugging the system.
Debug(msg string, keyvals ...interface{})
Debug(msg string, keyvals ...any)
// Info logs an Info event.
//
// General information about what's happening inside the system.
Info(msg string, keyvals ...interface{})
Info(msg string, keyvals ...any)
// Warn logs a Warn(ing) event.
//
// Non-critical events that should be looked at.
Warn(msg string, keyvals ...interface{})
Warn(msg string, keyvals ...any)
// Error logs an Error event.
//
// Critical events that require immediate attention.
// Loggers commonly provide Fatal and Panic levels above Error level,
// but exiting and panicing is out of scope for a logging library.
Error(msg string, keyvals ...interface{})
// but exiting and panicking is out of scope for a logging library.
Error(msg string, keyvals ...any)
}
type jwwLogger struct{}
func (jwwLogger) Trace(msg string, keyvals ...interface{}) {
jww.TRACE.Printf(jwwLogMessage(msg, keyvals...))
// WithLogger sets a custom logger.
func WithLogger(l *slog.Logger) Option {
return optionFunc(func(v *Viper) {
v.logger = l
})
}
func (jwwLogger) Debug(msg string, keyvals ...interface{}) {
jww.DEBUG.Printf(jwwLogMessage(msg, keyvals...))
type discardHandler struct{}
func (n *discardHandler) Enabled(_ context.Context, _ slog.Level) bool {
return false
}
func (jwwLogger) Info(msg string, keyvals ...interface{}) {
jww.INFO.Printf(jwwLogMessage(msg, keyvals...))
func (n *discardHandler) Handle(_ context.Context, _ slog.Record) error {
return nil
}
func (jwwLogger) Warn(msg string, keyvals ...interface{}) {
jww.WARN.Printf(jwwLogMessage(msg, keyvals...))
func (n *discardHandler) WithAttrs(_ []slog.Attr) slog.Handler {
return n
}
func (jwwLogger) Error(msg string, keyvals ...interface{}) {
jww.ERROR.Printf(jwwLogMessage(msg, keyvals...))
}
func jwwLogMessage(msg string, keyvals ...interface{}) string {
out := msg
if len(keyvals) > 0 && len(keyvals)%2 == 1 {
keyvals = append(keyvals, nil)
}
for i := 0; i <= len(keyvals)-2; i += 2 {
out = fmt.Sprintf("%s %v=%v", out, keyvals[i], keyvals[i+1])
}
return out
func (n *discardHandler) WithGroup(_ string) slog.Handler {
return n
}

View file

@ -1,7 +1,6 @@
package viper
import (
"fmt"
"strings"
"testing"
@ -46,11 +45,11 @@ func TestNestedOverrides(t *testing.T) {
deepCheckValue(assert, v, overrideLayer, []string{"tom", "size"}, 4)
// Case 4: key:value overridden by a map
v = overrideDefault(assert, "tom.size", 4, "tom", map[string]interface{}{"age": 10}) // "tom.size" is first given "4" as default value, then "tom" is overridden by map{"age":10}
assert.Equal(4, v.Get("tom.size")) // "tom.size" should still be reachable
assert.Equal(10, v.Get("tom.age")) // new value should be there
deepCheckValue(assert, v, overrideLayer, []string{"tom", "age"}, 10) // new value should be there
v = override(assert, "tom.size", 4, "tom", map[string]interface{}{"age": 10})
v = overrideDefault(assert, "tom.size", 4, "tom", map[string]any{"age": 10}) // "tom.size" is first given "4" as default value, then "tom" is overridden by map{"age":10}
assert.Equal(4, v.Get("tom.size")) // "tom.size" should still be reachable
assert.Equal(10, v.Get("tom.age")) // new value should be there
deepCheckValue(assert, v, overrideLayer, []string{"tom", "age"}, 10) // new value should be there
v = override(assert, "tom.size", 4, "tom", map[string]any{"age": 10})
assert.Nil(v.Get("tom.size"))
assert.Equal(10, v.Get("tom.age"))
deepCheckValue(assert, v, overrideLayer, []string{"tom", "age"}, 10)
@ -75,11 +74,11 @@ func TestNestedOverrides(t *testing.T) {
}
}
func overrideDefault(assert *assert.Assertions, firstPath string, firstValue interface{}, secondPath string, secondValue interface{}) *Viper {
func overrideDefault(assert *assert.Assertions, firstPath string, firstValue any, secondPath string, secondValue any) *Viper {
return overrideFromLayer(defaultLayer, assert, firstPath, firstValue, secondPath, secondValue)
}
func override(assert *assert.Assertions, firstPath string, firstValue interface{}, secondPath string, secondValue interface{}) *Viper {
func override(assert *assert.Assertions, firstPath string, firstValue any, secondPath string, secondValue any) *Viper {
return overrideFromLayer(overrideLayer, assert, firstPath, firstValue, secondPath, secondValue)
}
@ -94,11 +93,11 @@ func override(assert *assert.Assertions, firstPath string, firstValue interface{
//
// After each assignment, the value is checked, retrieved both by its full path
// and by its key sequence (successive maps).
func overrideFromLayer(l layer, assert *assert.Assertions, firstPath string, firstValue interface{}, secondPath string, secondValue interface{}) *Viper {
func overrideFromLayer(l layer, assert *assert.Assertions, firstPath string, firstValue any, secondPath string, secondValue any) *Viper {
v := New()
firstKeys := strings.Split(firstPath, v.keyDelim)
if assert == nil ||
len(firstKeys) == 0 || len(firstKeys[0]) == 0 {
len(firstKeys) == 0 || firstKeys[0] == "" {
return v
}
@ -116,7 +115,7 @@ func overrideFromLayer(l layer, assert *assert.Assertions, firstPath string, fir
// Override and check new value
secondKeys := strings.Split(secondPath, v.keyDelim)
if len(secondKeys) == 0 || len(secondKeys[0]) == 0 {
if len(secondKeys) == 0 || secondKeys[0] == "" {
return v
}
v.Set(secondPath, secondValue)
@ -127,15 +126,15 @@ func overrideFromLayer(l layer, assert *assert.Assertions, firstPath string, fir
}
// deepCheckValue checks that all given keys correspond to a valid path in the
// configuration map of the given layer, and that the final value equals the one given
func deepCheckValue(assert *assert.Assertions, v *Viper, l layer, keys []string, value interface{}) {
// configuration map of the given layer, and that the final value equals the one given.
func deepCheckValue(assert *assert.Assertions, v *Viper, l layer, keys []string, value any) {
if assert == nil || v == nil ||
len(keys) == 0 || len(keys[0]) == 0 {
len(keys) == 0 || keys[0] == "" {
return
}
// init
var val interface{}
var val any
var ms string
switch l {
case defaultLayer:
@ -147,28 +146,25 @@ func deepCheckValue(assert *assert.Assertions, v *Viper, l layer, keys []string,
}
// loop through map
var m map[string]interface{}
err := false
var m map[string]any
for _, k := range keys {
if val == nil {
assert.Fail(fmt.Sprintf("%s is not a map[string]interface{}", ms))
assert.Failf("%s is not a map[string]any", ms)
return
}
// deep scan of the map to get the final value
switch val.(type) {
case map[interface{}]interface{}:
switch val := val.(type) {
case map[any]any:
m = cast.ToStringMap(val)
case map[string]interface{}:
m = val.(map[string]interface{})
case map[string]any:
m = val
default:
assert.Fail(fmt.Sprintf("%s is not a map[string]interface{}", ms))
assert.Failf("%s is not a map[string]any", ms)
return
}
ms = ms + "[\"" + k + "\"]"
val = m[k]
}
if !err {
assert.Equal(value, val)
}
assert.Equal(value, val)
}

View file

@ -10,6 +10,7 @@ import (
"bytes"
"io"
"os"
"strings"
crypt "github.com/sagikazarmark/crypt/config"
@ -75,6 +76,7 @@ func getConfigManager(rp viper.RemoteProvider) (crypt.ConfigManager, error) {
var cm crypt.ConfigManager
var err error
endpoints := strings.Split(rp.Endpoint(), ";")
if rp.SecretKeyring() != "" {
var kr *os.File
kr, err = os.Open(rp.SecretKeyring())
@ -84,20 +86,28 @@ func getConfigManager(rp viper.RemoteProvider) (crypt.ConfigManager, error) {
defer kr.Close()
switch rp.Provider() {
case "etcd":
cm, err = crypt.NewEtcdConfigManager([]string{rp.Endpoint()}, kr)
cm, err = crypt.NewEtcdConfigManager(endpoints, kr)
case "etcd3":
cm, err = crypt.NewEtcdV3ConfigManager(endpoints, kr)
case "firestore":
cm, err = crypt.NewFirestoreConfigManager([]string{rp.Endpoint()}, kr)
cm, err = crypt.NewFirestoreConfigManager(endpoints, kr)
case "nats":
cm, err = crypt.NewNatsConfigManager(endpoints, kr)
default:
cm, err = crypt.NewConsulConfigManager([]string{rp.Endpoint()}, kr)
cm, err = crypt.NewConsulConfigManager(endpoints, kr)
}
} else {
switch rp.Provider() {
case "etcd":
cm, err = crypt.NewStandardEtcdConfigManager([]string{rp.Endpoint()})
cm, err = crypt.NewStandardEtcdConfigManager(endpoints)
case "etcd3":
cm, err = crypt.NewStandardEtcdV3ConfigManager(endpoints)
case "firestore":
cm, err = crypt.NewStandardFirestoreConfigManager([]string{rp.Endpoint()})
cm, err = crypt.NewStandardFirestoreConfigManager(endpoints)
case "nats":
cm, err = crypt.NewStandardNatsConfigManager(endpoints)
default:
cm, err = crypt.NewStandardConsulConfigManager([]string{rp.Endpoint()})
cm, err = crypt.NewStandardConsulConfigManager(endpoints)
}
}
if err != nil {

67
util.go
View file

@ -18,6 +18,7 @@ import (
"strings"
"unicode"
slog "github.com/sagikazarmark/slog-shim"
"github.com/spf13/cast"
)
@ -31,13 +32,18 @@ func (pe ConfigParseError) Error() string {
return fmt.Sprintf("While parsing config: %s", pe.err.Error())
}
// Unwrap returns the wrapped error.
func (pe ConfigParseError) Unwrap() error {
return pe.err
}
// toCaseInsensitiveValue checks if the value is a map;
// if so, create a copy and lower-case the keys recursively.
func toCaseInsensitiveValue(value interface{}) interface{} {
func toCaseInsensitiveValue(value any) any {
switch v := value.(type) {
case map[interface{}]interface{}:
case map[any]any:
value = copyAndInsensitiviseMap(cast.ToStringMap(v))
case map[string]interface{}:
case map[string]any:
value = copyAndInsensitiviseMap(v)
}
@ -46,15 +52,15 @@ func toCaseInsensitiveValue(value interface{}) interface{} {
// copyAndInsensitiviseMap behaves like insensitiviseMap, but creates a copy of
// any map it makes case insensitive.
func copyAndInsensitiviseMap(m map[string]interface{}) map[string]interface{} {
nm := make(map[string]interface{})
func copyAndInsensitiviseMap(m map[string]any) map[string]any {
nm := make(map[string]any)
for key, val := range m {
lkey := strings.ToLower(key)
switch v := val.(type) {
case map[interface{}]interface{}:
case map[any]any:
nm[lkey] = copyAndInsensitiviseMap(cast.ToStringMap(v))
case map[string]interface{}:
case map[string]any:
nm[lkey] = copyAndInsensitiviseMap(v)
default:
nm[lkey] = v
@ -64,18 +70,25 @@ func copyAndInsensitiviseMap(m map[string]interface{}) map[string]interface{} {
return nm
}
func insensitiviseMap(m map[string]interface{}) {
for key, val := range m {
switch val.(type) {
case map[interface{}]interface{}:
// nested map: cast and recursively insensitivise
val = cast.ToStringMap(val)
insensitiviseMap(val.(map[string]interface{}))
case map[string]interface{}:
// nested map: recursively insensitivise
insensitiviseMap(val.(map[string]interface{}))
}
func insensitiviseVal(val any) any {
switch v := val.(type) {
case map[any]any:
// nested map: cast and recursively insensitivise
val = cast.ToStringMap(val)
insensitiviseMap(val.(map[string]any))
case map[string]any:
// nested map: recursively insensitivise
insensitiviseMap(v)
case []any:
// nested array: recursively insensitivise
insensitiveArray(v)
}
return val
}
func insensitiviseMap(m map[string]any) {
for key, val := range m {
val = insensitiviseVal(val)
lower := strings.ToLower(key)
if key != lower {
// remove old key (not lower-cased)
@ -86,7 +99,13 @@ func insensitiviseMap(m map[string]interface{}) {
}
}
func absPathify(logger Logger, inPath string) string {
func insensitiveArray(a []any) {
for i, val := range a {
a[i] = insensitiviseVal(val)
}
}
func absPathify(logger *slog.Logger, inPath string) string {
logger.Info("trying to resolve absolute path", "path", inPath)
if inPath == "$HOME" || strings.HasPrefix(inPath, "$HOME"+string(os.PathSeparator)) {
@ -137,7 +156,7 @@ func safeMul(a, b uint) uint {
return c
}
// parseSizeInBytes converts strings like 1GB or 12 mb into an unsigned integer number of bytes
// parseSizeInBytes converts strings like 1GB or 12 mb into an unsigned integer number of bytes.
func parseSizeInBytes(sizeStr string) uint {
sizeStr = strings.TrimSpace(sizeStr)
lastChar := len(sizeStr) - 1
@ -179,22 +198,22 @@ func parseSizeInBytes(sizeStr string) uint {
// In case intermediate keys do not exist, or map to a non-map value,
// a new map is created and inserted, and the search continues from there:
// the initial map "m" may be modified!
func deepSearch(m map[string]interface{}, path []string) map[string]interface{} {
func deepSearch(m map[string]any, path []string) map[string]any {
for _, k := range path {
m2, ok := m[k]
if !ok {
// intermediate key does not exist
// => create it and continue from there
m3 := make(map[string]interface{})
m3 := make(map[string]any)
m[k] = m3
m = m3
continue
}
m3, ok := m2.(map[string]interface{})
m3, ok := m2.(map[string]any)
if !ok {
// intermediate key is a value
// => replace with a new map
m3 = make(map[string]interface{})
m3 = make(map[string]any)
m[k] = m3
}
// continue search from here

View file

@ -13,24 +13,24 @@ package viper
import (
"os"
"path/filepath"
"reflect"
"testing"
"github.com/spf13/viper/internal/testutil"
slog "github.com/sagikazarmark/slog-shim"
"github.com/stretchr/testify/assert"
)
func TestCopyAndInsensitiviseMap(t *testing.T) {
var (
given = map[string]interface{}{
given = map[string]any{
"Foo": 32,
"Bar": map[interface{}]interface{}{
"Bar": map[any]any{
"ABc": "A",
"cDE": "B",
},
}
expected = map[string]interface{}{
expected = map[string]any{
"foo": 32,
"bar": map[string]interface{}{
"bar": map[string]any{
"abc": "A",
"cde": "B",
},
@ -39,22 +39,15 @@ func TestCopyAndInsensitiviseMap(t *testing.T) {
got := copyAndInsensitiviseMap(given)
if !reflect.DeepEqual(got, expected) {
t.Fatalf("Got %q\nexpected\n%q", got, expected)
}
assert.Equal(t, expected, got)
_, ok := given["foo"]
assert.False(t, ok)
_, ok = given["bar"]
assert.False(t, ok)
if _, ok := given["foo"]; ok {
t.Fatal("Input map changed")
}
if _, ok := given["bar"]; ok {
t.Fatal("Input map changed")
}
m := given["Bar"].(map[interface{}]interface{})
if _, ok := m["ABc"]; !ok {
t.Fatal("Input map changed")
}
m := given["Bar"].(map[any]any)
_, ok = m["ABc"]
assert.True(t, ok)
}
func TestAbsPathify(t *testing.T) {
@ -64,8 +57,8 @@ func TestAbsPathify(t *testing.T) {
homer := filepath.Join(home, "homer")
wd, _ := os.Getwd()
testutil.Setenv(t, "HOMER_ABSOLUTE_PATH", homer)
testutil.Setenv(t, "VAR_WITH_RELATIVE_PATH", "relative")
t.Setenv("HOMER_ABSOLUTE_PATH", homer)
t.Setenv("VAR_WITH_RELATIVE_PATH", "relative")
tests := []struct {
input string
@ -87,9 +80,7 @@ func TestAbsPathify(t *testing.T) {
}
for _, test := range tests {
got := absPathify(jwwLogger{}, test.input)
if got != test.output {
t.Errorf("Got %v\nexpected\n%q", got, test.output)
}
got := absPathify(slog.Default(), test.input)
assert.Equal(t, test.output, got)
}
}

521
viper.go

File diff suppressed because it is too large Load diff

View file

@ -1,32 +0,0 @@
//go:build go1.16 && finder
// +build go1.16,finder
package viper
import (
"fmt"
"github.com/spf13/afero"
)
// Search all configPaths for any config file.
// Returns the first path that exists (and is a config file).
func (v *Viper) findConfigFile() (string, error) {
finder := finder{
paths: v.configPaths,
fileNames: []string{v.configName},
extensions: SupportedExts,
withoutExtension: v.configType != "",
}
file, err := finder.Find(afero.NewIOFS(v.fs))
if err != nil {
return "", err
}
if file == "" {
return "", ConfigFileNotFoundError{v.configName, fmt.Sprintf("%s", v.configPaths)}
}
return file, nil
}

File diff suppressed because it is too large Load diff

View file

@ -1,56 +0,0 @@
//go:build !viper_yaml3
// +build !viper_yaml3
package viper
var yamlExample = []byte(`Hacker: true
name: steve
hobbies:
- skateboarding
- snowboarding
- go
clothing:
jacket: leather
trousers: denim
pants:
size: large
age: 35
eyes : brown
beard: true
`)
var yamlWriteExpected = []byte(`age: 35
beard: true
clothing:
jacket: leather
pants:
size: large
trousers: denim
eyes: brown
hacker: true
hobbies:
- skateboarding
- snowboarding
- go
name: steve
`)
var yamlExampleWithDot = []byte(`Hacker: true
name: steve
hobbies:
- skateboarding
- snowboarding
- go
clothing:
jacket: leather
trousers: denim
pants:
size: large
age: 35
eyes : brown
beard: true
emails:
steve@hacker.com:
created: 01/02/03
active: true
`)

View file

@ -1,6 +1,3 @@
//go:build viper_yaml3
// +build viper_yaml3
package viper
var yamlExample = []byte(`Hacker: true

View file

@ -1,12 +0,0 @@
//go:build !js
// +build !js
package viper
import "github.com/fsnotify/fsnotify"
type watcher = fsnotify.Watcher
func newWatcher() (*watcher, error) {
return fsnotify.NewWatcher()
}

View file

@ -1,30 +0,0 @@
// +build js,wasm
package viper
import (
"errors"
"github.com/fsnotify/fsnotify"
)
type watcher struct {
Events chan fsnotify.Event
Errors chan error
}
func (*watcher) Close() error {
return nil
}
func (*watcher) Add(name string) error {
return nil
}
func (*watcher) Remove(name string) error {
return nil
}
func newWatcher() (*watcher, error) {
return &watcher{}, errors.New("fsnotify is not supported on WASM")
}