4040from rich .console import Console
4141from rich .panel import Panel
4242from rich .progress import Progress , SpinnerColumn , TextColumn , BarColumn , TimeElapsedColumn
43+ from rich .rule import Rule
4344from rich import box
4445
4546console = Console ()
4950
5051def check_infrahub_ready (max_retries : int = 30 , sleep_time : int = 2 ) -> bool :
5152 """Check if Infrahub is ready to accept requests."""
52- console .print ("\n [cyan]→[/cyan] Checking if Infrahub is ready..." )
53+ console .print ("\n [bold cyan]→ Checking if Infrahub is ready...[/bold cyan] " )
5354
5455 with Progress (
55- SpinnerColumn (),
56+ SpinnerColumn (spinner_name = "dots" ),
5657 TextColumn ("[progress.description]{task.description}" ),
57- BarColumn (),
58+ BarColumn (bar_width = 40 ),
5859 TimeElapsedColumn (),
5960 console = console ,
6061 ) as progress :
61- task = progress .add_task ("[cyan ]Waiting for Infrahub..." , total = max_retries )
62+ task = progress .add_task ("[bold magenta ]Waiting for Infrahub..." , total = max_retries )
6263
6364 for attempt in range (max_retries ):
6465 try :
6566 response = requests .get (f"{ INFRAHUB_ADDRESS } /api/schema" , timeout = 2 )
6667 if response .status_code == 200 :
6768 progress .update (task , completed = max_retries )
68- console .print ("[green]✓[/green] Infrahub is ready!\n " )
69+ console .print ("[bold green]✓ Infrahub is ready![/bold green] \n " )
6970 return True
7071 except requests .exceptions .RequestException :
7172 pass
@@ -87,9 +88,9 @@ def check_infrahub_ready(max_retries: int = 30, sleep_time: int = 2) -> bool:
8788 return False
8889
8990
90- def run_command (command : str , description : str , step : str ) -> bool :
91+ def run_command (command : str , description : str , step : str , color : str = "cyan" ) -> bool :
9192 """Run a shell command and display output."""
92- console .print (f"\n [cyan ]{ step } [/cyan] { description } " )
93+ console .print (f"\n [bold { color } on black ]{ step } [/bold { color } on black] [bold white] { description } [/bold white] " )
9394
9495 try :
9596 subprocess .run (
@@ -99,45 +100,50 @@ def run_command(command: str, description: str, step: str) -> bool:
99100 capture_output = False ,
100101 text = True
101102 )
102- console .print (f"[green]✓[/green] { description } completed" )
103+ console .print (f"[bold green]✓[/bold green] [green] { description } completed[/green] " )
103104 return True
104105 except subprocess .CalledProcessError as e :
105- console .print (f"[red]✗[/red] Failed: { description } " )
106+ console .print (f"[bold red]✗[/bold red] [red] Failed: { description } [/red] " )
106107 console .print (f"[dim]Error: { e } [/dim]" )
107108 return False
108109
109110
110111def wait_for_repository_sync (seconds : int = 120 ) -> None :
111112 """Wait for repository synchronization with progress bar."""
112- console .print (f"\n [cyan]→[/cyan] Waiting for repository sync ({ seconds } seconds)..." )
113+ console .print (f"\n [bold yellow]⏳ Waiting for repository sync ({ seconds } seconds)...[/bold yellow] " )
113114
114115 with Progress (
115- SpinnerColumn (),
116+ SpinnerColumn (spinner_name = "point" ),
116117 TextColumn ("[progress.description]{task.description}" ),
117- BarColumn (),
118+ BarColumn (bar_width = 40 , complete_style = "yellow" , finished_style = "green" ),
118119 TextColumn ("[progress.percentage]{task.percentage:>3.0f}%" ),
119120 TimeElapsedColumn (),
120121 console = console ,
121122 ) as progress :
122- task = progress .add_task ("[cyan ]Syncing repository..." , total = seconds )
123+ task = progress .add_task ("[bold yellow ]Syncing repository..." , total = seconds )
123124
124125 for _ in range (seconds ):
125126 time .sleep (1 )
126127 progress .update (task , advance = 1 )
127128
128- console .print ("[green]✓[/green] Repository sync complete\n " )
129+ console .print ("[bold green]✓ Repository sync complete[/bold green] \n " )
129130
130131
131132def main (branch : str = "main" ) -> int :
132133 """Main bootstrap function."""
133134 console .print ()
134135 console .print (Panel (
135- f"[bold blue]Infrahub Demo Bootstrap[/bold blue]\n "
136- f"[dim]Branch:[/dim] [bold]{ branch } [/bold]\n \n "
137- "[dim]This will load schemas, menu, bootstrap data, security, and repository[/dim]" ,
138- border_style = "blue" ,
139- box = box .ROUNDED ,
140- title = "Bootstrap Process"
136+ f"[bold bright_blue]🚀 Infrahub Demo Bootstrap[/bold bright_blue]\n "
137+ f"[bright_cyan]Branch:[/bright_cyan] [bold yellow]{ branch } [/bold yellow]\n \n "
138+ "[dim]This will load:[/dim]\n "
139+ " [blue]•[/blue] Schemas\n "
140+ " [magenta]•[/magenta] Menu definitions\n "
141+ " [yellow]•[/yellow] Bootstrap data\n "
142+ " [green]•[/green] Security data\n "
143+ " [bright_magenta]•[/bright_magenta] Demo repository" ,
144+ border_style = "bright_blue" ,
145+ box = box .DOUBLE ,
146+ title = "[bold bright_blue]Bootstrap Process[/bold bright_blue]"
141147 ))
142148
143149 # Check if Infrahub is ready
@@ -148,42 +154,52 @@ def main(branch: str = "main") -> int:
148154 {
149155 "step" : "[1/7]" ,
150156 "description" : "Loading schemas" ,
151- "command" : f"uv run infrahubctl schema load schemas --branch { branch } "
157+ "command" : f"uv run infrahubctl schema load schemas --branch { branch } " ,
158+ "color" : "blue"
152159 },
153160 {
154161 "step" : "[2/7]" ,
155162 "description" : "Loading menu definitions" ,
156- "command" : f"uv run infrahubctl menu load menu --branch { branch } "
163+ "command" : f"uv run infrahubctl menu load menu --branch { branch } " ,
164+ "color" : "magenta"
157165 },
158166 {
159167 "step" : "[3/7]" ,
160168 "description" : "Loading bootstrap data (locations, platforms, roles, etc.)" ,
161- "command" : f"uv run infrahubctl object load objects/bootstrap/ --branch { branch } "
169+ "command" : f"uv run infrahubctl object load objects/bootstrap/ --branch { branch } " ,
170+ "color" : "yellow"
162171 },
163172 {
164173 "step" : "[4/7]" ,
165174 "description" : "Loading security data (zones, policies, rules)" ,
166- "command" : f"uv run infrahubctl object load objects/security/ --branch { branch } "
175+ "command" : f"uv run infrahubctl object load objects/security/ --branch { branch } " ,
176+ "color" : "green"
167177 },
168178 {
169179 "step" : "[5/7]" ,
170180 "description" : "Populating security relationships" ,
171- "command" : "uv run python scripts/populate_security_relationships.py"
181+ "command" : "uv run python scripts/populate_security_relationships.py" ,
182+ "color" : "cyan"
172183 },
173184 ]
174185
175186 # Execute all steps
176- for step_info in steps :
187+ for i , step_info in enumerate ( steps ) :
177188 if not run_command (
178189 step_info ["command" ],
179190 step_info ["description" ],
180- step_info ["step" ]
191+ step_info ["step" ],
192+ step_info ["color" ]
181193 ):
182- console .print ("\n [red]Bootstrap failed![/red]" )
194+ console .print ("\n [bold red]✗ Bootstrap failed![/bold red]" )
183195 return 1
184196
197+ # Add visual separator after each step (except the last one)
198+ if i < len (steps ) - 1 :
199+ console .print (Rule (style = f"dim { step_info ['color' ]} " ))
200+
185201 # Add repository (may already exist)
186- console .print ("\n [cyan ][6/7][/cyan] Adding demo repository" )
202+ console .print ("\n [bold bright_magenta on black ][6/7][/bold bright_magenta on black] [bold white] Adding demo repository[/bold white] " )
187203 result = subprocess .run (
188204 "uv run infrahubctl repository add DEMO https://github.com/opsmill/infrahub-demo.git --ref main --read-only --ref main" ,
189205 shell = True ,
@@ -192,39 +208,46 @@ def main(branch: str = "main") -> int:
192208 )
193209
194210 if result .returncode == 0 :
195- console .print ("[green]✓[/green] Repository added" )
211+ console .print ("[bold green]✓[/bold green] [green] Repository added[/green] " )
196212 else :
197213 if "already exists" in result .stderr .lower () or "already exists" in result .stdout .lower ():
198- console .print ("[yellow]⚠[/yellow] Repository already exists, skipping..." )
214+ console .print ("[bold yellow]⚠[/bold yellow] [yellow] Repository already exists, skipping...[/yellow] " )
199215 else :
200- console .print ("[red]✗[/red] Failed to add repository" )
216+ console .print ("[bold red]✗[/bold red] [red] Failed to add repository[/red] " )
201217 console .print (f"[dim]{ result .stderr } [/dim]" )
202218
219+ console .print (Rule (style = "dim bright_magenta" ))
220+
203221 # Wait for repository sync
204- console .print ("\n [cyan ][7/7][/cyan] Waiting for repository sync" )
222+ console .print ("\n [bold bright_yellow on black ][7/7][/bold bright_yellow on black] [bold white] Waiting for repository sync[/bold white] " )
205223 wait_for_repository_sync (120 )
206224
225+ console .print (Rule (style = "dim bright_yellow" ))
226+
207227 # Load event actions
208- console .print ("\n [cyan]→[/cyan] Loading event actions" )
228+ console .print ("\n [bold bright_cyan]→ Loading event actions[/bold bright_cyan] " )
209229 if run_command (
210230 f"uv run infrahubctl object load objects/events/ --branch { branch } " ,
211231 "Event actions loading" ,
212- ""
232+ "" ,
233+ "bright_cyan"
213234 ):
214- console .print ("[green]✓[/green] Event actions loaded successfully" )
235+ console .print ("[bold green]✓[/bold green] [green]Event actions loaded successfully[/green]" )
236+
237+ console .print (Rule (style = "dim bright_cyan" ))
215238
216239 # Display completion message
217240 console .print ()
218241 console .print (Panel (
219- f"[bold green] Bootstrap Complete![/bold green ]\n \n "
242+ f"[bold bright_green]🎉 Bootstrap Complete![/bold bright_green ]\n \n "
220243 f"[dim]All data has been loaded into Infrahub[/dim]\n "
221- f"[dim ]Branch:[/dim ] [bold]{ branch } [/bold]\n \n "
222- "[cyan ]Next steps:[/cyan ]\n "
223- " • Demo a DC design: [bold]uv run invoke demo-dc-arista[/bold]\n "
224- " • Create a Proposed Change" ,
225- title = "Success" ,
226- border_style = "green " ,
227- box = box .ROUNDED
244+ f"[bright_cyan ]Branch:[/bright_cyan ] [bold yellow ]{ branch } [/bold yellow ]\n \n "
245+ "[bold bright_magenta ]Next steps:[/bold bright_magenta ]\n "
246+ " [green]•[/green] Demo a DC design: [bold bright_cyan ]uv run invoke demo-dc-arista[/bold bright_cyan ]\n "
247+ " [green]•[/green] Create a Proposed Change" ,
248+ title = "[bold bright_green]✓ Success[/bold bright_green] " ,
249+ border_style = "bright_green " ,
250+ box = box .DOUBLE
228251 ))
229252
230253 return 0
0 commit comments