Skip to content

Commit a2cba3e

Browse files
authored
fallback to json default cfg path if yaml does not exist (#1810)
Signed-off-by: Janine Olear <[email protected]>
1 parent c07462d commit a2cba3e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cmd/app/serve.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ import (
6767
"google.golang.org/grpc/keepalive"
6868
)
6969

70-
const serveCmdEnvPrefix = "FULCIO_SERVE"
70+
const (
71+
serveCmdEnvPrefix = "FULCIO_SERVE"
72+
defaultConfigPath string = "/etc/fulcio-config/config.yaml"
73+
)
7174

7275
var serveCmdConfigFilePath string
7376

@@ -88,7 +91,7 @@ func newServeCmd() *cobra.Command {
8891
cmd.Flags().String("hsm-caroot-id", "", "HSM ID for Root CA (only used with --ca pkcs11ca)")
8992
cmd.Flags().String("ct-log-url", "http://localhost:6962/test", "host and path (with log prefix at the end) to the ct log")
9093
cmd.Flags().String("ct-log-public-key-path", "", "Path to a PEM-encoded public key of the CT log, used to verify SCTs")
91-
cmd.Flags().String("config-path", "/etc/fulcio-config/config.yaml", "path to fulcio config yaml")
94+
cmd.Flags().String("config-path", defaultConfigPath, "path to fulcio config yaml")
9295
cmd.Flags().String("pkcs11-config-path", "config/crypto11.conf", "path to fulcio pkcs11 config file")
9396
cmd.Flags().String("fileca-cert", "", "Path to CA certificate")
9497
cmd.Flags().String("fileca-key", "", "Path to CA encrypted private key")
@@ -212,6 +215,13 @@ func runServeCmd(cmd *cobra.Command, args []string) { //nolint: revive
212215
_ = flag.CommandLine.Parse([]string{})
213216

214217
cp := viper.GetString("config-path")
218+
if cp == defaultConfigPath {
219+
if _, err := os.Stat(cp); os.IsNotExist(err) {
220+
log.Logger.Warnf("warn loading --config-path=%s: %v, fall back to json", cp, err)
221+
cp = strings.TrimSuffix(cp, ".yaml") + ".json"
222+
}
223+
}
224+
215225
cfg, err := config.Load(cp)
216226
if err != nil {
217227
log.Logger.Fatalf("error loading --config-path=%s: %v", cp, err)

0 commit comments

Comments
 (0)