environs/config/config.go doesn't use its own default values

Bug #1825252 reported by Tim McNamara
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
Low
Unassigned

Bug Description

environs/config/config.go[1] defines several dozen default values. In the code that accesses config values[2], the following pattern is common:

  // AgentMetadataURL returns the URL that locates the agent tarballs and metadata,
  // and whether it has been set.
  func (c *Config) AgentMetadataURL() (string, bool) {
   if url, ok := c.defined[AgentMetadataURLKey]; ok && url != "" {
    return url.(string), true
   }
   return "", false
  }

I would expect that this (and other methods) to defer to the defaults provided earlier, rather than duplicating them with hard coded values. The relevant change to this method would be the following:

  // AgentMetadataURL returns the URL that locates the agent tarballs and metadata,
  // and whether it has been set.
  func (c *Config) AgentMetadataURL() (string, bool) {
   if url, ok := c.defined[AgentMetadataURLKey]; ok && url != "" {
    return url.(string), true
   }
   return defaultConfigValues[AgentMetadataURLKey], false
  }

Reducing default duplicates will lead to code that's easier to maintain as updates will only need to occur in a single place.

[1]: https://github.com/juju/juju/blob/6fd5a67d63bbf9c71b2098a653d0af6b9adc85f2/environs/config/config.go#L407
[2]: https://github.com/juju/juju/blob/6fd5a67d63bbf9c71b2098a653d0af6b9adc85f2/environs/config/config.go#L1092

Revision history for this message
Canonical Juju QA Bot (juju-qa-bot) wrote :

This bug has not been updated in 2 years, so we're marking it Low importance. If you believe this is incorrect, please update the importance.

Changed in juju:
importance: Medium → Low
tags: added: expirebugs-bot
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.