Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
fa9a5476
Unverified
Commit
fa9a5476
authored
Aug 14, 2023
by
OptimismBot
Committed by
GitHub
Aug 14, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5944 from ethereum-optimism/willc/dotenv
feat(indexer): Load environment variables from .env
parents
3d5e1b2a
0079df87
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
0 deletions
+14
-0
go.mod
go.mod
+1
-0
go.sum
go.sum
+2
-0
config.go
indexer/config/config.go
+11
-0
No files found.
go.mod
View file @
fa9a5476
...
@@ -24,6 +24,7 @@ require (
...
@@ -24,6 +24,7 @@ require (
github.com/ipfs/go-ds-leveldb v0.5.0
github.com/ipfs/go-ds-leveldb v0.5.0
github.com/jackc/pgtype v1.14.0
github.com/jackc/pgtype v1.14.0
github.com/jackc/pgx/v5 v5.4.3
github.com/jackc/pgx/v5 v5.4.3
github.com/joho/godotenv v1.5.1
github.com/lib/pq v1.10.9
github.com/lib/pq v1.10.9
github.com/libp2p/go-libp2p v0.27.8
github.com/libp2p/go-libp2p v0.27.8
github.com/libp2p/go-libp2p-pubsub v0.9.3
github.com/libp2p/go-libp2p-pubsub v0.9.3
...
...
go.sum
View file @
fa9a5476
...
@@ -426,6 +426,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
...
@@ -426,6 +426,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
...
...
indexer/config/config.go
View file @
fa9a5476
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/ethereum-optimism/optimism/indexer/processor"
"github.com/ethereum-optimism/optimism/indexer/processor"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/joho/godotenv"
)
)
// Config represents the `indexer.toml` file used to configure the indexer
// Config represents the `indexer.toml` file used to configure the indexer
...
@@ -55,6 +56,13 @@ type MetricsConfig struct {
...
@@ -55,6 +56,13 @@ type MetricsConfig struct {
// LoadConfig loads the `indexer.toml` config file from a given path
// LoadConfig loads the `indexer.toml` config file from a given path
func
LoadConfig
(
path
string
)
(
Config
,
error
)
{
func
LoadConfig
(
path
string
)
(
Config
,
error
)
{
if
err
:=
godotenv
.
Load
();
err
!=
nil
{
log
.
Warn
(
"Unable to load .env file"
,
err
)
log
.
Info
(
"Continuing without .env file"
)
}
else
{
log
.
Info
(
"Loaded .env file"
)
}
var
conf
Config
var
conf
Config
// Read the config file.
// Read the config file.
...
@@ -68,8 +76,11 @@ func LoadConfig(path string) (Config, error) {
...
@@ -68,8 +76,11 @@ func LoadConfig(path string) (Config, error) {
// Decode the TOML data.
// Decode the TOML data.
if
_
,
err
:=
toml
.
Decode
(
string
(
data
),
&
conf
);
err
!=
nil
{
if
_
,
err
:=
toml
.
Decode
(
string
(
data
),
&
conf
);
err
!=
nil
{
log
.
Info
(
"Failed to decode config file"
,
"message"
,
err
)
return
conf
,
err
return
conf
,
err
}
}
log
.
Debug
(
"Loaded config file"
,
conf
)
return
conf
,
nil
return
conf
,
nil
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment