Skip to content

Commit

Permalink
remove ConfigAware
Browse files Browse the repository at this point in the history
  • Loading branch information
ktong committed Nov 14, 2023
1 parent e4eb38c commit 8838852
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 33 deletions.
4 changes: 0 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ func New(opts ...Option) (Config, error) {
continue
}

if configAware, ok := loader.(ConfigAware); ok {
configAware.WithConfig(config)
}

values, err := loader.Load()
if err != nil {
return Config{}, fmt.Errorf("[konf] load configuration: %w", err)
Expand Down
19 changes: 0 additions & 19 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,6 @@ func TestConfig_Unmarshal(t *testing.T) {
assert.Equal(t, "", cfg)
},
},
{
description: "configer",
opts: []konf.Option{
konf.WithLoader(mapLoader{}),
},
assert: func(config konf.Config) {
var configured bool
assert.NoError(t, config.Unmarshal("configured", &configured))
assert.True(t, configured)
},
},
}

for i := range testcases {
Expand All @@ -139,14 +128,6 @@ func TestConfig_Unmarshal(t *testing.T) {

type mapLoader map[string]any

func (m mapLoader) WithConfig(
interface {
Unmarshal(path string, target any) error
},
) {
m["configured"] = true
}

func (m mapLoader) Load() (map[string]any, error) {
return m, nil
}
Expand Down
10 changes: 0 additions & 10 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,3 @@ type Loader interface {
type Watcher interface {
Watch(ctx context.Context, onChange func(map[string]any)) error
}

// ConfigAware is the interface that wraps the WithConfig method.
//
// WithConfig enables provider uses configuration loaded by providers before it.
// It ensures the WithConfig is called before executing methods in Loader and Watcher.
type ConfigAware interface {
WithConfig(config interface {
Unmarshal(path string, target any) error
})
}

0 comments on commit 8838852

Please sign in to comment.