Skip to content

Commit 52dd6b3

Browse files
committed
Update versions, dependencies, documentation
1 parent 8531362 commit 52dd6b3

17 files changed

Lines changed: 93 additions & 106 deletions

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Examples of bad comments:
129129

130130
```go
131131
// This function loads the config
132-
func Load[T any](sources ...Source) (T, error) { ... }
132+
func Load[T any](sources ...Source) (*T, error) { ... }
133133

134134
// Increment the counter
135135
counter++
@@ -191,7 +191,7 @@ PORT must be between 1 and 65535, got 99999
191191
```go
192192
type Source interface {
193193
Name() string
194-
Lookup(field *FieldInfo) (any, bool, error)
194+
Lookup(ctx context.Context, field *FieldInfo) (any, bool, error)
195195
}
196196
```
197197

README.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ No custom error handling. No secret leaks in logs. Types are checked at compile
5555
**Secret redaction** — mark sensitive fields with `secret:"true"`, they're automatically hidden
5656
**Multiple sources** — load from YAML, env, JSON, TOML, Kubernetes, AWS, Vault with explicit precedence
5757
**Lightweight** — only 2 core dependencies, cloud integrations are optional modules
58-
**Production-ready**v0.9.0 with full test coverage, used in real services
58+
**Production-ready**v1.0.0 with full test coverage and API stability guarantee
5959

6060
```go
6161
type Config struct {
@@ -145,14 +145,14 @@ go get github.com/MimoJanra/confkit/aws@latest
145145

146146
---
147147

148-
## Breaking Changes in v0.10.0
148+
## Breaking Changes in v1.0.0
149149

150150
**`Load[T]` now returns `(*T, error)` instead of `(T, error)` (pointer)**
151151

152152
This aligns with Go idioms for larger configs. Go automatically dereferences pointers for field access, so most code works unchanged:
153153

154154
```go
155-
// v0.10+ — works exactly the same
155+
// v1.0+ — works exactly the same
156156
cfg, err := confkit.Load[Config](confkit.FromEnv())
157157
log.Printf("Port: %d", cfg.Port) // auto-dereference, works fine
158158
```
@@ -319,10 +319,16 @@ Built-in sources — pass any combination, first one to provide a value wins per
319319

320320
```go
321321
confkit.FromYAML(path string) Source
322+
confkit.FromYAMLOptional(path string) Source
323+
confkit.FromYAMLFiles(paths ...string) Source
322324
confkit.FromJSON(path string) Source
325+
confkit.FromJSONFiles(paths ...string) Source
323326
confkit.FromTOML(path string) Source
327+
confkit.FromTOMLFiles(paths ...string) Source
324328
confkit.FromEnv() Source
325329
confkit.FromFlags() Source
330+
confkit.FromFlagsWithArgs(args []string) Source
331+
326332
```
327333

328334
Optional sources (separate `go get` per module):
@@ -347,10 +353,10 @@ etcd.FromEtcdWithPrefix(endpoints []string, prefix string) confkit.Source
347353

348354
// go get confkit/aws
349355
aws.FromAWSSSMParameterStore(pathPrefix string) confkit.Source
350-
aws.FromAWSSSMParameterStoreWithTTL(pathPrefix string, ttl time.Duration) confkit.Source
356+
aws.FromAWSSSMParameterStoreWithTTL(pathPrefix string, cacheTTL time.Duration) confkit.Source
351357
aws.FromAWSSecretsManager(secretName string) confkit.Source
352358
aws.FromAWSSecretsManagerWithRegion(secretName, region string) confkit.Source
353-
aws.FromAWSSecretsManagerWithOptions(secretName, region string, ttl time.Duration) confkit.Source
359+
aws.FromAWSSecretsManagerWithOptions(secretName, region string, cacheTTL time.Duration) confkit.Source
354360
aws.FromAWSSecretsManagerMultiRegion(secretName string, regions []string) confkit.Source
355361
aws.FromAWSSSMParameterStoreMultiRegion(pathPrefix string, regions []string) confkit.Source
356362
```
@@ -408,15 +414,25 @@ func Load[T any](sources ...Source) (*T, error)
408414

409415
// Load with fine-grained options (validators, middleware, interpolation depth)
410416
func LoadWithOptions[T any](options ...Option) (*T, error)
417+
func LoadContext[T any](ctx context.Context, sources ...Source) (*T, error)
418+
func LoadWithOptionsContext[T any](ctx context.Context, options ...Option) (*T, error)
419+
func ValidateOnly[T any](ctx context.Context, options ...Option) (*T, error)
420+
func MustLoad[T any](sources ...Source) *T
421+
func MustLoadContext[T any](ctx context.Context, sources ...Source) *T
411422

412423
// Load and set up a file watcher in one call
413424
func LoadWithWatcher[T any](filePath string, sources ...Source) (*T, *ConfigWatcher, error)
414425

415426
// Option constructors
416427
func WithSource(source Source) Option
417-
func WithValidator(name string, fn func(reflect.Value) error) Option
428+
func WithValidator(name string, fn func (reflect.Value) error) Option
429+
func WithModelValidator[T any](fn func (*T) error) Option
418430
func WithMiddleware(fn MiddlewareFunc) Option
431+
func WithAuditLogger(fn AuditLogger) Option
432+
func WithLoadHook(fn LoadHookFunc) Option
433+
func WithContext(ctx context.Context) Option
419434
func WithInterpolationMaxDepth(depth int) Option
435+
420436
```
421437

422438
---
@@ -459,7 +475,8 @@ type Config struct {
459475
}
460476
```
461477

462-
- Error messages show `<redacted>` instead of the value
478+
- Error messages show `<redacted>` for secret fields
479+
- Validation values are redacted as `***REDACTED***`
463480
- `DumpConfig` substitutes `"***REDACTED***"`
464481
- Safe to log the output of `Explain(err)` and `DumpConfig` without leaking credentials
465482

@@ -587,9 +604,12 @@ type Source interface {
587604
// FieldInfo fields available to your Lookup implementation:
588605
// .Name string — "Password"
589606
// .Path string — "Database.Password"
607+
// .Type reflect.Type
608+
// .Value reflect.Value
590609
// .Tags map[string]string — all struct tags
591610
// .IsSecret bool
592611
// .HasDefault bool
612+
// .IsNested bool
593613
// .AncestorTags []map[string]string — tags of parent structs
594614

595615
// Helper for returning a permanently-errored source (e.g. from a constructor):
@@ -614,6 +634,15 @@ md := schema.GenerateMarkdown[Config]()
614634
help := schema.GenerateCLIHelp[Config]()
615635
```
616636

637+
638+
## Safe Dump API
639+
640+
```go
641+
func Dump[T any](cfg T, opts ...DumpOption) ([]byte, error)
642+
func DumpString[T any](cfg T, opts ...DumpOption) string
643+
func DumpYAML[T any](cfg T, opts ...DumpOption) ([]byte, error)
644+
```
645+
617646
---
618647

619648
## Supported Types
@@ -626,6 +655,7 @@ help := schema.GenerateCLIHelp[Config]()
626655
| `float32` / `float64` | decimal |
627656
| `bool` | `true` `false` `1` `0` `yes` `no` |
628657
| `time.Duration` | `"5s"` `"1m30s"` `"2h"` |
658+
| `time.Time` | RFC3339 `"2006-01-02T15:04:05Z07:00"` |
629659
| `[]string` | comma-separated `"a,b,c"` |
630660
| `[]int` | comma-separated `"1,2,3"` |
631661
| `map[string]string` / `map[string]int` etc. | `KEY=val,KEY2=val2` format |

confkit_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func TestExplainError(t *testing.T) {
294294
}
295295

296296
explained := Explain(err)
297-
if !strings.Contains(explained, "<redacted>") {
297+
if !strings.Contains(explained, "***REDACTED***") {
298298
t.Errorf("expected secret to be redacted, got: %s", explained)
299299
}
300300
}
@@ -655,7 +655,7 @@ func TestValidationWithSecretRedaction(t *testing.T) {
655655
})
656656

