@@ -180,7 +180,7 @@ class OktetoDeployment:
180180 sleeping : bool
181181 github : "GitHubDeployment" = field (init = False , default = None )
182182
183- def __init__ (self , name : str , scope : str , sleeping : str ):
183+ def __init__ (self , name : str , scope : str , sleeping : str , ** _ ):
184184 self .name = name
185185 self .scope = scope
186186 self .sleeping = sleeping .lower () in ("1" , "on" , "true" )
@@ -197,11 +197,19 @@ def get_all(cls) -> Iterator["OktetoDeployment"]:
197197 ["okteto" , "preview" , "list" ],
198198 capture_output = True , check = True , encoding = "utf8"
199199 )
200- # We need to scrap the first row as it contains the headers
201- if envs := proc .stdout .strip ().split ("\n " )[1 :]:
202- for env in envs :
203- cleaned = filter (None , env .split (" " ))
204- yield cls (* cleaned )
200+
201+ headings = None
202+ for row in proc .stdout .strip ().split ("\n " ):
203+ # The data only starts after the heading
204+ # We also use the hading to create structured data
205+ if headings is None and "Name" in row and "Scope" in row :
206+ headings = list (map (str .lower , filter (None , row .split (" " ))))
207+
208+ elif headings :
209+ # Combine row with headers to create structured data
210+ cleaned = filter (None , row .split (" " ))
211+ structured = dict (zip (headings , cleaned ))
212+ yield cls (** structured )
205213
206214
207215def connect_deployments (github : list [GitHubDeployment ], okteto : list [OktetoDeployment ]):
0 commit comments