Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config InitDefaults #3090

Open
michel-laterman opened this issue Nov 8, 2023 · 0 comments
Open

config InitDefaults #3090

michel-laterman opened this issue Nov 8, 2023 · 0 comments
Labels
Team:Fleet Label for the Fleet team tech debt

Comments

@michel-laterman
Copy link
Contributor

go-ucfg's Unpack method calls InitDefaults on the passed item along with any of it's children that implement the function.

However we explicity call the children's InitDefaults from the parent:

func (c *Input) InitDefaults() {
c.Type = fleetInputType
c.Server.InitDefaults()
c.Cache.InitDefaults()
c.Monitor.InitDefaults()
}

and this continues for a few extra layers:
func (c *Server) InitDefaults() {
c.Host = kDefaultHost
c.Port = kDefaultPort
c.InternalPort = kDefaultInternalPort
c.Timeouts.InitDefaults()
c.CompressionLevel = flate.BestSpeed
c.CompressionThresh = 1024
c.Profiler.InitDefaults()
c.Limits.InitDefaults()
c.Runtime.InitDefaults()
c.Bulk.InitDefaults()
c.GC.InitDefaults()
c.PGP.InitDefaults()
}

These extra InitDefaults calls are not needed; the input's InitDefaults can probably be reduced to

func (c *Input) InitDefaults() { 
 	c.Type = fleetInputType 
}

and most other structs in our config package can be redone as well.
We should try to clean this up to reduce extra calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Fleet Label for the Fleet team tech debt
Projects
None yet
Development

No branches or pull requests

1 participant