5 Commits

Author SHA1 Message Date
cuddle-please
7744707ea0 chore(release): 0.0.3
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2025-07-23 09:15:37 +00:00
b4c3193f01 feat: handle errors via. required (tests)
All checks were successful
continuous-integration/drone/push Build is passing
2025-07-23 11:15:18 +02:00
eaf71fe65b feat: only error on non required values
All checks were successful
continuous-integration/drone/push Build is passing
2025-07-23 11:12:52 +02:00
a525f93093 chore(release): v0.0.2 (#3)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
chore(release): 0.0.2

Co-authored-by: cuddle-please <bot@cuddle.sh>
Reviewed-on: https://git.front.kjuulh.io/kjuulh/yourconfig/pulls/3
2025-07-22 09:14:41 +02:00
ee07910833 chore: Configure Renovate (#2)
All checks were successful
continuous-integration/drone/push Build is passing
Add renovate.json

Reviewed-on: https://git.front.kjuulh.io/kjuulh/yourconfig/pulls/2
2025-07-22 09:14:01 +02:00
4 changed files with 46 additions and 1 deletions

View File

@@ -6,12 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [0.0.3] - 2025-07-23
### Added
- handle errors via. required (tests)
- only error on non required values
## [0.0.2] - 2025-07-22 ## [0.0.2] - 2025-07-22
### Added ### Added
- add a global handler for getting items - add a global handler for getting items
- rename tag - rename tag
### Other
- Configure Renovate (#2)
Add renovate.json
## [0.0.1] - 2025-07-21 ## [0.0.1] - 2025-07-21
### Added ### Added

View File

@@ -94,7 +94,7 @@ OUTER:
} }
valueStr, err := defaultLogger.Load().Get(ctx, tag.Env) valueStr, err := defaultLogger.Load().Get(ctx, tag.Env)
if err != nil { if err != nil && tag.Required {
errs = append(errs, fmt.Errorf("field: %s failed to load: %w", field.Name, err)) errs = append(errs, fmt.Errorf("field: %s failed to load: %w", field.Name, err))
continue OUTER continue OUTER
} }

View File

@@ -165,4 +165,36 @@ func TestLoad(t *testing.T) {
assert.Equal(t, "some-item", val.SomeItem) assert.Equal(t, "some-item", val.SomeItem)
assert.Equal(t, "some-other-item", val.SomeOtherItem) assert.Equal(t, "some-other-item", val.SomeOtherItem)
}) })
t.Run("required true, error returned", func(t *testing.T) {
type Config struct {
SomeItem string
SomeOtherItem string `cfg:"required:true"`
someBool bool
}
t.Setenv("SOME_OTHER_ITEM", "")
val, err := yourconfig.Load[Config]()
require.Error(t, err)
require.Zero(t, val)
assert.Equal(t, "config failed: field: SomeOtherItem (env=SOME_OTHER_ITEM) is not set and is required", err.Error())
})
t.Run("required false, no error returned", func(t *testing.T) {
type Config struct {
SomeItem string
SomeOtherItem string `cfg:"required:false"`
someBool bool
}
t.Setenv("SOME_OTHER_ITEM", "")
val, err := yourconfig.Load[Config]()
require.NoError(t, err)
assert.Zero(t, val)
})
} }

3
renovate.json Normal file
View File

@@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}