Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-locale-28959.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "locale",
"description": "Add support for AWS_CLI_FILE_ENCODING environment variable to cloudformation and eks customizations"
}
3 changes: 2 additions & 1 deletion awscli/customizations/cloudformation/artifact_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from awscli.compat import urlparse
from contextlib import contextmanager
from awscli.compat import compat_open
from awscli.customizations.cloudformation import exceptions
from awscli.customizations.cloudformation.yamlhelper import yaml_dump, \
yaml_parse
Expand Down Expand Up @@ -571,7 +572,7 @@ def __init__(self, template_path, parent_dir, uploader,
abs_template_path = make_abs_path(parent_dir, template_path)
template_dir = os.path.dirname(abs_template_path)

with open(abs_template_path, "r") as handle:
with compat_open(abs_template_path, "r") as handle:
template_str = handle.read()

self.template_dict = yaml_parse(template_str)
Expand Down
3 changes: 2 additions & 1 deletion awscli/customizations/cloudformation/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from botocore.client import Config

from awscli.compat import compat_open
from awscli.customizations.cloudformation import exceptions
from awscli.customizations.cloudformation.deployer import Deployer
from awscli.customizations.s3uploader import S3Uploader
Expand Down Expand Up @@ -250,7 +251,7 @@ def _run_main(self, parsed_args, parsed_globals):
template_path=template_path)

# Parse parameters
with open(template_path, "r") as handle:
with compat_open(template_path, "r") as handle:
template_str = handle.read()

stack_name = parsed_args.stack_name
Expand Down
5 changes: 3 additions & 2 deletions awscli/customizations/eks/kubeconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import ruamel.yaml as yaml
from botocore.compat import OrderedDict

from awscli.compat import compat_open
from awscli.customizations.eks.exceptions import EKSError
from awscli.customizations.eks.ordered_yaml import (
ordered_yaml_load,
Expand Down Expand Up @@ -153,7 +154,7 @@ def load_kubeconfig(self, path):
:rtype: Kubeconfig
"""
try:
with open(path, "r") as stream:
with compat_open(path, "r") as stream:
loaded_content = ordered_yaml_load(stream)
except IOError as e:
if e.errno == errno.ENOENT:
Expand Down Expand Up @@ -192,7 +193,7 @@ def write_kubeconfig(self, config):
raise KubeconfigInaccessableError(
"Can't create directory for writing: {0}".format(e))
try:
with open(config.path, "w+") as stream:
with compat_open(config.path, "w+") as stream:
ordered_yaml_dump(config.content, stream)
except IOError as e:
raise KubeconfigInaccessableError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,8 @@ def test_template_export_metadata(self, yaml_parse_mock):

# Patch the file open method to return template string
with patch(
"awscli.customizations.cloudformation.artifact_exporter.open",
"awscli.customizations.cloudformation."
"artifact_exporter.compat_open",
open_mock(read_data=template_str)) as open_mock:

template_exporter = Template(
Expand Down Expand Up @@ -983,7 +984,8 @@ def test_template_export(self, yaml_parse_mock):

# Patch the file open method to return template string
with patch(
"awscli.customizations.cloudformation.artifact_exporter.open",
"awscli.customizations.cloudformation."
"artifact_exporter.compat_open",
open_mock(read_data=template_str)) as open_mock:

template_exporter = Template(
Expand Down Expand Up @@ -1044,7 +1046,8 @@ def test_template_global_export(self, yaml_parse_mock):
yaml_parse_mock.return_value = template_dict

with patch(
"awscli.customizations.cloudformation.artifact_exporter.open",
"awscli.customizations.cloudformation."
"artifact_exporter.compat_open",
open_mock(read_data=template_str)) as open_mock:
with patch.dict(GLOBAL_EXPORT_DICT, {"Fn::Transform": include_transform_export_handler_mock}):
template_exporter = Template(
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/customizations/cloudformation/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_command_invoked(self, mock_yaml_parse):
open_mock = mock.mock_open()
# Patch the file open method to return template string
with patch(
"awscli.customizations.cloudformation.deploy.open",
"awscli.customizations.cloudformation.deploy.compat_open",
open_mock(read_data=template_str)) as open_mock:

fake_template = get_example_template()
Expand All @@ -108,7 +108,6 @@ def test_command_invoked(self, mock_yaml_parse):
result = self.deploy_command._run_main(self.parsed_args,
parsed_globals=self.parsed_globals)
self.assertEquals(0, result)

open_mock.assert_called_once_with(file_path, "r")

self.deploy_command.deploy.assert_called_once_with(
Expand Down Expand Up @@ -162,7 +161,7 @@ def test_s3_upload_required_but_missing_bucket(self, mock_getsize, mock_yaml_par
open_mock = mock.mock_open()

with patch(
"awscli.customizations.cloudformation.deploy.open",
"awscli.customizations.cloudformation.deploy.compat_open",
open_mock(read_data=template_str)) as open_mock:
with self.assertRaises(exceptions.DeployBucketRequiredError):
result = self.deploy_command._run_main(self.parsed_args,
Expand All @@ -187,7 +186,7 @@ def test_s3_uploader_is_configured_properly(self, s3UploaderMock,
open_mock = mock.mock_open()

with patch(
"awscli.customizations.cloudformation.deploy.open",
"awscli.customizations.cloudformation.deploy.compat_open",
open_mock(read_data=template_str)) as open_mock:

self.parsed_args.s3_bucket = bucket_name
Expand Down