mirror of
https://github.com/smallstep/certificates.git
synced 2024-10-31 03:20:16 +00:00
Improve configuration file initialization log output
This commit is contained in:
parent
fd38dd34f9
commit
54c560f620
@ -75,7 +75,7 @@ type Config struct {
|
||||
SkipValidation bool `json:"-"`
|
||||
|
||||
// Keeps record of the filename the Config is read from
|
||||
loadedFromFilename string
|
||||
loadedFromFilepath string
|
||||
}
|
||||
|
||||
// ASN1DN contains ASN1.DN attributes that are used in Subject and Issuer
|
||||
@ -167,7 +167,7 @@ func LoadConfiguration(filename string) (*Config, error) {
|
||||
}
|
||||
|
||||
// store filename that was read to populate Config
|
||||
c.loadedFromFilename = filename
|
||||
c.loadedFromFilepath = filename
|
||||
|
||||
// initialize the Config
|
||||
c.Init()
|
||||
@ -215,13 +215,19 @@ func (c *Config) Commit() error {
|
||||
if !c.WasLoadedFromFile() {
|
||||
return errors.New("cannot commit configuration if not loaded from file")
|
||||
}
|
||||
return c.Save(c.loadedFromFilename)
|
||||
return c.Save(c.loadedFromFilepath)
|
||||
}
|
||||
|
||||
// WasLoadedFromFile returns whether or not the Config was
|
||||
// read from a file.
|
||||
// loaded from a file.
|
||||
func (c *Config) WasLoadedFromFile() bool {
|
||||
return c.loadedFromFilename != ""
|
||||
return c.loadedFromFilepath != ""
|
||||
}
|
||||
|
||||
// Filepath returns the path to the file the Config was
|
||||
// loaded from.
|
||||
func (c *Config) Filepath() string {
|
||||
return c.loadedFromFilepath
|
||||
}
|
||||
|
||||
// Validate validates the configuration.
|
||||
|
9
ca/ca.go
9
ca/ca.go
@ -349,7 +349,7 @@ func (ca *CA) Run() error {
|
||||
if step.Contexts().GetCurrent() != nil {
|
||||
log.Printf("Current context: %s", step.Contexts().GetCurrent().Name)
|
||||
}
|
||||
log.Printf("Config file: %s", ca.opts.configFile)
|
||||
log.Printf("Config file: %s", ca.getConfigFileOutput())
|
||||
baseURL := fmt.Sprintf("https://%s%s",
|
||||
authorityInfo.DNSNames[0],
|
||||
ca.config.Address[strings.LastIndex(ca.config.Address, ":"):])
|
||||
@ -569,3 +569,10 @@ func dumpRoutes(mux chi.Routes) {
|
||||
fmt.Printf("Logging err: %s\n", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func (ca *CA) getConfigFileOutput() string {
|
||||
if ca.config.WasLoadedFromFile() {
|
||||
return ca.config.Filepath()
|
||||
}
|
||||
return "loaded from token"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user