Skip to content

Commit 958ee81

Browse files
committed
Renamed tools-metadata-url to agent-metadata-url. Deleted tools-url.
1 parent 2e6a46d commit 958ee81

16 files changed

+99
-89
lines changed

cmd/juju/upgradejuju_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ func (s *UpgradeJujuSuite) TestUpgradeJuju(c *gc.C) {
305305
// Set up state and environ, and run the command.
306306
toolsDir := c.MkDir()
307307
updateAttrs := map[string]interface{}{
308-
"agent-version": test.agentVersion,
309-
"tools-metadata-url": "file://" + toolsDir + "/tools",
308+
"agent-version": test.agentVersion,
309+
config.AgentMetadataURLKey: "file://" + toolsDir + "/tools",
310310
}
311311
err := s.State.UpdateEnvironConfig(updateAttrs, nil, nil)
312312
c.Assert(err, gc.IsNil)
@@ -482,8 +482,8 @@ upgrade to this version by running
482482
c.Assert(err, gc.IsNil)
483483
toolsDir := c.MkDir()
484484
updateAttrs := map[string]interface{}{
485-
"agent-version": test.agentVersion,
486-
"tools-metadata-url": "file://" + toolsDir + "/tools",
485+
"agent-version": test.agentVersion,
486+
config.AgentMetadataURLKey: "file://" + toolsDir + "/tools",
487487
}
488488

489489
err = s.State.UpdateEnvironConfig(updateAttrs, nil, nil)

doc/contributions/juju-14-10-plans.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@ Juju CI has functional tests that exercise a function works across multiple vers
19741974
1. 100% major.minor compatibility. Stable micro releases work with every combination?
19751975
1. The means keeping a pool of stable packages for CI.
19761976
1. Encourages creating new minor stables instead of adding test combinations; but SRU discourages minor releases.
1977-
1. CI is **blocked** because Juju doesn’t allow anyone to specify the juju version to bootstrap the env with, nor can tools-metadata-url be set more than once to control the version found.
1977+
1. CI is **blocked** because Juju doesn’t allow anyone to specify the juju version to bootstrap the env with, nor can agent-metadata-url be set more than once to control the version found.
19781978

19791979
### Work Items
19801980

doc/simplestreams-metadata.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Basic Workflow
2020
Whether images or tools, Juju uses a search path to try and find suitable metadata.
2121
The path components (in order of lookup) are:
2222

23-
1. User supplied location (specified by tools-metadata-url or image-metadata-url config settings)
23+
1. User supplied location (specified by agent-metadata-url or image-metadata-url config settings)
2424
2. The environment's cloud storage
2525
3. Provider specific locations (eg keystone endpoint if on Openstack)
2626
4. A web location with metadata for supported public clouds (https://streams.canonical.com/juju)
@@ -100,15 +100,15 @@ override what is provided by the cloud.
100100

101101
These are initially specified in the environments.yaml file (and then subsequently copied to the
102102
jenv file when the environment is bootstrapped). For images, use "image-metadata-url"; for tools,
103-
use "tools-metadata-url". The URLs can point to a world readable container/bucket in the cloud,
103+
use "agent-metadata-url". The URLs can point to a world readable container/bucket in the cloud,
104104
an address served by a http server, or even a shared directory accessible by all node instances
105105
running in the cloud.
106106

107107
eg assume an Apache http server with base URL https://juju-metadata, providing access to
108108
information at <base>/images and <base>/tools. The Juju environment yaml file could have
109109
the following entries (one or both):
110110

111-
tools-metadata-url: https://juju-metadata/tools
111+
agent-metadata-url: https://juju-metadata/tools
112112
image-metadata-url: https://juju-metadata/images
113113

114114
The required files in each location is as per the directory layout described earlier.
@@ -181,14 +181,14 @@ Then either
181181
or
182182
- optionally, copy image metadata to somewhere in the metadata search path
183183
- optionally, mirror tools to somewhere in the metadata search path
184-
- optionally, configure tools-metadata-url and/or image-metadata-url
184+
- optionally, configure agent-metadata-url and/or image-metadata-url
185185

186186
If the bootstrap --metadata-source directory option is used, any image metadata and tools found
187187
in the specified directory will be uploaded automatically to the cloud storage for that deployment.
188188
This is useful for situations where image and tools metadata do not need to be shared amongst several
189189
users, since each Juju environment will upload its own separate copy of the required files.
190190

191-
Using the image-metadata-url and tools-metadata-url to point to publicly accessible locations is useful
191+
Using the image-metadata-url and agent-metadata-url to point to publicly accessible locations is useful
192192
when several Juju environments are to be deployed on a private cloud and the metadata should be shared.
193193

194194
1. Image metadata
@@ -232,9 +232,9 @@ Then, the contents of <metadata_dir> can be uploaded to a location in the Juju m
232232
bootstrap --metadata-source option may be used.
233233

234234
Examples:
235-
1. tools-metadata-url
235+
1. agent-metadata-url
236236
- upload contents of <metadata_dir> to http://somelocation
237-
- set tools-metadata-url to http://somelocation/tools
237+
- set agent-metadata-url to http://somelocation/tools
238238
2. bootstrap option
239239
- juju bootstrap --metadata-source <tools_dir>
240240

environs/bootstrap/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

2828
const noToolsMessage = `Juju cannot bootstrap because no tools are available for your environment.
29-
You may want to use the 'tools-metadata-url' configuration setting to specify the tools location.
29+
You may want to use the 'agent-metadata-url' configuration setting to specify the tools location.
3030
`
3131

3232
var (

environs/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (envs *Environs) Config(name string) (*config.Config, error) {
7272

7373
// If deprecated config attributes are used, log warnings so the user can know
7474
// that they need to be fixed.
75-
envs.logDeprecatedWarnings(attrs, "tools-url", "tools-metadata-url")
75+
envs.logDeprecatedWarnings(attrs, config.ToolsMetadataURLKey, config.AgentMetadataURLKey)
7676

7777
// null has been renamed to manual (with an alias for existing config).
7878
if oldType, _ := attrs["type"].(string); oldType == "null" {

environs/config/config.go

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ const (
9494

9595
// ToolsStreamKey stores the key for this setting.
9696
ToolsStreamKey = "tools-stream"
97+
98+
// TOOL-METADATA- vs AGENT-METADATA- URL
99+
// AgentMetadataURLKey stores the key for this setting.
100+
AgentMetadataURLKey = "agent-metadata-url"
101+
102+
//
103+
// Deprecated Settings
104+
//
105+
106+
// ToolsMetadataURLKey stores the key for this setting.
107+
ToolsMetadataURLKey = "tools-metadata-url"
97108
)
98109

99110
// ParseHarvestMode parses description of harvesting method and
@@ -346,17 +357,17 @@ func (c *Config) fillInStringDefault(attr string) {
346357
// attribute values still be used.
347358
func (cfg *Config) processDeprecatedAttributes() {
348359
// The tools url has changed so ensure that both old and new values are in the config so that
349-
// upgrades work. "tools-url" is the old attribute name.
350-
if oldToolsURL := cfg.defined["tools-url"]; oldToolsURL != nil && oldToolsURL.(string) != "" {
351-
_, newToolsSpecified := cfg.ToolsURL()
352-
// Ensure the new attribute name "tools-metadata-url" is set.
360+
// upgrades work. "agent-metadata-url" is the old attribute name.
361+
if oldToolsURL := cfg.defined[ToolsMetadataURLKey]; oldToolsURL != nil && oldToolsURL.(string) != "" {
362+
_, newToolsSpecified := cfg.AgentMetadataURL()
363+
// Ensure the new attribute name "agent-metadata-url" is set.
353364
if !newToolsSpecified {
354-
cfg.defined["tools-metadata-url"] = oldToolsURL
365+
cfg.defined[AgentMetadataURLKey] = oldToolsURL
355366
}
356367
}
357-
// Even if the user has edited their environment yaml to remove the deprecated tools-url value,
368+
// Even if the user has edited their environment yaml to remove the deprecated tools-metadata-url value,
358369
// we still want it in the config for upgrades.
359-
cfg.defined["tools-url"], _ = cfg.ToolsURL()
370+
cfg.defined[ToolsMetadataURLKey], _ = cfg.AgentMetadataURL()
360371

361372
// Copy across lxc-use-clone to lxc-clone.
362373
if lxcUseClone, ok := cfg.defined["lxc-use-clone"]; ok {
@@ -817,10 +828,10 @@ func (c *Config) AgentVersion() (version.Number, bool) {
817828
return version.Zero, false
818829
}
819830

820-
// ToolsURL returns the URL that locates the tools tarballs and metadata,
831+
// AgentMetadataURL returns the URL that locates the agent tarballs and metadata,
821832
// and whether it has been set.
822-
func (c *Config) ToolsURL() (string, bool) {
823-
if url, ok := c.defined["tools-metadata-url"]; ok && url != "" {
833+
func (c *Config) AgentMetadataURL() (string, bool) {
834+
if url, ok := c.defined[AgentMetadataURLKey]; ok && url != "" {
824835
return url.(string), true
825836
}
826837
return "", false
@@ -994,7 +1005,7 @@ var fields = schema.Fields{
9941005
"name": schema.String(),
9951006
"uuid": schema.UUID(),
9961007
"default-series": schema.String(),
997-
"tools-metadata-url": schema.String(),
1008+
AgentMetadataURLKey: schema.String(),
9981009
"image-metadata-url": schema.String(),
9991010
"image-stream": schema.String(),
10001011
AgentStreamKey: schema.String(),
@@ -1037,7 +1048,7 @@ var fields = schema.Fields{
10371048
"disable-network-management": schema.Bool(),
10381049

10391050
// Deprecated fields, retain for backwards compatibility.
1040-
"tools-url": schema.String(),
1051+
ToolsMetadataURLKey: schema.String(),
10411052
"lxc-use-clone": schema.Bool(),
10421053
ProvisionerSafeModeKey: schema.Bool(),
10431054
ToolsStreamKey: schema.String(),
@@ -1077,7 +1088,7 @@ var alwaysOptional = schema.Defaults{
10771088
AgentStreamKey: schema.Omit,
10781089

10791090
// Deprecated fields, retain for backwards compatibility.
1080-
"tools-url": "",
1091+
ToolsMetadataURLKey: "",
10811092
"lxc-use-clone": schema.Omit,
10821093
ProvisionerSafeModeKey: schema.Omit,
10831094
ToolsStreamKey: schema.Omit,
@@ -1090,7 +1101,7 @@ var alwaysOptional = schema.Defaults{
10901101
"admin-secret": "", // TODO(rog) omit
10911102
"ca-private-key": "", // TODO(rog) omit
10921103
"image-metadata-url": "", // TODO(rog) omit
1093-
"tools-metadata-url": "", // TODO(rog) omit
1104+
AgentMetadataURLKey: "", // TODO(rog) omit
10941105

10951106
"default-series": "",
10961107

environs/config/config_test.go

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,27 @@ var configTests = []configTest{
106106
about: "Metadata URLs",
107107
useDefaults: config.UseDefaults,
108108
attrs: testing.Attrs{
109-
"type": "my-type",
110-
"name": "my-name",
111-
"image-metadata-url": "image-url",
112-
"tools-metadata-url": "tools-metadata-url-value",
109+
"type": "my-type",
110+
"name": "my-name",
111+
"image-metadata-url": "image-url",
112+
conf.AgentMetadataURLKey: "agent-metadata-url-value",
113113
},
114114
}, {
115115
about: "Deprecated tools metadata URL used",
116116
useDefaults: config.UseDefaults,
117117
attrs: testing.Attrs{
118-
"type": "my-type",
119-
"name": "my-name",
120-
"tools-url": "tools-metadata-url-value",
118+
"type": "my-type",
119+
"name": "my-name",
120+
conf.ToolsMetadataURLKey: "tools-metadata-url-value",
121121
},
122122
}, {
123123
about: "Deprecated tools metadata URL ignored",
124124
useDefaults: config.UseDefaults,
125125
attrs: testing.Attrs{
126-
"type": "my-type",
127-
"name": "my-name",
128-
"tools-metadata-url": "tools-metadata-url-value",
129-
"tools-url": "ignore-me",
126+
"type": "my-type",
127+
"name": "my-name",
128+
conf.AgentMetadataURLKey: "agent-metadata-url-value",
129+
conf.ToolsMetadataURLKey: "ignore-me",
130130
},
131131
}, {
132132
about: "Explicit series",
@@ -727,7 +727,7 @@ var configTests = []configTest{
727727
"image-metadata-url": "",
728728
"ca-private-key": "",
729729
"default-series": "precise",
730-
"tools-metadata-url": "",
730+
conf.AgentMetadataURLKey: "",
731731
"secret-key": "a-secret-key",
732732
"access-key": "an-access-key",
733733
"agent-version": "1.13.2",
@@ -1162,37 +1162,36 @@ func (test configTest) check(c *gc.C, home *gitjujutesting.FakeHome) {
11621162
} else {
11631163
c.Assert(urlPresent, jc.IsFalse)
11641164
}
1165-
toolsURL, urlPresent := cfg.ToolsURL()
1166-
oldToolsURL, oldURLPresent := cfg.AllAttrs()["tools-url"]
1167-
oldToolsURLAttrValue, oldURLAttrPresent := test.attrs["tools-url"]
1168-
expectedToolsURLValue := test.attrs["tools-metadata-url"]
1169-
if expectedToolsURLValue == nil {
1170-
expectedToolsURLValue = oldToolsURLAttrValue
1171-
}
1172-
if expectedToolsURLValue != nil && expectedToolsURLValue != "" {
1173-
c.Assert(expectedToolsURLValue, gc.Equals, "tools-metadata-url-value")
1174-
c.Assert(toolsURL, gc.Equals, expectedToolsURLValue)
1175-
c.Assert(urlPresent, jc.IsTrue)
1176-
c.Assert(oldToolsURL, gc.Equals, expectedToolsURLValue)
1177-
c.Assert(oldURLPresent, jc.IsTrue)
1178-
} else {
1179-
c.Assert(urlPresent, jc.IsFalse)
1180-
c.Assert(oldURLAttrPresent, jc.IsFalse)
1181-
c.Assert(oldToolsURL, gc.Equals, "")
1165+
1166+
toolsURL, urlPresent := cfg.AgentMetadataURL()
1167+
oldToolsURL := cfg.AllAttrs()[conf.ToolsMetadataURLKey]
1168+
oldToolsURLAttrValue, oldTSTPresent := test.attrs[conf.ToolsMetadataURLKey]
1169+
expectedToolsURLValue := test.attrs[conf.AgentMetadataURLKey]
1170+
expectedToolsURLPresent := true
1171+
if expectedToolsURLValue == nil || expectedToolsURLValue == "" {
1172+
if oldTSTPresent {
1173+
expectedToolsURLValue = oldToolsURLAttrValue
1174+
} else {
1175+
expectedToolsURLValue = oldToolsURL
1176+
expectedToolsURLPresent = false
1177+
}
11821178
}
1179+
c.Assert(toolsURL, gc.Equals, expectedToolsURLValue)
1180+
c.Assert(urlPresent, gc.Equals, expectedToolsURLPresent)
11831181

11841182
// assertions for deprecated tools-stream attribute used with new agent-stream
11851183
agentStreamValue := cfg.AgentStream()
1186-
oldTstToolsStreamAttr := test.attrs[conf.ToolsStreamKey]
1184+
oldTstToolsStreamAttr, oldTstOk := test.attrs[conf.ToolsStreamKey]
11871185
expectedAgentStreamAttr := test.attrs[conf.AgentStreamKey]
11881186

11891187
// When no agent-stream provided, look for tools-stream
11901188
if expectedAgentStreamAttr == nil {
1191-
expectedAgentStreamAttr = oldTstToolsStreamAttr
1192-
}
1193-
// If it's still nil, then hard-coded default is used
1194-
if expectedAgentStreamAttr == nil {
1195-
expectedAgentStreamAttr = "released"
1189+
if oldTstOk {
1190+
expectedAgentStreamAttr = oldTstToolsStreamAttr
1191+
} else {
1192+
// If it's still nil, then hard-coded default is used
1193+
expectedAgentStreamAttr = "released"
1194+
}
11961195
}
11971196
c.Assert(agentStreamValue, gc.Equals, expectedAgentStreamAttr)
11981197

@@ -1259,8 +1258,8 @@ func (s *ConfigSuite) TestConfigAttrs(c *gc.C) {
12591258
attrs["logging-config"] = "<root>=WARNING;unit=DEBUG"
12601259
attrs["ca-private-key"] = ""
12611260
attrs["image-metadata-url"] = ""
1262-
attrs["tools-metadata-url"] = ""
1263-
attrs["tools-url"] = ""
1261+
attrs[conf.AgentMetadataURLKey] = ""
1262+
attrs[conf.ToolsMetadataURLKey] = ""
12641263
attrs["image-stream"] = ""
12651264
attrs["proxy-ssh"] = false
12661265
attrs["lxc-clone-aufs"] = false

environs/config_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ environments:
104104
deprecated:
105105
type: dummy
106106
state-server: false
107-
tools-url: aknowndeprecatedfield
107+
tools-metadata-url: aknowndeprecatedfield
108108
lxc-use-clone: true
109109
`
110110
var tw loggo.TestWriter
@@ -439,7 +439,7 @@ const (
439439

440440
func (s *ConfigDeprecationSuite) TestDeprecatedToolsURLWarning(c *gc.C) {
441441
attrs := testing.Attrs{
442-
"tools-url": "aknowndeprecatedfield",
442+
config.ToolsMetadataURLKey: "aknowndeprecatedfield",
443443
}
444444
expected := fmt.Sprintf(standardDeprecationWarning)
445445
s.checkDeprecationWarning(c, attrs, expected)
@@ -464,8 +464,8 @@ func (s *ConfigDeprecationSuite) TestDeprecatedSafeModeWarningWithHarvest(c *gc.
464464

465465
func (s *ConfigDeprecationSuite) TestDeprecatedToolsURLWithNewURLWarning(c *gc.C) {
466466
attrs := testing.Attrs{
467-
"tools-url": "aknowndeprecatedfield",
468-
"tools-metadata-url": "newvalue",
467+
config.ToolsMetadataURLKey: "aknowndeprecatedfield",
468+
config.AgentMetadataURLKey: "newvalue",
469469
}
470470
expected := fmt.Sprintf(standardDeprecationWarningWithNew)
471471
s.checkDeprecationWarning(c, attrs, expected)

environs/simplestreams/datasource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
// A DataSource retrieves simplestreams metadata.
1717
type DataSource interface {
1818
// Description describes the origin of this datasource.
19-
// eg tools-metadata-url, cloud storage, keystone catalog etc.
19+
// eg agent-metadata-url, cloud storage, keystone catalog etc.
2020
Description() string
2121
// Fetch loads the data at the specified relative path. It returns a reader from which
2222
// the data can be retrieved as well as the full URL of the file. The full URL is typically

environs/tools/tools_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ func (s *SimpleStreamsToolsSuite) TearDownTest(c *gc.C) {
6262

6363
func (s *SimpleStreamsToolsSuite) reset(c *gc.C, attrs map[string]interface{}) {
6464
final := map[string]interface{}{
65-
"tools-metadata-url": "file://" + s.customToolsDir,
66-
config.AgentStreamKey: "proposed",
65+
config.AgentMetadataURLKey: "file://" + s.customToolsDir,
66+
config.AgentStreamKey: "proposed",
6767
}
6868
for k, v := range attrs {
6969
final[k] = v

environs/tools/urls.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/juju/utils"
1414

1515
"github.com/juju/juju/environs"
16+
conf "github.com/juju/juju/environs/config"
1617
"github.com/juju/juju/environs/simplestreams"
1718
"github.com/juju/juju/environs/storage"
1819
)
@@ -72,12 +73,12 @@ func GetMetadataSources(env environs.Environ) ([]simplestreams.DataSource, error
7273

7374
// Add configured and environment-specific datasources.
7475
var sources []simplestreams.DataSource
75-
if userURL, ok := config.ToolsURL(); ok {
76+
if userURL, ok := config.AgentMetadataURL(); ok {
7677
verify := utils.VerifySSLHostnames
7778
if !config.SSLHostnameVerification() {
7879
verify = utils.NoVerifySSLHostnames
7980
}
80-
sources = append(sources, simplestreams.NewURLDataSource("tools-metadata-url", userURL, verify))
81+
sources = append(sources, simplestreams.NewURLDataSource(conf.AgentMetadataURLKey, userURL, verify))
8182
}
8283

8384
envDataSources, err := environmentDataSources(env)

environs/tools/urls_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (s *URLsSuite) env(c *gc.C, toolsMetadataURL string) environs.Environ {
3434
attrs := dummy.SampleConfig()
3535
if toolsMetadataURL != "" {
3636
attrs = attrs.Merge(testing.Attrs{
37-
"tools-metadata-url": toolsMetadataURL,
37+
config.AgentMetadataURLKey: toolsMetadataURL,
3838
})
3939
}
4040
cfg, err := config.New(config.NoDefaults, attrs)

0 commit comments

Comments
 (0)