Skip to content

Commit 8078d44

Browse files
Bug Fix: Fix auto-loading search (algorand#1065)
1 parent 6cb6f97 commit 8078d44

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ Below is a snippet of the output from `algorand-indexer api-config`:
144144

145145
Seeing this we know that the `/v2/accounts` endpoint will return an error if either `currency-greater-than` or `currency-less-than` is provided. Additionally, because a "required" parameter is provided for `/v2/assets/{asset-id}/transactions` then we know this entire endpoint is disabled. The optional parameters are provided so that you can understand what else is disabled if you enable all "required" parameters.
146146

147+
**NOTE: An empty parameter configuration file results in all parameters being ENABLED.**
148+
147149
For more information on disabling parameters see the [Disabling Parameters Guide](docs/DisablingParametersGuide.md).
148150

149151
## Metrics
@@ -212,6 +214,8 @@ The Indexer data directory is the location where the Indexer can store and/or lo
212214

213215
**It is a required argument for Indexer daemon operation. Supply it to the Indexer via the `--data-dir` flag.**
214216

217+
**It is HIGHLY recommended placing the data directory in a separate, stateful directory for production usage of the Indexer.**
218+
215219

216220
### Auto-Loading Configuration
217221

cmd/algorand-indexer/daemon.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ var daemonCmd = &cobra.Command{
109109
maybeFail(err, "invalid config file (%s): %v", viper.ConfigFileUsed(), err)
110110
}
111111
fmt.Printf("Using configuration file: %s\n", configFile)
112+
config.BindFlags(cmd)
112113
}
113114

114115
if paramConfigFound {
@@ -119,7 +120,7 @@ var daemonCmd = &cobra.Command{
119120
panic(exit{1})
120121
}
121122
suppliedAPIConfigFile = filepath.Join(indexerDataDir, autoLoadParameterConfigName)
122-
fmt.Printf("Auto-loading parameter configuration file: %s", suppliedAPIConfigFile)
123+
fmt.Printf("Auto-loading parameter configuration file: %s\n", suppliedAPIConfigFile)
123124

124125
}
125126

@@ -343,7 +344,14 @@ func makeOptions() (options api.ExtraOptions) {
343344
fmt.Fprintf(os.Stderr, "failed to created disabled map config from file: %v", err)
344345
panic(exit{1})
345346
}
347+
348+
if len((*potentialDisabledMapConfig).Data) == 0 {
349+
logger.Warnf("All parameters are enabled since the provided parameter configuration file (%s) is empty.", suppliedAPIConfigFile)
350+
}
351+
346352
options.DisabledMapConfig = potentialDisabledMapConfig
353+
} else {
354+
logger.Infof("Enable all parameters flag is set to: %v", enableAllParameters)
347355
}
348356

349357
return

cmd/algorand-indexer/main.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,8 @@ func init() {
136136
// Setup configuration file
137137
viper.SetConfigName(config.FileName)
138138
viper.SetConfigType(config.FileType)
139-
for _, k := range config.ConfigPaths {
140-
viper.AddConfigPath(k)
141-
}
142139
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
143140

144-
if err := viper.ReadInConfig(); err != nil {
145-
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
146-
// Config file not found, not an error since it may be set on the CLI.
147-
} else {
148-
fmt.Fprintf(os.Stderr, "invalid config file (%s): %v", viper.ConfigFileUsed(), err)
149-
panic(exit{1})
150-
}
151-
} else {
152-
fmt.Printf("Using configuration file: %s\n", viper.ConfigFileUsed())
153-
}
154-
155141
viper.SetEnvPrefix(config.EnvPrefix)
156142
viper.AutomaticEnv()
157143

config/config.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ const FileType = "yml"
1919
// gets confused and thinks the binary is a config file with no extension.
2020
const FileName = "indexer"
2121

22-
// ConfigPaths are the different locations that algorand-indexer should look for config files.
23-
var ConfigPaths = [...]string{".", "$HOME", "$HOME/.algorand-indexer/", "$HOME/.config/algorand-indexer/", "/etc/algorand-indexer/"}
24-
2522
// BindFlags glues the cobra and viper libraries together.
2623
func BindFlags(cmd *cobra.Command) {
2724
cmd.Flags().VisitAll(func(f *pflag.Flag) {

docs/DisablingParametersGuide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ The first "level" is a key-value pair where the key is the REST path to the endp
4545

4646
As a concrete example: in the above snippet the endpoint `/v2/accounts` has two optional parameters that are disabled: `currency-greater-than` and `currency-less-than`. Querying that endpoint and providing either of those two parameters would result in an error being returned.
4747

48+
**NOTE: An empty parameter configuration file results in all parameters being ENABLED.**
49+
4850
### Error Return Value
4951

5052
If you query an endpoint with a required parameter you will receive a `400` response with a json message explaining the error.

0 commit comments

Comments
 (0)