When running inside a vscode devcontainer, git credential settings are
injected using a modified .gitconfig file. In addition, the injected
credential handler needs access to environment variables like
REMOTE_CONTAINERS_IPC.
As all this is rather undocumented territory, we first detect if we are
running inside a remotecontainers environment and then forward all
REMOTE_CONTAINERS_* variables. This should also enable the use of kas in
the github codespaces (not tested).
Xref:
https://patchwork.yoctoproject.org/project/bitbake/patch/20231002064106....@schnelte.de/
Proposed-by: Matthias Schnelte <
dev...@schnelte.de>
Signed-off-by: Felix Moessbauer <
felix.mo...@siemens.com>
---
kas/context.py | 7 +++++++
kas/libcmds.py | 6 ++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/kas/context.py b/kas/context.py
index 6ca529151..8ac6205d1 100644
--- a/kas/context.py
+++ b/kas/context.py
@@ -111,6 +111,13 @@ class Context:
if val:
self.environ[key] = val
+ # make remote containers environment available in kas
+ if os.environ.get('REMOTE_CONTAINERS', False) == 'true':
+ logging.debug('Running inside devcontainer environment')
+ for k in os.environ.keys():
+ if k.startswith('REMOTE_CONTAINERS_'):
+ self.environ[k] = os.environ[k]
+
@property
def build_dir(self):
"""
diff --git a/kas/libcmds.py b/kas/libcmds.py
index b64d186a6..955d63ca9 100644
--- a/kas/libcmds.py
+++ b/kas/libcmds.py
@@ -223,9 +223,11 @@ class SetupHome(Command):
gitconfig_host = os.environ.get('GITCONFIG_FILE', False)
gitconfig_kas = self.tmpdirname + '/.gitconfig'
- # when running in the github ci, always try to read the gitconfig
+ # when running in the github ci or a vscode devcontainer,
+ # always try to read the gitconfig
if not gitconfig_host and \
- os.environ.get('GITHUB_ACTIONS', False) == 'true':
+ os.environ.get('GITHUB_ACTIONS', False) == 'true' or \
+ os.environ.get('REMOTE_CONTAINERS', False) == 'true':
gitconfig_host = os.path.expanduser('~/.gitconfig')
if gitconfig_host and os.path.exists(gitconfig_host):
--
2.39.2