Skip to content

Commit

Permalink
Merge pull request #265 from SiaFoundation/nate/omit-empty-yaml-config
Browse files Browse the repository at this point in the history
Hide unset config fields from encoder
  • Loading branch information
n8maninger authored Jan 8, 2024
2 parents 6403c8e + bbbf39e commit 085f43a
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,68 @@ package config
type (
// HTTP contains the configuration for the HTTP server.
HTTP struct {
Address string `yaml:"address"`
Password string `yaml:"password"`
Address string `yaml:"address,omitempty"`
Password string `yaml:"password,omitempty"`
}

// Consensus contains the configuration for the consensus set.
Consensus struct {
GatewayAddress string `yaml:"gatewayAddress"`
Bootstrap bool `yaml:"bootstrap"`
GatewayAddress string `yaml:"gatewayAddress,omitempty"`
Bootstrap bool `yaml:"bootstrap,omitempty"`
Peers []string `toml:"peers,omitempty"`
}

// RHP2 contains the configuration for the RHP2 server.
RHP2 struct {
Address string `yaml:"address"`
Address string `yaml:"address,omitempty"`
}

// RHP3 contains the configuration for the RHP3 server.
RHP3 struct {
TCPAddress string `yaml:"tcp"`
WebSocketAddress string `yaml:"websocket"`
CertPath string `yaml:"certPath"`
KeyPath string `yaml:"keyPath"`
TCPAddress string `yaml:"tcp,omitempty"`
WebSocketAddress string `yaml:"websocket,omitempty"`
CertPath string `yaml:"certPath,omitempty"`
KeyPath string `yaml:"keyPath,omitempty"`
}

// LogFile configures the file output of the logger.
LogFile struct {
Enabled bool `yaml:"enabled"`
Level string `yaml:"level"` // override the file log level
Format string `yaml:"format"`
Enabled bool `yaml:"enabled,omitempty"`
Level string `yaml:"level,omitempty"` // override the file log level
Format string `yaml:"format,omitempty"`
// Path is the path of the log file.
Path string `yaml:"path"`
Path string `yaml:"path,omitempty"`
}

// StdOut configures the standard output of the logger.
StdOut struct {
Level string `yaml:"level"` // override the stdout log level
Enabled bool `yaml:"enabled"`
Format string `yaml:"format"`
EnableANSI bool `yaml:"enableANSI"` //nolint:tagliatelle
Level string `yaml:"level,omitempty"` // override the stdout log level
Enabled bool `yaml:"enabled,omitempty"`
Format string `yaml:"format,omitempty"`
EnableANSI bool `yaml:"enableANSI,omitempty"` //nolint:tagliatelle
}

// Log contains the configuration for the logger.
Log struct {
// Path is the directory to store the hostd.log file.
// Deprecated: use File.Path instead.
Path string `yaml:"path"`
Level string `yaml:"level"` // global log level
StdOut StdOut `yaml:"stdout"`
File LogFile `yaml:"file"`
Path string `yaml:"path,omitempty"`
Level string `yaml:"level,omitempty"` // global log level
StdOut StdOut `yaml:"stdout,omitempty"`
File LogFile `yaml:"file,omitempty"`
}

// Config contains the configuration for the host.
Config struct {
Name string `yaml:"name"`
Directory string `yaml:"directory"`
RecoveryPhrase string `yaml:"recoveryPhrase"`
AutoOpenWebUI bool `yaml:"autoOpenWebUI"`
Name string `yaml:"name,omitempty"`
Directory string `yaml:"directory,omitempty"`
RecoveryPhrase string `yaml:"recoveryPhrase,omitempty"`
AutoOpenWebUI bool `yaml:"autoOpenWebUI,omitempty"`

HTTP HTTP `yaml:"http"`
Consensus Consensus `yaml:"consensus"`
RHP2 RHP2 `yaml:"rhp2"`
RHP3 RHP3 `yaml:"rhp3"`
Log Log `yaml:"log"`
HTTP HTTP `yaml:"http,omitempty"`
Consensus Consensus `yaml:"consensus,omitempty"`
RHP2 RHP2 `yaml:"rhp2,omitempty"`
RHP3 RHP3 `yaml:"rhp3,omitempty"`
Log Log `yaml:"log,omitempty"`
}
)

0 comments on commit 085f43a

Please sign in to comment.