657657
formatted := report.Format()
658-
if !strings.Contains(formatted, "<redacted>") {
658+
if !strings.Contains(formatted, "***REDACTED***") {
659659
t.Errorf("expected secret to be redacted in error, got: %s", formatted)
660660
}
661661
if strings.Contains(formatted, "super-secret-12345") {

docs/api/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Complete reference for confkit's public API.
1212
### Load
1313

1414
```go
15-
func Load[T any](sources ...Source) (T, error)
15+
func Load[T any](sources ...Source) (*T, error)
1616
```
1717

1818
Loads configuration from the provided sources and returns a fully typed, validated config or an error.
@@ -43,7 +43,7 @@ if err != nil {
4343
### LoadWithOptions
4444

4545
```go
46-
func LoadWithOptions[T any](options ...Option) (T, error)
46+
func LoadWithOptions[T any](options ...Option) (*T, error)
4747
```
4848

4949
Advanced loading with functional options for custom validators, middleware, and interpolation configuration.
@@ -90,7 +90,7 @@ cfg, err := confkit.LoadWithOptions[Config](
9090
### LoadWithWatcher
9191

9292
```go
93-
func LoadWithWatcher[T any](filePath string, sources ...Source) (T, *ConfigWatcher, error)
93+
func LoadWithWatcher[T any](filePath string, sources ...Source) (*T, *ConfigWatcher, error)
9494
```
9595

9696
Loads configuration and returns a watcher for hot-reloading when files change.

docs/comparison/envconfig.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,4 @@ cfg, err := confkit.Load[Config](
235235
## Maturity
236236

237237
- **envconfig:** Lightweight, stable, minimal changes
238-
- **confkit:** Production-ready v0.9.0, actively developed with cloud integrations
238+
- **confkit:** Production-ready v1.0.0, actively developed with cloud integrations

docs/comparison/koanf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,4 @@ value := k.Get("some.dynamic.key")
314314
## Maturity
315315

316316
- **koanf:** Stable, widely used for flexible configurations
317-
- **confkit:** Production-ready v0.9.0, focused on typed, validated, struct-first config
317+
- **confkit:** Production-ready v1.0.0, focused on typed, validated, struct-first config

docs/comparison/viper.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@ If you're moving from Viper to confkit:
162162
## Maturity
163163

164164
- **Viper:** Mature, widely used, large community
165-
- **confkit:** Production-ready v0.9.0, focused on a specific use case (type-safe, validated, struct-first)
165+
- **confkit:** Production-ready v1.0.0, focused on a specific use case (type-safe, validated, struct-first)

docs/docs/index.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,34 @@ title: Documentation
77

88
## Getting Started
99

10-
- **[Installation & Quick Start](./getting-started/)** — Set up confkit in 5 minutes
11-
- **[Core Concepts](./concepts/)**Understanding sources, validation, and error handling
10+
- **[Installation & Quick Start](./getting-started.md)** — Set up confkit in 5 minutes
11+
- **[Configuration Sources](./sources.md)**Environment variables, files, cloud services
1212
- **[Examples](https://github.com/MimoJanra/confkit/tree/main/examples)** — Production-ready code samples
1313

1414
## Usage Guides
1515

16-
- **[Configuration Sources](./sources/)** — Environment variables, files, cloud services
17-
- **[Validation](./validation/)** — Built-in rules and custom validators
18-
- **[Error Handling](./errors/)** — Human-readable error messages and debugging
19-
- **[Advanced Features](./advanced/)** — Interpolation, options, hot reload
16+
- **[Validation](./validation.md)** — Built-in rules and custom validators
17+
- **[Defaults & Fallbacks](./defaults.md)** — Setting default values and merging sources
18+
- **[Schema Generation](./schema-generation.md)** — Generate JSON Schema and CLI help
19+
- **[Secret Redaction](./secret-redaction.md)** — Secure handling of sensitive fields
20+
- **[Hot Reload](./hot-reload.md)** — File watching and configuration updates
2021

2122
## Upgrading
2223

23-
- **[Migration Guide: v0.10.0](./migration-v0.10.md)** — Breaking changes and how to migrate from v0.9
24+
- **[Migration Guide: v1.0.0](./migration-v0.10.md)** — Breaking changes and how to migrate from v0.9
2425

2526
## Cloud & Enterprise
2627

27-
- **[Kubernetes](./cloud/kubernetes/)** — ConfigMap and Secret sources
28-
- **[AWS](./cloud/aws/)** — SSM Parameter Store and Secrets Manager
29-
- **[HashiCorp](./cloud/hashicorp/)** — Vault, Consul, and etcd
30-
- **[Secret Rotation](./enterprise/rotation/)** — Automatic credential refresh
28+
- **[Kubernetes Integration](./recipes/kubernetes-configmap.md)** — ConfigMap and Secret sources
29+
- **[AWS Integration](./recipes/aws-secrets-manager.md)** — SSM Parameter Store and Secrets Manager
30+
- **[HashiCorp Integration](./recipes/vault.md)** — Vault, Consul, and etcd
31+
- **[Environment-Only Config](./recipes/env-only.md)** — Simple env var loading
32+
- **[CLI Flags](./recipes/cli-flags.md)** — Command-line argument parsing
3133

32-
## Versions
34+
## Latest Version
3335

34-
- **[v0.5](./v0.5/)** — Latest stable (full feature set)
35-
- **[v0.4](./v0.4/)** — Production with cloud sources
36-
- **[v0.3](./v0.3/)** — Enhanced DX with interpolation
37-
- **[v0.2](./v0.2/)** — Schema generation and TOML
38-
- **[v0.1](./v0.1/)** — Core MVP
36+
**v1.0.0** — Full API stability, production-ready release with comprehensive documentation
3937

4038
## Philosophy
4139

42-
[Design principles and philosophy behind confkit](./philosophy/)
40+
- **[Design Principles](../philosophy.md)** — Design decisions and architecture behind confkit

docs/docs/installation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func main() {
138138
if err != nil {
139139
log.Fatal(err)
140140
}
141-
log.Printf("Port: %d", cfg.Port) // cfg is *Config pointer (v0.10+)
141+
log.Printf("Port: %d", cfg.Port) // cfg is *Config pointer (v1.0+)
142142
}
143143
```
144144

@@ -151,10 +151,10 @@ go run main.go
151151

152152
## Version Notes
153153

154-
**v0.10.0 (current stable):**
154+
**v1.0.0 (current stable):**
155155
- `Load[T]` returns `(*T, error)` instead of `(T, error)` — pointer return (breaking change from v0.9)
156156
- Most code works unchanged due to Go auto-dereference behavior
157-
- See [Migration Guide](./migration-v0.10.md) for details
157+
- See [Migration Guide](./migration-v1.0.md) for details
158158

159159
**v0.9:**
160160
- `Load[T]` returned `(T, error)` — value return
@@ -210,7 +210,7 @@ If you see version conflicts with other dependencies (especially AWS SDK):
210210

211211
```bash
212212
go mod tidy
213-
go get github.com/MimoJanra/confkit@v0.9.0 # pin explicit version
213+
go get github.com/MimoJanra/confkit@v1.0.0 # pin explicit version
214214
```
215215

216216
## Next Steps

docs/docs/migration-v0.10.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
layout: default
3-
title: Migration Guide - v0.10.0
3+
title: Migration Guide - v1.0.0
44
---
55

6-
# Migration Guide: v0.9 → v0.10
6+
# Migration Guide: v0.9 → v1.0
77

8-
v0.10.0 introduces breaking changes. This guide explains what changed and how to migrate.
8+
v1.0.0 introduces breaking changes. This guide explains what changed and how to migrate.
99

1010
## Breaking Changes
1111

@@ -17,7 +17,7 @@ cfg, err := confkit.Load[Config](confkit.FromEnv())
1717
// cfg type: Config
1818
```
1919

20-
**After (v0.10):**
20+
**After (v1.0):**
2121
```go
2222
cfg, err := confkit.Load[Config](confkit.FromEnv())
2323
// cfg type: *Config (pointer)
@@ -42,7 +42,7 @@ log.Printf("Port: %d", (*cfg).Port) // ✅ Explicit dereference (unnecessary)
4242
func Handler(cfg Config) {}
4343
handler(cfg) // ERROR: type mismatch
4444

45-
// Fixed (v0.10+)
45+
// Fixed (v1.0+)
4646
func Handler(cfg *Config) {}
4747
handler(cfg) // ✅ Works
4848

@@ -98,7 +98,7 @@ cfg, err := otel.Load[Config](tracer, sources...)
9898
// cfg type: *Config (pointer)
9999
```
100100

101-
## New Features in v0.10
101+
## New Features in v1.0
102102

103103
### FromYAMLOptional()
104104

@@ -183,7 +183,7 @@ func main() {
183183
server := &Server{Config: cfg} // Store in struct
184184
}
185185

186-
// v0.10 — same code, no changes needed!
186+
// v1.0 — same code, no changes needed!
187187
func main() {
188188
cfg, err := confkit.Load[Config](confkit.FromEnv())
189189
if err != nil {
@@ -211,4 +211,4 @@ A: No, but migration is simple. Most code works unchanged due to Go's auto-deref
211211

212212
- See **[FromYAMLOptional()](./sources.md#yaml-files)** for optional file loading
213213
- See **[Automatic snake_case mapping](./sources.md#automatic-snake_case-mapping-v010)** for field mapping
214-
- See **[Examples](https://github.com/MimoJanra/confkit/tree/main/examples)** for production-ready code with v0.10
214+
- See **[Examples](https://github.com/MimoJanra/confkit/tree/main/examples)** for production-ready code with v1.0

0 commit comments

Comments
 (0)