Make parsing methods local
The parsing methods are used only internally; they must not be
exposed to users outside the respective packages.
diff --git a/openstack/orchestration/v1/stacks/environment.go b/openstack/orchestration/v1/stacks/environment.go
index 94fda6c..4d4779c 100644
--- a/openstack/orchestration/v1/stacks/environment.go
+++ b/openstack/orchestration/v1/stacks/environment.go
@@ -35,7 +35,7 @@
// Parse environment file to resolve the URL's of the resources. This is done by
// reading from the `Resource Registry` section, which is why the function is
// named GetRRFileContents.
-func (e *Environment) GetRRFileContents(ignoreIf igFunc) error {
+func (e *Environment) getRRFileContents(ignoreIf igFunc) error {
// initialize environment if empty
if e.Files == nil {
e.Files = make(map[string]string)
@@ -72,7 +72,7 @@
tempTemplate.client = e.client
// Fetch the contents of remote resource URL's
- if err = tempTemplate.GetFileContents(rr, ignoreIf, false); err != nil {
+ if err = tempTemplate.getFileContents(rr, ignoreIf, false); err != nil {
return err
}
// check the `resources` section (if it exists) for more URL's. Note that
@@ -101,7 +101,7 @@
resourceBaseURL = baseURL
}
tempTemplate.baseURL = resourceBaseURL
- if err := tempTemplate.GetFileContents(v, ignoreIf, false); err != nil {
+ if err := tempTemplate.getFileContents(v, ignoreIf, false); err != nil {
return err
}
}
diff --git a/openstack/orchestration/v1/stacks/environment_test.go b/openstack/orchestration/v1/stacks/environment_test.go
index 5a02d7a..bbef283 100644
--- a/openstack/orchestration/v1/stacks/environment_test.go
+++ b/openstack/orchestration/v1/stacks/environment_test.go
@@ -161,7 +161,7 @@
err = env.Parse()
th.AssertNoErr(t, err)
- err = env.GetRRFileContents(ignoreIfEnvironment)
+ err = env.getRRFileContents(ignoreIfEnvironment)
th.AssertNoErr(t, err)
expected_env_files_content := "\nheat_template_version: 2013-05-23\n\ndescription:\n Heat WordPress template to support F18, using only Heat OpenStack-native\n resource types, and without the requirement for heat-cfntools in the image.\n WordPress is web software you can use to create a beautiful website or blog.\n This template installs a single-instance WordPress deployment using a local\n MySQL database to store the data.\n\nparameters:\n\n key_name:\n type: string\n description : Name of a KeyPair to enable SSH access to the instance\n\nresources:\n wordpress_instance:\n type: OS::Nova::Server\n properties:\n image: { get_param: image_id }\n flavor: { get_param: instance_type }\n key_name: { get_param: key_name }"
expected_db_files_content := "\nheat_template_version: 2014-10-16\n\ndescription:\n Test template for Trove resource capabilities\n\nparameters:\n db_pass:\n type: string\n hidden: true\n description: Database access password\n default: secrete\n\nresources:\n\nservice_db:\n type: OS::Trove::Instance\n properties:\n name: trove_test_db\n datastore_type: mariadb\n flavor: 1GB Instance\n size: 10\n databases:\n - name: test_data\n users:\n - name: kitchen_sink\n password: { get_param: db_pass }\n databases: [ test_data ]"
@@ -169,7 +169,7 @@
th.AssertEquals(t, expected_env_files_content, env.Files[fakeEnvURL])
th.AssertEquals(t, expected_db_files_content, env.Files[fakeDBURL])
- env.FixFileRefs()
+ env.fixFileRefs()
expected_parsed := map[string]interface{}{
"resource_registry": "2015-04-30",
"My::WP::Server": fakeEnvURL,
diff --git a/openstack/orchestration/v1/stacks/requests.go b/openstack/orchestration/v1/stacks/requests.go
index 230525c..8616644 100644
--- a/openstack/orchestration/v1/stacks/requests.go
+++ b/openstack/orchestration/v1/stacks/requests.go
@@ -100,10 +100,10 @@
return nil, err
}
- if err := opts.TemplateOpts.GetFileContents(opts.TemplateOpts.Parsed, ignoreIfTemplate, true); err != nil {
+ if err := opts.TemplateOpts.getFileContents(opts.TemplateOpts.Parsed, ignoreIfTemplate, true); err != nil {
return nil, err
}
- opts.TemplateOpts.FixFileRefs()
+ opts.TemplateOpts.fixFileRefs()
s["template"] = string(opts.TemplateOpts.Bin)
for k, v := range opts.TemplateOpts.Files {
@@ -118,10 +118,10 @@
if err := opts.EnvironmentOpts.Parse(); err != nil {
return nil, err
}
- if err := opts.EnvironmentOpts.GetRRFileContents(ignoreIfEnvironment); err != nil {
+ if err := opts.EnvironmentOpts.getRRFileContents(ignoreIfEnvironment); err != nil {
return nil, err
}
- opts.EnvironmentOpts.FixFileRefs()
+ opts.EnvironmentOpts.fixFileRefs()
for k, v := range opts.EnvironmentOpts.Files {
Files[k] = v
}
@@ -250,10 +250,10 @@
return nil, err
}
- if err := opts.TemplateOpts.GetFileContents(opts.TemplateOpts.Parsed, ignoreIfTemplate, true); err != nil {
+ if err := opts.TemplateOpts.getFileContents(opts.TemplateOpts.Parsed, ignoreIfTemplate, true); err != nil {
return nil, err
}
- opts.TemplateOpts.FixFileRefs()
+ opts.TemplateOpts.fixFileRefs()
s["template"] = string(opts.TemplateOpts.Bin)
for k, v := range opts.TemplateOpts.Files {
@@ -273,10 +273,10 @@
if err := opts.EnvironmentOpts.Parse(); err != nil {
return nil, err
}
- if err := opts.EnvironmentOpts.GetRRFileContents(ignoreIfEnvironment); err != nil {
+ if err := opts.EnvironmentOpts.getRRFileContents(ignoreIfEnvironment); err != nil {
return nil, err
}
- opts.EnvironmentOpts.FixFileRefs()
+ opts.EnvironmentOpts.fixFileRefs()
for k, v := range opts.EnvironmentOpts.Files {
Files[k] = v
}
@@ -461,10 +461,10 @@
return nil, err
}
- if err := opts.TemplateOpts.GetFileContents(opts.TemplateOpts.Parsed, ignoreIfTemplate, true); err != nil {
+ if err := opts.TemplateOpts.getFileContents(opts.TemplateOpts.Parsed, ignoreIfTemplate, true); err != nil {
return nil, err
}
- opts.TemplateOpts.FixFileRefs()
+ opts.TemplateOpts.fixFileRefs()
s["template"] = string(opts.TemplateOpts.Bin)
for k, v := range opts.TemplateOpts.Files {
@@ -476,10 +476,10 @@
if err := opts.EnvironmentOpts.Parse(); err != nil {
return nil, err
}
- if err := opts.EnvironmentOpts.GetRRFileContents(ignoreIfEnvironment); err != nil {
+ if err := opts.EnvironmentOpts.getRRFileContents(ignoreIfEnvironment); err != nil {
return nil, err
}
- opts.EnvironmentOpts.FixFileRefs()
+ opts.EnvironmentOpts.fixFileRefs()
for k, v := range opts.EnvironmentOpts.Files {
Files[k] = v
}
@@ -607,10 +607,10 @@
return nil, err
}
- if err := opts.TemplateOpts.GetFileContents(opts.TemplateOpts.Parsed, ignoreIfTemplate, true); err != nil {
+ if err := opts.TemplateOpts.getFileContents(opts.TemplateOpts.Parsed, ignoreIfTemplate, true); err != nil {
return nil, err
}
- opts.TemplateOpts.FixFileRefs()
+ opts.TemplateOpts.fixFileRefs()
s["template"] = string(opts.TemplateOpts.Bin)
for k, v := range opts.TemplateOpts.Files {
@@ -625,10 +625,10 @@
if err := opts.EnvironmentOpts.Parse(); err != nil {
return nil, err
}
- if err := opts.EnvironmentOpts.GetRRFileContents(ignoreIfEnvironment); err != nil {
+ if err := opts.EnvironmentOpts.getRRFileContents(ignoreIfEnvironment); err != nil {
return nil, err
}
- opts.EnvironmentOpts.FixFileRefs()
+ opts.EnvironmentOpts.fixFileRefs()
for k, v := range opts.EnvironmentOpts.Files {
Files[k] = v
}
diff --git a/openstack/orchestration/v1/stacks/template.go b/openstack/orchestration/v1/stacks/template.go
index b54fe52..32fe95b 100644
--- a/openstack/orchestration/v1/stacks/template.go
+++ b/openstack/orchestration/v1/stacks/template.go
@@ -38,7 +38,7 @@
// parameter of the template structure. This is the only way that a user can
// use child templates that are located in their filesystem; urls located on the
// web (e.g. on github or swift) can be fetched directly by Heat engine.
-func (t *Template) GetFileContents(te interface{}, ignoreIf igFunc, recurse bool) error {
+func (t *Template) getFileContents(te interface{}, ignoreIf igFunc, recurse bool) error {
// initialize template if empty
if t.Files == nil {
t.Files = make(map[string]string)
@@ -57,7 +57,7 @@
value, ok := v.(string)
if !ok {
// if the value is not a string, recursively parse that value
- if err := t.GetFileContents(v, ignoreIf, recurse); err != nil {
+ if err := t.getFileContents(v, ignoreIf, recurse); err != nil {
return err
}
} else if !ignoreIf(k, value) {
@@ -87,7 +87,7 @@
// required if the child template itself contains references to
// other templates
if recurse {
- if err := childTemplate.GetFileContents(childTemplate.Parsed, ignoreIf, recurse); err != nil {
+ if err := childTemplate.getFileContents(childTemplate.Parsed, ignoreIf, recurse); err != nil {
return err
}
}
@@ -103,7 +103,7 @@
case []interface{}:
te_slice := te.([]interface{})
for i := range te_slice {
- if err := t.GetFileContents(te_slice[i], ignoreIf, recurse); err != nil {
+ if err := t.getFileContents(te_slice[i], ignoreIf, recurse); err != nil {
return err
}
}
diff --git a/openstack/orchestration/v1/stacks/template_test.go b/openstack/orchestration/v1/stacks/template_test.go
index c944e9a..a297f77 100644
--- a/openstack/orchestration/v1/stacks/template_test.go
+++ b/openstack/orchestration/v1/stacks/template_test.go
@@ -114,7 +114,7 @@
err = te.Parse()
th.AssertNoErr(t, err)
- err = te.GetFileContents(te.Parsed, ignoreIfTemplate, true)
+ err = te.getFileContents(te.Parsed, ignoreIfTemplate, true)
th.AssertNoErr(t, err)
expected_files := map[string]string{
"my_nova.yaml": `heat_template_version: 2014-10-16
@@ -134,7 +134,7 @@
networks:
- {uuid: 11111111-1111-1111-1111-111111111111}`}
th.AssertEquals(t, expected_files["my_nova.yaml"], te.Files[fakeURL])
- te.FixFileRefs()
+ te.fixFileRefs()
expected_parsed := map[string]interface{}{
"heat_template_version": "2015-04-30",
"resources": map[string]interface{}{
diff --git a/openstack/orchestration/v1/stacks/utils.go b/openstack/orchestration/v1/stacks/utils.go
index 299cbc0..420a7fa 100644
--- a/openstack/orchestration/v1/stacks/utils.go
+++ b/openstack/orchestration/v1/stacks/utils.go
@@ -150,7 +150,7 @@
// fix the template reference to files by replacing relative URL's by absolute
// URL's
-func (t *TE) FixFileRefs() {
+func (t *TE) fixFileRefs() {
t_str := string(t.Bin)
if t.fileMaps == nil {
return
diff --git a/openstack/orchestration/v1/stacks/utils_test.go b/openstack/orchestration/v1/stacks/utils_test.go
index 2f01c3b..6a3c5c0 100644
--- a/openstack/orchestration/v1/stacks/utils_test.go
+++ b/openstack/orchestration/v1/stacks/utils_test.go
@@ -17,7 +17,7 @@
"string_to_replace": "london bridge is falling down",
},
}
- te.FixFileRefs()
+ te.fixFileRefs()
th.AssertEquals(t, string(te.Bin), `london bridge is falling down: my fair lady`)
}