@@ -161,7 +161,7 @@ def get_taskruns(namespace, task_name):
161161 plural = "taskruns"
162162
163163 # access the custom resource from tekton
164- tektonV1 = client .CustomObjectsApi ()
164+ tektonV1 = client .CustomObjectsApi (client . ApiClient () )
165165 taskruns = tektonV1 .list_namespaced_custom_object (
166166 group ,
167167 version ,
@@ -214,11 +214,33 @@ def process_taskrun_logs(
214214
215215def get_tekton_ci_output ():
216216 """Get the latest successful scheduled tekton pipeline output"""
217+ import os
218+
217219 try :
218- config .load_incluster_config ()
219- print ("Using in-cluster Kubernetes configuration..." )
220- except config .config_exception .ConfigException :
221- # Fall back to local config if running locally and not inside cluster
220+ token_path = "/var/run/secrets/kubernetes.io/serviceaccount/token"
221+ if os .path .exists (token_path ):
222+ print (f"ServiceAccount token found at { token_path } " )
223+ with open (token_path , 'r' ) as f :
224+ token = f .read ().strip ()
225+ print (f"Token length: { len (token )} " )
226+ print (f"Token preview: { token [:50 ]} ..." ) # İlk 50 karakter
227+
228+ # Manuel olarak configuration oluştur
229+ configuration = client .Configuration ()
230+ configuration .host = "https://kubernetes.default.svc"
231+ configuration .verify_ssl = True
232+ configuration .ssl_ca_cert = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
233+
234+ with open (token_path , 'r' ) as f :
235+ token = f .read ().strip ()
236+ configuration .api_key = {"authorization" : f"Bearer { token } " }
237+
238+ client .Configuration .set_default (configuration )
239+ print ("Using manually configured in-cluster Kubernetes configuration..." )
240+ print (f"API Server: { configuration .host } " )
241+
242+ except Exception as e :
243+ print (f"Error setting up configuration: { e } " )
222244 config .load_kube_config ()
223245 print ("Using local Kubernetes configuration..." )
224246
0 commit comments