Skip to content

Commit

Permalink
fix: updated according to code review
Browse files Browse the repository at this point in the history
Summary of changes:
- Modified code to only retrieve image configuration.
  • Loading branch information
Ivan Chvets committed Aug 31, 2023
1 parent d686f6e commit 24324b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
21 changes: 10 additions & 11 deletions charms/istio-pilot/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,21 @@ def __init__(self, *args):
)
self.grafana_dashboards = GrafanaDashboardProvider(self, relation_name="grafana-dashboard")

def _get_config(self):
"""Retrieve and return configuration."""
config = {}
config[IMAGE_CONFIGURATION] = yaml.safe_load(self.model.config[IMAGE_CONFIGURATION])
return config
def _get_image_config(self):
"""Retrieve and return image configuration."""
image_config = yaml.safe_load(self.model.config[IMAGE_CONFIGURATION])
return image_config

def install(self, _):
"""Install charm."""
self._log_and_set_status(MaintenanceStatus("Deploying Istio control plane"))

config = self._get_config()
pilot_image = config[IMAGE_CONFIGURATION]["pilot-image"]
global_tag = config[IMAGE_CONFIGURATION]["global-tag"]
global_hub = config[IMAGE_CONFIGURATION]["global-hub"]
global_proxy_image = config[IMAGE_CONFIGURATION]["global-proxy-image"]
global_proxy_init_image = config[IMAGE_CONFIGURATION]["global-proxy-init-image"]
image_config = self._get_image_config()
pilot_image = image_config["pilot-image"]
global_tag = image_config["global-tag"]
global_hub = image_config["global-hub"]
global_proxy_image = image_config["global-proxy-image"]
global_proxy_init_image = image_config["global-proxy-init-image"]

# Call istioctl install and set parameters based on image configuration
subprocess.check_call(
Expand Down
9 changes: 4 additions & 5 deletions charms/istio-pilot/tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,10 @@ def test_xor(self, left, right, expected):
def test_get_config(self, harness):
"""Test configuration retrieval function."""
harness.begin()
config = harness.charm._get_config()
assert "image-configuration" in config.keys()
assert "pilot-image" in config["image-configuration"].keys()
assert "pilot" == config["image-configuration"]["pilot-image"]
assert "proxyv2" == config["image-configuration"]["global-proxy-image"]
image_config = harness.charm._get_image_config()
assert "pilot-image" in image_config.keys()
assert "pilot" == image_config["pilot-image"]
assert "proxyv2" == image_config["global-proxy-image"]


class TestCharmUpgrade:
Expand Down

0 comments on commit 24324b1

Please sign in to comment.