Skip to content

Commit

Permalink
fixing encoding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
eamonnfaherty committed Dec 16, 2024
1 parent f68405b commit 81215db
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
from servicecatalog_puppet.commands.task_reference_helpers.generators.boto3_parameter_handler import (
boto3_parameter_handler,
)
from servicecatalog_puppet.commands.task_reference_helpers.generators.s3_parameter_handler import (
s3_parameter_handler,
)
from servicecatalog_puppet.commands.task_reference_helpers.generators.ssm_outputs_handler import (
ssm_outputs_handler,
)
from servicecatalog_puppet.commands.task_reference_helpers.generators.ssm_parameter_handler import (
ssm_parameter_handler,
)
from servicecatalog_puppet.commands.task_reference_helpers.generators.s3_parameter_handler import (
s3_parameter_handler,
)
from servicecatalog_puppet.waluigi.shared_tasks.task_topological_generations_without_scheduler_unit_test import (
dependency_task_reference,
)
Expand Down
12 changes: 9 additions & 3 deletions servicecatalog_puppet/waluigi/task_mixins/io_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,16 @@ def write_empty_output(self):
with self.output().open("wb") as f:
f.write(b"{}")

def write_output(self, content):
def write_output(self, content, skip_json_encode=False):
if self.should_use_caching:
with self.output().open("w") as f:
f.write(serialisation_utils.json_dumps(content).decode("utf-8"))
if skip_json_encode:
f.write(content.decode("utf-8"))
else:
f.write(serialisation_utils.json_dumps(content).decode("utf-8"))
else:
with self.output().open("wb") as f:
f.write(serialisation_utils.json_dumps(content))
if skip_json_encode:
f.write(content)
else:
f.write(serialisation_utils.json_dumps(content))
4 changes: 2 additions & 2 deletions servicecatalog_puppet/workflow/s3/get_s3_object_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import json
from copy import deepcopy

import jmespath
import luigi

from servicecatalog_puppet import constants
from servicecatalog_puppet.workflow.dependencies import tasks
import jmespath


class GetS3ObjectTask(tasks.TaskWithReference):
Expand All @@ -33,4 +33,4 @@ def run(self):
.get("Body")
.read()
)
self.write_output(object)
self.write_output(object, skip_json_encode=True)
4 changes: 2 additions & 2 deletions servicecatalog_puppet/workflow/s3/get_s3_parameter_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def params_for_results_display(self):
}

def run(self):
object = self.get_output_from_reference_dependency_raw(
object = self.get_output_from_reference_dependency(
self.s3_object_task_reference
)
result = jmespath.search(self.jmespath_location, json.loads(object))
result = jmespath.search(self.jmespath_location, object)
if result is None:
if self.default is None:
raise Exception(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import json
from copy import deepcopy

import jmespath
import luigi

from servicecatalog_puppet import constants
from servicecatalog_puppet.workflow.dependencies import tasks
import jmespath


class GetSSMParameterTask(tasks.TaskWithReference):
Expand Down

0 comments on commit 81215db

Please sign in to comment.