-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71edd75
commit 830e674
Showing
6 changed files
with
47 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package docs | ||
|
||
import ( | ||
"log" | ||
"strings" | ||
"sync" | ||
|
||
"github.com/smartcontractkit/chainlink/v2/core/config/toml" | ||
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink/cfgtest" | ||
"github.com/smartcontractkit/chainlink/v2/core/store/dialects" | ||
"github.com/smartcontractkit/chainlink/v2/core/utils/config" | ||
) | ||
|
||
var ( | ||
defaults toml.Core | ||
defaultsMu sync.Mutex | ||
) | ||
|
||
func CoreDefaults() (c toml.Core) { | ||
defaultsMu.Lock() | ||
defer defaultsMu.Unlock() | ||
|
||
if (defaults == toml.Core{}) { | ||
if err := cfgtest.DocDefaultsOnly(strings.NewReader(coreDefaultsTOML), &defaults, config.DecodeTOML); err != nil { | ||
log.Fatalf("Failed to initialize defaults from docs: %v", err) | ||
} | ||
} | ||
|
||
c.SetFrom(&defaults) | ||
c.Database.Dialect = dialects.Postgres // not user visible - overridden for tests only | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package docs | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink/cfgtest" | ||
) | ||
|
||
func TestCoreDefaults_notNil(t *testing.T) { | ||
cfgtest.AssertFieldsNotNil(t, CoreDefaults()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters