Skip to content

Commit 67838a9

Browse files
committed
fix: use ct_index path from config file if no outfile is given
Instead of always relying on the --out parameter, we first check the config file for a file path. Only if a file is passed via the --out parameter, we use that instead. fixes #102
1 parent 360b799 commit 67838a9

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

cmd/certstream-server-go/createIndex.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ create-index will create and pre fill the ct-index.json file with the current va
4242
return fmt.Errorf("failed to obtain 'out' flag: %w", err)
4343
}
4444

45+
// Obtain ct_index file path from config
46+
if outFilePath == "" && conf.General.Recovery.CTIndexFile != "" {
47+
outFilePath = config.AppConfig.General.Recovery.CTIndexFile
48+
}
49+
4550
// Check if outfile already exists
46-
outFileAbsPath, err := filepath.Abs(outFilePath)
47-
if err != nil {
48-
return fmt.Errorf("failed to obtain absolute path: %w", err)
51+
outFileAbsPath, absErr := filepath.Abs(outFilePath)
52+
if absErr != nil {
53+
return fmt.Errorf("failed to obtain absolute path: %w", absErr)
4954
}
5055

5156
if _, statErr := os.Stat(outFileAbsPath); statErr == nil {
@@ -67,6 +72,6 @@ create-index will create and pre fill the ct-index.json file with the current va
6772
func init() {
6873
rootCmd.AddCommand(createIndexCmd)
6974

70-
createIndexCmd.Flags().StringP("out", "o", "ct_index.json", "Path to the index file to create")
75+
createIndexCmd.Flags().StringP("out", "o", "", "Path to the index file to create. Overrides the path in the config.")
7176
createIndexCmd.Flags().BoolP("force", "f", false, "Whether to override the index file if it already exists")
7277
}

0 commit comments

Comments
 (0)