Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KubernetesHook kube_config extra can take dict #41413

Merged
merged 2 commits into from
Sep 30, 2024
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
2 changes: 2 additions & 0 deletions airflow/providers/cncf/kubernetes/hooks/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ def get_conn(self) -> client.ApiClient:
if kubeconfig is not None:
with tempfile.NamedTemporaryFile() as temp_config:
self.log.debug("loading kube_config from: connection kube_config")
if isinstance(kubeconfig, dict):
kubeconfig = json.dumps(kubeconfig)
temp_config.write(kubeconfig.encode())
temp_config.flush()
self._is_in_cluster = False
Expand Down
2 changes: 2 additions & 0 deletions tests/providers/cncf/kubernetes/hooks/test_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def setup_class(cls) -> None:
("in_cluster", {"in_cluster": True}),
("in_cluster_empty", {"in_cluster": ""}),
("kube_config", {"kube_config": '{"test": "kube"}'}),
("kube_config_dict", {"kube_config": {"test": "kube"}}),
("kube_config_path", {"kube_config_path": "path/to/file"}),
("kube_config_empty", {"kube_config": ""}),
("kube_config_path_empty", {"kube_config_path": ""}),
Expand Down Expand Up @@ -285,6 +286,7 @@ def test_kube_config_path(
(
(None, False),
("kube_config", True),
("kube_config_dict", True),
("kube_config_empty", False),
),
)
Expand Down
Loading