diff options
author | James Falcon <james.falcon@canonical.com> | 2022-09-02 13:34:26 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-02 12:34:26 -0600 |
commit | 5c15e24f7cb781db85fa31720d48988bf59db31d (patch) | |
tree | b8896ecab46e405bfea9462c79d775154be29fa8 /cloudinit/handlers | |
parent | 3eb2dfce6046fbe67bab7475b8ed17c1d38d64e5 (diff) | |
download | cloud-init-git-5c15e24f7cb781db85fa31720d48988bf59db31d.tar.gz |
Refactor instance json files to use Paths (SC-1238) (#1709)
We have multiple areas of the codebase where we fetch the rundir path
and join it with the filename for instance-data.json or
instance-data-sensitive.json. This commit refactors those calls to use a
'Paths' lookup instead.
Diffstat (limited to 'cloudinit/handlers')
-rw-r--r-- | cloudinit/handlers/jinja_template.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/cloudinit/handlers/jinja_template.py b/cloudinit/handlers/jinja_template.py index b8196cb1..7a550298 100644 --- a/cloudinit/handlers/jinja_template.py +++ b/cloudinit/handlers/jinja_template.py @@ -8,8 +8,8 @@ from typing import Optional, Type from cloudinit import handlers from cloudinit import log as logging +from cloudinit.helpers import Paths from cloudinit.settings import PER_ALWAYS -from cloudinit.sources import INSTANCE_JSON_SENSITIVE_FILE from cloudinit.templater import MISSING_JINJA_PREFIX, render_string from cloudinit.util import b64d, json_dumps, load_file, load_json @@ -29,7 +29,7 @@ class JinjaTemplatePartHandler(handlers.Handler): prefixes = ["## template: jinja"] - def __init__(self, paths, **_kwargs): + def __init__(self, paths: Paths, **_kwargs): handlers.Handler.__init__(self, PER_ALWAYS, version=3) self.paths = paths self.sub_handlers = {} @@ -40,9 +40,7 @@ class JinjaTemplatePartHandler(handlers.Handler): def handle_part(self, data, ctype, filename, payload, frequency, headers): if ctype in handlers.CONTENT_SIGNALS: return - jinja_json_file = os.path.join( - self.paths.run_dir, INSTANCE_JSON_SENSITIVE_FILE - ) + jinja_json_file = self.paths.get_runpath("instance_data_sensitive") rendered_payload = render_jinja_payload_from_file( payload, filename, jinja_json_file ) |