@@ -83,38 +83,6 @@ def _create_image_pull_secret_data(
8383 }
8484
8585
86- def _get_container_registry_credentials (
87- container_registry = None ,
88- ) -> List [Tuple [str , str , str ]]:
89- """Extract container registry credentials from the active stack.
90-
91- Args:
92- container_registry: Optional container registry instance to use.
93- If None, uses the container registry from the active stack.
94-
95- Returns:
96- List of tuples containing (registry_uri, username, password) for each
97- container registry that has credentials available.
98- """
99- credentials = []
100-
101- # If no container registry provided, get from active stack
102- if container_registry is None :
103- client = Client ()
104- stack = client .active_stack
105- container_registry = stack .container_registry
106-
107- if not container_registry :
108- return credentials
109-
110- # Use the new method from base container registry
111- registry_data = container_registry .get_kubernetes_image_pull_secret_data ()
112- if registry_data :
113- credentials .append (registry_data )
114-
115- return credentials
116-
117-
11886def _should_refresh_image_pull_secret (
11987 secret_name : str , namespace : str , core_api
12088) -> bool :
@@ -154,16 +122,15 @@ def _should_refresh_image_pull_secret(
154122
155123def _generate_image_pull_secrets (
156124 namespace : str = "default" ,
157- container_registry = None ,
125+ registry_credentials : Optional [ Tuple [ str , str , str ]] = None ,
158126 force_refresh : bool = False ,
159127 core_api = None ,
160128) -> Tuple [List [Dict [str , Any ]], List [k8s_client .V1LocalObjectReference ]]:
161129 """Generate Kubernetes secrets and references for container registry credentials.
162130
163131 Args:
164132 namespace: The Kubernetes namespace to create secrets in.
165- container_registry: Optional container registry instance to use.
166- If None, uses the container registry from the active stack.
133+ registry_credentials: Tuple of (registry_uri, username, password).
167134 force_refresh: If True, forces regeneration of secrets even if they exist.
168135 core_api: Optional Kubernetes Core API client for checking existing secrets.
169136
@@ -172,21 +139,16 @@ def _generate_image_pull_secrets(
172139 - secret_manifests: List of Kubernetes secret manifests to create
173140 - local_object_references: List of V1LocalObjectReference objects for imagePullSecrets
174141 """
175- credentials = _get_container_registry_credentials (container_registry )
176- if not credentials :
142+ if not registry_credentials :
177143 return [], []
178144
145+ credentials = [registry_credentials ]
146+
179147 secret_manifests = []
180148 local_object_references = []
181149
182150 # Check if credentials need refresh (for service connectors)
183151 needs_refresh = force_refresh
184- if container_registry and hasattr (
185- container_registry , "connector_has_expired"
186- ):
187- needs_refresh = (
188- needs_refresh or container_registry .connector_has_expired ()
189- )
190152
191153 for i , (registry_uri , username , password ) in enumerate (credentials ):
192154 # Create a unique secret name for this registry
@@ -503,15 +465,22 @@ def build_pod_manifest(
503465 )
504466
505467 # Auto-generate imagePullSecrets from container registry credentials
506- if auto_generate_image_pull_secrets :
468+ if auto_generate_image_pull_secrets and container_registry :
507469 try :
508- generated_secrets , generated_refs = _generate_image_pull_secrets (
509- namespace = namespace ,
510- container_registry = container_registry ,
511- core_api = core_api ,
470+ # Extract credentials using dependency injection approach
471+ registry_data = (
472+ container_registry .get_kubernetes_image_pull_secret_data ()
512473 )
513- secret_manifests .extend (generated_secrets )
514- image_pull_secrets .extend (generated_refs )
474+ if registry_data :
475+ generated_secrets , generated_refs = (
476+ _generate_image_pull_secrets (
477+ namespace = namespace ,
478+ registry_credentials = registry_data ,
479+ core_api = core_api ,
480+ )
481+ )
482+ secret_manifests .extend (generated_secrets )
483+ image_pull_secrets .extend (generated_refs )
515484 except Exception as e :
516485 logger .warning (
517486 f"Failed to auto-generate imagePullSecrets from container "
0 commit comments