forked from toolshed/abra
		
	Compare commits
	
		
			331 Commits
		
	
	
		
			deploy-rel
			...
			improve-mo
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9daac54144 | |||
| 
						
						
							
						
						11656c009d
	
				 | 
					
					
						|||
| 
						
						
							
						
						e4e1b58501
	
				 | 
					
					
						|||
| 
						
						
							
						
						3b8f12643c
	
				 | 
					
					
						|||
| 
						
						
							
						
						e5f5154197
	
				 | 
					
					
						|||
| 
						
						
							
						
						6c1c0a8a8a
	
				 | 
					
					
						|||
| 662f45008c | |||
| 
						
						
							
						
						708c5f5223
	
				 | 
					
					
						|||
| d58552b748 | |||
| 
						
						
							
						
						51fe809851
	
				 | 
					
					
						|||
| 3f6a22747f | |||
| 
						
						
							
						
						4e75b96914
	
				 | 
					
					
						|||
| fd4ee75ab7 | |||
| 
						
						
							
						
						964ed834ee
	
				 | 
					
					
						|||
| fcb3167394 | |||
| 
						
						
							
						
						3845b40aa3
	
				 | 
					
					
						|||
| 0dc5c307af | |||
| fc5855ff28 | |||
| 
						
						
							
						
						5b504a1550
	
				 | 
					
					
						|||
| fc16a21f1c | |||
| 
						
						
							
						
						7b4d2d7230
	
				 | 
					
					
						|||
| 
						
						
							
						
						d0ccb805c6
	
				 | 
					
					
						|||
| 
						
						
							
						
						2460dd9438
	
				 | 
					
					
						|||
| 9c648a2566 | |||
| 
						
						
							
						
						22ecfb9c4c
	
				 | 
					
					
						|||
| 
						
						
							
						
						9f3cf718be
	
				 | 
					
					
						|||
| 
						
						
							
						
						b737ce2107
	
				 | 
					
					
						|||
| 
						
						
							
						
						a3d0ece7cb
	
				 | 
					
					
						|||
| 
						
						
							
						
						d63a1c28ea
	
				 | 
					
					
						|||
| 1c10e64c58 | |||
| 
						
						
							
						
						21826ec555
	
				 | 
					
					
						|||
| 
						
						
							
						
						4b4c56d406
	
				 | 
					
					
						|||
| 
						
						
							
						
						4314195dd7
	
				 | 
					
					
						|||
| df4447b038 | |||
| 
						
						
							
						
						3fa660e579
	
				 | 
					
					
						|||
| 
						
						
							
						
						a430b1e4fd
	
				 | 
					
					
						|||
| 896c434f38 | |||
| 
						
						
							
						
						847b7238c5
	
				 | 
					
					
						|||
| 
						
						
							
						
						89d5fc91b0
	
				 | 
					
					
						|||
| 5af3c5f56e | |||
| 
						
						
							
						
						beb3864b2d
	
				 | 
					
					
						|||
| 
						
						
							
						
						581e6ef538
	
				 | 
					
					
						|||
| 
						
						
							
						
						fd642ddb84
	
				 | 
					
					
						|||
| 
						
						
							
						
						1ad8c127d9
	
				 | 
					
					
						|||
| 40aab6a6c1 | |||
| 
						
						
							
						
						4d33a24a07
	
				 | 
					
					
						|||
| 
						
						
							
						
						ee59eb350b
	
				 | 
					
					
						|||
| 
						
						
							
						
						5da13ff15a
	
				 | 
					
					
						|||
| 
						
						
							
						
						491c594ad3
	
				 | 
					
					
						|||
| 
						
						
							
						
						c794d533be
	
				 | 
					
					
						|||
| 
						
						
							
						
						a6daf7030e
	
				 | 
					
					
						|||
| 
						
						
							
						
						fe3b7ffa9c
	
				 | 
					
					
						|||
| 
						
						
							
						
						4c066a92d8
	
				 | 
					
					
						|||
| 
						
						
							
						
						7899b57781
	
				 | 
					
					
						|||
| 
						
						
							
						
						6e0a901887
	
				 | 
					
					
						|||
| 
						
						
							
						
						713fdebc90
	
				 | 
					
					
						|||
| 
						
						
							
						
						6944d138c6
	
				 | 
					
					
						|||
| 
						
						
							
						
						fbb1f16470
	
				 | 
					
					
						|||
| 
						
						
							
						
						2473cafdf5
	
				 | 
					
					
						|||
| 0ccfbd253e | |||
| 
						
						
							
						
						6c4bee0ac7
	
				 | 
					
					
						|||
| 4fa9f536eb | |||
| 
						
						
							
						
						033c9bfc13
	
				 | 
					
					
						|||
| 0db1ee87fc | |||
| 
						
						
							
						
						d180bb924f
	
				 | 
					
					
						|||
| 
						
						
							
						
						d50d68d95a
	
				 | 
					
					
						|||
| 
						
						
							
						
						f468bc7443
	
				 | 
					
					
						|||
| 
						
						
							
						
						dee2d9d104
	
				 | 
					
					
						|||
| 
						
						
							
						
						5c892b1d6a
	
				 | 
					
					
						|||
| 
						
						
							
						
						81b96fc7b1
	
				 | 
					
					
						|||
| c92a0d0703 | |||
| 
						
						
							
						
						1c4abcf12f
	
				 | 
					
					
						|||
| 
						
						
							
						
						f590870672
	
				 | 
					
					
						|||
| 
						
						
							
						
						a31a25cfa1
	
				 | 
					
					
						|||
| 870dcfb342 | |||
| f53ba48efa | |||
| 26c920e570 | |||
| c67fc57902 | |||
| 07cafd371c | |||
| 5bb6241172 | |||
| 66e6a2c47e | |||
| d866527138 | |||
| 39d1997edf | |||
| d5f5d96944 | |||
| 076d522b1a | |||
| 34934cf62d | |||
| 241dffb8cd | |||
| e42b42e882 | |||
| 0a45424658 | |||
| e73b0cc2fc | |||
| 33aca42181 | |||
| 5c659bae5f | |||
| d9f1f82923 | |||
| 117f64a9d6 | |||
| 90e9e9b5aa | |||
| 7e217f8892 | |||
| bf68ec56a3 | |||
| 40b5c5cd63 | |||
| 14d3f1f669 | |||
| 8e8f7715a2 | |||
| 745651e962 | |||
| c2848cb3ec | |||
| f3edfea744 | |||
| 719722a25b | |||
| 7f9f8f9d6a | |||
| 155df518dd | |||
| 984bdd8792 | |||
| 0b7c38c213 | |||
| 1df0de2e65 | |||
| 6d634ea4e2 | |||
| 
						
						
							
						
						dc207a0138
	
				 | 
					
					
						|||
| 
						
						
							
						
						02add8c3ef
	
				 | 
					
					
						|||
| 
						
						
							
						
						560d609013
	
				 | 
					
					
						|||
| 
						
						
							
						
						b4c9fbfe6d
	
				 | 
					
					
						|||
| 7f456a3f24 | |||
| 709a9ad659 | |||
| a468245413 | |||
| e895b852bc | |||
| bef92d53a8 | |||
| a4b47b431b | |||
| bddf8039af | |||
| d74e760940 | |||
| 7f75d25d56 | |||
| 0bb6d9609c | |||
| e858dcdd14 | |||
| 3606349a4a | |||
| 
						
						
							
						
						4547cf2579
	
				 | 
					
					
						|||
| 
						
						
							
						
						e1f029d2db
	
				 | 
					
					
						|||
| 
						
						
							
						
						cf2952dc65
	
				 | 
					
					
						|||
| 
						
						
							
						
						2291712661
	
				 | 
					
					
						|||
| 
						
						
							
						
						f0e2b012c6
	
				 | 
					
					
						|||
| 
						
						
							
						
						9c37b9b748
	
				 | 
					
					
						|||
| 
						
						
							
						
						824f314472
	
				 | 
					
					
						|||
| 
						
						
							
						
						61849a358c
	
				 | 
					
					
						|||
| 
						
						
							
						
						8c7b06a7bb
	
				 | 
					
					
						|||
| 
						
						
							
						
						4c9abbf925
	
				 | 
					
					
						|||
| 
						
						
							
						
						09176801e1
	
				 | 
					
					
						|||
| 
						
						
							
						
						36d4648114
	
				 | 
					
					
						|||
| 
						
						
							
						
						83ca2a63d1
	
				 | 
					
					
						|||
| 
						
						
							
						
						e25ce5d1a0
	
				 | 
					
					
						|||
| 
						
						
							
						
						4cb5091d50
	
				 | 
					
					
						|||
| 
						
						
							
						
						4bfbc53b94
	
				 | 
					
					
						|||
| 
						
						
							
						
						52f02ad9b9
	
				 | 
					
					
						|||
| c0acc3663b | |||
| 
						
						
							
						
						d5c66020ad
	
				 | 
					
					
						|||
| 
						
						
							
						
						86ba006e17
	
				 | 
					
					
						|||
| 
						
						
							
						
						cb4355e61e
	
				 | 
					
					
						|||
| 
						
						
							
						
						069f8fec54
	
				 | 
					
					
						|||
| c2819b9366 | |||
| 
						
						
							
						
						850264d085
	
				 | 
					
					
						|||
| 
						
						
							
						
						e019142c9e
	
				 | 
					
					
						|||
| e23c6197b5 | |||
| 6539b1be7e | |||
| 02b520200e | |||
| acb6170768 | |||
| 
						
						
							
						
						e04af4e582
	
				 | 
					
					
						|||
| 
						
						
							
						
						8bf0d7addc
	
				 | 
					
					
						|||
| 20909695e0 | |||
| baf7631105 | |||
| 57fbc4c061 | |||
| c43e68ea6a | |||
| d3d3358a79 | |||
| cb310c56b5 | |||
| 67c0a64f60 | |||
| db5da1656a | |||
| 5b6254a243 | |||
| 2a0857c388 | |||
| 92a0294f2f | |||
| f79775d726 | |||
| e095bbe9d6 | |||
| eb12127578 | |||
| 82779b233b | |||
| ac4ac1d40f | |||
| 7c31e4dc45 | |||
| b86cd2e85f | |||
| 7dd7f763f4 | |||
| 7b7477062f | |||
| 238647a987 | |||
| 
						
						
							
						
						f39eab8f1e
	
				 | 
					
					
						|||
| 
						
						
							
						
						6a52575ae0
	
				 | 
					
					
						|||
| 
						
						
							
						
						44a7d288af
	
				 | 
					
					
						|||
| 
						
						
							
						
						97377dea39
	
				 | 
					
					
						|||
| 
						
						
							
						
						a2940a84b3
	
				 | 
					
					
						|||
| 
						
						
							
						
						0c708f6592
	
				 | 
					
					
						|||
| 
						
						
							
						
						4cb660c348
	
				 | 
					
					
						|||
| 
						
						
							
						
						42dde0930d
	
				 | 
					
					
						|||
| 
						
						
							
						
						7ccbbe8916
	
				 | 
					
					
						|||
| 
						
						
							
						
						e421e00631
	
				 | 
					
					
						|||
| 
						
						
							
						
						a5104336a2
	
				 | 
					
					
						|||
| 
						
						
							
						
						4e205cf13e
	
				 | 
					
					
						|||
| 
						
						
							
						
						5cf6048ecb
	
				 | 
					
					
						|||
| 
						
						
							
						
						3e2797c433
	
				 | 
					
					
						|||
| df89e8143a | |||
| b4ddd3e77c | |||
| 
						
						
							
						
						81c28e3006
	
				 | 
					
					
						|||
| 
						
						
							
						
						34d2e3b092
	
				 | 
					
					
						|||
| 
						
						
							
						
						1894c2f5fc
	
				 | 
					
					
						|||
| 
						
						
							
						
						e0bd03bec3
	
				 | 
					
					
						|||
| 
						
						
							
						
						77ff146991
	
				 | 
					
					
						|||
| 
						
						
							
						
						6fad1a1dcc
	
				 | 
					
					
						|||
| 
						
						
							
						
						a90e239547
	
				 | 
					
					
						|||
| 
						
						
							
						
						9ee094fcd7
	
				 | 
					
					
						|||
| 
						
						
							
						
						1aa7016789
	
				 | 
					
					
						|||
| 60b3af1fa4 | |||
| 5f4b5e0fad | |||
| feadfca0d6 | |||
| 73d4ee1c98 | |||
| 
						
						
							
						
						f46c18c8d7
	
				 | 
					
					
						|||
| f5a843bd90 | |||
| 
						
						
							
						
						fac372dc73
	
				 | 
					
					
						|||
| 
						
						
							
						
						8a3be01c3e
	
				 | 
					
					
						|||
| 
						
						
							
						
						4193d63d23
	
				 | 
					
					
						|||
| 
						
						
							
						
						38f308910a
	
				 | 
					
					
						|||
| 
						
						
							
						
						4aaa7400b8
	
				 | 
					
					
						|||
| 091611b984 | |||
| 2cfc40dc28 | |||
| 6849e3554d | |||
| 
						
						
							
						
						452de7fdc2
	
				 | 
					
					
						|||
| 
						
						
							
						
						952d768ab0
	
				 | 
					
					
						|||
| 2c91d2040e | |||
| eff4435971 | |||
| 032fe99086 | |||
| 7add56df00 | |||
| 0ab05cece2 | |||
| c63f6db61e | |||
| 56a68dfa91 | |||
| 157d131b37 | |||
| 3fae036db2 | |||
| ce9d0934b6 | |||
| 
						
						
							
						
						a32e30374f
	
				 | 
					
					
						|||
| 
						
						
							
						
						cf46569f04
	
				 | 
					
					
						|||
| 
						
						
							
						
						022606c13c
	
				 | 
					
					
						|||
| 
						
						
							
						
						8cfda5229f
	
				 | 
					
					
						|||
| 
						
						
							
						
						855a4c37c4
	
				 | 
					
					
						|||
| 7c3b740e14 | |||
| 
						
						
							
						
						2fbef41a3a
	
				 | 
					
					
						|||
| 6fb41e5300 | |||
| 1432f480c7 | |||
| 
						
						
							
						
						83af39771b
	
				 | 
					
					
						|||
| 
						
						
							
						
						4d1333202e
	
				 | 
					
					
						|||
| 
						
						
							
						
						55c24f070c
	
				 | 
					
					
						|||
| 229e8eb9da | |||
| 
						
						
							
						
						b3ab95750e
	
				 | 
					
					
						|||
| de009921a2 | |||
| 
						
						
							
						
						d081bbaefa
	
				 | 
					
					
						|||
| 
						
						
							
						
						515b5466ca
	
				 | 
					
					
						|||
| 
						
						
							
						
						6965799bdc
	
				 | 
					
					
						|||
| 
						
						
							
						
						f75c9a6259
	
				 | 
					
					
						|||
| a43a092ba7 | |||
| fa084a61d2 | |||
| 
						
						
							
						
						895a7fe7d6
	
				 | 
					
					
						|||
| 
						
						
							
						
						742a726778
	
				 | 
					
					
						|||
| 
						
						
							
						
						2b9a185aff
	
				 | 
					
					
						|||
| 
						
						
							
						
						b7c1e87c0b
	
				 | 
					
					
						|||
| 
						
						
							
						
						cdfb8a08bb
	
				 | 
					
					
						|||
| 
						
						
							
						
						8943cea13f
	
				 | 
					
					
						|||
| 
						
						
							
						
						6d64e0edd3
	
				 | 
					
					
						|||
| 47045ca8f1 | |||
| d0f982456e | |||
| 80ad6c6681 | |||
| 
						
						
							
						
						cb63cfe9c2
	
				 | 
					
					
						|||
| 
						
						
							
						
						d1e49d17ce
	
				 | 
					
					
						|||
| 
						
						
							
						
						1574aa0631
	
				 | 
					
					
						|||
| 
						
						
							
						
						1723025fbf
	
				 | 
					
					
						|||
| 
						
						
							
						
						a2b678caf6
	
				 | 
					
					
						|||
| 0a371ec360 | |||
| e58a716fe1 | |||
| d09a19a385 | |||
| cee808ff06 | |||
| 4326d1d259 | |||
| b976872f77 | |||
| 7b6ea76437 | |||
| 9069758969 | |||
| 15d6b1a2a5 | |||
| 
						
						
							
						
						8a7fe4ca07
	
				 | 
					
					
						|||
| 64ad60663f | |||
| cb3f46b46e | |||
| 
						
						
							
						
						41e514ae9a
	
				 | 
					
					
						|||
| 
						
						
							
						
						086b4828ff
	
				 | 
					
					
						|||
| 
						
						
							
						
						ed263854d4
	
				 | 
					
					
						|||
| 
						
						
							
						
						eb6fe4ba6e
	
				 | 
					
					
						|||
| 993172d31b | |||
| c70b6e72a7 | |||
| 22e4dd7fca | |||
| 
						
						
							
						
						b6009057a8
	
				 | 
					
					
						|||
| 
						
						
							
						
						b978f04910
	
				 | 
					
					
						|||
| 
						
						
							
						
						3ac29d54d9
	
				 | 
					
					
						|||
| 
						
						
							
						
						877c17fab5
	
				 | 
					
					
						|||
| 
						
						
							
						
						f01fd26ce3
	
				 | 
					
					
						|||
| 
						
						
							
						
						273c165a41
	
				 | 
					
					
						|||
| 
						
						
							
						
						c88fc66c99
	
				 | 
					
					
						|||
| 
						
						
							
						
						9b271a6963
	
				 | 
					
					
						|||
| 
						
						
							
						
						8af87aa382
	
				 | 
					
					
						|||
| 
						
						
							
						
						ac0b9cd052
	
				 | 
					
					
						|||
| 
						
						
							
						
						4923984e84
	
				 | 
					
					
						|||
| 
						
						
							
						
						2bc77de751
	
				 | 
					
					
						|||
| 
						
						
							
						
						b3a2402cec
	
				 | 
					
					
						|||
| 
						
						
							
						
						a773fd4256
	
				 | 
					
					
						|||
| 
						
						
							
						
						b1a0d54bd3
	
				 | 
					
					
						|||
| 
						
						
							
						
						3869d6bce9
	
				 | 
					
					
						|||
| 
						
						
							
						
						0ff07ab224
	
				 | 
					
					
						|||
| 
						
						
							
						
						936c1b0626
	
				 | 
					
					
						|||
| 
						
						
							
						
						b576cba227
	
				 | 
					
					
						|||
| 
						
						
							
						
						d087f3debf
	
				 | 
					
					
						|||
| 
						
						
							
						
						e57a6d87a3
	
				 | 
					
					
						|||
| 
						
						
							
						
						74b64099de
	
				 | 
					
					
						|||
| 
						
						
							
						
						354712ca46
	
				 | 
					
					
						|||
| 
						
						
							
						
						81cdc843ec
	
				 | 
					
					
						|||
| 
						
						
							
						
						d2931e3af0
	
				 | 
					
					
						|||
| 
						
						
							
						
						b9f2d1f568
	
				 | 
					
					
						|||
| a379b31a19 | |||
| 
						
						
							
						
						17e15dba77
	
				 | 
					
					
						|||
| 
						
						
							
						
						1194f3b228
	
				 | 
					
					
						|||
| 
						
						
							
						
						2dc8034c16
	
				 | 
					
					
						|||
| 
						
						
							
						
						c5ddeb2d8a
	
				 | 
					
					
						|||
| 
						
						
							
						
						0a63f9ce27
	
				 | 
					
					
						|||
| 
						
						
							
						
						3a71dc47f8
	
				 | 
					
					
						|||
| 
						
						
							
						
						f07c64f7b8
	
				 | 
					
					
						|||
| 
						
						
							
						
						dd03c40e10
	
				 | 
					
					
						|||
| 
						
						
							
						
						48198d55bd
	
				 | 
					
					
						|||
| 
						
						
							
						
						c0931b96d8
	
				 | 
					
					
						|||
| 
						
						
							
						
						64ea0f9684
	
				 | 
					
					
						|||
| 
						
						
							
						
						b0cd8ccbb9
	
				 | 
					
					
						|||
| 
						
						
							
						
						5975be6870
	
				 | 
					
					
						|||
| 
						
						
							
						
						bfed51a69c
	
				 | 
					
					
						|||
| 
						
						
							
						
						5d0faf5e13
	
				 | 
					
					
						|||
| 
						
						
							
						
						cd6af9708c
	
				 | 
					
					
						|||
| 
						
						
							
						
						ef95bce1e4
	
				 | 
					
					
						|||
| 
						
						
							
						
						a159583874
	
				 | 
					
					
						|||
| 
						
						
							
						
						e3b0500875
	
				 | 
					
					
						|||
| 
						
						
							
						
						994310a4ff
	
				 | 
					
					
						
@ -4,5 +4,4 @@
 | 
			
		||||
Dockerfile
 | 
			
		||||
abra
 | 
			
		||||
dist
 | 
			
		||||
kadabra
 | 
			
		||||
tags
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										78
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										78
									
								
								.drone.yml
									
									
									
									
									
								
							@ -3,14 +3,45 @@ kind: pipeline
 | 
			
		||||
name: coopcloud.tech/abra
 | 
			
		||||
steps:
 | 
			
		||||
  - name: make check
 | 
			
		||||
    image: golang:1.22
 | 
			
		||||
    image: golang:1.24
 | 
			
		||||
    commands:
 | 
			
		||||
      - make check
 | 
			
		||||
 | 
			
		||||
  - name: xgettext-go
 | 
			
		||||
    image: git.coopcloud.tech/toolshed/drone-xgettext-go:latest
 | 
			
		||||
    settings:
 | 
			
		||||
      keyword: i18n.G
 | 
			
		||||
      keyword_ctx: i18n.GC
 | 
			
		||||
      out: pkg/i18n/locales/abra.pot
 | 
			
		||||
      comments_tag: translators
 | 
			
		||||
    depends_on:
 | 
			
		||||
      - make check
 | 
			
		||||
    when:
 | 
			
		||||
      event:
 | 
			
		||||
        exclude:
 | 
			
		||||
          - tag
 | 
			
		||||
 | 
			
		||||
  - name: xgettext-go status
 | 
			
		||||
    image: golang:1.24-alpine3.22
 | 
			
		||||
    commands:
 | 
			
		||||
      - apk add patchutils git make
 | 
			
		||||
      - cd /drone/src
 | 
			
		||||
      - sed -i "s/charset=CHARSET/charset=UTF-8/g" pkg/i18n/locales/*.pot
 | 
			
		||||
      - git diff pkg/i18n/locales/abra.pot | grepdiff --output-matching=hunk POT-Creation-Date | git apply --reverse --allow-empty
 | 
			
		||||
      - git diff
 | 
			
		||||
      - git diff-files --exit-code
 | 
			
		||||
    depends_on:
 | 
			
		||||
      - xgettext-go
 | 
			
		||||
    when:
 | 
			
		||||
      event:
 | 
			
		||||
        exclude:
 | 
			
		||||
          - tag
 | 
			
		||||
 | 
			
		||||
  - name: make test
 | 
			
		||||
    image: golang:1.22
 | 
			
		||||
    image: golang:1.24
 | 
			
		||||
    environment:
 | 
			
		||||
      CATL_URL: https://git.coopcloud.tech/coop-cloud/recipes-catalogue-json.git
 | 
			
		||||
      ABRA_DIR: $HOME/.abra
 | 
			
		||||
      CATL_URL: https://git.coopcloud.tech/toolshed/recipes-catalogue-json.git
 | 
			
		||||
    commands:
 | 
			
		||||
      - mkdir -p $HOME/.abra
 | 
			
		||||
      - git clone $CATL_URL $HOME/.abra/catalogue
 | 
			
		||||
@ -29,7 +60,7 @@ steps:
 | 
			
		||||
      event: tag
 | 
			
		||||
 | 
			
		||||
  - name: release
 | 
			
		||||
    image: goreleaser/goreleaser:v1.24.0
 | 
			
		||||
    image: goreleaser/goreleaser:v2.5.1
 | 
			
		||||
    environment:
 | 
			
		||||
      GITEA_TOKEN:
 | 
			
		||||
        from_secret: goreleaser_gitea_token
 | 
			
		||||
@ -47,10 +78,10 @@ steps:
 | 
			
		||||
    image: plugins/docker
 | 
			
		||||
    settings:
 | 
			
		||||
      auto_tag: true
 | 
			
		||||
      username: 3wordchant
 | 
			
		||||
      username: abra-bot
 | 
			
		||||
      password:
 | 
			
		||||
        from_secret: git_coopcloud_tech_token_3wc
 | 
			
		||||
      repo: git.coopcloud.tech/coop-cloud/abra
 | 
			
		||||
        from_secret: git_coopcloud_tech_token_abra_bot
 | 
			
		||||
      repo: git.coopcloud.tech/toolshed/abra
 | 
			
		||||
      tags: dev
 | 
			
		||||
      registry: git.coopcloud.tech
 | 
			
		||||
    when:
 | 
			
		||||
@ -60,7 +91,7 @@ steps:
 | 
			
		||||
      - make check
 | 
			
		||||
      - make test
 | 
			
		||||
 | 
			
		||||
  - name: integration test
 | 
			
		||||
  - name: on-demand integration test
 | 
			
		||||
    image: appleboy/drone-ssh
 | 
			
		||||
    settings:
 | 
			
		||||
      host:
 | 
			
		||||
@ -74,7 +105,31 @@ steps:
 | 
			
		||||
      request_pty: true
 | 
			
		||||
      script:
 | 
			
		||||
        - |
 | 
			
		||||
          wget https://git.coopcloud.tech/coop-cloud/abra/raw/branch/main/scripts/tests/run-ci-int -O run-ci-int
 | 
			
		||||
          wget https://git.coopcloud.tech/toolshed/abra/raw/branch/main/scripts/tests/run-ci-int -O run-ci-int
 | 
			
		||||
          chmod +x run-ci-int
 | 
			
		||||
          sh run-ci-int
 | 
			
		||||
    when:
 | 
			
		||||
      ref:
 | 
			
		||||
        - refs/heads/int-*
 | 
			
		||||
    depends_on:
 | 
			
		||||
      - make check
 | 
			
		||||
      - make test
 | 
			
		||||
 | 
			
		||||
  - name: nightly integration test
 | 
			
		||||
    image: appleboy/drone-ssh
 | 
			
		||||
    settings:
 | 
			
		||||
      host:
 | 
			
		||||
        - int.coopcloud.tech
 | 
			
		||||
      username: abra
 | 
			
		||||
      key:
 | 
			
		||||
        from_secret: abra_int_private_key
 | 
			
		||||
      port: 22
 | 
			
		||||
      command_timeout: 60m
 | 
			
		||||
      script_stop: true
 | 
			
		||||
      request_pty: true
 | 
			
		||||
      script:
 | 
			
		||||
        - |
 | 
			
		||||
          wget https://git.coopcloud.tech/toolshed/abra/raw/branch/main/scripts/tests/run-ci-int -O run-ci-int
 | 
			
		||||
          chmod +x run-ci-int
 | 
			
		||||
          sh run-ci-int
 | 
			
		||||
    when:
 | 
			
		||||
@ -87,3 +142,8 @@ steps:
 | 
			
		||||
volumes:
 | 
			
		||||
  - name: deps
 | 
			
		||||
    temp: {}
 | 
			
		||||
 | 
			
		||||
trigger:
 | 
			
		||||
  action:
 | 
			
		||||
    exclude:
 | 
			
		||||
      - synchronized
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
# integration test suite
 | 
			
		||||
# export ABRA_DIR="$HOME/.abra_test"
 | 
			
		||||
# export ABRA_TEST_DOMAIN=test.example.com
 | 
			
		||||
# export TEST_SERVER=test.example.com
 | 
			
		||||
# export ABRA_CI=1
 | 
			
		||||
 | 
			
		||||
# release automation
 | 
			
		||||
 | 
			
		||||
@ -1,8 +0,0 @@
 | 
			
		||||
---
 | 
			
		||||
name: "Do not use this issue tracker"
 | 
			
		||||
about: "Do not use this issue tracker"
 | 
			
		||||
title: "Do not use this issue tracker"
 | 
			
		||||
labels: []
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
Please report your issue on [`coop-cloud/organising`](https://git.coopcloud.tech/coop-cloud/organising)
 | 
			
		||||
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,8 +1,9 @@
 | 
			
		||||
*.tar.gz
 | 
			
		||||
*fmtcoverage.html
 | 
			
		||||
.e2e.env
 | 
			
		||||
.envrc
 | 
			
		||||
.vscode/
 | 
			
		||||
/abra
 | 
			
		||||
/kadabra
 | 
			
		||||
/bin
 | 
			
		||||
dist/
 | 
			
		||||
tests/integration/.bats
 | 
			
		||||
 | 
			
		||||
@ -32,31 +32,6 @@ builds:
 | 
			
		||||
      - "-s"
 | 
			
		||||
      - "-w"
 | 
			
		||||
 | 
			
		||||
  - id: kadabra
 | 
			
		||||
    binary: kadabra
 | 
			
		||||
    dir: cmd/kadabra
 | 
			
		||||
    env:
 | 
			
		||||
      - CGO_ENABLED=0
 | 
			
		||||
    goos:
 | 
			
		||||
      - linux
 | 
			
		||||
      - darwin
 | 
			
		||||
    goarch:
 | 
			
		||||
      - 386
 | 
			
		||||
      - amd64
 | 
			
		||||
      - arm
 | 
			
		||||
      - arm64
 | 
			
		||||
    goarm:
 | 
			
		||||
      - 5
 | 
			
		||||
      - 6
 | 
			
		||||
      - 7
 | 
			
		||||
    gcflags:
 | 
			
		||||
      - "all=-l -B"
 | 
			
		||||
    ldflags:
 | 
			
		||||
      - "-X 'main.Commit={{ .Commit }}'"
 | 
			
		||||
      - "-X 'main.Version={{ .Version }}'"
 | 
			
		||||
      - "-s"
 | 
			
		||||
      - "-w"
 | 
			
		||||
 | 
			
		||||
checksum:
 | 
			
		||||
  name_template: "checksums.txt"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -4,13 +4,19 @@
 | 
			
		||||
> please do add yourself! This is a community project, let's show some 💞
 | 
			
		||||
 | 
			
		||||
- 3wordchant
 | 
			
		||||
- ammaratef45
 | 
			
		||||
- apfelwurm
 | 
			
		||||
- basebuilder
 | 
			
		||||
- cassowary
 | 
			
		||||
- chasqui
 | 
			
		||||
- codegod100
 | 
			
		||||
- decentral1se
 | 
			
		||||
- fauno
 | 
			
		||||
- frando
 | 
			
		||||
- iexos
 | 
			
		||||
- kawaiipunk
 | 
			
		||||
- knoflook
 | 
			
		||||
- mayel
 | 
			
		||||
- moritz
 | 
			
		||||
- p4u1
 | 
			
		||||
- rix
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
# Build image
 | 
			
		||||
FROM golang:1.22-alpine AS build
 | 
			
		||||
FROM golang:1.24-alpine AS build
 | 
			
		||||
 | 
			
		||||
ENV GOPRIVATE coopcloud.tech
 | 
			
		||||
ENV GOPRIVATE=coopcloud.tech
 | 
			
		||||
 | 
			
		||||
RUN apk add --no-cache \
 | 
			
		||||
  gcc \
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										74
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										74
									
								
								Makefile
									
									
									
									
									
								
							@ -1,48 +1,35 @@
 | 
			
		||||
ABRA         := ./cmd/abra
 | 
			
		||||
KADABRA      := ./cmd/kadabra
 | 
			
		||||
XGETTEXT     := ./bin/xgettext-go
 | 
			
		||||
COMMIT       := $(shell git rev-list -1 HEAD)
 | 
			
		||||
GOPATH       := $(shell go env GOPATH)
 | 
			
		||||
GOVERSION    := 1.22
 | 
			
		||||
GOVERSION    := 1.24
 | 
			
		||||
LDFLAGS      := "-X 'main.Commit=$(COMMIT)'"
 | 
			
		||||
DIST_LDFLAGS := $(LDFLAGS)" -s -w"
 | 
			
		||||
GCFLAGS      := "all=-l -B"
 | 
			
		||||
DOMAIN       := abra
 | 
			
		||||
POFILES      := $(wildcard pkg/i18n/locales/*.po)
 | 
			
		||||
MOFILES      := $(patsubst %.po,%.mo,$(POFILES))
 | 
			
		||||
LINGUAS      := $(basename $(POFILES))
 | 
			
		||||
 | 
			
		||||
export GOPRIVATE=coopcloud.tech
 | 
			
		||||
 | 
			
		||||
# NOTE(d1): default `make` optimised for Abra hacking
 | 
			
		||||
all: format check build-abra test
 | 
			
		||||
all: format check build
 | 
			
		||||
 | 
			
		||||
run-abra:
 | 
			
		||||
run:
 | 
			
		||||
	@go run -gcflags=$(GCFLAGS) -ldflags=$(LDFLAGS) $(ABRA)
 | 
			
		||||
 | 
			
		||||
run-kadabra:
 | 
			
		||||
	@go run -gcflags=$(GCFLAGS) -ldflags=$(LDFLAGS) $(KADABRA)
 | 
			
		||||
 | 
			
		||||
install-abra:
 | 
			
		||||
install:
 | 
			
		||||
	@go install -gcflags=$(GCFLAGS) -ldflags=$(LDFLAGS) $(ABRA)
 | 
			
		||||
 | 
			
		||||
install-kadabra:
 | 
			
		||||
	@go install -gcflags=$(GCFLAGS) -ldflags=$(LDFLAGS) $(KADABRA)
 | 
			
		||||
 | 
			
		||||
install: install-abra install-kadabra
 | 
			
		||||
 | 
			
		||||
build-abra:
 | 
			
		||||
build:
 | 
			
		||||
	@go build -v -gcflags=$(GCFLAGS) -ldflags=$(DIST_LDFLAGS) $(ABRA)
 | 
			
		||||
 | 
			
		||||
build-kadabra:
 | 
			
		||||
	@go build -v -gcflags=$(GCFLAGS) -ldflags=$(DIST_LDFLAGS) $(KADABRA)
 | 
			
		||||
 | 
			
		||||
build: build-abra build-kadabra
 | 
			
		||||
 | 
			
		||||
build-docker-abra:
 | 
			
		||||
build-docker:
 | 
			
		||||
	@docker run -it -v $(PWD):/abra golang:$(GOVERSION) \
 | 
			
		||||
		bash -c 'cd /abra; ./scripts/docker/build.sh'
 | 
			
		||||
 | 
			
		||||
build-docker: build-docker-abra
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	@rm '$(GOPATH)/bin/abra'
 | 
			
		||||
	@rm '$(GOPATH)/bin/kadabra'
 | 
			
		||||
 | 
			
		||||
format:
 | 
			
		||||
	@gofmt -s -w $$(find . -type f -name '*.go' | grep -v "/vendor/")
 | 
			
		||||
@ -54,8 +41,47 @@ check:
 | 
			
		||||
test:
 | 
			
		||||
	@go test ./... -cover -v
 | 
			
		||||
 | 
			
		||||
find-tests:
 | 
			
		||||
	@find . -name "*_test.go"
 | 
			
		||||
 | 
			
		||||
loc:
 | 
			
		||||
	@find . -name "*.go" | xargs wc -l
 | 
			
		||||
 | 
			
		||||
deps:
 | 
			
		||||
	@go get -t -u ./...
 | 
			
		||||
 | 
			
		||||
.PHONY: i18n
 | 
			
		||||
i18n: update-pot update-pot-po-metadata update-po build-mo
 | 
			
		||||
 | 
			
		||||
.PHONY: update-po
 | 
			
		||||
update-po:
 | 
			
		||||
	@set -eu; \
 | 
			
		||||
	for lang in $(LINGUAS); do \
 | 
			
		||||
		msgmerge --backup=none -U $$lang.po pkg/i18n/locales/$(DOMAIN).pot; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
.PHONY: update-pot
 | 
			
		||||
update-pot: $(XGETTEXT)
 | 
			
		||||
	@${XGETTEXT} \
 | 
			
		||||
		-o pkg/i18n/locales/$(DOMAIN).pot \
 | 
			
		||||
		--keyword=i18n.G \
 | 
			
		||||
		--keyword-ctx=i18n.GC \
 | 
			
		||||
		--sort-output \
 | 
			
		||||
		--add-comments-tag="translators" \
 | 
			
		||||
		$$(find . -name "*.go" -not -path "*vendor*" | sort)
 | 
			
		||||
 | 
			
		||||
${XGETTEXT}:
 | 
			
		||||
	@mkdir -p ./bin && \
 | 
			
		||||
	wget -O ./bin/xgettext-go https://git.coopcloud.tech/toolshed/xgettext-go/raw/branch/main/xgettext-go && \
 | 
			
		||||
	chmod +x ./bin/xgettext-go
 | 
			
		||||
 | 
			
		||||
.PHONY: update-pot-po-metadata
 | 
			
		||||
update-pot-po-metadata:
 | 
			
		||||
	@sed -i "s/charset=CHARSET/charset=UTF-8/g" pkg/i18n/locales/*.po pkg/i18n/locales/*.pot
 | 
			
		||||
 | 
			
		||||
.PHONY: build-mo
 | 
			
		||||
build-mo:
 | 
			
		||||
	@set -eu; \
 | 
			
		||||
	for lang in $(POFILES); do \
 | 
			
		||||
		msgfmt $$lang -o $$(echo $$lang | sed 's/.po/.mo/g') --statistics; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,9 @@
 | 
			
		||||
# `abra`
 | 
			
		||||
 | 
			
		||||
[](https://build.coopcloud.tech/coop-cloud/abra)
 | 
			
		||||
[](https://goreportcard.com/report/git.coopcloud.tech/coop-cloud/abra)
 | 
			
		||||
[](https://build.coopcloud.tech/toolshed/abra)
 | 
			
		||||
[](https://goreportcard.com/report/git.coopcloud.tech/toolshed/abra)
 | 
			
		||||
[](https://pkg.go.dev/coopcloud.tech/abra)
 | 
			
		||||
[](https://translate.coopcloud.tech/engage/co-op-cloud/)
 | 
			
		||||
 | 
			
		||||
The Co-op Cloud utility belt 🎩🐇
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,20 @@
 | 
			
		||||
package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appAliases = i18n.GC("a", "abra app")
 | 
			
		||||
 | 
			
		||||
var AppCommand = &cobra.Command{
 | 
			
		||||
	Use:     "app [cmd] [args] [flags]",
 | 
			
		||||
	Aliases: []string{"a"},
 | 
			
		||||
	Short:   "Manage apps",
 | 
			
		||||
	// translators: `app` command group
 | 
			
		||||
	Use:     i18n.G("app [cmd] [args] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appAliases, ","),
 | 
			
		||||
	// translators: Short description for `app` command group
 | 
			
		||||
	Short: i18n.G("Manage apps"),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,19 +2,27 @@ package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app backup list` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appBackupListAliases = i18n.G("ls")
 | 
			
		||||
 | 
			
		||||
var AppBackupListCommand = &cobra.Command{
 | 
			
		||||
	Use:     "list <app> [flags]",
 | 
			
		||||
	Aliases: []string{"ls"},
 | 
			
		||||
	Short:   "List the contents of a snapshot",
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	// translators: `app backup list` command
 | 
			
		||||
	Use:     i18n.G("list <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appBackupListAliases, ","),
 | 
			
		||||
	// translators: Short description for `app backup list` command
 | 
			
		||||
	Short: i18n.G("List the contents of a snapshot"),
 | 
			
		||||
	Args:  cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -40,17 +48,17 @@ var AppBackupListCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if snapshot != "" {
 | 
			
		||||
			log.Debugf("including SNAPSHOT=%s in backupbot exec invocation", snapshot)
 | 
			
		||||
			log.Debug(i18n.G("including SNAPSHOT=%s in backupbot exec invocation", snapshot))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("SNAPSHOT=%s", snapshot))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if showAllPaths {
 | 
			
		||||
			log.Debugf("including SHOW_ALL=%v in backupbot exec invocation", showAllPaths)
 | 
			
		||||
			log.Debug(i18n.G("including SHOW_ALL=%v in backupbot exec invocation", showAllPaths))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("SHOW_ALL=%v", showAllPaths))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if timestamps {
 | 
			
		||||
			log.Debugf("including TIMESTAMPS=%v in backupbot exec invocation", timestamps)
 | 
			
		||||
			log.Debug(i18n.G("including TIMESTAMPS=%v in backupbot exec invocation", timestamps))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("TIMESTAMPS=%v", timestamps))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -60,14 +68,20 @@ var AppBackupListCommand = &cobra.Command{
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra app backup download` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appBackupDownloadAliases = i18n.G("d")
 | 
			
		||||
 | 
			
		||||
var AppBackupDownloadCommand = &cobra.Command{
 | 
			
		||||
	Use:     "download <app> [flags]",
 | 
			
		||||
	Aliases: []string{"d"},
 | 
			
		||||
	Short:   "Download a snapshot",
 | 
			
		||||
	Long: `Downloads a backup.tar.gz to the current working directory.
 | 
			
		||||
	// translators: `app backup download` command
 | 
			
		||||
	Use:     i18n.G("download <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appBackupDownloadAliases, ","),
 | 
			
		||||
	// translators: Short description for `app backup download` command
 | 
			
		||||
	Short: i18n.G("Download a snapshot"),
 | 
			
		||||
	Long: i18n.G(`Downloads a backup.tar.gz to the current working directory.
 | 
			
		||||
 | 
			
		||||
"--volumes/-v" includes data contained in volumes alongide paths specified in
 | 
			
		||||
"backupbot.backup.path" labels.`,
 | 
			
		||||
"backupbot.backup.path" labels.`),
 | 
			
		||||
	Args: cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -78,7 +92,7 @@ var AppBackupDownloadCommand = &cobra.Command{
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -98,22 +112,22 @@ var AppBackupDownloadCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if snapshot != "" {
 | 
			
		||||
			log.Debugf("including SNAPSHOT=%s in backupbot exec invocation", snapshot)
 | 
			
		||||
			log.Debug(i18n.G("including SNAPSHOT=%s in backupbot exec invocation", snapshot))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("SNAPSHOT=%s", snapshot))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if includePath != "" {
 | 
			
		||||
			log.Debugf("including INCLUDE_PATH=%s in backupbot exec invocation", includePath)
 | 
			
		||||
			log.Debug(i18n.G("including INCLUDE_PATH=%s in backupbot exec invocation", includePath))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("INCLUDE_PATH=%s", includePath))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if includeSecrets {
 | 
			
		||||
			log.Debugf("including SECRETS=%v in backupbot exec invocation", includeSecrets)
 | 
			
		||||
			log.Debug(i18n.G("including SECRETS=%v in backupbot exec invocation", includeSecrets))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("SECRETS=%v", includeSecrets))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if includeVolumes {
 | 
			
		||||
			log.Debugf("including VOLUMES=%v in backupbot exec invocation", includeVolumes)
 | 
			
		||||
			log.Debug(i18n.G("including VOLUMES=%v in backupbot exec invocation", includeVolumes))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("VOLUMES=%v", includeVolumes))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -129,11 +143,17 @@ var AppBackupDownloadCommand = &cobra.Command{
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra app backup create` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appBackupCreateAliases = i18n.G("c")
 | 
			
		||||
 | 
			
		||||
var AppBackupCreateCommand = &cobra.Command{
 | 
			
		||||
	Use:     "create <app> [flags]",
 | 
			
		||||
	Aliases: []string{"c"},
 | 
			
		||||
	Short:   "Create a new snapshot",
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	// translators: `app backup create` command
 | 
			
		||||
	Use:     i18n.G("create <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appBackupCreateAliases, ","),
 | 
			
		||||
	// translators: Short description for `app backup create` command
 | 
			
		||||
	Short: i18n.G("Create a new snapshot"),
 | 
			
		||||
	Args:  cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -143,7 +163,7 @@ var AppBackupCreateCommand = &cobra.Command{
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -163,7 +183,7 @@ var AppBackupCreateCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if retries != "" {
 | 
			
		||||
			log.Debugf("including RETRIES=%s in backupbot exec invocation", retries)
 | 
			
		||||
			log.Debug(i18n.G("including RETRIES=%s in backupbot exec invocation", retries))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("RETRIES=%s", retries))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -173,11 +193,17 @@ var AppBackupCreateCommand = &cobra.Command{
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra app backup snapshots` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appBackupSnapshotsAliases = i18n.G("s")
 | 
			
		||||
 | 
			
		||||
var AppBackupSnapshotsCommand = &cobra.Command{
 | 
			
		||||
	Use:     "snapshots <app> [flags]",
 | 
			
		||||
	Aliases: []string{"s"},
 | 
			
		||||
	Short:   "List all snapshots",
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	// translators: `app backup snapshots` command
 | 
			
		||||
	Use:     i18n.G("snapshots <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appBackupSnapshotsAliases, ","),
 | 
			
		||||
	// translators: Short description for `app backup snapshots` command
 | 
			
		||||
	Short: i18n.G("List all snapshots"),
 | 
			
		||||
	Args:  cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -208,10 +234,16 @@ var AppBackupSnapshotsCommand = &cobra.Command{
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra app backup` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appBackupAliases = i18n.G("b")
 | 
			
		||||
 | 
			
		||||
var AppBackupCommand = &cobra.Command{
 | 
			
		||||
	Use:     "backup [cmd] [args] [flags]",
 | 
			
		||||
	Aliases: []string{"b"},
 | 
			
		||||
	Short:   "Manage app backups",
 | 
			
		||||
	// translators: `app backup` command group
 | 
			
		||||
	Use:     i18n.G("backup [cmd] [args] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appBackupAliases, ","),
 | 
			
		||||
	// translators: Short description for `app backup` command group
 | 
			
		||||
	Short: i18n.G("Manage app backups"),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
@ -227,81 +259,81 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	AppBackupListCommand.Flags().StringVarP(
 | 
			
		||||
		&snapshot,
 | 
			
		||||
		"snapshot",
 | 
			
		||||
		"s",
 | 
			
		||||
		i18n.G("snapshot"),
 | 
			
		||||
		i18n.G("s"),
 | 
			
		||||
		"",
 | 
			
		||||
		"list specific snapshot",
 | 
			
		||||
		i18n.G("list specific snapshot"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppBackupListCommand.Flags().BoolVarP(
 | 
			
		||||
		&showAllPaths,
 | 
			
		||||
		"all",
 | 
			
		||||
		"a",
 | 
			
		||||
		i18n.G("all"),
 | 
			
		||||
		i18n.GC("a", "app backup list"),
 | 
			
		||||
		false,
 | 
			
		||||
		"show all paths",
 | 
			
		||||
		i18n.G("show all paths"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppBackupListCommand.Flags().BoolVarP(
 | 
			
		||||
		×tamps,
 | 
			
		||||
		"timestamps",
 | 
			
		||||
		"t",
 | 
			
		||||
		i18n.G("timestamps"),
 | 
			
		||||
		i18n.G("t"),
 | 
			
		||||
		false,
 | 
			
		||||
		"include timestamps",
 | 
			
		||||
		i18n.G("include timestamps"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppBackupDownloadCommand.Flags().StringVarP(
 | 
			
		||||
		&snapshot,
 | 
			
		||||
		"snapshot",
 | 
			
		||||
		"s",
 | 
			
		||||
		i18n.G("snapshot"),
 | 
			
		||||
		i18n.G("s"),
 | 
			
		||||
		"",
 | 
			
		||||
		"list specific snapshot",
 | 
			
		||||
		i18n.G("list specific snapshot"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppBackupDownloadCommand.Flags().StringVarP(
 | 
			
		||||
		&includePath,
 | 
			
		||||
		"path",
 | 
			
		||||
		"p",
 | 
			
		||||
		i18n.G("path"),
 | 
			
		||||
		i18n.G("p"),
 | 
			
		||||
		"",
 | 
			
		||||
		"volumes path",
 | 
			
		||||
		i18n.G("volumes path"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppBackupDownloadCommand.Flags().BoolVarP(
 | 
			
		||||
		&includeSecrets,
 | 
			
		||||
		"secrets",
 | 
			
		||||
		"S",
 | 
			
		||||
		i18n.G("secrets"),
 | 
			
		||||
		i18n.G("S"),
 | 
			
		||||
		false,
 | 
			
		||||
		"include secrets",
 | 
			
		||||
		i18n.G("include secrets"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppBackupDownloadCommand.Flags().BoolVarP(
 | 
			
		||||
		&includeVolumes,
 | 
			
		||||
		"volumes",
 | 
			
		||||
		"v",
 | 
			
		||||
		i18n.G("volumes"),
 | 
			
		||||
		i18n.G("v"),
 | 
			
		||||
		false,
 | 
			
		||||
		"include volumes",
 | 
			
		||||
		i18n.G("include volumes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppBackupDownloadCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppBackupCreateCommand.Flags().StringVarP(
 | 
			
		||||
		&retries,
 | 
			
		||||
		"retries",
 | 
			
		||||
		"r",
 | 
			
		||||
		i18n.G("retries"),
 | 
			
		||||
		i18n.G("r"),
 | 
			
		||||
		"1",
 | 
			
		||||
		"number of retry attempts",
 | 
			
		||||
		i18n.G("number of retry attempts"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppBackupCreateCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,21 +2,29 @@ package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/charmbracelet/lipgloss"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app check` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appCheckAliases = i18n.G("chk")
 | 
			
		||||
 | 
			
		||||
var AppCheckCommand = &cobra.Command{
 | 
			
		||||
	Use:     "check <app> [flags]",
 | 
			
		||||
	Aliases: []string{"chk"},
 | 
			
		||||
	Short:   "Ensure an app is well configured",
 | 
			
		||||
	Long: `Compare env vars in both the app ".env" and recipe ".env.sample" file.
 | 
			
		||||
	// translators: `app check` command
 | 
			
		||||
	Use:     i18n.G("check <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appCheckAliases, ","),
 | 
			
		||||
	// translators: Short description for `app check` command
 | 
			
		||||
	Short: i18n.G("Ensure an app is well configured"),
 | 
			
		||||
	Long: i18n.G(`Compare env vars in both the app ".env" and recipe ".env.sample" file.
 | 
			
		||||
 | 
			
		||||
The goal is to ensure that recipe ".env.sample" env vars are defined in your
 | 
			
		||||
app ".env" file. Only env var definitions in the ".env.sample" which are
 | 
			
		||||
@ -25,7 +33,7 @@ these env vars, then "check" will complain.
 | 
			
		||||
 | 
			
		||||
Recipe maintainers may or may not provide defaults for env vars within their
 | 
			
		||||
recipes regardless of commenting or not (e.g. through the use of
 | 
			
		||||
${FOO:<default>} syntax). "check" does not confirm or deny this for you.`,
 | 
			
		||||
${FOO:<default>} syntax). "check" does not confirm or deny this for you.`),
 | 
			
		||||
	Args: cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -36,7 +44,7 @@ ${FOO:<default>} syntax). "check" does not confirm or deny this for you.`,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -83,9 +91,9 @@ ${FOO:<default>} syntax). "check" does not confirm or deny this for you.`,
 | 
			
		||||
func init() {
 | 
			
		||||
	AppCheckCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -13,15 +13,22 @@ import (
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app cmd` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appCmdAliases = i18n.G("cmd")
 | 
			
		||||
 | 
			
		||||
var AppCmdCommand = &cobra.Command{
 | 
			
		||||
	Use:     "command <app> [service | --local] <cmd> [[args] [flags] | [flags] -- [args]]",
 | 
			
		||||
	Aliases: []string{"cmd"},
 | 
			
		||||
	Short:   "Run app commands",
 | 
			
		||||
	Long: `Run an app specific command.
 | 
			
		||||
	// translators: `app command` command
 | 
			
		||||
	Use:     i18n.G("command <domain> [service | --local] <cmd> [[args] [flags] | [flags] -- [args]]"),
 | 
			
		||||
	Aliases: strings.Split(appCmdAliases, ","),
 | 
			
		||||
	// translators: Short description for `app cmd` command
 | 
			
		||||
	Short: i18n.G("Run app commands"),
 | 
			
		||||
	Long: i18n.G(`Run an app specific command.
 | 
			
		||||
 | 
			
		||||
These commands are bash functions, defined in the abra.sh of the recipe itself.
 | 
			
		||||
They can be run within the context of a service (e.g. app) or locally on your
 | 
			
		||||
@ -30,24 +37,24 @@ work station by passing "--local/-l".
 | 
			
		||||
N.B. If using the "--" style to pass arguments, flags (e.g. "--local/-l") must
 | 
			
		||||
be passed *before* the "--". It is possible to pass arguments without the "--"
 | 
			
		||||
as long as no dashes are present (i.e. "foo" works without "--", "-foo"
 | 
			
		||||
does not).`,
 | 
			
		||||
	Example: `  # pass <cmd> args/flags without "--"
 | 
			
		||||
does not).`),
 | 
			
		||||
	Example: i18n.G(`  # pass <cmd> args/flags without "--"
 | 
			
		||||
  abra app cmd 1312.net app my_cmd_arg foo --user bar
 | 
			
		||||
 | 
			
		||||
  # pass <cmd> args/flags with "--"
 | 
			
		||||
  abra app cmd 1312.net app my_cmd_args --user bar -- foo -vvv
 | 
			
		||||
 | 
			
		||||
  # drop the [service] arg if using "--local/-l"
 | 
			
		||||
  abra app cmd 1312.net my_cmd --local`,
 | 
			
		||||
  abra app cmd 1312.net my_cmd --local`),
 | 
			
		||||
	Args: func(cmd *cobra.Command, args []string) error {
 | 
			
		||||
		if local {
 | 
			
		||||
			if !(len(args) >= 2) {
 | 
			
		||||
				return errors.New("requires at least 2 arguments with --local/-l")
 | 
			
		||||
				return errors.New(i18n.G("requires at least 2 arguments with --local/-l"))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if slices.Contains(os.Args, "--") {
 | 
			
		||||
				if cmd.ArgsLenAtDash() > 2 {
 | 
			
		||||
					return errors.New("accepts at most 2 args with --local/-l")
 | 
			
		||||
					return errors.New(i18n.G("accepts at most 2 args with --local/-l"))
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -63,7 +70,7 @@ does not).`,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !(len(args) >= 3) {
 | 
			
		||||
			return errors.New("requires at least 3 arguments")
 | 
			
		||||
			return errors.New(i18n.G("requires at least 3 arguments"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return nil
 | 
			
		||||
@ -92,19 +99,19 @@ does not).`,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if local && remoteUser != "" {
 | 
			
		||||
			log.Fatal("cannot use --local & --user together")
 | 
			
		||||
			log.Fatal(i18n.G("cannot use --local & --user together"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		hasCmdArgs, parsedCmdArgs := parseCmdArgs(args, local)
 | 
			
		||||
 | 
			
		||||
		if _, err := os.Stat(app.Recipe.AbraShPath); err != nil {
 | 
			
		||||
			if os.IsNotExist(err) {
 | 
			
		||||
				log.Fatalf("%s does not exist for %s?", app.Recipe.AbraShPath, app.Name)
 | 
			
		||||
				log.Fatal(i18n.G("%s does not exist for %s?", app.Recipe.AbraShPath, app.Name))
 | 
			
		||||
			}
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
@ -115,7 +122,7 @@ does not).`,
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debugf("--local detected, running %s on local work station", cmdName)
 | 
			
		||||
			log.Debug(i18n.G("--local detected, running %s on local work station", cmdName))
 | 
			
		||||
 | 
			
		||||
			var exportEnv string
 | 
			
		||||
			for k, v := range app.Env {
 | 
			
		||||
@ -124,16 +131,16 @@ does not).`,
 | 
			
		||||
 | 
			
		||||
			var sourceAndExec string
 | 
			
		||||
			if hasCmdArgs {
 | 
			
		||||
				log.Debugf("parsed following command arguments: %s", parsedCmdArgs)
 | 
			
		||||
				log.Debug(i18n.G("parsed following command arguments: %s", parsedCmdArgs))
 | 
			
		||||
				sourceAndExec = fmt.Sprintf("TARGET=local; APP_NAME=%s; STACK_NAME=%s; %s . %s; %s %s", app.Name, app.StackName(), exportEnv, app.Recipe.AbraShPath, cmdName, parsedCmdArgs)
 | 
			
		||||
			} else {
 | 
			
		||||
				log.Debug("did not detect any command arguments")
 | 
			
		||||
				log.Debug(i18n.G("did not detect any command arguments"))
 | 
			
		||||
				sourceAndExec = fmt.Sprintf("TARGET=local; APP_NAME=%s; STACK_NAME=%s; %s . %s; %s", app.Name, app.StackName(), exportEnv, app.Recipe.AbraShPath, cmdName)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			shell := "/bin/bash"
 | 
			
		||||
			if _, err := os.Stat(shell); errors.Is(err, os.ErrNotExist) {
 | 
			
		||||
				log.Debugf("%s does not exist locally, use /bin/sh as fallback", shell)
 | 
			
		||||
				log.Debug(i18n.G("%s does not exist locally, use /bin/sh as fallback", shell))
 | 
			
		||||
				shell = "/bin/sh"
 | 
			
		||||
			}
 | 
			
		||||
			cmd := exec.Command(shell, "-c", sourceAndExec)
 | 
			
		||||
@ -164,15 +171,15 @@ does not).`,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !matchingServiceName {
 | 
			
		||||
			log.Fatalf("no service %s for %s?", targetServiceName, app.Name)
 | 
			
		||||
			log.Fatal(i18n.G("no service %s for %s?", targetServiceName, app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("running command %s within the context of %s_%s", cmdName, app.StackName(), targetServiceName)
 | 
			
		||||
		log.Debug(i18n.G("running command %s within the context of %s_%s", cmdName, app.StackName(), targetServiceName))
 | 
			
		||||
 | 
			
		||||
		if hasCmdArgs {
 | 
			
		||||
			log.Debugf("parsed following command arguments: %s", parsedCmdArgs)
 | 
			
		||||
			log.Debug(i18n.G("parsed following command arguments: %s", parsedCmdArgs))
 | 
			
		||||
		} else {
 | 
			
		||||
			log.Debug("did not detect any command arguments")
 | 
			
		||||
			log.Debug(i18n.G("did not detect any command arguments"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cl, err := client.New(app.Server)
 | 
			
		||||
@ -183,7 +190,7 @@ does not).`,
 | 
			
		||||
		if err := internal.RunCmdRemote(
 | 
			
		||||
			cl,
 | 
			
		||||
			app,
 | 
			
		||||
			requestTTY,
 | 
			
		||||
			disableTTY,
 | 
			
		||||
			app.Recipe.AbraShPath,
 | 
			
		||||
			targetServiceName, cmdName, parsedCmdArgs, remoteUser); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
@ -191,15 +198,21 @@ does not).`,
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra app command list` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var appCmdListAliases = i18n.G("ls")
 | 
			
		||||
 | 
			
		||||
var AppCmdListCommand = &cobra.Command{
 | 
			
		||||
	Use:     "list <app> [flags]",
 | 
			
		||||
	Aliases: []string{"ls"},
 | 
			
		||||
	Short:   "List all available commands",
 | 
			
		||||
	Args:    cobra.MinimumNArgs(1),
 | 
			
		||||
	// translators: `app cmd list` command
 | 
			
		||||
	Use:     i18n.G("list <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appCmdListAliases, ","),
 | 
			
		||||
	// translators: Short description for `app cmd list` command
 | 
			
		||||
	Short: i18n.G("List all available commands"),
 | 
			
		||||
	Args:  cobra.MinimumNArgs(1),
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -238,39 +251,39 @@ func parseCmdArgs(args []string, isLocal bool) (bool, string) {
 | 
			
		||||
var (
 | 
			
		||||
	local      bool
 | 
			
		||||
	remoteUser string
 | 
			
		||||
	requestTTY bool
 | 
			
		||||
	disableTTY bool
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppCmdCommand.Flags().BoolVarP(
 | 
			
		||||
		&local,
 | 
			
		||||
		"local",
 | 
			
		||||
		"l",
 | 
			
		||||
		i18n.G("local"),
 | 
			
		||||
		i18n.G("l"),
 | 
			
		||||
		false,
 | 
			
		||||
		"run command locally",
 | 
			
		||||
		i18n.G("run command locally"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppCmdCommand.Flags().StringVarP(
 | 
			
		||||
		&remoteUser,
 | 
			
		||||
		"user",
 | 
			
		||||
		"u",
 | 
			
		||||
		i18n.G("user"),
 | 
			
		||||
		i18n.G("u"),
 | 
			
		||||
		"",
 | 
			
		||||
		"request remote user",
 | 
			
		||||
		i18n.G("request remote user"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppCmdCommand.Flags().BoolVarP(
 | 
			
		||||
		&requestTTY,
 | 
			
		||||
		"tty",
 | 
			
		||||
		"t",
 | 
			
		||||
		&disableTTY,
 | 
			
		||||
		i18n.G("tty"),
 | 
			
		||||
		i18n.G("T"),
 | 
			
		||||
		false,
 | 
			
		||||
		"request remote TTY",
 | 
			
		||||
		i18n.G("disable remote TTY"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppCmdCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@ func TestParseCmdArgs(t *testing.T) {
 | 
			
		||||
	}{
 | 
			
		||||
		// `--` is not parsed when passed in from the command-line e.g. -- foo bar baz
 | 
			
		||||
		// so we need to eumlate that as missing when testing if bash args are passed in
 | 
			
		||||
		// see https://git.coopcloud.tech/coop-cloud/organising/issues/336 for more
 | 
			
		||||
		// see https://git.coopcloud.tech/toolshed/organising/issues/336 for more
 | 
			
		||||
		{[]string{"foo.com", "app", "test"}, false, ""},
 | 
			
		||||
		{[]string{"foo.com", "app", "test", "foo"}, true, "foo "},
 | 
			
		||||
		{[]string{"foo.com", "app", "test", "foo", "bar", "baz"}, true, "foo bar baz "},
 | 
			
		||||
 | 
			
		||||
@ -3,19 +3,27 @@ package app
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
	"os/exec"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app config` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var appConfigAliases = i18n.G("cfg")
 | 
			
		||||
 | 
			
		||||
var AppConfigCommand = &cobra.Command{
 | 
			
		||||
	Use:     "config <app> [flags]",
 | 
			
		||||
	Aliases: []string{"cfg"},
 | 
			
		||||
	Short:   "Edit app config",
 | 
			
		||||
	Example: "  abra config 1312.net",
 | 
			
		||||
	// translators: `app config` command
 | 
			
		||||
	Use:     i18n.G("config <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appConfigAliases, ","),
 | 
			
		||||
	// translators: Short description for `app config` command
 | 
			
		||||
	Short:   i18n.G("Edit app config"),
 | 
			
		||||
	Example: i18n.G("  abra config 1312.net"),
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -32,13 +40,13 @@ var AppConfigCommand = &cobra.Command{
 | 
			
		||||
		appName := args[0]
 | 
			
		||||
		appFile, exists := files[appName]
 | 
			
		||||
		if !exists {
 | 
			
		||||
			log.Fatalf("cannot find app with name %s", appName)
 | 
			
		||||
			log.Fatal(i18n.G("cannot find app with name %s", appName))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		ed, ok := os.LookupEnv("EDITOR")
 | 
			
		||||
		if !ok {
 | 
			
		||||
			edPrompt := &survey.Select{
 | 
			
		||||
				Message: "which editor do you wish to use?",
 | 
			
		||||
				Message: i18n.G("which editor do you wish to use?"),
 | 
			
		||||
				Options: []string{"vi", "vim", "nvim", "nano", "pico", "emacs"},
 | 
			
		||||
			}
 | 
			
		||||
			if err := survey.AskOne(edPrompt, &ed); err != nil {
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,6 @@ package app
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
@ -15,25 +14,32 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	containerPkg "coopcloud.tech/abra/pkg/container"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/container"
 | 
			
		||||
	"github.com/docker/cli/cli/command"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	containertypes "github.com/docker/docker/api/types/container"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/docker/docker/errdefs"
 | 
			
		||||
	"github.com/docker/docker/pkg/archive"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app cp` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appCpAliases = i18n.G("c")
 | 
			
		||||
 | 
			
		||||
var AppCpCommand = &cobra.Command{
 | 
			
		||||
	Use:     "cp <app> <src> <dst> [flags]",
 | 
			
		||||
	Aliases: []string{"c"},
 | 
			
		||||
	Short:   "Copy files to/from a deployed app service",
 | 
			
		||||
	Example: `  # copy myfile.txt to the root of the app service
 | 
			
		||||
	// translators: `app cp` command
 | 
			
		||||
	Use:     i18n.G("cp <domain> <src> <dst> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appCpAliases, ","),
 | 
			
		||||
	// translators: Short description for `app cp` command
 | 
			
		||||
	Short: i18n.G("Copy files to/from a deployed app service"),
 | 
			
		||||
	Example: i18n.G(`  # copy myfile.txt to the root of the app service
 | 
			
		||||
  abra app cp 1312.net myfile.txt app:/
 | 
			
		||||
 | 
			
		||||
  # copy that file back to your current working directory locally
 | 
			
		||||
  abra app cp 1312.net app:/myfile.txt`,
 | 
			
		||||
  abra app cp 1312.net app:/myfile.txt ./`),
 | 
			
		||||
	Args: cobra.ExactArgs(3),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -49,7 +55,7 @@ var AppCpCommand = &cobra.Command{
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -69,7 +75,7 @@ var AppCpCommand = &cobra.Command{
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		log.Debugf("retrieved %s as target container on %s", formatter.ShortenID(container.ID), app.Server)
 | 
			
		||||
		log.Debug(i18n.G("retrieved %s as target container on %s", formatter.ShortenID(container.ID), app.Server))
 | 
			
		||||
 | 
			
		||||
		if toContainer {
 | 
			
		||||
			err = CopyToContainer(cl, container.ID, srcPath, dstPath)
 | 
			
		||||
@ -82,7 +88,7 @@ var AppCpCommand = &cobra.Command{
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var errServiceMissing = errors.New("one of <src>/<dest> arguments must take $SERVICE:$PATH form")
 | 
			
		||||
var errServiceMissing = errors.New(i18n.G("one of <src>/<dest> arguments must take $SERVICE:$PATH form"))
 | 
			
		||||
 | 
			
		||||
// parseSrcAndDst parses src and dest string. One of src or dst must be of the form $SERVICE:$PATH
 | 
			
		||||
func parseSrcAndDst(src, dst string) (srcPath string, dstPath string, service string, toContainer bool, err error) {
 | 
			
		||||
@ -105,7 +111,7 @@ func parseSrcAndDst(src, dst string) (srcPath string, dstPath string, service st
 | 
			
		||||
func CopyToContainer(cl *dockerClient.Client, containerID, srcPath, dstPath string) error {
 | 
			
		||||
	srcStat, err := os.Stat(srcPath)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("local %s ", err)
 | 
			
		||||
		return errors.New(i18n.G("local %s ", err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	dstStat, err := cl.ContainerStatPath(context.Background(), containerID, dstPath)
 | 
			
		||||
@ -114,7 +120,7 @@ func CopyToContainer(cl *dockerClient.Client, containerID, srcPath, dstPath stri
 | 
			
		||||
		if errdefs.IsNotFound(err) {
 | 
			
		||||
			dstExists = false
 | 
			
		||||
		} else {
 | 
			
		||||
			return fmt.Errorf("remote path: %s", err)
 | 
			
		||||
			return errors.New(i18n.G("remote path: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -134,7 +140,7 @@ func CopyToContainer(cl *dockerClient.Client, containerID, srcPath, dstPath stri
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		if _, err := container.RunExec(dcli, cl, containerID, &types.ExecConfig{
 | 
			
		||||
		if _, err := container.RunExec(dcli, cl, containerID, &containertypes.ExecOptions{
 | 
			
		||||
			AttachStderr: true,
 | 
			
		||||
			AttachStdin:  true,
 | 
			
		||||
			AttachStdout: true,
 | 
			
		||||
@ -142,7 +148,7 @@ func CopyToContainer(cl *dockerClient.Client, containerID, srcPath, dstPath stri
 | 
			
		||||
			Detach:       false,
 | 
			
		||||
			Tty:          true,
 | 
			
		||||
		}); err != nil {
 | 
			
		||||
			return fmt.Errorf("create remote directory: %s", err)
 | 
			
		||||
			return errors.New(i18n.G("create remote directory: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	case CopyModeFileToFile:
 | 
			
		||||
		// Remove the file component from the path, since docker can only copy
 | 
			
		||||
@ -161,8 +167,8 @@ func CopyToContainer(cl *dockerClient.Client, containerID, srcPath, dstPath stri
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("copy %s from local to %s on container", srcPath, dstPath)
 | 
			
		||||
	copyOpts := types.CopyToContainerOptions{AllowOverwriteDirWithFile: false, CopyUIDGID: false}
 | 
			
		||||
	log.Debug(i18n.G("copy %s from local to %s on container", srcPath, dstPath))
 | 
			
		||||
	copyOpts := containertypes.CopyToContainerOptions{AllowOverwriteDirWithFile: false, CopyUIDGID: false}
 | 
			
		||||
	if err := cl.CopyToContainer(context.Background(), containerID, dstPath, content, copyOpts); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
@ -173,7 +179,7 @@ func CopyToContainer(cl *dockerClient.Client, containerID, srcPath, dstPath stri
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		if _, err := container.RunExec(dcli, cl, containerID, &types.ExecConfig{
 | 
			
		||||
		if _, err := container.RunExec(dcli, cl, containerID, &containertypes.ExecOptions{
 | 
			
		||||
			AttachStderr: true,
 | 
			
		||||
			AttachStdin:  true,
 | 
			
		||||
			AttachStdout: true,
 | 
			
		||||
@ -181,7 +187,7 @@ func CopyToContainer(cl *dockerClient.Client, containerID, srcPath, dstPath stri
 | 
			
		||||
			Detach:       false,
 | 
			
		||||
			Tty:          true,
 | 
			
		||||
		}); err != nil {
 | 
			
		||||
			return fmt.Errorf("create remote directory: %s", err)
 | 
			
		||||
			return errors.New(i18n.G("create remote directory: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -194,9 +200,9 @@ func CopyFromContainer(cl *dockerClient.Client, containerID, srcPath, dstPath st
 | 
			
		||||
	srcStat, err := cl.ContainerStatPath(context.Background(), containerID, srcPath)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if errdefs.IsNotFound(err) {
 | 
			
		||||
			return fmt.Errorf("remote: %s does not exist", srcPath)
 | 
			
		||||
			return errors.New(i18n.G("remote: %s does not exist", srcPath))
 | 
			
		||||
		} else {
 | 
			
		||||
			return fmt.Errorf("remote path: %s", err)
 | 
			
		||||
			return errors.New(i18n.G("remote path: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -207,7 +213,7 @@ func CopyFromContainer(cl *dockerClient.Client, containerID, srcPath, dstPath st
 | 
			
		||||
		if os.IsNotExist(err) {
 | 
			
		||||
			dstExists = false
 | 
			
		||||
		} else {
 | 
			
		||||
			return fmt.Errorf("remote path: %s", err)
 | 
			
		||||
			return errors.New(i18n.G("remote path: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		dstMode = dstStat.Mode()
 | 
			
		||||
@ -242,7 +248,7 @@ func CopyFromContainer(cl *dockerClient.Client, containerID, srcPath, dstPath st
 | 
			
		||||
 | 
			
		||||
	content, _, err := cl.CopyFromContainer(context.Background(), containerID, srcPath)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("copy: %s", err)
 | 
			
		||||
		return errors.New(i18n.G("copy: %s", err))
 | 
			
		||||
	}
 | 
			
		||||
	defer content.Close()
 | 
			
		||||
	if err := archive.Untar(content, dstPath, &archive.TarOptions{
 | 
			
		||||
@ -250,7 +256,7 @@ func CopyFromContainer(cl *dockerClient.Client, containerID, srcPath, dstPath st
 | 
			
		||||
		Compression:          archive.Gzip,
 | 
			
		||||
		NoLchown:             true,
 | 
			
		||||
	}); err != nil {
 | 
			
		||||
		return fmt.Errorf("untar: %s", err)
 | 
			
		||||
		return errors.New(i18n.G("untar: %s", err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if moveDstFile != "" {
 | 
			
		||||
@ -269,8 +275,8 @@ func CopyFromContainer(cl *dockerClient.Client, containerID, srcPath, dstPath st
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	ErrCopyDirToFile  = fmt.Errorf("can't copy dir to file")
 | 
			
		||||
	ErrDstDirNotExist = fmt.Errorf("destination directory does not exist")
 | 
			
		||||
	ErrCopyDirToFile  = errors.New(i18n.G("can't copy dir to file"))
 | 
			
		||||
	ErrDstDirNotExist = errors.New(i18n.G("destination directory does not exist"))
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CopyMode int
 | 
			
		||||
@ -375,9 +381,9 @@ func moveFile(sourcePath, destPath string) error {
 | 
			
		||||
func init() {
 | 
			
		||||
	AppCpCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,33 +4,42 @@ import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/envfile"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/secret"
 | 
			
		||||
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/deploy"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/dns"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/lint"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var AppDeployCommand = &cobra.Command{
 | 
			
		||||
	Use:     "deploy <app> [version] [flags]",
 | 
			
		||||
	Aliases: []string{"d"},
 | 
			
		||||
	Short:   "Deploy an app",
 | 
			
		||||
	Long: `Deploy an app.
 | 
			
		||||
// translators: `abra app deploy` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appDeployAliases = i18n.G("d")
 | 
			
		||||
 | 
			
		||||
This command supports chaos operations. Use "--chaos/-c" to deploy your recipe
 | 
			
		||||
checkout as-is. Recipe commit hashes are also supported values for "[version]".
 | 
			
		||||
Please note, "upgrade"/"rollback" do not support chaos operations.`,
 | 
			
		||||
	Example: `  # standard deployment
 | 
			
		||||
var AppDeployCommand = &cobra.Command{
 | 
			
		||||
	// translators: `app deploy` command
 | 
			
		||||
	Use:     i18n.G("deploy <domain> [version] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appDeployAliases, ","),
 | 
			
		||||
	// translators: Short description for `app deploy` command
 | 
			
		||||
	Short: i18n.G("Deploy an app"),
 | 
			
		||||
	Long: i18n.G(`Deploy an app.
 | 
			
		||||
 | 
			
		||||
This command supports chaos operations. Use "--chaos/-C" to deploy your recipe
 | 
			
		||||
checkout as-is. Recipe commit hashes are also supported as values for
 | 
			
		||||
"[version]". Please note, "upgrade"/"rollback" do not support chaos operations.`),
 | 
			
		||||
	Example: i18n.G(`  # standard deployment
 | 
			
		||||
  abra app deploy 1312.net
 | 
			
		||||
 | 
			
		||||
  # chaos deployment
 | 
			
		||||
@ -40,19 +49,20 @@ Please note, "upgrade"/"rollback" do not support chaos operations.`,
 | 
			
		||||
  abra app deploy 1312.net 2.0.0+1.2.3
 | 
			
		||||
 | 
			
		||||
  # deploy a specific git hash
 | 
			
		||||
  abra app deploy 1312.net 886db76d`,
 | 
			
		||||
  abra app deploy 1312.net 886db76d`),
 | 
			
		||||
	Args: cobra.RangeArgs(1, 2),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
		toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		toComplete string,
 | 
			
		||||
	) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		switch l := len(args); l {
 | 
			
		||||
		case 0:
 | 
			
		||||
			return autocomplete.AppNameComplete()
 | 
			
		||||
		case 1:
 | 
			
		||||
			app, err := appPkg.Get(args[0])
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				errMsg := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
				errMsg := i18n.G("autocomplete failed: %s", err)
 | 
			
		||||
				return []string{errMsg}, cobra.ShellCompDirectiveError
 | 
			
		||||
			}
 | 
			
		||||
			return autocomplete.RecipeVersionComplete(app.Recipe.Name)
 | 
			
		||||
@ -61,132 +71,67 @@ Please note, "upgrade"/"rollback" do not support chaos operations.`,
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		var warnMessages []string
 | 
			
		||||
		var (
 | 
			
		||||
			deployWarnMessages []string
 | 
			
		||||
			toDeployVersion    string
 | 
			
		||||
		)
 | 
			
		||||
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
		stackName := app.StackName()
 | 
			
		||||
 | 
			
		||||
		ok, err := validateChaosXORVersion(args)
 | 
			
		||||
		if !ok {
 | 
			
		||||
			log.Fatalf(err.Error())
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		specificVersion := getSpecifiedVersion(args)
 | 
			
		||||
 | 
			
		||||
		if specificVersion != "" {
 | 
			
		||||
			log.Debugf("overriding env file version (%s) with %s", app.Recipe.Version, specificVersion)
 | 
			
		||||
			app.Recipe.Version = specificVersion
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if specificVersion == "" && app.Recipe.Version != "" && !internal.Chaos {
 | 
			
		||||
			log.Debugf("retrieved %s as version from env file", app.Recipe.Version)
 | 
			
		||||
			specificVersion = app.Recipe.Version
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := validateArgsAndFlags(args); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := lint.LintForErrors(app.Recipe); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("checking whether %s is already deployed", stackName)
 | 
			
		||||
 | 
			
		||||
		cl, err := client.New(app.Server)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		deployMeta, err := stack.IsDeployed(context.Background(), cl, stackName)
 | 
			
		||||
		log.Debug(i18n.G("checking whether %s is already deployed", app.StackName()))
 | 
			
		||||
 | 
			
		||||
		deployMeta, err := stack.IsDeployed(context.Background(), cl, app.StackName())
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// NOTE(d1): handles "<version> as git hash" use case
 | 
			
		||||
		var isChaosCommit bool
 | 
			
		||||
		if deployMeta.IsDeployed && !(internal.Force || internal.Chaos) {
 | 
			
		||||
			log.Fatal(i18n.G("%s is already deployed", app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// NOTE(d1): check out specific version before dealing with secrets. This
 | 
			
		||||
		// is because we need to deal with GetComposeFiles under the hood and these
 | 
			
		||||
		// files change from version to version which therefore affects which
 | 
			
		||||
		// secrets might be generated
 | 
			
		||||
		toDeployVersion := deployMeta.Version
 | 
			
		||||
		if specificVersion != "" {
 | 
			
		||||
			toDeployVersion = specificVersion
 | 
			
		||||
			log.Debugf("choosing %s as version to deploy", toDeployVersion)
 | 
			
		||||
		toDeployVersion, err = getDeployVersion(args, deployMeta, app)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
			var err error
 | 
			
		||||
			isChaosCommit, err = app.Recipe.EnsureVersion(toDeployVersion)
 | 
			
		||||
		if !internal.Chaos {
 | 
			
		||||
			isChaosCommit, err := app.Recipe.EnsureVersion(toDeployVersion)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
				log.Fatal(i18n.G("ensure recipe: %s", err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if isChaosCommit {
 | 
			
		||||
				log.Debugf("assuming '%s' is a chaos commit", toDeployVersion)
 | 
			
		||||
				log.Warnf(i18n.G("version '%s' appears to be a chaos commit, but --chaos/-C was not provided", toDeployVersion))
 | 
			
		||||
				internal.Chaos = true
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		secStats, err := secret.PollSecretsStatus(cl, app)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, secStat := range secStats {
 | 
			
		||||
			if !secStat.CreatedOnRemote {
 | 
			
		||||
				log.Fatalf("unable to deploy, secrets not generated (%s)?", secStat.LocalName)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if deployMeta.IsDeployed && !(internal.Force || internal.Chaos) {
 | 
			
		||||
			log.Fatalf("%s is already deployed", app.Name)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !internal.Chaos && specificVersion == "" {
 | 
			
		||||
			versions, err := app.Recipe.Tags()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
		if err := lint.LintForErrors(app.Recipe); err != nil {
 | 
			
		||||
			if internal.Chaos {
 | 
			
		||||
				log.Warn(err)
 | 
			
		||||
			} else {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if len(versions) > 0 && !internal.Chaos {
 | 
			
		||||
				toDeployVersion = versions[len(versions)-1]
 | 
			
		||||
				log.Debugf("choosing %s as version to deploy", toDeployVersion)
 | 
			
		||||
				if _, err := app.Recipe.EnsureVersion(toDeployVersion); err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				head, err := app.Recipe.Head()
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
				toDeployVersion = formatter.SmallSHA(head.String())
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		toDeployChaosVersion := config.CHAOS_DEFAULT
 | 
			
		||||
		if internal.Chaos {
 | 
			
		||||
			if isChaosCommit {
 | 
			
		||||
				toDeployChaosVersion = specificVersion
 | 
			
		||||
				versionLabelLocal, err := app.Recipe.GetVersionLabelLocal()
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
				toDeployVersion = versionLabelLocal
 | 
			
		||||
			} else {
 | 
			
		||||
				var err error
 | 
			
		||||
				toDeployChaosVersion, err = app.Recipe.ChaosVersion()
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		abraShEnv, err := envfile.ReadAbraShEnvVars(app.Recipe.AbraShPath)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
		if err := validateSecrets(cl, app); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		for k, v := range abraShEnv {
 | 
			
		||||
			app.Env[k] = v
 | 
			
		||||
 | 
			
		||||
		if err := deploy.MergeAbraShEnv(app.Recipe, app.Env); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
 | 
			
		||||
@ -194,6 +139,7 @@ Please note, "upgrade"/"rollback" do not support chaos operations.`,
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		stackName := app.StackName()
 | 
			
		||||
		deployOpts := stack.Deploy{
 | 
			
		||||
			Composefiles: composeFiles,
 | 
			
		||||
			Namespace:    stackName,
 | 
			
		||||
@ -209,8 +155,21 @@ Please note, "upgrade"/"rollback" do not support chaos operations.`,
 | 
			
		||||
		appPkg.ExposeAllEnv(stackName, compose, app.Env)
 | 
			
		||||
		appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name)
 | 
			
		||||
		appPkg.SetChaosLabel(compose, stackName, internal.Chaos)
 | 
			
		||||
		appPkg.SetChaosVersionLabel(compose, stackName, toDeployChaosVersion)
 | 
			
		||||
		appPkg.SetUpdateLabel(compose, stackName, app.Env)
 | 
			
		||||
		if internal.Chaos {
 | 
			
		||||
			appPkg.SetChaosVersionLabel(compose, stackName, toDeployVersion)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		versionLabel := toDeployVersion
 | 
			
		||||
		if internal.Chaos {
 | 
			
		||||
			for _, service := range compose.Services {
 | 
			
		||||
				if service.Name == "app" {
 | 
			
		||||
					labelKey := fmt.Sprintf("coop-cloud.%s.version", stackName)
 | 
			
		||||
					// NOTE(d1): keep non-chaos version labbeling when doing chaos ops
 | 
			
		||||
					versionLabel = service.Deploy.Labels[labelKey]
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		appPkg.SetVersionLabel(compose, stackName, versionLabel)
 | 
			
		||||
 | 
			
		||||
		envVars, err := appPkg.CheckEnv(app)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
@ -219,37 +178,61 @@ Please note, "upgrade"/"rollback" do not support chaos operations.`,
 | 
			
		||||
 | 
			
		||||
		for _, envVar := range envVars {
 | 
			
		||||
			if !envVar.Present {
 | 
			
		||||
				warnMessages = append(warnMessages,
 | 
			
		||||
					fmt.Sprintf("env var %s missing from %s.env, present in recipe .env.sample", envVar.Name, app.Domain),
 | 
			
		||||
				deployWarnMessages = append(deployWarnMessages,
 | 
			
		||||
					i18n.G("%s missing from %s.env", envVar.Name, app.Domain),
 | 
			
		||||
				)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !internal.NoDomainChecks {
 | 
			
		||||
			domainName, ok := app.Env["DOMAIN"]
 | 
			
		||||
			if ok {
 | 
			
		||||
			if domainName, ok := app.Env["DOMAIN"]; ok {
 | 
			
		||||
				if _, err = dns.EnsureDomainsResolveSameIPv4(domainName, app.Server); err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				log.Debug("skipping domain checks as no DOMAIN=... configured for app")
 | 
			
		||||
				log.Debug(i18n.G("skipping domain checks, no DOMAIN=... configured"))
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			log.Debug("skipping domain checks as requested")
 | 
			
		||||
			log.Debug(i18n.G("skipping domain checks"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		deployedVersion := config.NO_VERSION_DEFAULT
 | 
			
		||||
		deployedVersion := config.MISSING_DEFAULT
 | 
			
		||||
		if deployMeta.IsDeployed {
 | 
			
		||||
			deployedVersion = deployMeta.Version
 | 
			
		||||
			if deployMeta.IsChaos {
 | 
			
		||||
				deployedVersion = deployMeta.ChaosVersion
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Gather secrets
 | 
			
		||||
		secretInfo, err := deploy.GatherSecretsForDeploy(cl, app, internal.ShowUnchanged)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Gather configs
 | 
			
		||||
		configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env, internal.ShowUnchanged)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Gather images
 | 
			
		||||
		imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose, internal.ShowUnchanged)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Show deploy overview
 | 
			
		||||
		if err := internal.DeployOverview(
 | 
			
		||||
			app,
 | 
			
		||||
			warnMessages,
 | 
			
		||||
			deployedVersion,
 | 
			
		||||
			deployMeta.ChaosVersion,
 | 
			
		||||
			toDeployVersion,
 | 
			
		||||
			toDeployChaosVersion); err != nil {
 | 
			
		||||
			"",
 | 
			
		||||
			deployWarnMessages,
 | 
			
		||||
			secretInfo,
 | 
			
		||||
			configInfo,
 | 
			
		||||
			imageInfo,
 | 
			
		||||
		); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -257,77 +240,198 @@ Please note, "upgrade"/"rollback" do not support chaos operations.`,
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		log.Debugf("set waiting timeout to %d s", stack.WaitTimeout)
 | 
			
		||||
 | 
			
		||||
		if err := stack.RunDeploy(cl, deployOpts, compose, app.Name, internal.DontWaitConverge); err != nil {
 | 
			
		||||
		serviceNames, err := appPkg.GetAppServiceNames(app.Name)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		f, err := app.Filters(true, false, serviceNames...)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := stack.RunDeploy(
 | 
			
		||||
			cl,
 | 
			
		||||
			deployOpts,
 | 
			
		||||
			compose,
 | 
			
		||||
			app.Name,
 | 
			
		||||
			app.Server,
 | 
			
		||||
			internal.DontWaitConverge,
 | 
			
		||||
			f,
 | 
			
		||||
		); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		postDeployCmds, ok := app.Env["POST_DEPLOY_CMDS"]
 | 
			
		||||
		if ok && !internal.DontWaitConverge {
 | 
			
		||||
			log.Debugf("run the following post-deploy commands: %s", postDeployCmds)
 | 
			
		||||
			log.Debug(i18n.G("run the following post-deploy commands: %s", postDeployCmds))
 | 
			
		||||
			if err := internal.PostCmds(cl, app, postDeployCmds); err != nil {
 | 
			
		||||
				log.Fatalf("attempting to run post deploy commands, saw: %s", err)
 | 
			
		||||
				log.Fatal(i18n.G("attempting to run post deploy commands, saw: %s", err))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		app.Recipe.Version = toDeployVersion
 | 
			
		||||
		if toDeployChaosVersion != config.CHAOS_DEFAULT {
 | 
			
		||||
			app.Recipe.Version = toDeployChaosVersion
 | 
			
		||||
		}
 | 
			
		||||
		log.Debugf("choosing %s as version to save to env file", app.Recipe.Version)
 | 
			
		||||
		if err := app.WriteRecipeVersion(app.Recipe.Version, false); err != nil {
 | 
			
		||||
			log.Fatalf("writing new recipe version in env file: %s", err)
 | 
			
		||||
		if err := app.WriteRecipeVersion(toDeployVersion, false); err != nil {
 | 
			
		||||
			log.Fatal(i18n.G("writing recipe version failed: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// validateChaosXORVersion xor checks version/chaos mode
 | 
			
		||||
func validateChaosXORVersion(args []string) (bool, error) {
 | 
			
		||||
	if getSpecifiedVersion(args) != "" && internal.Chaos {
 | 
			
		||||
		return false, errors.New("cannot use <version> and --chaos together")
 | 
			
		||||
func getLatestVersionOrCommit(app appPkg.App) (string, error) {
 | 
			
		||||
	versions, err := app.Recipe.Tags()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	return true, nil
 | 
			
		||||
 | 
			
		||||
	if len(versions) > 0 && !internal.Chaos {
 | 
			
		||||
		return versions[len(versions)-1], nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	head, err := app.Recipe.Head()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return formatter.SmallSHA(head.String()), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getSpecifiedVersion retrieves the specific version if available
 | 
			
		||||
func getSpecifiedVersion(args []string) string {
 | 
			
		||||
	if len(args) >= 2 {
 | 
			
		||||
		return args[1]
 | 
			
		||||
// validateArgsAndFlags ensures compatible args/flags.
 | 
			
		||||
func validateArgsAndFlags(args []string) error {
 | 
			
		||||
	if len(args) == 2 && args[1] != "" && internal.Chaos {
 | 
			
		||||
		return errors.New(i18n.G("cannot use [version] and --chaos together"))
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
 | 
			
		||||
	if len(args) == 2 && args[1] != "" && internal.DeployLatest {
 | 
			
		||||
		return errors.New(i18n.G("cannot use [version] and --latest together"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if internal.DeployLatest && internal.Chaos {
 | 
			
		||||
		return errors.New(i18n.G("cannot use --chaos and --latest together"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func validateSecrets(cl *dockerClient.Client, app appPkg.App) error {
 | 
			
		||||
	composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	secretsConfig, err := secret.ReadSecretsConfig(app.Path, composeFiles, app.StackName())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	secStats, err := secret.PollSecretsStatus(cl, app)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, secStat := range secStats {
 | 
			
		||||
		if !secStat.CreatedOnRemote {
 | 
			
		||||
			secretConfig := secretsConfig[secStat.LocalName]
 | 
			
		||||
			if secretConfig.SkipGenerate {
 | 
			
		||||
				return errors.New(i18n.G("secret not inserted (#generate=false): %s", secStat.LocalName))
 | 
			
		||||
			}
 | 
			
		||||
			return errors.New(i18n.G("secret not generated: %s", secStat.LocalName))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getDeployVersion(cliArgs []string, deployMeta stack.DeployMeta, app appPkg.App) (string, error) {
 | 
			
		||||
	// Chaos mode overrides everything
 | 
			
		||||
	if internal.Chaos {
 | 
			
		||||
		v, err := app.Recipe.ChaosVersion()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", err
 | 
			
		||||
		}
 | 
			
		||||
		log.Debug(i18n.G("version: taking chaos version: %s", v))
 | 
			
		||||
		return v, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Check if the deploy version is set with a cli argument
 | 
			
		||||
	if len(cliArgs) == 2 && cliArgs[1] != "" {
 | 
			
		||||
		log.Debug(i18n.G("version: taking version from cli arg: %s", cliArgs[1]))
 | 
			
		||||
		return cliArgs[1], nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Check if the recipe has a version in the .env file
 | 
			
		||||
	if app.Recipe.EnvVersion != "" && !internal.DeployLatest {
 | 
			
		||||
		if strings.HasSuffix(app.Recipe.EnvVersionRaw, "+U") {
 | 
			
		||||
			// NOTE(d1): use double-line 5 spaces ("FATA ") trick to make a more
 | 
			
		||||
			// informative error message. it's ugly but that's our logging situation
 | 
			
		||||
			// atm
 | 
			
		||||
			return "", errors.New(i18n.G(`cannot redeploy previous chaos version (%s), did you mean to use "--chaos"?
 | 
			
		||||
     to return to a regular release, specify a release tag, commit SHA or use "--latest"`,
 | 
			
		||||
				formatter.BoldDirtyDefault(app.Recipe.EnvVersionRaw)))
 | 
			
		||||
		}
 | 
			
		||||
		log.Debug(i18n.G("version: taking version from .env file: %s", app.Recipe.EnvVersion))
 | 
			
		||||
		return app.Recipe.EnvVersion, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Take deployed version
 | 
			
		||||
	if deployMeta.IsDeployed && !internal.DeployLatest {
 | 
			
		||||
		log.Debug(i18n.G("version: taking deployed version: %s", deployMeta.Version))
 | 
			
		||||
		return deployMeta.Version, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	v, err := getLatestVersionOrCommit(app)
 | 
			
		||||
	log.Debug(i18n.G("version: taking new recipe version: %s", v))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	return v, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppDeployCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppDeployCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Force,
 | 
			
		||||
		"force",
 | 
			
		||||
		"f",
 | 
			
		||||
		i18n.G("force"),
 | 
			
		||||
		i18n.G("f"),
 | 
			
		||||
		false,
 | 
			
		||||
		"perform action without further prompt",
 | 
			
		||||
		i18n.G("perform action without further prompt"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppDeployCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.NoDomainChecks,
 | 
			
		||||
		"no-domain-checks",
 | 
			
		||||
		"D",
 | 
			
		||||
		i18n.G("no-domain-checks"),
 | 
			
		||||
		i18n.G("D"),
 | 
			
		||||
		false,
 | 
			
		||||
		"disable public DNS checks",
 | 
			
		||||
		i18n.G("disable public DNS checks"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppDeployCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.DontWaitConverge,
 | 
			
		||||
		"no-converge-checks",
 | 
			
		||||
		"c",
 | 
			
		||||
		i18n.G("no-converge-checks"),
 | 
			
		||||
		i18n.G("c"),
 | 
			
		||||
		false,
 | 
			
		||||
		"do not wait for converge logic checks",
 | 
			
		||||
		i18n.G("disable converge logic checks"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppDeployCommand.PersistentFlags().BoolVarP(
 | 
			
		||||
		&internal.DeployLatest,
 | 
			
		||||
		i18n.G("latest"),
 | 
			
		||||
		i18n.G("l"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("deploy latest recipe version"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppDeployCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.ShowUnchanged,
 | 
			
		||||
		i18n.G("show-unchanged"),
 | 
			
		||||
		i18n.G("U"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("show all configs & images, including unchanged ones"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,57 +0,0 @@
 | 
			
		||||
package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestGetSpecificVersion(t *testing.T) {
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		input          []string
 | 
			
		||||
		expectedOutput string
 | 
			
		||||
	}{
 | 
			
		||||
		// No specified version when command has one or less args
 | 
			
		||||
		{[]string{}, ""},
 | 
			
		||||
		{[]string{"arg0"}, ""},
 | 
			
		||||
		// Second in arg (index-1) is the specified result when command has more than 1 args
 | 
			
		||||
		{[]string{"arg0", "arg1"}, "arg1"},
 | 
			
		||||
		{[]string{"arg0", "arg1", "arg2"}, "arg1"},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		if test.expectedOutput != getSpecifiedVersion(test.input) {
 | 
			
		||||
			t.Fatalf("result for %s should be %s", test.input, test.expectedOutput)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestValidateChaosXORVersion(t *testing.T) {
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		input          []string
 | 
			
		||||
		isChaos        bool
 | 
			
		||||
		expectedResult bool
 | 
			
		||||
	}{
 | 
			
		||||
		// Chaos = true, Specified Version absent
 | 
			
		||||
		{[]string{}, true, true},
 | 
			
		||||
		// Chaos = false, Specified Version absent
 | 
			
		||||
		{[]string{}, false, true},
 | 
			
		||||
		// Chaos = true, Specified Version present
 | 
			
		||||
		{[]string{"arg0", "arg1"}, true, false},
 | 
			
		||||
		// Chaos = false, Specified Version present
 | 
			
		||||
		{[]string{"arg0", "arg1", "arg2"}, false, true},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		internal.Chaos = test.isChaos
 | 
			
		||||
		res, _ := validateChaosXORVersion(test.input)
 | 
			
		||||
		if res != test.expectedResult {
 | 
			
		||||
			t.Fatalf(
 | 
			
		||||
				"When args are %s and Chaos mode is %t result needs to be %t",
 | 
			
		||||
				test.input,
 | 
			
		||||
				test.isChaos,
 | 
			
		||||
				test.expectedResult,
 | 
			
		||||
			)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										51
									
								
								cli/app/env.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								cli/app/env.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,51 @@
 | 
			
		||||
package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app env` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appEnvAliases = i18n.G("e")
 | 
			
		||||
 | 
			
		||||
var AppEnvCommand = &cobra.Command{
 | 
			
		||||
	// translators: `app env` command
 | 
			
		||||
	Use:     i18n.G("env <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appEnvAliases, ","),
 | 
			
		||||
	// translators: Short description for `app env` command
 | 
			
		||||
	Short:   i18n.G("Show app .env values"),
 | 
			
		||||
	Example: i18n.G("  abra app env 1312.net"),
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
		toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		return autocomplete.AppNameComplete()
 | 
			
		||||
	},
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		var envKeys []string
 | 
			
		||||
		for k := range app.Env {
 | 
			
		||||
			envKeys = append(envKeys, k)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		sort.Strings(envKeys)
 | 
			
		||||
 | 
			
		||||
		var rows [][]string
 | 
			
		||||
		for _, k := range envKeys {
 | 
			
		||||
			rows = append(rows, []string{k, app.Env[k]})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		overview := formatter.CreateOverview(i18n.G("ENV OVERVIEW"), rows)
 | 
			
		||||
		fmt.Println(overview)
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										147
									
								
								cli/app/labels.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								cli/app/labels.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,147 @@
 | 
			
		||||
package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/convert"
 | 
			
		||||
	composetypes "github.com/docker/cli/cli/compose/types"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app labels` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var appLabelsAliases = i18n.G("lb")
 | 
			
		||||
 | 
			
		||||
var AppLabelsCommand = &cobra.Command{
 | 
			
		||||
	// translators: `app labels` command
 | 
			
		||||
	Use:     i18n.G("labels <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appLabelsAliases, ","),
 | 
			
		||||
	// translators: Short description for `app labels` command
 | 
			
		||||
	Short:   i18n.G("Show deployment labels"),
 | 
			
		||||
	Long:    i18n.G("Both local recipe and live deployment labels are shown."),
 | 
			
		||||
	Example: "  " + i18n.G("abra app labels 1312.net"),
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
		toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		return autocomplete.AppNameComplete()
 | 
			
		||||
	},
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cl, err := client.New(app.Server)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		remoteLabels, err := getLabels(cl, app.StackName())
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		rows := [][]string{
 | 
			
		||||
			{i18n.G("DEPLOYED LABELS"), "---"},
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		remoteLabelKeys := make([]string, 0, len(remoteLabels))
 | 
			
		||||
		for k := range remoteLabels {
 | 
			
		||||
			remoteLabelKeys = append(remoteLabelKeys, k)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		sort.Strings(remoteLabelKeys)
 | 
			
		||||
 | 
			
		||||
		for _, k := range remoteLabelKeys {
 | 
			
		||||
			rows = append(rows, []string{
 | 
			
		||||
				k,
 | 
			
		||||
				remoteLabels[k],
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(remoteLabelKeys) == 0 {
 | 
			
		||||
			rows = append(rows, []string{i18n.G("unknown")})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		rows = append(rows, []string{i18n.G("RECIPE LABELS"), "---"})
 | 
			
		||||
 | 
			
		||||
		config, err := app.Recipe.GetComposeConfig(app.Env)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var localLabelKeys []string
 | 
			
		||||
		var appServiceConfig composetypes.ServiceConfig
 | 
			
		||||
		for _, service := range config.Services {
 | 
			
		||||
			if service.Name == "app" {
 | 
			
		||||
				appServiceConfig = service
 | 
			
		||||
 | 
			
		||||
				for k := range service.Deploy.Labels {
 | 
			
		||||
					localLabelKeys = append(localLabelKeys, k)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		sort.Strings(localLabelKeys)
 | 
			
		||||
 | 
			
		||||
		for _, k := range localLabelKeys {
 | 
			
		||||
			rows = append(rows, []string{
 | 
			
		||||
				k,
 | 
			
		||||
				appServiceConfig.Deploy.Labels[k],
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		overview := formatter.CreateOverview(i18n.G("LABELS OVERVIEW"), rows)
 | 
			
		||||
		fmt.Println(overview)
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getLabels reads docker labels from running services in the format of "coop-cloud.${STACK_NAME}.${LABEL}".
 | 
			
		||||
func getLabels(cl *dockerClient.Client, stackName string) (map[string]string, error) {
 | 
			
		||||
	labels := make(map[string]string)
 | 
			
		||||
 | 
			
		||||
	filter := filters.NewArgs()
 | 
			
		||||
	filter.Add("label", fmt.Sprintf("%s=%s", convert.LabelNamespace, stackName))
 | 
			
		||||
 | 
			
		||||
	services, err := cl.ServiceList(context.Background(), types.ServiceListOptions{Filters: filter})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return labels, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, service := range services {
 | 
			
		||||
		if service.Spec.Name != fmt.Sprintf("%s_app", stackName) {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for k, v := range service.Spec.Labels {
 | 
			
		||||
			labels[k] = v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return labels, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppLabelsCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
@ -11,6 +11,7 @@ import (
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/tagcmp"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
@ -24,7 +25,6 @@ type appStatus struct {
 | 
			
		||||
	Status       string `json:"status"`
 | 
			
		||||
	Chaos        string `json:"chaos"`
 | 
			
		||||
	ChaosVersion string `json:"chaosVersion"`
 | 
			
		||||
	AutoUpdate   string `json:"autoUpdate"`
 | 
			
		||||
	Version      string `json:"version"`
 | 
			
		||||
	Upgrade      string `json:"upgrade"`
 | 
			
		||||
}
 | 
			
		||||
@ -38,21 +38,27 @@ type serverStatus struct {
 | 
			
		||||
	UpgradeCount     int         `json:"upgradeCount"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var AppListCommand = &cobra.Command{
 | 
			
		||||
	Use:     "list [flags]",
 | 
			
		||||
	Aliases: []string{"ls"},
 | 
			
		||||
	Short:   "List all managed apps",
 | 
			
		||||
	Long: `Generate a report of all managed apps.
 | 
			
		||||
// translators: `abra app list` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appListAliases = i18n.G("ls")
 | 
			
		||||
 | 
			
		||||
Use "--status/-S" flag to query all servers for the live deployment status.`,
 | 
			
		||||
	Example: `  # list apps of all servers without live status
 | 
			
		||||
var AppListCommand = &cobra.Command{
 | 
			
		||||
	// translators: `app list` command
 | 
			
		||||
	Use:     i18n.G("list [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appListAliases, ","),
 | 
			
		||||
	// translators: Short description for `app list` command
 | 
			
		||||
	Short: i18n.G("List all managed apps"),
 | 
			
		||||
	Long: i18n.G(`Generate a report of all managed apps.
 | 
			
		||||
 | 
			
		||||
Use "--status/-S" flag to query all servers for the live deployment status.`),
 | 
			
		||||
	Example: i18n.G(`  # list apps of all servers without live status
 | 
			
		||||
  abra app ls
 | 
			
		||||
 | 
			
		||||
  # list apps of a specific server with live status
 | 
			
		||||
  abra app ls -s 1312.net -S
 | 
			
		||||
 | 
			
		||||
  # list apps of all servers which match a specific recipe
 | 
			
		||||
  abra app ls -r gitea`,
 | 
			
		||||
  abra app ls -r gitea`),
 | 
			
		||||
	Args: cobra.NoArgs,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		appFiles, err := appPkg.LoadAppFiles(listAppServer)
 | 
			
		||||
@ -107,11 +113,10 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
 | 
			
		||||
				totalAppsCount++
 | 
			
		||||
 | 
			
		||||
				if status {
 | 
			
		||||
					status := "unknown"
 | 
			
		||||
					version := "unknown"
 | 
			
		||||
					chaos := "unknown"
 | 
			
		||||
					chaosVersion := "unknown"
 | 
			
		||||
					autoUpdate := "unknown"
 | 
			
		||||
					status := i18n.G("unknown")
 | 
			
		||||
					version := i18n.G("unknown")
 | 
			
		||||
					chaos := i18n.G("unknown")
 | 
			
		||||
					chaosVersion := i18n.G("unknown")
 | 
			
		||||
					if statusMeta, ok := statuses[app.StackName()]; ok {
 | 
			
		||||
						if currentVersion, exists := statusMeta["version"]; exists {
 | 
			
		||||
							if currentVersion != "" {
 | 
			
		||||
@ -124,9 +129,6 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
 | 
			
		||||
						if chaosDeployVersion, exists := statusMeta["chaosVersion"]; exists {
 | 
			
		||||
							chaosVersion = chaosDeployVersion
 | 
			
		||||
						}
 | 
			
		||||
						if autoUpdateState, exists := statusMeta["autoUpdate"]; exists {
 | 
			
		||||
							autoUpdate = autoUpdateState
 | 
			
		||||
						}
 | 
			
		||||
						if statusMeta["status"] != "" {
 | 
			
		||||
							status = statusMeta["status"]
 | 
			
		||||
						}
 | 
			
		||||
@ -139,13 +141,16 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
 | 
			
		||||
					appStats.Chaos = chaos
 | 
			
		||||
					appStats.ChaosVersion = chaosVersion
 | 
			
		||||
					appStats.Version = version
 | 
			
		||||
					appStats.AutoUpdate = autoUpdate
 | 
			
		||||
 | 
			
		||||
					var newUpdates []string
 | 
			
		||||
					if version != "unknown" {
 | 
			
		||||
					if version != "unknown" && chaos == "false" {
 | 
			
		||||
						if err := app.Recipe.EnsureExists(); err != nil {
 | 
			
		||||
							log.Fatal(i18n.G("unable to clone %s: %s", app.Name, err))
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
						updates, err := app.Recipe.Tags()
 | 
			
		||||
						if err != nil {
 | 
			
		||||
							log.Fatal(err)
 | 
			
		||||
							log.Fatal(i18n.G("unable to retrieve tags for %s: %s", app.Name, err))
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
						parsedVersion, err := tagcmp.Parse(version)
 | 
			
		||||
@ -154,6 +159,11 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
						for _, update := range updates {
 | 
			
		||||
							if ok := tagcmp.IsParsable(update); !ok {
 | 
			
		||||
								log.Debug(i18n.G("unable to parse %s, skipping as upgrade option", update))
 | 
			
		||||
								continue
 | 
			
		||||
							}
 | 
			
		||||
 | 
			
		||||
							parsedUpdate, err := tagcmp.Parse(update)
 | 
			
		||||
							if err != nil {
 | 
			
		||||
								log.Fatal(err)
 | 
			
		||||
@ -167,9 +177,9 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
 | 
			
		||||
 | 
			
		||||
					if len(newUpdates) == 0 {
 | 
			
		||||
						if version == "unknown" {
 | 
			
		||||
							appStats.Upgrade = "unknown"
 | 
			
		||||
							appStats.Upgrade = i18n.G("unknown")
 | 
			
		||||
						} else {
 | 
			
		||||
							appStats.Upgrade = "latest"
 | 
			
		||||
							appStats.Upgrade = i18n.G("latest")
 | 
			
		||||
							stats.LatestCount++
 | 
			
		||||
						}
 | 
			
		||||
					} else {
 | 
			
		||||
@ -208,14 +218,14 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
 | 
			
		||||
 | 
			
		||||
			serverStat := allStats[app.Server]
 | 
			
		||||
 | 
			
		||||
			headers := []string{"RECIPE", "DOMAIN", "SERVER"}
 | 
			
		||||
			headers := []string{i18n.G("RECIPE"), i18n.G("DOMAIN"), i18n.G("SERVER")}
 | 
			
		||||
			if status {
 | 
			
		||||
				headers = append(headers, []string{
 | 
			
		||||
					"STATUS",
 | 
			
		||||
					"CHAOS",
 | 
			
		||||
					"VERSION",
 | 
			
		||||
					"UPGRADE",
 | 
			
		||||
					"AUTOUPDATE"}...,
 | 
			
		||||
					i18n.G("STATUS"),
 | 
			
		||||
					i18n.G("CHAOS"),
 | 
			
		||||
					i18n.G("VERSION"),
 | 
			
		||||
					i18n.G("UPGRADE"),
 | 
			
		||||
				}...,
 | 
			
		||||
				)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -245,8 +255,7 @@ Use "--status/-S" flag to query all servers for the live deployment status.`,
 | 
			
		||||
						appStat.Status,
 | 
			
		||||
						chaosStatus,
 | 
			
		||||
						appStat.Version,
 | 
			
		||||
						appStat.Upgrade,
 | 
			
		||||
						appStat.AutoUpdate}...,
 | 
			
		||||
						appStat.Upgrade}...,
 | 
			
		||||
					)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
@ -279,22 +288,22 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	AppListCommand.Flags().BoolVarP(
 | 
			
		||||
		&status,
 | 
			
		||||
		"status",
 | 
			
		||||
		"S",
 | 
			
		||||
		i18n.G("status"),
 | 
			
		||||
		i18n.G("S"),
 | 
			
		||||
		false,
 | 
			
		||||
		"show app deployment status",
 | 
			
		||||
		i18n.G("show app deployment status"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppListCommand.Flags().StringVarP(
 | 
			
		||||
		&recipeFilter,
 | 
			
		||||
		"recipe",
 | 
			
		||||
		"r",
 | 
			
		||||
		i18n.G("recipe"),
 | 
			
		||||
		i18n.G("r"),
 | 
			
		||||
		"",
 | 
			
		||||
		"show apps of a specific recipe",
 | 
			
		||||
		i18n.G("show apps of a specific recipe"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppListCommand.RegisterFlagCompletionFunc(
 | 
			
		||||
		"recipe",
 | 
			
		||||
		i18n.G("recipe"),
 | 
			
		||||
		func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
			return autocomplete.RecipeNameComplete()
 | 
			
		||||
		},
 | 
			
		||||
@ -302,22 +311,22 @@ func init() {
 | 
			
		||||
 | 
			
		||||
	AppListCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.MachineReadable,
 | 
			
		||||
		"machine",
 | 
			
		||||
		"m",
 | 
			
		||||
		i18n.G("machine"),
 | 
			
		||||
		i18n.G("m"),
 | 
			
		||||
		false,
 | 
			
		||||
		"print machine-readable output",
 | 
			
		||||
		i18n.G("print machine-readable output"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppListCommand.Flags().StringVarP(
 | 
			
		||||
		&listAppServer,
 | 
			
		||||
		"server",
 | 
			
		||||
		"s",
 | 
			
		||||
		i18n.G("server"),
 | 
			
		||||
		i18n.G("s"),
 | 
			
		||||
		"",
 | 
			
		||||
		"show apps of a specific server",
 | 
			
		||||
		i18n.G("show apps of a specific server"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppListCommand.RegisterFlagCompletionFunc(
 | 
			
		||||
		"server",
 | 
			
		||||
		i18n.G("server"),
 | 
			
		||||
		func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
			return autocomplete.ServerNameComplete()
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										128
									
								
								cli/app/logs.go
									
									
									
									
									
								
							
							
						
						
									
										128
									
								
								cli/app/logs.go
									
									
									
									
									
								
							@ -2,32 +2,30 @@ package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"os"
 | 
			
		||||
	"slices"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"time"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/logs"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	containerTypes "github.com/docker/docker/api/types/container"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
	"github.com/docker/docker/api/types/swarm"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app logs` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appLogsAliases = i18n.G("l")
 | 
			
		||||
 | 
			
		||||
var AppLogsCommand = &cobra.Command{
 | 
			
		||||
	Use:     "logs <app> [service] [flags]",
 | 
			
		||||
	Aliases: []string{"l"},
 | 
			
		||||
	Short:   "Tail app logs",
 | 
			
		||||
	Args:    cobra.RangeArgs(1, 2),
 | 
			
		||||
	// translators: `app logs` command
 | 
			
		||||
	Use:     i18n.G("logs <domain> [service] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appLogsAliases, ","),
 | 
			
		||||
	// translators: Short description for `app logs` command
 | 
			
		||||
	Short: i18n.G("Tail app logs"),
 | 
			
		||||
	Args:  cobra.RangeArgs(1, 2),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -38,8 +36,7 @@ var AppLogsCommand = &cobra.Command{
 | 
			
		||||
		case 1:
 | 
			
		||||
			app, err := appPkg.Get(args[0])
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				errMsg := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
				return []string{errMsg}, cobra.ShellCompDirectiveError
 | 
			
		||||
				return []string{i18n.G("autocomplete failed: %s", err)}, cobra.ShellCompDirectiveError
 | 
			
		||||
			}
 | 
			
		||||
			return autocomplete.ServiceNameComplete(app.Name)
 | 
			
		||||
		default:
 | 
			
		||||
@ -65,7 +62,7 @@ var AppLogsCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !deployMeta.IsDeployed {
 | 
			
		||||
			log.Fatalf("%s is not deployed?", app.Name)
 | 
			
		||||
			log.Fatal(i18n.G("%s is not deployed?", app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var serviceNames []string
 | 
			
		||||
@ -73,80 +70,25 @@ var AppLogsCommand = &cobra.Command{
 | 
			
		||||
			serviceNames = []string{args[1]}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err = tailLogs(cl, app, serviceNames); err != nil {
 | 
			
		||||
		f, err := app.Filters(true, false, serviceNames...)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		opts := logs.TailOpts{
 | 
			
		||||
			AppName:  app.Name,
 | 
			
		||||
			Services: serviceNames,
 | 
			
		||||
			StdErr:   stdErr,
 | 
			
		||||
			Since:    sinceLogs,
 | 
			
		||||
			Filters:  f,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := logs.TailLogs(cl, opts); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// tailLogs prints logs for the given app with optional service names to be
 | 
			
		||||
// filtered on. It also checks if the latest task is not runnning and then
 | 
			
		||||
// prints the past tasks.
 | 
			
		||||
func tailLogs(cl *dockerClient.Client, app appPkg.App, serviceNames []string) error {
 | 
			
		||||
	f, err := app.Filters(true, false, serviceNames...)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	services, err := cl.ServiceList(context.Background(), types.ServiceListOptions{Filters: f})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var wg sync.WaitGroup
 | 
			
		||||
	for _, service := range services {
 | 
			
		||||
		filters := filters.NewArgs()
 | 
			
		||||
		filters.Add("name", service.Spec.Name)
 | 
			
		||||
		tasks, err := cl.TaskList(context.Background(), types.TaskListOptions{Filters: f})
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		if len(tasks) > 0 {
 | 
			
		||||
			// Need to sort the tasks by the CreatedAt field in the inverse order.
 | 
			
		||||
			// Otherwise they are in the reversed order and not sorted properly.
 | 
			
		||||
			slices.SortFunc[[]swarm.Task](tasks, func(t1, t2 swarm.Task) int {
 | 
			
		||||
				return int(t2.Meta.CreatedAt.Unix() - t1.Meta.CreatedAt.Unix())
 | 
			
		||||
			})
 | 
			
		||||
			lastTask := tasks[0].Status
 | 
			
		||||
			if lastTask.State != swarm.TaskStateRunning {
 | 
			
		||||
				for _, task := range tasks {
 | 
			
		||||
					log.Errorf("[%s] %s State %s: %s", service.Spec.Name, task.Meta.CreatedAt.Format(time.RFC3339), task.Status.State, task.Status.Err)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Collect the logs in a go routine, so the logs from all services are
 | 
			
		||||
		// collected in parallel.
 | 
			
		||||
		wg.Add(1)
 | 
			
		||||
		go func(serviceID string) {
 | 
			
		||||
			logs, err := cl.ServiceLogs(context.Background(), serviceID, containerTypes.LogsOptions{
 | 
			
		||||
				ShowStderr: true,
 | 
			
		||||
				ShowStdout: !stdErr,
 | 
			
		||||
				Since:      sinceLogs,
 | 
			
		||||
				Until:      "",
 | 
			
		||||
				Timestamps: true,
 | 
			
		||||
				Follow:     true,
 | 
			
		||||
				Tail:       "20",
 | 
			
		||||
				Details:    false,
 | 
			
		||||
			})
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
			defer logs.Close()
 | 
			
		||||
 | 
			
		||||
			_, err = io.Copy(os.Stdout, logs)
 | 
			
		||||
			if err != nil && err != io.EOF {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}(service.ID)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Wait for all log streams to be closed.
 | 
			
		||||
	wg.Wait()
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	stdErr    bool
 | 
			
		||||
	sinceLogs string
 | 
			
		||||
@ -155,17 +97,17 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	AppLogsCommand.Flags().BoolVarP(
 | 
			
		||||
		&stdErr,
 | 
			
		||||
		"stderr",
 | 
			
		||||
		"s",
 | 
			
		||||
		i18n.G("stderr"),
 | 
			
		||||
		i18n.G("s"),
 | 
			
		||||
		false,
 | 
			
		||||
		"only tail stderr",
 | 
			
		||||
		i18n.G("only tail stderr"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppLogsCommand.Flags().StringVarP(
 | 
			
		||||
		&sinceLogs,
 | 
			
		||||
		"since",
 | 
			
		||||
		"S",
 | 
			
		||||
		i18n.G("since"),
 | 
			
		||||
		i18n.G("S"),
 | 
			
		||||
		"",
 | 
			
		||||
		"tail logs since YYYY-MM-DDTHH:MM:SSZ",
 | 
			
		||||
		i18n.G("tail logs since YYYY-MM-DDTHH:MM:SSZ"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										354
									
								
								cli/app/move.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										354
									
								
								cli/app/move.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,354 @@
 | 
			
		||||
package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"os/exec"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	containerPkg "coopcloud.tech/abra/pkg/container"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/secret"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	containertypes "github.com/docker/docker/api/types/container"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
	"github.com/docker/docker/api/types/mount"
 | 
			
		||||
	"github.com/docker/docker/api/types/swarm"
 | 
			
		||||
	"github.com/docker/docker/api/types/volume"
 | 
			
		||||
	dockerclient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app move` aliases. use a comma separated list of aliases
 | 
			
		||||
// with no spaces in between
 | 
			
		||||
var appMoveAliases = i18n.G("m")
 | 
			
		||||
 | 
			
		||||
var AppMoveCommand = &cobra.Command{
 | 
			
		||||
	// translators: `app move` command
 | 
			
		||||
	Use:     i18n.G("move <domain> <server> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appMoveAliases, ","),
 | 
			
		||||
	// translators: Short description for `app move` command
 | 
			
		||||
	Short: i18n.G("Moves an app to a different server"),
 | 
			
		||||
	Long: i18n.G(`Move an app to a differnt server.
 | 
			
		||||
 | 
			
		||||
This command will migrate an app config and copy secrets and volumes from the
 | 
			
		||||
old server to the new one. The app MUST be deployed on the old server before
 | 
			
		||||
doing the move. The app will be undeployed from the current server but not
 | 
			
		||||
deployed on the new server.
 | 
			
		||||
 | 
			
		||||
The "tar" command is required on both the old and new server as well as "sudo"
 | 
			
		||||
permissions. The "rsync" command is required on your local machine for
 | 
			
		||||
transferring volumes.
 | 
			
		||||
 | 
			
		||||
Do not forget to update your DNS records. Don't panic, it might take a while
 | 
			
		||||
for the dust to settle after you move an app. If anything goes wrong, you can
 | 
			
		||||
always move the app config file to the original server and deploy it there
 | 
			
		||||
again. No data is removed from the old server.
 | 
			
		||||
 | 
			
		||||
Use "--dry-run/-r" to see which secrets and volumes will be moved.`),
 | 
			
		||||
	Example: i18n.G(`  # move an app
 | 
			
		||||
  abra app move nextcloud.1312.net myserver.com`),
 | 
			
		||||
	Args: cobra.RangeArgs(1, 2),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
		toComplete string,
 | 
			
		||||
	) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		switch l := len(args); l {
 | 
			
		||||
		case 0:
 | 
			
		||||
			return autocomplete.AppNameComplete()
 | 
			
		||||
		case 1:
 | 
			
		||||
			return autocomplete.ServerNameComplete()
 | 
			
		||||
		default:
 | 
			
		||||
			return nil, cobra.ShellCompDirectiveDefault
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if len(args) <= 1 {
 | 
			
		||||
			log.Fatal(i18n.G("no server provided?"))
 | 
			
		||||
		}
 | 
			
		||||
		newServer := internal.ValidateServer([]string{args[1]})
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		currentServerClient, err := client.New(app.Server)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		deployMeta, err := stack.IsDeployed(context.Background(), currentServerClient, app.StackName())
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !deployMeta.IsDeployed {
 | 
			
		||||
			log.Fatal(i18n.G("%s must first be deployed on %s before moving", app.Name, app.Server))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		resources, err := getAppResources(currentServerClient, app)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(i18n.G("unable to retrieve %s resources on %s: %s", app.Name, app.Server, err))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		internal.MoveOverview(app, newServer, resources.SecretNames(), resources.VolumeNames())
 | 
			
		||||
		if err := internal.PromptProcced(); err != nil {
 | 
			
		||||
			log.Fatal(i18n.G("bailing out: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Info(i18n.G("undeploying %s on %s", app.Name, app.Server))
 | 
			
		||||
		rmOpts := stack.Remove{
 | 
			
		||||
			Namespaces: []string{app.StackName()},
 | 
			
		||||
			Detach:     false,
 | 
			
		||||
		}
 | 
			
		||||
		if err := stack.RunRemove(context.Background(), currentServerClient, rmOpts); err != nil {
 | 
			
		||||
			log.Fatal(i18n.G("failed to remove app from %s: %s", err, app.Server))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		newServerClient, err := client.New(newServer)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, s := range resources.SecretList {
 | 
			
		||||
			sname := strings.Split(strings.TrimPrefix(s.Spec.Name, app.StackName()+"_"), "_")
 | 
			
		||||
			secretName := strings.Join(sname[:len(sname)-1], "_")
 | 
			
		||||
			data := resources.Secrets[secretName]
 | 
			
		||||
			if err := client.StoreSecret(newServerClient, s.Spec.Name, data); err != nil {
 | 
			
		||||
				if strings.Contains(err.Error(), "already exists") {
 | 
			
		||||
					log.Info(i18n.G("skipping secret (because it already exists) on %s: %s", s.Spec.Name, newServer))
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
				log.Fatal(i18n.G("failed to store secret on %s: %s", err, newServer))
 | 
			
		||||
			}
 | 
			
		||||
			log.Info(i18n.G("created secret on %s: %s", s.Spec.Name, newServer))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, v := range resources.Volumes {
 | 
			
		||||
			log.Info(i18n.G("moving volume %s from %s to %s", v.Name, app.Server, newServer))
 | 
			
		||||
 | 
			
		||||
			// NOTE(p4u1): Need to create the volume before copying the data, because
 | 
			
		||||
			// when docker creates a new volume it set the folder permissions to
 | 
			
		||||
			// root, which might be wrong. This ensures we always have the correct
 | 
			
		||||
			// folder permissions inside the volume.
 | 
			
		||||
			log.Debug(i18n.G("creating volume %s on %s", v.Name, newServer))
 | 
			
		||||
			_, err := newServerClient.VolumeCreate(context.Background(), volume.CreateOptions{
 | 
			
		||||
				Name:   v.Name,
 | 
			
		||||
				Driver: v.Driver,
 | 
			
		||||
			})
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(i18n.G("failed to create volume %s on %s: %s", v.Name, newServer, err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			filename := fmt.Sprintf("%s_outgoing.tar.gz", v.Name)
 | 
			
		||||
			log.Debug(i18n.G("creating %s on %s", filename, app.Server))
 | 
			
		||||
			tarCmd := fmt.Sprintf("sudo tar --same-owner -czhpf %s -C /var/lib/docker/volumes %s", filename, v.Name)
 | 
			
		||||
			cmd := exec.Command("ssh", app.Server, "-tt", tarCmd)
 | 
			
		||||
			if out, err := cmd.CombinedOutput(); err != nil {
 | 
			
		||||
				log.Fatal(i18n.G("%s failed on %s: output:%s err:%s", tarCmd, app.Server, string(out), err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debug(i18n.G("rsyncing %s from %s to local machine", filename, app.Server))
 | 
			
		||||
			cmd = exec.Command("rsync", "-a", "-v", fmt.Sprintf("%s:%s", app.Server, filename), filename)
 | 
			
		||||
			if out, err := cmd.CombinedOutput(); err != nil {
 | 
			
		||||
				log.Fatal(i18n.G("failed to copy %s from %s to local machine: output:%s err:%s", filename, app.Server, string(out), err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debug(i18n.G("rsyncing %s to %s from local machine", filename, filename, newServer))
 | 
			
		||||
			cmd = exec.Command("rsync", "-a", "-v", filename, fmt.Sprintf("%s:%s", newServer, filename))
 | 
			
		||||
			if out, err := cmd.CombinedOutput(); err != nil {
 | 
			
		||||
				log.Fatal(i18n.G("failed to copy %s from local machine to %s: output:%s err:%s", filename, newServer, string(out), err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debug(i18n.G("extracting %s on %s", filename, newServer))
 | 
			
		||||
			tarExtractCmd := fmt.Sprintf("sudo tar --same-owner -xzpf %s -C /var/lib/docker/volumes", filename)
 | 
			
		||||
			cmd = exec.Command("ssh", newServer, "-tt", tarExtractCmd)
 | 
			
		||||
			if out, err := cmd.CombinedOutput(); err != nil {
 | 
			
		||||
				log.Fatal(i18n.G("%s failed to extract %s on %s: output:%s err:%s", tarExtractCmd, filename, newServer, string(out), err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// Remove tar files
 | 
			
		||||
			log.Debug(i18n.G("removing %s from %s", filename, newServer))
 | 
			
		||||
			cmd = exec.Command("ssh", newServer, "-tt", fmt.Sprintf("sudo rm -rf %s", filename))
 | 
			
		||||
			if out, err := cmd.CombinedOutput(); err != nil {
 | 
			
		||||
				log.Fatal(i18n.G("failed to remove %s from %s: output:%s err:%s", filename, newServer, string(out), err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debug(i18n.G("removing %s from %s", filename, app.Server))
 | 
			
		||||
			cmd = exec.Command("ssh", app.Server, "-tt", fmt.Sprintf("sudo rm -rf %s", filename))
 | 
			
		||||
			if out, err := cmd.CombinedOutput(); err != nil {
 | 
			
		||||
				log.Fatal(i18n.G("failed to remove %s from %s: output:%s err:%s", filename, app.Server, string(out), err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debug(i18n.G("removing %s from local machine", filename))
 | 
			
		||||
			cmd = exec.Command("rm", "-r", "-f", filename)
 | 
			
		||||
			if out, err := cmd.CombinedOutput(); err != nil {
 | 
			
		||||
				log.Fatal(i18n.G("failed to remove %s on local machine: output:%s err:%s", filename, string(out), err))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		newServerPath := fmt.Sprintf("%s/servers/%s/%s.env", config.ABRA_DIR, newServer, app.Name)
 | 
			
		||||
		log.Info(i18n.G("migrating app config from %s to %s", app.Server, newServerPath))
 | 
			
		||||
		if err := copyFile(app.Path, newServerPath); err != nil {
 | 
			
		||||
			log.Fatal(i18n.G("failed to migrate app config: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := os.Remove(app.Path); err != nil {
 | 
			
		||||
			log.Fatal(i18n.G("unable to remove %s: %s", app.Path, err))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Info(i18n.G("%s was successfully moved from %s to %s 🎉", app.Name, app.Server, newServer))
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type AppResources struct {
 | 
			
		||||
	Secrets    map[string]string
 | 
			
		||||
	SecretList []swarm.Secret
 | 
			
		||||
	Volumes    map[string]containertypes.MountPoint
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AppResources) SecretNames() []string {
 | 
			
		||||
	secrets := []string{}
 | 
			
		||||
	for name := range a.Secrets {
 | 
			
		||||
		secrets = append(secrets, name)
 | 
			
		||||
	}
 | 
			
		||||
	return secrets
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AppResources) VolumeNames() []string {
 | 
			
		||||
	volumes := []string{}
 | 
			
		||||
	for name := range a.Volumes {
 | 
			
		||||
		volumes = append(volumes, name)
 | 
			
		||||
	}
 | 
			
		||||
	return volumes
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getAppResources(cl *dockerclient.Client, app app.App) (*AppResources, error) {
 | 
			
		||||
	filter, err := app.Filters(false, false)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	services, err := cl.ServiceList(context.Background(), types.ServiceListOptions{Filters: filter})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	secretList, err := cl.SecretList(context.Background(), types.SecretListOptions{Filters: filter})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	secretConfigs, err := secret.ReadSecretsConfig(app.Path, composeFiles, app.StackName())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	opts := stack.Deploy{Composefiles: composeFiles, Namespace: app.StackName()}
 | 
			
		||||
	compose, err := appPkg.GetAppComposeConfig(app.Name, opts, app.Env)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	resources := &AppResources{
 | 
			
		||||
		Secrets:    make(map[string]string),
 | 
			
		||||
		SecretList: secretList,
 | 
			
		||||
		Volumes:    make(map[string]containertypes.MountPoint),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, s := range services {
 | 
			
		||||
		secretNames := map[string]string{}
 | 
			
		||||
		for _, serviceCompose := range compose.Services {
 | 
			
		||||
			stackService := fmt.Sprintf("%s_%s", app.StackName(), serviceCompose.Name)
 | 
			
		||||
			if stackService != s.Spec.Name {
 | 
			
		||||
				log.Debug(i18n.G("skipping %s as it does not match %s", stackService, s.Spec.Name))
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for _, secret := range serviceCompose.Secrets {
 | 
			
		||||
				for _, s := range secretList {
 | 
			
		||||
					stackSecret := fmt.Sprintf("%s_%s_%s", app.StackName(), secret.Source, secretConfigs[secret.Source].Version)
 | 
			
		||||
					if s.Spec.Name == stackSecret {
 | 
			
		||||
						secretNames[secret.Source] = s.ID
 | 
			
		||||
						break
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		f := filters.NewArgs()
 | 
			
		||||
		f.Add("name", s.Spec.Name)
 | 
			
		||||
		targetContainer, err := containerPkg.GetContainer(context.Background(), cl, f, true)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, errors.New(i18n.G("unable to get container matching %s: %s", s.Spec.Name, err))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, m := range targetContainer.Mounts {
 | 
			
		||||
			if m.Type == mount.TypeVolume {
 | 
			
		||||
				resources.Volumes[m.Name] = m
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for secretName, secretID := range secretNames {
 | 
			
		||||
			if _, ok := resources.Secrets[secretName]; ok {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debug(i18n.G("extracting secret %s on %s", secretName, app.Server))
 | 
			
		||||
 | 
			
		||||
			cmd := fmt.Sprintf("sudo cat /var/lib/docker/containers/%s/mounts/secrets/%s", targetContainer.ID, secretID)
 | 
			
		||||
			out, err := exec.Command("ssh", app.Server, "-tt", cmd).Output()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, errors.New(i18n.G("%s failed on %s: output:%s err:%s", cmd, app.Server, string(out), err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			resources.Secrets[secretName] = string(out)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return resources, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func copyFile(src string, dst string) error {
 | 
			
		||||
	// Read all content of src to data, may cause OOM for a large file.
 | 
			
		||||
	data, err := os.ReadFile(src)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Write data to dst
 | 
			
		||||
	err = os.WriteFile(dst, data, 0o644)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppMoveCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Dry,
 | 
			
		||||
		i18n.G("dry-run"),
 | 
			
		||||
		i18n.G("r"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("report changes that would be made"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										237
									
								
								cli/app/new.go
									
									
									
									
									
								
							
							
						
						
									
										237
									
								
								cli/app/new.go
									
									
									
									
									
								
							@ -1,7 +1,9 @@
 | 
			
		||||
package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/app"
 | 
			
		||||
@ -10,22 +12,22 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	recipePkg "coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/secret"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
	"github.com/charmbracelet/lipgloss/table"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var appNewDescription = `Creates a new app from a default recipe.
 | 
			
		||||
var appNewDescription = i18n.G(`Creates a new app from a default recipe.
 | 
			
		||||
 | 
			
		||||
This new app configuration is stored in your $ABRA_DIR directory under the
 | 
			
		||||
appropriate server.
 | 
			
		||||
 | 
			
		||||
This command does not deploy your app for you. You will need to run "abra app
 | 
			
		||||
deploy <app>" to do so.
 | 
			
		||||
deploy <domain>" to do so.
 | 
			
		||||
 | 
			
		||||
You can see what recipes are available (i.e. values for the [recipe] argument)
 | 
			
		||||
by running "abra recipe ls".
 | 
			
		||||
@ -39,14 +41,20 @@ store them somewhere safe.
 | 
			
		||||
 | 
			
		||||
You can use the "--pass/-P" to store these generated passwords locally in a
 | 
			
		||||
pass store (see passwordstore.org for more). The pass command must be available
 | 
			
		||||
on your $PATH.`
 | 
			
		||||
on your $PATH.`)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app new` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appNewAliases = i18n.G("n")
 | 
			
		||||
 | 
			
		||||
var AppNewCommand = &cobra.Command{
 | 
			
		||||
	Use:     "new [recipe] [version] [flags]",
 | 
			
		||||
	Aliases: []string{"n"},
 | 
			
		||||
	Short:   "Create a new app",
 | 
			
		||||
	Long:    appNewDescription,
 | 
			
		||||
	Args:    cobra.RangeArgs(0, 2),
 | 
			
		||||
	// translators: `app new` command
 | 
			
		||||
	Use:     i18n.G("new [recipe] [version] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appNewAliases, ","),
 | 
			
		||||
	// translators: Short description for `app new` command
 | 
			
		||||
	Short: i18n.G("Create a new app"),
 | 
			
		||||
	Long:  appNewDescription,
 | 
			
		||||
	Args:  cobra.RangeArgs(0, 2),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -65,7 +73,7 @@ var AppNewCommand = &cobra.Command{
 | 
			
		||||
		recipe := internal.ValidateRecipe(args, cmd.Name())
 | 
			
		||||
 | 
			
		||||
		if len(args) == 2 && internal.Chaos {
 | 
			
		||||
			log.Fatal("cannot use [version] and --chaos together")
 | 
			
		||||
			log.Fatal(i18n.G("cannot use [version] and --chaos together"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var recipeVersion string
 | 
			
		||||
@ -75,43 +83,50 @@ var AppNewCommand = &cobra.Command{
 | 
			
		||||
 | 
			
		||||
		chaosVersion := config.CHAOS_DEFAULT
 | 
			
		||||
		if internal.Chaos {
 | 
			
		||||
			recipeVersion = chaosVersion
 | 
			
		||||
 | 
			
		||||
			if !internal.Offline {
 | 
			
		||||
				if err := recipe.EnsureUpToDate(); err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !internal.Chaos {
 | 
			
		||||
			if err := recipe.EnsureIsClean(); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var recipeVersions recipePkg.RecipeVersions
 | 
			
		||||
		if recipeVersion == "" {
 | 
			
		||||
			var err error
 | 
			
		||||
			recipeVersions, err = recipe.GetRecipeVersions()
 | 
			
		||||
			chaosVersion, err = recipe.ChaosVersion()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(recipeVersions) > 0 {
 | 
			
		||||
			latest := recipeVersions[len(recipeVersions)-1]
 | 
			
		||||
			for tag := range latest {
 | 
			
		||||
				recipeVersion = tag
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if _, err := recipe.EnsureVersion(recipeVersion); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
			recipeVersion = chaosVersion
 | 
			
		||||
		} else {
 | 
			
		||||
			if err := recipe.EnsureLatest(); err != nil {
 | 
			
		||||
			if err := recipe.EnsureIsClean(); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			var recipeVersions recipePkg.RecipeVersions
 | 
			
		||||
			if recipeVersion == "" {
 | 
			
		||||
				var err error
 | 
			
		||||
				recipeVersions, _, err = recipe.GetRecipeVersions()
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if len(recipeVersions) > 0 {
 | 
			
		||||
				latest := recipeVersions[len(recipeVersions)-1]
 | 
			
		||||
				for tag := range latest {
 | 
			
		||||
					recipeVersion = tag
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if _, err := recipe.EnsureVersion(recipeVersion); err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				if err := recipe.EnsureLatest(); err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if recipeVersion == "" {
 | 
			
		||||
					head, err := recipe.Head()
 | 
			
		||||
					if err != nil {
 | 
			
		||||
						log.Fatal(i18n.G("failed to retrieve latest commit for %s: %s", recipe.Name, err))
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					recipeVersion = formatter.SmallSHA(head.String())
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := ensureServerFlag(); err != nil {
 | 
			
		||||
@ -123,7 +138,7 @@ var AppNewCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		sanitisedAppName := appPkg.SanitiseAppName(appDomain)
 | 
			
		||||
		log.Debugf("%s sanitised as %s for new app", appDomain, sanitisedAppName)
 | 
			
		||||
		log.Debug(i18n.G("%s sanitised as %s for new app", appDomain, sanitisedAppName))
 | 
			
		||||
 | 
			
		||||
		if err := appPkg.TemplateAppEnvSample(
 | 
			
		||||
			recipe,
 | 
			
		||||
@ -134,28 +149,27 @@ var AppNewCommand = &cobra.Command{
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		sampleEnv, err := recipe.SampleEnv()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		composeFiles, err := recipe.GetComposeFiles(sampleEnv)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		secretsConfig, err := secret.ReadSecretsConfig(
 | 
			
		||||
			recipe.SampleEnvPath,
 | 
			
		||||
			composeFiles,
 | 
			
		||||
			appPkg.StackName(appDomain),
 | 
			
		||||
		)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var appSecrets AppSecrets
 | 
			
		||||
		var secretsTable *table.Table
 | 
			
		||||
		if generateSecrets {
 | 
			
		||||
			sampleEnv, err := recipe.SampleEnv()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			composeFiles, err := recipe.GetComposeFiles(sampleEnv)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			secretsConfig, err := secret.ReadSecretsConfig(
 | 
			
		||||
				recipe.SampleEnvPath,
 | 
			
		||||
				composeFiles,
 | 
			
		||||
				appPkg.StackName(appDomain),
 | 
			
		||||
			)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if err := promptForSecrets(recipe.Name, secretsConfig); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
@ -169,25 +183,37 @@ var AppNewCommand = &cobra.Command{
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			secretsTable, err = formatter.CreateTable()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			headers := []string{"NAME", "VALUE"}
 | 
			
		||||
			secretsTable.Headers(headers...)
 | 
			
		||||
 | 
			
		||||
			for name, val := range appSecrets {
 | 
			
		||||
				secretsTable.Row(name, val)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if newAppServer == "default" {
 | 
			
		||||
			newAppServer = "local"
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Infof("%s created successfully (version: %s, chaos: %s)", appDomain, recipeVersion, chaosVersion)
 | 
			
		||||
		log.Info(i18n.G("%s created (version: %s)", appDomain, recipeVersion))
 | 
			
		||||
 | 
			
		||||
		if len(secretsConfig) > 0 {
 | 
			
		||||
			var (
 | 
			
		||||
				hasSecretToGenerate bool
 | 
			
		||||
				hasSecretToSkip     bool
 | 
			
		||||
			)
 | 
			
		||||
 | 
			
		||||
			for _, secretConfig := range secretsConfig {
 | 
			
		||||
				if secretConfig.SkipGenerate {
 | 
			
		||||
					hasSecretToSkip = true
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				hasSecretToGenerate = true
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if hasSecretToGenerate && !generateSecrets {
 | 
			
		||||
				log.Warn(i18n.G("%s requires secret generation before deploy, run \"abra app secret generate %s --all\"", recipe.Name, appDomain))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if hasSecretToSkip {
 | 
			
		||||
				log.Warn(i18n.G("%s requires secret insertion before deploy (#generate=false)", recipe.Name))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(appSecrets) > 0 {
 | 
			
		||||
			rows := [][]string{}
 | 
			
		||||
@ -195,15 +221,15 @@ var AppNewCommand = &cobra.Command{
 | 
			
		||||
				rows = append(rows, []string{k, v})
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			overview := formatter.CreateOverview("SECRETS OVERVIEW", rows)
 | 
			
		||||
			overview := formatter.CreateOverview(i18n.G("SECRETS OVERVIEW"), rows)
 | 
			
		||||
 | 
			
		||||
			fmt.Println(overview)
 | 
			
		||||
 | 
			
		||||
			log.Warnf(
 | 
			
		||||
			log.Warn(i18n.G(
 | 
			
		||||
				"secrets are %s shown again, please save them %s",
 | 
			
		||||
				formatter.BoldStyle.Render("NOT"),
 | 
			
		||||
				formatter.BoldStyle.Render("NOW"),
 | 
			
		||||
			)
 | 
			
		||||
				formatter.BoldUnderlineStyle.Render("NOT"),
 | 
			
		||||
				formatter.BoldUnderlineStyle.Render("NOW"),
 | 
			
		||||
			))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		app, err := app.Get(appDomain)
 | 
			
		||||
@ -211,9 +237,8 @@ var AppNewCommand = &cobra.Command{
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("choosing %s as version to save to env file", recipeVersion)
 | 
			
		||||
		if err := app.WriteRecipeVersion(recipeVersion, false); err != nil {
 | 
			
		||||
			log.Fatalf("writing new recipe version in env file: %s", err)
 | 
			
		||||
			log.Fatal(i18n.G("writing recipe version failed: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
@ -225,7 +250,7 @@ type AppSecrets map[string]string
 | 
			
		||||
func createSecrets(cl *dockerClient.Client, secretsConfig map[string]secret.Secret, sanitisedAppName string) (AppSecrets, error) {
 | 
			
		||||
	// NOTE(d1): trim to match app.StackName() implementation
 | 
			
		||||
	if len(sanitisedAppName) > config.MAX_SANITISED_APP_NAME_LENGTH {
 | 
			
		||||
		log.Debugf("trimming %s to %s to avoid runtime limits", sanitisedAppName, sanitisedAppName[:config.MAX_SANITISED_APP_NAME_LENGTH])
 | 
			
		||||
		log.Debug(i18n.G("trimming %s to %s to avoid runtime limits", sanitisedAppName, sanitisedAppName[:config.MAX_SANITISED_APP_NAME_LENGTH]))
 | 
			
		||||
		sanitisedAppName = sanitisedAppName[:config.MAX_SANITISED_APP_NAME_LENGTH]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -255,7 +280,7 @@ func createSecrets(cl *dockerClient.Client, secretsConfig map[string]secret.Secr
 | 
			
		||||
func ensureDomainFlag(recipe recipePkg.Recipe, server string) error {
 | 
			
		||||
	if appDomain == "" && !internal.NoInput {
 | 
			
		||||
		prompt := &survey.Input{
 | 
			
		||||
			Message: "Specify app domain",
 | 
			
		||||
			Message: i18n.G("Specify app domain"),
 | 
			
		||||
			Default: fmt.Sprintf("%s.%s", recipe.Name, server),
 | 
			
		||||
		}
 | 
			
		||||
		if err := survey.AskOne(prompt, &appDomain); err != nil {
 | 
			
		||||
@ -264,7 +289,7 @@ func ensureDomainFlag(recipe recipePkg.Recipe, server string) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if appDomain == "" {
 | 
			
		||||
		return fmt.Errorf("no domain provided")
 | 
			
		||||
		return errors.New(i18n.G("no domain provided"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
@ -273,13 +298,13 @@ func ensureDomainFlag(recipe recipePkg.Recipe, server string) error {
 | 
			
		||||
// promptForSecrets asks if we should generate secrets for a new app.
 | 
			
		||||
func promptForSecrets(recipeName string, secretsConfig map[string]secret.Secret) error {
 | 
			
		||||
	if len(secretsConfig) == 0 {
 | 
			
		||||
		log.Debugf("%s has no secrets to generate, skipping...", recipeName)
 | 
			
		||||
		log.Debug(i18n.G("%s has no secrets to generate, skipping...", recipeName))
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !generateSecrets && !internal.NoInput {
 | 
			
		||||
		prompt := &survey.Confirm{
 | 
			
		||||
			Message: "Generate app secrets?",
 | 
			
		||||
			Message: i18n.G("Generate app secrets?"),
 | 
			
		||||
		}
 | 
			
		||||
		if err := survey.AskOne(prompt, &generateSecrets); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
@ -296,9 +321,15 @@ func ensureServerFlag() error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(servers) == 1 {
 | 
			
		||||
		newAppServer = servers[0]
 | 
			
		||||
		log.Info(i18n.G("single server detected, choosing %s automatically", newAppServer))
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if newAppServer == "" && !internal.NoInput {
 | 
			
		||||
		prompt := &survey.Select{
 | 
			
		||||
			Message: "Select app server:",
 | 
			
		||||
			Message: i18n.G("Select app server:"),
 | 
			
		||||
			Options: servers,
 | 
			
		||||
		}
 | 
			
		||||
		if err := survey.AskOne(prompt, &newAppServer); err != nil {
 | 
			
		||||
@ -307,7 +338,7 @@ func ensureServerFlag() error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if newAppServer == "" {
 | 
			
		||||
		return fmt.Errorf("no server provided")
 | 
			
		||||
		return errors.New(i18n.G("no server provided"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
@ -323,14 +354,14 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	AppNewCommand.Flags().StringVarP(
 | 
			
		||||
		&newAppServer,
 | 
			
		||||
		"server",
 | 
			
		||||
		"s",
 | 
			
		||||
		i18n.G("server"),
 | 
			
		||||
		i18n.G("s"),
 | 
			
		||||
		"",
 | 
			
		||||
		"specify server for new app",
 | 
			
		||||
		i18n.G("specify server for new app"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppNewCommand.RegisterFlagCompletionFunc(
 | 
			
		||||
		"server",
 | 
			
		||||
		i18n.G("server"),
 | 
			
		||||
		func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
			return autocomplete.ServerNameComplete()
 | 
			
		||||
		},
 | 
			
		||||
@ -338,34 +369,34 @@ func init() {
 | 
			
		||||
 | 
			
		||||
	AppNewCommand.Flags().StringVarP(
 | 
			
		||||
		&appDomain,
 | 
			
		||||
		"domain",
 | 
			
		||||
		"D",
 | 
			
		||||
		i18n.G("domain"),
 | 
			
		||||
		i18n.G("D"),
 | 
			
		||||
		"",
 | 
			
		||||
		"domain name for app",
 | 
			
		||||
		i18n.G("domain name for app"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppNewCommand.Flags().BoolVarP(
 | 
			
		||||
		&saveInPass,
 | 
			
		||||
		"pass",
 | 
			
		||||
		"p",
 | 
			
		||||
		i18n.G("pass"),
 | 
			
		||||
		i18n.G("p"),
 | 
			
		||||
		false,
 | 
			
		||||
		"store secrets in a local pass store",
 | 
			
		||||
		i18n.G("store secrets in a local pass store"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppNewCommand.Flags().BoolVarP(
 | 
			
		||||
		&generateSecrets,
 | 
			
		||||
		"secrets",
 | 
			
		||||
		"S",
 | 
			
		||||
		i18n.G("secrets"),
 | 
			
		||||
		i18n.G("S"),
 | 
			
		||||
		false,
 | 
			
		||||
		"automatically generate secrets",
 | 
			
		||||
		i18n.G("automatically generate secrets"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppNewCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,6 +4,8 @@ import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
@ -11,6 +13,7 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	abraService "coopcloud.tech/abra/pkg/service"
 | 
			
		||||
	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
@ -21,11 +24,17 @@ import (
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app ps` aliases. use a comma separated list of aliases
 | 
			
		||||
// with no spaces in between
 | 
			
		||||
var appPsAliases = i18n.G("p")
 | 
			
		||||
 | 
			
		||||
var AppPsCommand = &cobra.Command{
 | 
			
		||||
	Use:     "ps <app> [flags]",
 | 
			
		||||
	Aliases: []string{"p"},
 | 
			
		||||
	Short:   "Check app status",
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	// translators: `app ps` command
 | 
			
		||||
	Use:     i18n.G("ps <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appPsAliases, ","),
 | 
			
		||||
	// translators: Short description for `app ps` command
 | 
			
		||||
	Short: i18n.G("Check app deployment status"),
 | 
			
		||||
	Args:  cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -35,7 +44,7 @@ var AppPsCommand = &cobra.Command{
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -50,16 +59,18 @@ var AppPsCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !deployMeta.IsDeployed {
 | 
			
		||||
			log.Fatalf("%s is not deployed?", app.Name)
 | 
			
		||||
			log.Fatal(i18n.G("%s is not deployed?", app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		chaosVersion := config.CHAOS_DEFAULT
 | 
			
		||||
		statuses, err := appPkg.GetAppStatuses([]appPkg.App{app}, true)
 | 
			
		||||
		if statusMeta, ok := statuses[app.StackName()]; ok {
 | 
			
		||||
			if isChaos, exists := statusMeta["chaos"]; exists && isChaos == "true" {
 | 
			
		||||
				chaosVersion, err = app.Recipe.ChaosVersion()
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				if cVersion, exists := statusMeta["chaosVersion"]; exists {
 | 
			
		||||
					chaosVersion = cVersion
 | 
			
		||||
					if strings.HasSuffix(chaosVersion, config.DIRTY_DEFAULT) {
 | 
			
		||||
						chaosVersion = formatter.BoldDirtyDefault(chaosVersion)
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@ -88,9 +99,14 @@ func showPSOutput(app appPkg.App, cl *dockerClient.Client, deployedVersion, chao
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	services := compose.Services
 | 
			
		||||
	sort.Slice(services, func(i, j int) bool {
 | 
			
		||||
		return services[i].Name < services[j].Name
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	var rows [][]string
 | 
			
		||||
	allContainerStats := make(map[string]map[string]string)
 | 
			
		||||
	for _, service := range compose.Services {
 | 
			
		||||
	for _, service := range services {
 | 
			
		||||
		filters := filters.NewArgs()
 | 
			
		||||
		filters.Add("name", fmt.Sprintf("^%s_%s", app.StackName(), service.Name))
 | 
			
		||||
 | 
			
		||||
@ -106,11 +122,11 @@ func showPSOutput(app appPkg.App, cl *dockerClient.Client, deployedVersion, chao
 | 
			
		||||
				"version": deployedVersion,
 | 
			
		||||
				"chaos":   chaosVersion,
 | 
			
		||||
				"service": service.Name,
 | 
			
		||||
				"image":   "unknown",
 | 
			
		||||
				"created": "unknown",
 | 
			
		||||
				"status":  "unknown",
 | 
			
		||||
				"state":   "unknown",
 | 
			
		||||
				"ports":   "unknown",
 | 
			
		||||
				"image":   i18n.G("unknown"),
 | 
			
		||||
				"created": i18n.G("unknown"),
 | 
			
		||||
				"status":  i18n.G("unknown"),
 | 
			
		||||
				"state":   i18n.G("unknown"),
 | 
			
		||||
				"ports":   i18n.G("unknown"),
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			container := containers[0]
 | 
			
		||||
@ -140,10 +156,10 @@ func showPSOutput(app appPkg.App, cl *dockerClient.Client, deployedVersion, chao
 | 
			
		||||
 | 
			
		||||
		row := []string{
 | 
			
		||||
			containerStats["service"],
 | 
			
		||||
			containerStats["status"],
 | 
			
		||||
			containerStats["image"],
 | 
			
		||||
			dVersion,
 | 
			
		||||
			cVersion,
 | 
			
		||||
			containerStats["status"],
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		rows = append(rows, row)
 | 
			
		||||
@ -152,7 +168,7 @@ func showPSOutput(app appPkg.App, cl *dockerClient.Client, deployedVersion, chao
 | 
			
		||||
	if internal.MachineReadable {
 | 
			
		||||
		rendered, err := json.Marshal(allContainerStats)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal("unable to convert to JSON: %s", err)
 | 
			
		||||
			log.Fatal(i18n.G("unable to convert to JSON: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		fmt.Println(string(rendered))
 | 
			
		||||
@ -166,11 +182,11 @@ func showPSOutput(app appPkg.App, cl *dockerClient.Client, deployedVersion, chao
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	headers := []string{
 | 
			
		||||
		"SERVICE",
 | 
			
		||||
		"IMAGE",
 | 
			
		||||
		"VERSION",
 | 
			
		||||
		"CHAOS",
 | 
			
		||||
		"STATUS",
 | 
			
		||||
		i18n.G("SERVICE"),
 | 
			
		||||
		i18n.G("STATUS"),
 | 
			
		||||
		i18n.G("IMAGE"),
 | 
			
		||||
		i18n.G("VERSION"),
 | 
			
		||||
		i18n.G("CHAOS"),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	table.
 | 
			
		||||
@ -185,17 +201,17 @@ func showPSOutput(app appPkg.App, cl *dockerClient.Client, deployedVersion, chao
 | 
			
		||||
func init() {
 | 
			
		||||
	AppPsCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.MachineReadable,
 | 
			
		||||
		"machine",
 | 
			
		||||
		"m",
 | 
			
		||||
		i18n.G("machine"),
 | 
			
		||||
		i18n.G("m"),
 | 
			
		||||
		false,
 | 
			
		||||
		"print machine-readable output",
 | 
			
		||||
		i18n.G("print machine-readable output"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppPsCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,24 +2,31 @@ package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app remove` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appRemoveAliases = i18n.G("rm")
 | 
			
		||||
 | 
			
		||||
var AppRemoveCommand = &cobra.Command{
 | 
			
		||||
	Use:     "remove <app> [flags]",
 | 
			
		||||
	Aliases: []string{"rm"},
 | 
			
		||||
	Short:   "Remove all app data, locally and remotely",
 | 
			
		||||
	Long: `Remove everything related to an app which is already undeployed.
 | 
			
		||||
	// translators: `app remove` command
 | 
			
		||||
	Use:     i18n.G("remove <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appRemoveAliases, ","),
 | 
			
		||||
	// translators: Short description for `app remove` command
 | 
			
		||||
	Short: i18n.G("Remove all app data, locally and remotely"),
 | 
			
		||||
	Long: i18n.G(`Remove everything related to an app which is already undeployed.
 | 
			
		||||
 | 
			
		||||
By default, it will prompt for confirmation before proceeding. All secrets,
 | 
			
		||||
volumes and the local app env file will be deleted.
 | 
			
		||||
@ -34,8 +41,8 @@ Please note, if you delete the local app env file without removing volumes and
 | 
			
		||||
secrets first, Abra will *not* be able to help you remove them afterwards.
 | 
			
		||||
 | 
			
		||||
To delete everything without prompt, use the "--force/-f" or the "--no-input/n"
 | 
			
		||||
flag.`,
 | 
			
		||||
	Example: "  abra app remove 1312.net",
 | 
			
		||||
flag.`),
 | 
			
		||||
	Example: i18n.G("  abra app remove 1312.net"),
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -47,16 +54,16 @@ flag.`,
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if !internal.Force && !internal.NoInput {
 | 
			
		||||
			log.Warnf("ALERTA ALERTA: deleting %s data and config (local/remote)", app.Name)
 | 
			
		||||
			log.Warn(i18n.G("ALERTA ALERTA: deleting %s data and config (local/remote)", app.Name))
 | 
			
		||||
 | 
			
		||||
			response := false
 | 
			
		||||
			prompt := &survey.Confirm{Message: "are you sure?"}
 | 
			
		||||
			prompt := &survey.Confirm{Message: i18n.G("are you sure?")}
 | 
			
		||||
			if err := survey.AskOne(prompt, &response); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if !response {
 | 
			
		||||
				log.Fatal("aborting as requested")
 | 
			
		||||
				log.Fatal(i18n.G("aborting as requested"))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -70,7 +77,7 @@ flag.`,
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		if deployMeta.IsDeployed {
 | 
			
		||||
			log.Fatalf("%s is still deployed. Run \"abra app undeploy %s\"", app.Name, app.Name)
 | 
			
		||||
			log.Fatal(i18n.G("%s is still deployed. Run \"abra app undeploy %s\"", app.Name, app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		fs, err := app.Filters(false, false)
 | 
			
		||||
@ -78,6 +85,22 @@ flag.`,
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		configs, err := client.GetConfigs(cl, context.Background(), app.Server, fs)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		configNames := client.GetConfigNames(configs)
 | 
			
		||||
 | 
			
		||||
		if len(configNames) > 0 {
 | 
			
		||||
			if err := client.RemoveConfigs(cl, context.Background(), configNames, internal.Force); err != nil {
 | 
			
		||||
				log.Fatal(i18n.G("removing configs failed: %s", err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Info(i18n.G("%d config(s) removed successfully", len(configNames)))
 | 
			
		||||
		} else {
 | 
			
		||||
			log.Info(i18n.G("no configs to remove"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		secretList, err := cl.SecretList(context.Background(), types.SecretListOptions{Filters: fs})
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
@ -97,10 +120,10 @@ flag.`,
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
				log.Info(fmt.Sprintf("secret: %s removed", name))
 | 
			
		||||
				log.Info(i18n.G("secret: %s removed", name))
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			log.Info("no secrets to remove")
 | 
			
		||||
			log.Info(i18n.G("no secrets to remove"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		fs, err = app.Filters(false, true)
 | 
			
		||||
@ -117,28 +140,28 @@ flag.`,
 | 
			
		||||
		if len(volumeNames) > 0 {
 | 
			
		||||
			err := client.RemoveVolumes(cl, context.Background(), volumeNames, internal.Force, 5)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatalf("removing volumes failed: %s", err)
 | 
			
		||||
				log.Fatal(i18n.G("removing volumes failed: %s", err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Infof("%d volumes removed successfully", len(volumeNames))
 | 
			
		||||
			log.Info(i18n.G("%d volume(s) removed successfully", len(volumeNames)))
 | 
			
		||||
		} else {
 | 
			
		||||
			log.Info("no volumes to remove")
 | 
			
		||||
			log.Info(i18n.G("no volumes to remove"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err = os.Remove(app.Path); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Info(fmt.Sprintf("file: %s removed", app.Path))
 | 
			
		||||
		log.Info(i18n.G("file: %s removed", app.Path))
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppRemoveCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Force,
 | 
			
		||||
		"force",
 | 
			
		||||
		"f",
 | 
			
		||||
		i18n.G("force"),
 | 
			
		||||
		i18n.G("f"),
 | 
			
		||||
		false,
 | 
			
		||||
		"perform action without further prompt",
 | 
			
		||||
		i18n.G("perform action without further prompt"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,31 +3,41 @@ package app
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/ui"
 | 
			
		||||
	upstream "coopcloud.tech/abra/pkg/upstream/service"
 | 
			
		||||
	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app restart` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appRestartAliases = i18n.G("re")
 | 
			
		||||
 | 
			
		||||
var AppRestartCommand = &cobra.Command{
 | 
			
		||||
	Use:     "restart <app> [[service] | --all-services] [flags]",
 | 
			
		||||
	Aliases: []string{"re"},
 | 
			
		||||
	Short:   "Restart an app",
 | 
			
		||||
	Long: `This command restarts services within a deployed app.
 | 
			
		||||
	// translators: `app restart` command
 | 
			
		||||
	Use:     i18n.G("restart <domain> [[service] | --all-services] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appRestartAliases, ","),
 | 
			
		||||
	// translators: Short description for `app restart` command
 | 
			
		||||
	Short: i18n.G("Restart an app"),
 | 
			
		||||
	Long: i18n.G(`This command restarts services within a deployed app.
 | 
			
		||||
 | 
			
		||||
Run "abra app ps <app>" to see a list of service names.
 | 
			
		||||
Run "abra app ps <domain>" to see a list of service names.
 | 
			
		||||
 | 
			
		||||
Pass "--all-services/-a" to restart all services.`,
 | 
			
		||||
	Example: `  # restart a single app service
 | 
			
		||||
Pass "--all-services/-a" to restart all services.`),
 | 
			
		||||
	Example: i18n.G(`  # restart a single app service
 | 
			
		||||
  abra app restart 1312.net app
 | 
			
		||||
 | 
			
		||||
  # restart all app services
 | 
			
		||||
  abra app restart 1312.net -a`,
 | 
			
		||||
  abra app restart 1312.net -a`),
 | 
			
		||||
	Args: cobra.RangeArgs(1, 2),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -48,7 +58,7 @@ Pass "--all-services/-a" to restart all services.`,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(false, false); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -58,11 +68,11 @@ Pass "--all-services/-a" to restart all services.`,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if serviceName == "" && !allServices {
 | 
			
		||||
			log.Fatal("missing [service]")
 | 
			
		||||
			log.Fatal(i18n.G("missing [service]"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if serviceName != "" && allServices {
 | 
			
		||||
			log.Fatal("cannot use [service] and --all-services/-a together")
 | 
			
		||||
			log.Fatal(i18n.G("cannot use [service] and --all-services/-a together"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var serviceNames []string
 | 
			
		||||
@ -87,35 +97,58 @@ Pass "--all-services/-a" to restart all services.`,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !deployMeta.IsDeployed {
 | 
			
		||||
			log.Fatalf("%s is not deployed?", app.Name)
 | 
			
		||||
			log.Fatal(i18n.G("%s is not deployed?", app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, serviceName := range serviceNames {
 | 
			
		||||
			stackServiceName := fmt.Sprintf("%s_%s", app.StackName(), serviceName)
 | 
			
		||||
 | 
			
		||||
			log.Debugf("attempting to scale %s to 0", stackServiceName)
 | 
			
		||||
			service, _, err := cl.ServiceInspectWithRaw(
 | 
			
		||||
				context.Background(),
 | 
			
		||||
				stackServiceName,
 | 
			
		||||
				types.ServiceInspectOptions{},
 | 
			
		||||
			)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debug(i18n.G("attempting to scale %s to 0", stackServiceName))
 | 
			
		||||
 | 
			
		||||
			if err := upstream.RunServiceScale(context.Background(), cl, stackServiceName, 0); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if err := stack.WaitOnService(context.Background(), cl, stackServiceName, app.Name); err != nil {
 | 
			
		||||
			f, err := app.Filters(true, false, serviceName)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debugf("%s has been scaled to 0", stackServiceName)
 | 
			
		||||
			log.Debugf("attempting to scale %s to 1", stackServiceName)
 | 
			
		||||
			waitOpts := stack.WaitOpts{
 | 
			
		||||
				Services:   []ui.ServiceMeta{{Name: stackServiceName, ID: service.ID}},
 | 
			
		||||
				AppName:    app.Name,
 | 
			
		||||
				ServerName: app.Server,
 | 
			
		||||
				Filters:    f,
 | 
			
		||||
				NoLog:      true,
 | 
			
		||||
				Quiet:      true,
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if err := stack.WaitOnServices(cmd.Context(), cl, waitOpts); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debug(i18n.G("%s has been scaled to 0", stackServiceName))
 | 
			
		||||
			log.Debug(i18n.G("attempting to scale %s to 1", stackServiceName))
 | 
			
		||||
 | 
			
		||||
			if err := upstream.RunServiceScale(context.Background(), cl, stackServiceName, 1); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if err := stack.WaitOnService(context.Background(), cl, stackServiceName, app.Name); err != nil {
 | 
			
		||||
			if err := stack.WaitOnServices(cmd.Context(), cl, waitOpts); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debugf("%s has been scaled to 1", stackServiceName)
 | 
			
		||||
			log.Infof("%s service successfully restarted", serviceName)
 | 
			
		||||
			log.Debug(i18n.G("%s has been scaled to 1", stackServiceName))
 | 
			
		||||
			log.Info(i18n.G("%s service successfully restarted", serviceName))
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
@ -124,10 +157,17 @@ var allServices bool
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppRestartCommand.Flags().BoolVarP(
 | 
			
		||||
		&allServices,
 | 
			
		||||
		"all-services",
 | 
			
		||||
		"a",
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"restart all services",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
	AppRestartCommand.Flags().BoolVarP(
 | 
			
		||||
		&allServices,
 | 
			
		||||
		i18n.G("all-services"),
 | 
			
		||||
		i18n.GC("a", "app restart"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("restart all services"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -7,17 +7,24 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var AppRestoreCommand = &cobra.Command{
 | 
			
		||||
	Use:     "restore <app> [flags]",
 | 
			
		||||
	Aliases: []string{"rs"},
 | 
			
		||||
	Short:   "Restore a snapshot",
 | 
			
		||||
	Long: `Snapshots are restored while apps are deployed.
 | 
			
		||||
// translators: `abra app restore` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var appRestoreAliases = i18n.G("rs")
 | 
			
		||||
 | 
			
		||||
Some restore scenarios may require service / app restarts.`,
 | 
			
		||||
var AppRestoreCommand = &cobra.Command{
 | 
			
		||||
	// translators: `app restore` command
 | 
			
		||||
	Use:     i18n.G("restore <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appRestoreAliases, ","),
 | 
			
		||||
	// translators: Short description for `app restore` command
 | 
			
		||||
	Short: i18n.G("Restore a snapshot"),
 | 
			
		||||
	Long: i18n.G(`Snapshots are restored while apps are deployed.
 | 
			
		||||
 | 
			
		||||
Some restore scenarios may require service / app restarts.`),
 | 
			
		||||
	Args: cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -28,7 +35,7 @@ Some restore scenarios may require service / app restarts.`,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -48,34 +55,34 @@ Some restore scenarios may require service / app restarts.`,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if snapshot != "" {
 | 
			
		||||
			log.Debugf("including SNAPSHOT=%s in backupbot exec invocation", snapshot)
 | 
			
		||||
			log.Debug(i18n.G("including SNAPSHOT=%s in backupbot exec invocation", snapshot))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("SNAPSHOT=%s", snapshot))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if targetPath != "" {
 | 
			
		||||
			log.Debugf("including TARGET=%s in backupbot exec invocation", targetPath)
 | 
			
		||||
			log.Debug(i18n.G("including TARGET=%s in backupbot exec invocation", targetPath))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("TARGET=%s", targetPath))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if internal.NoInput {
 | 
			
		||||
			log.Debugf("including NONINTERACTIVE=%v in backupbot exec invocation", internal.NoInput)
 | 
			
		||||
			log.Debug(i18n.G("including NONINTERACTIVE=%v in backupbot exec invocation", internal.NoInput))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("NONINTERACTIVE=%v", internal.NoInput))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(volumes) > 0 {
 | 
			
		||||
			allVolumes := strings.Join(volumes, ",")
 | 
			
		||||
			log.Debugf("including VOLUMES=%s in backupbot exec invocation", allVolumes)
 | 
			
		||||
			log.Debug(i18n.G("including VOLUMES=%s in backupbot exec invocation", allVolumes))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("VOLUMES=%s", allVolumes))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(services) > 0 {
 | 
			
		||||
			allServices := strings.Join(services, ",")
 | 
			
		||||
			log.Debugf("including CONTAINER=%s in backupbot exec invocation", allServices)
 | 
			
		||||
			log.Debug(i18n.G("including CONTAINER=%s in backupbot exec invocation", allServices))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("CONTAINER=%s", allServices))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if hooks {
 | 
			
		||||
			log.Debugf("including NO_COMMANDS=%v in backupbot exec invocation", false)
 | 
			
		||||
			log.Debug(i18n.G("including NO_COMMANDS=%v in backupbot exec invocation", false))
 | 
			
		||||
			execEnv = append(execEnv, fmt.Sprintf("NO_COMMANDS=%v", false))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -95,41 +102,41 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	AppRestoreCommand.Flags().StringVarP(
 | 
			
		||||
		&targetPath,
 | 
			
		||||
		"target",
 | 
			
		||||
		"t",
 | 
			
		||||
		i18n.G("target"),
 | 
			
		||||
		i18n.G("t"),
 | 
			
		||||
		"/",
 | 
			
		||||
		"target path",
 | 
			
		||||
		i18n.G("target path"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppRestoreCommand.Flags().StringArrayVarP(
 | 
			
		||||
		&services,
 | 
			
		||||
		"services",
 | 
			
		||||
		"s",
 | 
			
		||||
		i18n.G("services"),
 | 
			
		||||
		i18n.G("s"),
 | 
			
		||||
		[]string{},
 | 
			
		||||
		"restore specific services",
 | 
			
		||||
		i18n.G("restore specific services"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppRestoreCommand.Flags().StringArrayVarP(
 | 
			
		||||
		&volumes,
 | 
			
		||||
		"volumes",
 | 
			
		||||
		"v",
 | 
			
		||||
		i18n.G("volumes"),
 | 
			
		||||
		i18n.G("v"),
 | 
			
		||||
		[]string{},
 | 
			
		||||
		"restore specific volumes",
 | 
			
		||||
		i18n.G("restore specific volumes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppRestoreCommand.Flags().BoolVarP(
 | 
			
		||||
		&hooks,
 | 
			
		||||
		"hooks",
 | 
			
		||||
		"H",
 | 
			
		||||
		i18n.G("hooks"),
 | 
			
		||||
		i18n.G("H"),
 | 
			
		||||
		false,
 | 
			
		||||
		"enable pre/post-hook command execution",
 | 
			
		||||
		i18n.G("enable pre/post-hook command execution"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppRestoreCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,15 @@
 | 
			
		||||
package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/envfile"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/deploy"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/lint"
 | 
			
		||||
	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"coopcloud.tech/tagcmp"
 | 
			
		||||
@ -19,22 +21,35 @@ import (
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app rollback` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var appRollbackAliases = i18n.G("rl")
 | 
			
		||||
 | 
			
		||||
var AppRollbackCommand = &cobra.Command{
 | 
			
		||||
	Use:     "rollback <app> [version] [flags]",
 | 
			
		||||
	Aliases: []string{"rl"},
 | 
			
		||||
	Short:   "Roll an app back to a previous version",
 | 
			
		||||
	Long: `This command rolls an app back to a previous version.
 | 
			
		||||
	// translators: `app rollback` command
 | 
			
		||||
	Use:     i18n.G("rollback <domain> [version] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appRollbackAliases, ","),
 | 
			
		||||
	// translators: Short description for `app rollback` command
 | 
			
		||||
	Short: i18n.G("Roll an app back to a previous version"),
 | 
			
		||||
	Long: i18n.G(`This command rolls an app back to a previous version.
 | 
			
		||||
 | 
			
		||||
Unlike "deploy", chaos operations are not supported here. Only recipe versions
 | 
			
		||||
are supported values for "[<version>]".
 | 
			
		||||
Unlike "abra app deploy", chaos operations are not supported here. Only recipe
 | 
			
		||||
versions are supported values for "[version]".
 | 
			
		||||
 | 
			
		||||
A rollback can be destructive, please ensure you have a copy of your app data
 | 
			
		||||
beforehand.`,
 | 
			
		||||
	Example: ` # standard rollback
 | 
			
		||||
It is possible to "--force/-f" an downgrade if you want to re-deploy a specific
 | 
			
		||||
version.
 | 
			
		||||
 | 
			
		||||
Only the deployed version is consulted when trying to determine what downgrades
 | 
			
		||||
are available. The live deployment version is the "source of truth" in this
 | 
			
		||||
case. The stored .env version is not consulted.
 | 
			
		||||
 | 
			
		||||
A downgrade can be destructive, please ensure you have a copy of your app data
 | 
			
		||||
beforehand. See "abra app backup" for more.`),
 | 
			
		||||
	Example: i18n.G(` # standard rollback
 | 
			
		||||
  abra app rollback 1312.net
 | 
			
		||||
 | 
			
		||||
  # rollback to specific version
 | 
			
		||||
  abra app rollback 1312.net 2.0.0+1.2.3`,
 | 
			
		||||
  abra app rollback 1312.net 2.0.0+1.2.3`),
 | 
			
		||||
	Args: cobra.RangeArgs(1, 2),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -46,8 +61,7 @@ beforehand.`,
 | 
			
		||||
		case 1:
 | 
			
		||||
			app, err := appPkg.Get(args[0])
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				errMsg := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
				return []string{errMsg}, cobra.ShellCompDirectiveError
 | 
			
		||||
				return []string{i18n.G("autocomplete failed: %s", err)}, cobra.ShellCompDirectiveError
 | 
			
		||||
			}
 | 
			
		||||
			return autocomplete.RecipeVersionComplete(app.Recipe.Name)
 | 
			
		||||
		default:
 | 
			
		||||
@ -55,26 +69,15 @@ beforehand.`,
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		var warnMessages []string
 | 
			
		||||
		var (
 | 
			
		||||
			downgradeWarnMessages []string
 | 
			
		||||
			chosenDowngrade       string
 | 
			
		||||
			availableDowngrades   []string
 | 
			
		||||
		)
 | 
			
		||||
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
		stackName := app.StackName()
 | 
			
		||||
 | 
			
		||||
		var specificVersion string
 | 
			
		||||
		if len(args) == 2 {
 | 
			
		||||
			specificVersion = args[1]
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if specificVersion != "" {
 | 
			
		||||
			log.Debugf("overriding env file version (%s) with %s", app.Recipe.Version, specificVersion)
 | 
			
		||||
			app.Recipe.Version = specificVersion
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := lint.LintForErrors(app.Recipe); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -83,15 +86,13 @@ beforehand.`,
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("checking whether %s is already deployed", stackName)
 | 
			
		||||
 | 
			
		||||
		deployMeta, err := stack.IsDeployed(context.Background(), cl, stackName)
 | 
			
		||||
		deployMeta, err := ensureDeployed(cl, app)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !deployMeta.IsDeployed {
 | 
			
		||||
			log.Fatalf("%s is not deployed?", app.Name)
 | 
			
		||||
		if err := lint.LintForErrors(app.Recipe); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		versions, err := app.Recipe.Tags()
 | 
			
		||||
@ -99,101 +100,70 @@ beforehand.`,
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var availableDowngrades []string
 | 
			
		||||
		if deployMeta.Version == "unknown" {
 | 
			
		||||
		// NOTE(d1): we've no idea what the live deployment version is, so every
 | 
			
		||||
		// possible downgrade can be shown. it's up to the user to make the choice
 | 
			
		||||
		if deployMeta.Version == config.UNKNOWN_DEFAULT {
 | 
			
		||||
			availableDowngrades = versions
 | 
			
		||||
			warnMessages = append(warnMessages, fmt.Sprintf("failed to determine deployed version of %s", app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if specificVersion != "" {
 | 
			
		||||
			parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatalf("'%s' is not a known version for %s", deployMeta.Version, app.Recipe.Name)
 | 
			
		||||
		if len(args) == 2 && args[1] != "" {
 | 
			
		||||
			chosenDowngrade = args[1]
 | 
			
		||||
 | 
			
		||||
			if err := validateDowngradeVersionArg(chosenDowngrade, app, deployMeta); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			parsedSpecificVersion, err := tagcmp.Parse(specificVersion)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatalf("'%s' is not a known version for %s", specificVersion, app.Recipe.Name)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if parsedSpecificVersion.IsGreaterThan(parsedDeployedVersion) && !parsedSpecificVersion.Equals(parsedDeployedVersion) {
 | 
			
		||||
				log.Fatalf("%s is not a downgrade for %s?", deployMeta.Version, specificVersion)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if parsedSpecificVersion.Equals(parsedDeployedVersion) && !internal.Force {
 | 
			
		||||
				log.Fatalf("%s is not a downgrade for %s?", deployMeta.Version, specificVersion)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			availableDowngrades = append(availableDowngrades, specificVersion)
 | 
			
		||||
			availableDowngrades = append(availableDowngrades, chosenDowngrade)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if deployMeta.Version != "unknown" && specificVersion == "" {
 | 
			
		||||
			if deployMeta.IsChaos {
 | 
			
		||||
				warnMessages = append(warnMessages, fmt.Sprintf("attempting to rollback a chaos deployment"))
 | 
			
		||||
		if deployMeta.Version != config.UNKNOWN_DEFAULT && chosenDowngrade == "" {
 | 
			
		||||
			downgradeAvailable, err := ensureDowngradesAvailable(versions, &availableDowngrades, deployMeta)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for _, version := range versions {
 | 
			
		||||
				parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				parsedVersion, err := tagcmp.Parse(version)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if parsedVersion.IsLessThan(parsedDeployedVersion) && !(parsedVersion.Equals(parsedDeployedVersion)) {
 | 
			
		||||
					availableDowngrades = append(availableDowngrades, version)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if len(availableDowngrades) == 0 && !internal.Force {
 | 
			
		||||
				log.Info("no available downgrades")
 | 
			
		||||
			if !downgradeAvailable {
 | 
			
		||||
				log.Info(i18n.G("no available downgrades"))
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var chosenDowngrade string
 | 
			
		||||
		if len(availableDowngrades) > 0 {
 | 
			
		||||
			if internal.Force || internal.NoInput || specificVersion != "" {
 | 
			
		||||
		if internal.Force || internal.NoInput || chosenDowngrade != "" {
 | 
			
		||||
			if len(availableDowngrades) > 0 {
 | 
			
		||||
				chosenDowngrade = availableDowngrades[len(availableDowngrades)-1]
 | 
			
		||||
				log.Debugf("choosing %s as version to downgrade to (--force/--no-input)", chosenDowngrade)
 | 
			
		||||
			} else {
 | 
			
		||||
				msg := fmt.Sprintf("please select a downgrade (version: %s):", deployMeta.Version)
 | 
			
		||||
				if deployMeta.IsChaos {
 | 
			
		||||
					msg = fmt.Sprintf("please select a downgrade (version: %s, chaosVersion: %s):", deployMeta.Version, deployMeta.ChaosVersion)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				prompt := &survey.Select{
 | 
			
		||||
					Message: msg,
 | 
			
		||||
					Options: internal.SortVersionsDesc(availableDowngrades),
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if err := survey.AskOne(prompt, &chosenDowngrade); err != nil {
 | 
			
		||||
					return
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			if err := chooseDowngrade(availableDowngrades, deployMeta, &chosenDowngrade); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("choosing %s as version to rollback", chosenDowngrade)
 | 
			
		||||
		if internal.Force &&
 | 
			
		||||
			chosenDowngrade == "" &&
 | 
			
		||||
			deployMeta.Version != config.UNKNOWN_DEFAULT {
 | 
			
		||||
			chosenDowngrade = deployMeta.Version
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if chosenDowngrade == "" {
 | 
			
		||||
			log.Fatal(i18n.G("unknown deployed version, unable to downgrade"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debug(i18n.G("choosing %s as version to rollback", chosenDowngrade))
 | 
			
		||||
 | 
			
		||||
		if _, err := app.Recipe.EnsureVersion(chosenDowngrade); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		abraShEnv, err := envfile.ReadAbraShEnvVars(app.Recipe.AbraShPath)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
		if err := deploy.MergeAbraShEnv(app.Recipe, app.Env); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		for k, v := range abraShEnv {
 | 
			
		||||
			app.Env[k] = v
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		stackName := app.StackName()
 | 
			
		||||
		deployOpts := stack.Deploy{
 | 
			
		||||
			Composefiles: composeFiles,
 | 
			
		||||
			Namespace:    stackName,
 | 
			
		||||
@ -210,59 +180,198 @@ beforehand.`,
 | 
			
		||||
		appPkg.ExposeAllEnv(stackName, compose, app.Env)
 | 
			
		||||
		appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name)
 | 
			
		||||
		appPkg.SetChaosLabel(compose, stackName, internal.Chaos)
 | 
			
		||||
		appPkg.SetChaosVersionLabel(compose, stackName, chosenDowngrade)
 | 
			
		||||
		appPkg.SetUpdateLabel(compose, stackName, app.Env)
 | 
			
		||||
		if internal.Chaos {
 | 
			
		||||
			appPkg.SetChaosVersionLabel(compose, stackName, chosenDowngrade)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		chaosVersion := config.CHAOS_DEFAULT
 | 
			
		||||
		// Gather secrets
 | 
			
		||||
		secretInfo, err := deploy.GatherSecretsForDeploy(cl, app, internal.ShowUnchanged)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Gather configs
 | 
			
		||||
		configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env, internal.ShowUnchanged)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Gather images
 | 
			
		||||
		imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose, internal.ShowUnchanged)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		deployedVersion := deployMeta.Version
 | 
			
		||||
		if deployMeta.IsChaos {
 | 
			
		||||
			chaosVersion = deployMeta.ChaosVersion
 | 
			
		||||
			deployedVersion = deployMeta.ChaosVersion
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// NOTE(d1): no release notes implemeneted for rolling back
 | 
			
		||||
		if err := internal.NewVersionOverview(
 | 
			
		||||
		if err := internal.DeployOverview(
 | 
			
		||||
			app,
 | 
			
		||||
			warnMessages,
 | 
			
		||||
			"rollback",
 | 
			
		||||
			deployMeta.Version,
 | 
			
		||||
			chaosVersion,
 | 
			
		||||
			deployedVersion,
 | 
			
		||||
			chosenDowngrade,
 | 
			
		||||
			""); err != nil {
 | 
			
		||||
			"",
 | 
			
		||||
			downgradeWarnMessages,
 | 
			
		||||
			secretInfo,
 | 
			
		||||
			configInfo,
 | 
			
		||||
			imageInfo,
 | 
			
		||||
		); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := stack.RunDeploy(cl, deployOpts, compose, stackName, internal.DontWaitConverge); err != nil {
 | 
			
		||||
		stack.WaitTimeout, err = appPkg.GetTimeoutFromLabel(compose, stackName)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		app.Recipe.Version = chosenDowngrade
 | 
			
		||||
		log.Debugf("choosing %s as version to save to env file", app.Recipe.Version)
 | 
			
		||||
		if err := app.WriteRecipeVersion(app.Recipe.Version, false); err != nil {
 | 
			
		||||
			log.Fatalf("writing new recipe version in env file: %s", err)
 | 
			
		||||
		serviceNames, err := appPkg.GetAppServiceNames(app.Name)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		f, err := app.Filters(true, false, serviceNames...)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := stack.RunDeploy(
 | 
			
		||||
			cl,
 | 
			
		||||
			deployOpts,
 | 
			
		||||
			compose,
 | 
			
		||||
			stackName,
 | 
			
		||||
			app.Server,
 | 
			
		||||
			internal.DontWaitConverge,
 | 
			
		||||
			f,
 | 
			
		||||
		); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := app.WriteRecipeVersion(chosenDowngrade, false); err != nil {
 | 
			
		||||
			log.Fatal(i18n.G("writing recipe version failed: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// chooseDowngrade prompts the user to choose an downgrade interactively.
 | 
			
		||||
func chooseDowngrade(
 | 
			
		||||
	availableDowngrades []string,
 | 
			
		||||
	deployMeta stack.DeployMeta,
 | 
			
		||||
	chosenDowngrade *string,
 | 
			
		||||
) error {
 | 
			
		||||
	msg := i18n.G("please select a downgrade (version: %s):", deployMeta.Version)
 | 
			
		||||
 | 
			
		||||
	if deployMeta.IsChaos {
 | 
			
		||||
		chaosVersion := formatter.BoldDirtyDefault(deployMeta.ChaosVersion)
 | 
			
		||||
 | 
			
		||||
		msg = i18n.G(
 | 
			
		||||
			"please select a downgrade (version: %s, chaos: %s):",
 | 
			
		||||
			deployMeta.Version,
 | 
			
		||||
			chaosVersion,
 | 
			
		||||
		)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	prompt := &survey.Select{
 | 
			
		||||
		Message: msg,
 | 
			
		||||
		Options: internal.SortVersionsDesc(availableDowngrades),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := survey.AskOne(prompt, chosenDowngrade); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// validateDownpgradeVersionArg validates the specific version.
 | 
			
		||||
func validateDowngradeVersionArg(
 | 
			
		||||
	specificVersion string,
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	deployMeta stack.DeployMeta,
 | 
			
		||||
) error {
 | 
			
		||||
	parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.New(i18n.G("current deployment '%s' is not a known version for %s", deployMeta.Version, app.Recipe.Name))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	parsedSpecificVersion, err := tagcmp.Parse(specificVersion)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.New(i18n.G("'%s' is not a known version for %s", specificVersion, app.Recipe.Name))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if parsedSpecificVersion.IsGreaterThan(parsedDeployedVersion) &&
 | 
			
		||||
		!parsedSpecificVersion.Equals(parsedDeployedVersion) {
 | 
			
		||||
		return errors.New(i18n.G("%s is not a downgrade for %s?", deployMeta.Version, specificVersion))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if parsedSpecificVersion.Equals(parsedDeployedVersion) && !internal.Force {
 | 
			
		||||
		return errors.New(i18n.G("%s is not a downgrade for %s?", deployMeta.Version, specificVersion))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ensureDowngradesAvailable ensures that there are available downgrades.
 | 
			
		||||
func ensureDowngradesAvailable(
 | 
			
		||||
	versions []string,
 | 
			
		||||
	availableDowngrades *[]string,
 | 
			
		||||
	deployMeta stack.DeployMeta,
 | 
			
		||||
) (bool, error) {
 | 
			
		||||
	parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, version := range versions {
 | 
			
		||||
		parsedVersion, err := tagcmp.Parse(version)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if parsedVersion.IsLessThan(parsedDeployedVersion) &&
 | 
			
		||||
			!(parsedVersion.Equals(parsedDeployedVersion)) {
 | 
			
		||||
			*availableDowngrades = append(*availableDowngrades, version)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(*availableDowngrades) == 0 && !internal.Force {
 | 
			
		||||
		return false, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return true, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppRollbackCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Force,
 | 
			
		||||
		"force",
 | 
			
		||||
		"f",
 | 
			
		||||
		i18n.G("force"),
 | 
			
		||||
		i18n.G("f"),
 | 
			
		||||
		false,
 | 
			
		||||
		"perform action without further prompt",
 | 
			
		||||
		i18n.G("perform action without further prompt"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppRollbackCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.NoDomainChecks,
 | 
			
		||||
		"no-domain-checks",
 | 
			
		||||
		"D",
 | 
			
		||||
		i18n.G("no-domain-checks"),
 | 
			
		||||
		i18n.G("D"),
 | 
			
		||||
		false,
 | 
			
		||||
		"disable public DNS checks",
 | 
			
		||||
		i18n.G("disable public DNS checks"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppRollbackCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.DontWaitConverge, "no-converge-checks",
 | 
			
		||||
		"c",
 | 
			
		||||
		&internal.DontWaitConverge,
 | 
			
		||||
		i18n.G("no-converge-checks"),
 | 
			
		||||
		i18n.G("c"),
 | 
			
		||||
		false,
 | 
			
		||||
		"do not wait for converge logic checks",
 | 
			
		||||
		i18n.G("disable converge logic checks"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppRollbackCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.ShowUnchanged,
 | 
			
		||||
		i18n.G("show-unchanged"),
 | 
			
		||||
		i18n.G("U"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("show all configs & images, including unchanged ones"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,31 +3,39 @@ package app
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	containerPkg "coopcloud.tech/abra/pkg/container"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/container"
 | 
			
		||||
	"github.com/docker/cli/cli/command"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	containertypes "github.com/docker/docker/api/types/container"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app run` aliases. use a comma separated list of aliases
 | 
			
		||||
// with no spaces in between
 | 
			
		||||
var appRunAliases = i18n.G("r")
 | 
			
		||||
 | 
			
		||||
var AppRunCommand = &cobra.Command{
 | 
			
		||||
	Use:     "run <app> <service> <cmd> [[args] [flags] | [flags] -- [args]]",
 | 
			
		||||
	Aliases: []string{"r"},
 | 
			
		||||
	Short:   "Run a command inside a service container",
 | 
			
		||||
	Example: `  # run <cmd> with args/flags
 | 
			
		||||
	// translators: `app run` command
 | 
			
		||||
	Use:     i18n.G("run <domain> <service> <cmd> [[args] [flags] | [flags] -- [args]]"),
 | 
			
		||||
	Aliases: strings.Split(appRunAliases, ","),
 | 
			
		||||
	// translators: Short description for `app run` command
 | 
			
		||||
	Short: i18n.G("Run a command inside a service container"),
 | 
			
		||||
	Example: i18n.G(`  # run <cmd> with args/flags
 | 
			
		||||
  abra app run 1312.net app -- ls -lha
 | 
			
		||||
 | 
			
		||||
  # run <cmd> without args/flags
 | 
			
		||||
  abra app run 1312.net app bash --user nobody
 | 
			
		||||
 | 
			
		||||
  # run <cmd> with both kinds of args/flags 
 | 
			
		||||
  abra app run 1312.net app --user nobody -- ls -lha`,
 | 
			
		||||
  abra app run 1312.net app --user nobody -- ls -lha`),
 | 
			
		||||
	Args: cobra.MinimumNArgs(3),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -64,7 +72,7 @@ var AppRunCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		userCmd := args[2:]
 | 
			
		||||
		execCreateOpts := types.ExecConfig{
 | 
			
		||||
		execCreateOpts := containertypes.ExecOptions{
 | 
			
		||||
			AttachStderr: true,
 | 
			
		||||
			AttachStdin:  true,
 | 
			
		||||
			AttachStdout: true,
 | 
			
		||||
@ -98,17 +106,17 @@ var (
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppRunCommand.Flags().BoolVarP(&noTTY,
 | 
			
		||||
		"no-tty",
 | 
			
		||||
		"t",
 | 
			
		||||
		i18n.G("no-tty"),
 | 
			
		||||
		i18n.G("t"),
 | 
			
		||||
		false,
 | 
			
		||||
		"do not request a TTY",
 | 
			
		||||
		i18n.G("do not request a TTY"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppRunCommand.Flags().StringVarP(
 | 
			
		||||
		&runAsUser,
 | 
			
		||||
		"user",
 | 
			
		||||
		"u",
 | 
			
		||||
		i18n.G("user"),
 | 
			
		||||
		i18n.G("u"),
 | 
			
		||||
		"",
 | 
			
		||||
		"run command as user",
 | 
			
		||||
		i18n.G("run command as user"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,11 @@ package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"os"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
@ -12,30 +15,38 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/secret"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app secret generate` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appSecretGenerateAliases = i18n.G("g")
 | 
			
		||||
 | 
			
		||||
var AppSecretGenerateCommand = &cobra.Command{
 | 
			
		||||
	Use:     "generate <app> [[secret] [version] | --all] [flags]",
 | 
			
		||||
	Aliases: []string{"g"},
 | 
			
		||||
	Short:   "Generate secrets",
 | 
			
		||||
	Args:    cobra.RangeArgs(1, 3),
 | 
			
		||||
	// translators: `app secret generate` command
 | 
			
		||||
	Use:     i18n.G("generate <domain> [[secret] [version] | --all] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appSecretGenerateAliases, ","),
 | 
			
		||||
	// translators: Short description for `app secret generate` command
 | 
			
		||||
	Short: i18n.G("Generate secrets"),
 | 
			
		||||
	Args:  cobra.RangeArgs(1, 3),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
		toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		toComplete string,
 | 
			
		||||
	) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		switch l := len(args); l {
 | 
			
		||||
		case 0:
 | 
			
		||||
			return autocomplete.AppNameComplete()
 | 
			
		||||
		case 1:
 | 
			
		||||
			app, err := appPkg.Get(args[0])
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				errMsg := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
				return []string{errMsg}, cobra.ShellCompDirectiveError
 | 
			
		||||
				return []string{i18n.G("autocomplete failed: %s", err)}, cobra.ShellCompDirectiveError
 | 
			
		||||
			}
 | 
			
		||||
			return autocomplete.SecretComplete(app.Recipe.Name)
 | 
			
		||||
		default:
 | 
			
		||||
@ -45,16 +56,16 @@ var AppSecretGenerateCommand = &cobra.Command{
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(args) == 1 && !generateAllSecrets {
 | 
			
		||||
			log.Fatal("missing arguments [secret]/[version] or '--all'")
 | 
			
		||||
		if len(args) <= 2 && !generateAllSecrets {
 | 
			
		||||
			log.Fatal(i18n.G("missing arguments [secret]/[version] or '--all'"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(args) > 1 && generateAllSecrets {
 | 
			
		||||
			log.Fatal("cannot use '[secret] [version]' and '--all' together")
 | 
			
		||||
		if len(args) > 2 && generateAllSecrets {
 | 
			
		||||
			log.Fatal(i18n.G("cannot use '[secret] [version]' and '--all' together"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
 | 
			
		||||
@ -72,7 +83,7 @@ var AppSecretGenerateCommand = &cobra.Command{
 | 
			
		||||
			secretVersion := args[2]
 | 
			
		||||
			s, ok := secrets[secretName]
 | 
			
		||||
			if !ok {
 | 
			
		||||
				log.Fatalf("%s doesn't exist in the env config?", secretName)
 | 
			
		||||
				log.Fatal(i18n.G("%s doesn't exist in the env config?", secretName))
 | 
			
		||||
			}
 | 
			
		||||
			s.Version = secretVersion
 | 
			
		||||
			secrets = map[string]secret.Secret{
 | 
			
		||||
@ -99,11 +110,11 @@ var AppSecretGenerateCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(secretVals) == 0 {
 | 
			
		||||
			log.Warn("no secrets generated")
 | 
			
		||||
			log.Warn(i18n.G("no secrets generated"))
 | 
			
		||||
			os.Exit(1)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		headers := []string{"NAME", "VALUE"}
 | 
			
		||||
		headers := []string{i18n.G("NAME"), i18n.G("VALUE")}
 | 
			
		||||
		table, err := formatter.CreateTable()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
@ -121,7 +132,7 @@ var AppSecretGenerateCommand = &cobra.Command{
 | 
			
		||||
		if internal.MachineReadable {
 | 
			
		||||
			out, err := formatter.ToJSON(headers, rows)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal("unable to render to JSON: %s", err)
 | 
			
		||||
				log.Fatal(i18n.G("unable to render to JSON: %s", err))
 | 
			
		||||
			}
 | 
			
		||||
			fmt.Println(out)
 | 
			
		||||
			return
 | 
			
		||||
@ -131,36 +142,53 @@ var AppSecretGenerateCommand = &cobra.Command{
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Warnf(
 | 
			
		||||
		log.Warn(i18n.G(
 | 
			
		||||
			"generated secrets %s shown again, please take note of them %s",
 | 
			
		||||
			formatter.BoldStyle.Render("NOT"),
 | 
			
		||||
			formatter.BoldStyle.Render("NOW"),
 | 
			
		||||
		)
 | 
			
		||||
			formatter.BoldStyle.Render(i18n.G("NOT")),
 | 
			
		||||
			formatter.BoldStyle.Render(i18n.G("NOW")),
 | 
			
		||||
		))
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var AppSecretInsertCommand = &cobra.Command{
 | 
			
		||||
	Use:     "insert <app> <secret> <version> <data> [flags]",
 | 
			
		||||
	Aliases: []string{"i"},
 | 
			
		||||
	Short:   "Insert secret",
 | 
			
		||||
	Long: `This command inserts a secret into an app environment.
 | 
			
		||||
// translators: `abra app secret insert` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appSecretInsertAliases = i18n.G("i")
 | 
			
		||||
 | 
			
		||||
This can be useful when you want to manually generate secrets for an app
 | 
			
		||||
var AppSecretInsertCommand = &cobra.Command{
 | 
			
		||||
	// translators: `app secret insert` command
 | 
			
		||||
	Use:     i18n.G("insert <domain> <secret> <version> [<data>] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appSecretInsertAliases, ","),
 | 
			
		||||
	// translators: Short description for `app secret insert` command
 | 
			
		||||
	Short: i18n.G("Insert secret"),
 | 
			
		||||
	Long: i18n.G(`This command inserts a secret into an app environment.
 | 
			
		||||
 | 
			
		||||
Arbitrary secret insertion is not supported. Secrets that are inserted must
 | 
			
		||||
match those configured in the recipe beforehand.
 | 
			
		||||
 | 
			
		||||
This command can be useful when you want to manually generate secrets for an app
 | 
			
		||||
environment. Typically, you can let Abra generate them for you on app creation
 | 
			
		||||
(see "abra app new --secrets/-S" for more).`,
 | 
			
		||||
	Args: cobra.MinimumNArgs(4),
 | 
			
		||||
(see "abra app new --secrets/-S" for more).`),
 | 
			
		||||
	Example: i18n.G(`  # insert regular secret
 | 
			
		||||
  abra app secret insert 1312.net my_secret v1 mySuperSecret
 | 
			
		||||
 | 
			
		||||
  # insert secret as file
 | 
			
		||||
  abra app secret insert 1312.net my_secret v1 secret.txt -f
 | 
			
		||||
 | 
			
		||||
  # insert secret from stdin
 | 
			
		||||
  echo "mmySuperSecret" | abra app secret insert 1312.net my_secret v1`),
 | 
			
		||||
	Args: cobra.MinimumNArgs(3),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
		toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		toComplete string,
 | 
			
		||||
	) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		switch l := len(args); l {
 | 
			
		||||
		case 0:
 | 
			
		||||
			return autocomplete.AppNameComplete()
 | 
			
		||||
		case 1:
 | 
			
		||||
			app, err := appPkg.Get(args[0])
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				errMsg := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
				return []string{errMsg}, cobra.ShellCompDirectiveError
 | 
			
		||||
				return []string{i18n.G("autocomplete failed: %s", err)}, cobra.ShellCompDirectiveError
 | 
			
		||||
			}
 | 
			
		||||
			return autocomplete.SecretComplete(app.Recipe.Name)
 | 
			
		||||
		default:
 | 
			
		||||
@ -170,7 +198,7 @@ environment. Typically, you can let Abra generate them for you on app creation
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -181,12 +209,35 @@ environment. Typically, you can let Abra generate them for you on app creation
 | 
			
		||||
 | 
			
		||||
		name := args[1]
 | 
			
		||||
		version := args[2]
 | 
			
		||||
		data := args[3]
 | 
			
		||||
		data, err := readSecretData(args)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		secrets, err := secret.ReadSecretsConfig(app.Path, composeFiles, app.StackName())
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var isRecipeSecret bool
 | 
			
		||||
		for secretName := range secrets {
 | 
			
		||||
			if secretName == name {
 | 
			
		||||
				isRecipeSecret = true
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if !isRecipeSecret {
 | 
			
		||||
			log.Fatal(i18n.G("no secret %s available for recipe %s?", name, app.Recipe.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if insertFromFile {
 | 
			
		||||
			raw, err := os.ReadFile(data)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatalf("reading secret from file: %s", err)
 | 
			
		||||
				log.Fatal(i18n.G("reading secret from file: %s", err))
 | 
			
		||||
			}
 | 
			
		||||
			data = string(raw)
 | 
			
		||||
		}
 | 
			
		||||
@ -196,11 +247,11 @@ environment. Typically, you can let Abra generate them for you on app creation
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		secretName := fmt.Sprintf("%s_%s_%s", app.StackName(), name, version)
 | 
			
		||||
		if err := client.StoreSecret(cl, secretName, data, app.Server); err != nil {
 | 
			
		||||
		if err := client.StoreSecret(cl, secretName, data); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Infof("%s successfully stored on server", secretName)
 | 
			
		||||
		log.Info(i18n.G("%s successfully stored on server", secretName))
 | 
			
		||||
 | 
			
		||||
		if storeInPass {
 | 
			
		||||
			if err := secret.PassInsertSecret(data, name, app.Name, app.Server); err != nil {
 | 
			
		||||
@ -210,34 +261,95 @@ environment. Typically, you can let Abra generate them for you on app creation
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func readSecretData(args []string) (string, error) {
 | 
			
		||||
	if len(args) == 4 {
 | 
			
		||||
		return args[3], nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(args) != 3 {
 | 
			
		||||
		return "", errors.New(i18n.G("need 3 or 4 arguments"))
 | 
			
		||||
	}
 | 
			
		||||
	// First check if data is provided by stdin
 | 
			
		||||
	fi, err := os.Stdin.Stat()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	if fi.Mode()&os.ModeNamedPipe != 0 {
 | 
			
		||||
		// Can't insert from stdin and read from file
 | 
			
		||||
		if insertFromFile {
 | 
			
		||||
			return "", errors.New(i18n.G("can not insert from file and read from stdin"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debug(i18n.G("reading secret data from stdin"))
 | 
			
		||||
		bytes, err := io.ReadAll(os.Stdin)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", errors.New(i18n.G("reading data from stdin: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return string(bytes), nil
 | 
			
		||||
	}
 | 
			
		||||
	if internal.NoInput {
 | 
			
		||||
		return "", errors.New(i18n.G("must provide <data> argument if --no-input is passed"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debug(i18n.G("secret data not provided on command-line or stdin, prompting"))
 | 
			
		||||
	var prompt survey.Prompt
 | 
			
		||||
	if !insertFromFile {
 | 
			
		||||
		prompt = &survey.Password{
 | 
			
		||||
			Message: i18n.G("specify secret value"),
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		prompt = &survey.Input{
 | 
			
		||||
			Message: i18n.G("specify secret file"),
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	var data string
 | 
			
		||||
	if err := survey.AskOne(prompt, &data); err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	return data, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// secretRm removes a secret.
 | 
			
		||||
func secretRm(cl *dockerClient.Client, app appPkg.App, secretName, parsed string) error {
 | 
			
		||||
	if err := cl.SecretRemove(context.Background(), secretName); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Infof("deleted %s successfully from server", secretName)
 | 
			
		||||
	log.Info(i18n.G("deleted %s successfully from server", secretName))
 | 
			
		||||
 | 
			
		||||
	if removeFromPass {
 | 
			
		||||
		if err := secret.PassRmSecret(parsed, app.StackName(), app.Server); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Infof("deleted %s successfully from local pass store", secretName)
 | 
			
		||||
		log.Info(i18n.G("deleted %s successfully from local pass store", secretName))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra app secret remove` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appSecretRemoveAliases = i18n.G("rm")
 | 
			
		||||
 | 
			
		||||
var AppSecretRmCommand = &cobra.Command{
 | 
			
		||||
	Use:     "remove <app> [[secret] | --all] [flags]",
 | 
			
		||||
	Aliases: []string{"rm"},
 | 
			
		||||
	Short:   "Remove a secret",
 | 
			
		||||
	// translators: `app secret remove` command
 | 
			
		||||
	Use:     i18n.G("remove <domain> [[secret] | --all] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appSecretRemoveAliases, ","),
 | 
			
		||||
	// translators: Short description for `app secret remove` command
 | 
			
		||||
	Short: i18n.G("Remove a secret"),
 | 
			
		||||
	Long: i18n.G(`This command removes a secret from an app environment.
 | 
			
		||||
 | 
			
		||||
Arbitrary secret removal is not supported. Secrets that are removed must
 | 
			
		||||
match those configured in the recipe beforehand.`),
 | 
			
		||||
	Example: i18n.G("  abra app secret rm 1312.net oauth_key"),
 | 
			
		||||
	Args:    cobra.RangeArgs(1, 2),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
		toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		toComplete string,
 | 
			
		||||
	) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		switch l := len(args); l {
 | 
			
		||||
		case 0:
 | 
			
		||||
			return autocomplete.AppNameComplete()
 | 
			
		||||
@ -245,8 +357,7 @@ var AppSecretRmCommand = &cobra.Command{
 | 
			
		||||
			if !rmAllSecrets {
 | 
			
		||||
				app, err := appPkg.Get(args[0])
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					errMsg := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
					return []string{errMsg}, cobra.ShellCompDirectiveError
 | 
			
		||||
					return []string{i18n.G("autocomplete failed: %s", err)}, cobra.ShellCompDirectiveError
 | 
			
		||||
				}
 | 
			
		||||
				return autocomplete.SecretComplete(app.Recipe.Name)
 | 
			
		||||
			}
 | 
			
		||||
@ -258,7 +369,7 @@ var AppSecretRmCommand = &cobra.Command{
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -273,11 +384,11 @@ var AppSecretRmCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(args) == 2 && rmAllSecrets {
 | 
			
		||||
			log.Fatal("cannot use [secret] and --all/-a together")
 | 
			
		||||
			log.Fatal(i18n.G("cannot use [secret] and --all/-a together"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(args) != 2 && !rmAllSecrets {
 | 
			
		||||
			log.Fatal("no secret(s) specified?")
 | 
			
		||||
			log.Fatal(i18n.G("no secret(s) specified?"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cl, err := client.New(app.Server)
 | 
			
		||||
@ -328,30 +439,37 @@ var AppSecretRmCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !match && secretToRm != "" {
 | 
			
		||||
			log.Fatalf("%s doesn't exist on server?", secretToRm)
 | 
			
		||||
			log.Fatal(i18n.G("%s doesn't exist on server?", secretToRm))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !match {
 | 
			
		||||
			log.Fatal("no secrets to remove?")
 | 
			
		||||
			log.Fatal(i18n.G("no secrets to remove?"))
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra app secret ls` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appSecretLsAliases = i18n.G("ls")
 | 
			
		||||
 | 
			
		||||
var AppSecretLsCommand = &cobra.Command{
 | 
			
		||||
	Use:     "list <app>",
 | 
			
		||||
	Aliases: []string{"ls"},
 | 
			
		||||
	Short:   "List all secrets",
 | 
			
		||||
	Args:    cobra.MinimumNArgs(1),
 | 
			
		||||
	// translators: `app secret list` command
 | 
			
		||||
	Use:     i18n.G("list <domain>"),
 | 
			
		||||
	Aliases: strings.Split(appSecretLsAliases, ","),
 | 
			
		||||
	// translators: Short description for `app secret list` command
 | 
			
		||||
	Short: i18n.G("List all secrets"),
 | 
			
		||||
	Args:  cobra.MinimumNArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
		toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		toComplete string,
 | 
			
		||||
	) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		return autocomplete.AppNameComplete()
 | 
			
		||||
	},
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -360,7 +478,7 @@ var AppSecretLsCommand = &cobra.Command{
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		headers := []string{"NAME", "VERSION", "GENERATED NAME", "CREATED ON SERVER"}
 | 
			
		||||
		headers := []string{i18n.G("NAME"), i18n.G("VERSION"), i18n.G("GENERATED NAME"), i18n.G("CREATED ON SERVER")}
 | 
			
		||||
		table, err := formatter.CreateTable()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
@ -373,6 +491,10 @@ var AppSecretLsCommand = &cobra.Command{
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Sort secrets to ensure reproducible output
 | 
			
		||||
		sort.Slice(secStats, func(i, j int) bool {
 | 
			
		||||
			return secStats[i].LocalName < secStats[j].LocalName
 | 
			
		||||
		})
 | 
			
		||||
		var rows [][]string
 | 
			
		||||
		for _, secStat := range secStats {
 | 
			
		||||
			row := []string{
 | 
			
		||||
@ -390,7 +512,7 @@ var AppSecretLsCommand = &cobra.Command{
 | 
			
		||||
			if internal.MachineReadable {
 | 
			
		||||
				out, err := formatter.ToJSON(headers, rows)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal("unable to render to JSON: %s", err)
 | 
			
		||||
					log.Fatal(i18n.G("unable to render to JSON: %s", err))
 | 
			
		||||
				}
 | 
			
		||||
				fmt.Println(out)
 | 
			
		||||
				return
 | 
			
		||||
@ -403,14 +525,16 @@ var AppSecretLsCommand = &cobra.Command{
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Warnf("no secrets stored for %s", app.Name)
 | 
			
		||||
		log.Warn(i18n.G("no secrets stored for %s", app.Name))
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var AppSecretCommand = &cobra.Command{
 | 
			
		||||
	Use:     "secret [cmd] [args] [flags]",
 | 
			
		||||
	Aliases: []string{"s"},
 | 
			
		||||
	Short:   "Manage app secrets",
 | 
			
		||||
	// translators: `app secret` command group
 | 
			
		||||
	Use:     i18n.G("secret [cmd] [args] [flags]"),
 | 
			
		||||
	Aliases: []string{i18n.G("s")},
 | 
			
		||||
	// translators: Short description for `app secret` command group
 | 
			
		||||
	Short: i18n.G("Manage app secrets"),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
@ -425,105 +549,105 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	AppSecretGenerateCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.MachineReadable,
 | 
			
		||||
		"machine",
 | 
			
		||||
		"m",
 | 
			
		||||
		i18n.G("machine"),
 | 
			
		||||
		i18n.G("m"),
 | 
			
		||||
		false,
 | 
			
		||||
		"print machine-readable output",
 | 
			
		||||
		i18n.G("print machine-readable output"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretGenerateCommand.Flags().BoolVarP(
 | 
			
		||||
		&storeInPass,
 | 
			
		||||
		"pass",
 | 
			
		||||
		"p",
 | 
			
		||||
		i18n.G("pass"),
 | 
			
		||||
		i18n.G("p"),
 | 
			
		||||
		false,
 | 
			
		||||
		"store generated secrets in a local pass store",
 | 
			
		||||
		i18n.G("store generated secrets in a local pass store"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretGenerateCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretGenerateCommand.Flags().BoolVarP(
 | 
			
		||||
		&generateAllSecrets,
 | 
			
		||||
		"all",
 | 
			
		||||
		"a",
 | 
			
		||||
		i18n.G("all"),
 | 
			
		||||
		i18n.GC("a", "app secret generate"),
 | 
			
		||||
		false,
 | 
			
		||||
		"generate all secrets",
 | 
			
		||||
		i18n.G("generate all secrets"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretInsertCommand.Flags().BoolVarP(
 | 
			
		||||
		&storeInPass,
 | 
			
		||||
		"pass",
 | 
			
		||||
		"p",
 | 
			
		||||
		i18n.G("pass"),
 | 
			
		||||
		i18n.G("p"),
 | 
			
		||||
		false,
 | 
			
		||||
		"store generated secrets in a local pass store",
 | 
			
		||||
		i18n.G("store generated secrets in a local pass store"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretInsertCommand.Flags().BoolVarP(
 | 
			
		||||
		&insertFromFile,
 | 
			
		||||
		"file",
 | 
			
		||||
		"f",
 | 
			
		||||
		i18n.G("file"),
 | 
			
		||||
		i18n.G("f"),
 | 
			
		||||
		false,
 | 
			
		||||
		"treat input as a file",
 | 
			
		||||
		i18n.G("treat input as a file"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretInsertCommand.Flags().BoolVarP(
 | 
			
		||||
		&trimInput,
 | 
			
		||||
		"trim",
 | 
			
		||||
		"t",
 | 
			
		||||
		i18n.G("trim"),
 | 
			
		||||
		i18n.G("t"),
 | 
			
		||||
		false,
 | 
			
		||||
		"trim input",
 | 
			
		||||
		i18n.G("trim input"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretInsertCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretRmCommand.Flags().BoolVarP(
 | 
			
		||||
		&rmAllSecrets,
 | 
			
		||||
		"all",
 | 
			
		||||
		"a",
 | 
			
		||||
		i18n.G("all"),
 | 
			
		||||
		i18n.GC("a", "app secret rm"),
 | 
			
		||||
		false,
 | 
			
		||||
		"remove all secrets",
 | 
			
		||||
		i18n.G("remove all secrets"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretRmCommand.Flags().BoolVarP(
 | 
			
		||||
		&removeFromPass,
 | 
			
		||||
		"pass",
 | 
			
		||||
		"p",
 | 
			
		||||
		i18n.G("pass"),
 | 
			
		||||
		i18n.G("p"),
 | 
			
		||||
		false,
 | 
			
		||||
		"remove generated secrets from a local pass store",
 | 
			
		||||
		i18n.G("remove generated secrets from a local pass store"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretRmCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretLsCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppSecretLsCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.MachineReadable,
 | 
			
		||||
		"machine",
 | 
			
		||||
		"m",
 | 
			
		||||
		i18n.G("machine"),
 | 
			
		||||
		i18n.G("m"),
 | 
			
		||||
		false,
 | 
			
		||||
		"print machine-readable output",
 | 
			
		||||
		i18n.G("print machine-readable output"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -9,6 +9,7 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/service"
 | 
			
		||||
	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
@ -16,11 +17,17 @@ import (
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app services` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var appServicesAliases = i18n.G("sr")
 | 
			
		||||
 | 
			
		||||
var AppServicesCommand = &cobra.Command{
 | 
			
		||||
	Use:     "services <app> [flags]",
 | 
			
		||||
	Aliases: []string{"sr"},
 | 
			
		||||
	Short:   "Display all services of an app",
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	// translators: `app services` command
 | 
			
		||||
	Use:     i18n.G("services <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appServicesAliases, ","),
 | 
			
		||||
	// translators: Short description for `app services` command
 | 
			
		||||
	Short: i18n.G("Display all services of an app"),
 | 
			
		||||
	Args:  cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -30,7 +37,7 @@ var AppServicesCommand = &cobra.Command{
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -45,7 +52,7 @@ var AppServicesCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !deployMeta.IsDeployed {
 | 
			
		||||
			log.Fatalf("%s is not deployed?", app.Name)
 | 
			
		||||
			log.Fatal(i18n.G("%s is not deployed?", app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		filters, err := app.Filters(true, true)
 | 
			
		||||
@ -63,7 +70,7 @@ var AppServicesCommand = &cobra.Command{
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		headers := []string{"SERVICE (SHORT)", "SERVICE (LONG)"}
 | 
			
		||||
		headers := []string{i18n.G("SERVICE (SHORT)"), i18n.G("SERVICE (LONG)")}
 | 
			
		||||
		table.Headers(headers...)
 | 
			
		||||
 | 
			
		||||
		var rows [][]string
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@ package app
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
@ -10,6 +11,7 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
@ -17,16 +19,21 @@ import (
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app undeploy` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appUndeployAliases = i18n.G("un")
 | 
			
		||||
 | 
			
		||||
var AppUndeployCommand = &cobra.Command{
 | 
			
		||||
	Use:     "undeploy <app> [flags]",
 | 
			
		||||
	Aliases: []string{"un"},
 | 
			
		||||
	Short:   "Undeploy an app",
 | 
			
		||||
	Long: `This does not destroy any application data.
 | 
			
		||||
	// translators: `app undeploy` command
 | 
			
		||||
	Use: i18n.G("undeploy <domain> [flags]"),
 | 
			
		||||
	// translators: Short description for `app undeploy` command
 | 
			
		||||
	Aliases: strings.Split(appUndeployAliases, ","),
 | 
			
		||||
	Long: i18n.G(`This does not destroy any application data.
 | 
			
		||||
 | 
			
		||||
However, you should remain vigilant, as your swarm installation will consider
 | 
			
		||||
any previously attached volumes as eligible for pruning once undeployed.
 | 
			
		||||
 | 
			
		||||
Passing "--prune/-p" does not remove those volumes.`,
 | 
			
		||||
Passing "--prune/-p" does not remove those volumes.`),
 | 
			
		||||
	Args: cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -38,12 +45,16 @@ Passing "--prune/-p" does not remove those volumes.`,
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
		stackName := app.StackName()
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.EnsureExists(); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cl, err := client.New(app.Server)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("checking whether %s is already deployed", stackName)
 | 
			
		||||
		log.Debug(i18n.G("checking whether %s is already deployed", stackName))
 | 
			
		||||
 | 
			
		||||
		deployMeta, err := stack.IsDeployed(context.Background(), cl, stackName)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
@ -51,23 +62,45 @@ Passing "--prune/-p" does not remove those volumes.`,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !deployMeta.IsDeployed {
 | 
			
		||||
			log.Fatalf("%s is not deployed?", app.Name)
 | 
			
		||||
			log.Fatal(i18n.G("%s is not deployed?", app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		chaosVersion := config.CHAOS_DEFAULT
 | 
			
		||||
		version := deployMeta.Version
 | 
			
		||||
		if deployMeta.IsChaos {
 | 
			
		||||
			chaosVersion = deployMeta.ChaosVersion
 | 
			
		||||
			version = deployMeta.ChaosVersion
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := internal.UndeployOverview(
 | 
			
		||||
		if err := internal.DeployOverview(
 | 
			
		||||
			app,
 | 
			
		||||
			deployMeta.Version,
 | 
			
		||||
			chaosVersion); err != nil {
 | 
			
		||||
			version,
 | 
			
		||||
			config.MISSING_DEFAULT,
 | 
			
		||||
			"",
 | 
			
		||||
			nil,
 | 
			
		||||
			nil,
 | 
			
		||||
			nil,
 | 
			
		||||
			nil,
 | 
			
		||||
		); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		opts := stack.Deploy{Composefiles: composeFiles, Namespace: stackName}
 | 
			
		||||
		compose, err := appPkg.GetAppComposeConfig(app.Name, opts, app.Env)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		stack.WaitTimeout, err = appPkg.GetTimeoutFromLabel(compose, stackName)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		rmOpts := stack.Remove{
 | 
			
		||||
			Namespaces: []string{app.StackName()},
 | 
			
		||||
			Namespaces: []string{stackName},
 | 
			
		||||
			Detach:     false,
 | 
			
		||||
		}
 | 
			
		||||
		if err := stack.RunRemove(context.Background(), cl, rmOpts); err != nil {
 | 
			
		||||
@ -80,9 +113,10 @@ Passing "--prune/-p" does not remove those volumes.`,
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("choosing %s as version to save to env file", deployMeta.Version)
 | 
			
		||||
		if err := app.WriteRecipeVersion(deployMeta.Version, false); err != nil {
 | 
			
		||||
			log.Fatalf("writing undeployed recipe version in env file: %s", err)
 | 
			
		||||
		log.Info(i18n.G("undeploy succeeded 🟢"))
 | 
			
		||||
 | 
			
		||||
		if err := app.WriteRecipeVersion(version, false); err != nil {
 | 
			
		||||
			log.Fatal(i18n.G("writing recipe version failed: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
@ -103,14 +137,14 @@ func pruneApp(cl *dockerClient.Client, app appPkg.App) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cntSpaceReclaimed := formatter.ByteCountSI(cr.SpaceReclaimed)
 | 
			
		||||
	log.Infof("containers pruned: %d; space reclaimed: %s", len(cr.ContainersDeleted), cntSpaceReclaimed)
 | 
			
		||||
	log.Info(i18n.G("containers pruned: %d; space reclaimed: %s", len(cr.ContainersDeleted), cntSpaceReclaimed))
 | 
			
		||||
 | 
			
		||||
	nr, err := cl.NetworksPrune(ctx, pruneFilters)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Infof("networks pruned: %d", len(nr.NetworksDeleted))
 | 
			
		||||
	log.Info(i18n.G("networks pruned: %d", len(nr.NetworksDeleted)))
 | 
			
		||||
 | 
			
		||||
	ir, err := cl.ImagesPrune(ctx, pruneFilters)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@ -118,7 +152,7 @@ func pruneApp(cl *dockerClient.Client, app appPkg.App) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	imgSpaceReclaimed := formatter.ByteCountSI(ir.SpaceReclaimed)
 | 
			
		||||
	log.Infof("images pruned: %d; space reclaimed: %s", len(ir.ImagesDeleted), imgSpaceReclaimed)
 | 
			
		||||
	log.Info(i18n.G("images pruned: %d; space reclaimed: %s", len(ir.ImagesDeleted), imgSpaceReclaimed))
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
@ -130,9 +164,9 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	AppUndeployCommand.Flags().BoolVarP(
 | 
			
		||||
		&prune,
 | 
			
		||||
		"prune",
 | 
			
		||||
		"p",
 | 
			
		||||
		i18n.G("prune"),
 | 
			
		||||
		i18n.G("p"),
 | 
			
		||||
		false,
 | 
			
		||||
		"prune unused containers, networks, and dangling images",
 | 
			
		||||
		i18n.G("prune unused containers, networks, and dangling images"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,46 +2,65 @@ package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/envfile"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/deploy"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/lint"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"coopcloud.tech/tagcmp"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var AppUpgradeCommand = &cobra.Command{
 | 
			
		||||
	Use:     "upgrade <app> [version] [flags]",
 | 
			
		||||
	Aliases: []string{"up"},
 | 
			
		||||
	Short:   "Upgrade an app",
 | 
			
		||||
	Long: `Upgrade an app.
 | 
			
		||||
// translators: `abra app upgrade` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appUpgradeAliases = i18n.G("up")
 | 
			
		||||
 | 
			
		||||
Unlike "deploy", chaos operations are not supported here. Only recipe versions
 | 
			
		||||
are supported values for "[version]".
 | 
			
		||||
var AppUpgradeCommand = &cobra.Command{
 | 
			
		||||
	// translators: `app upgrade` command
 | 
			
		||||
	Use:     i18n.G("upgrade <domain> [version] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appUpgradeAliases, ","),
 | 
			
		||||
	// translators: Short description for `app upgrade` command
 | 
			
		||||
	Short: i18n.G("Upgrade an app"),
 | 
			
		||||
	Long: i18n.G(`Upgrade an app.
 | 
			
		||||
 | 
			
		||||
Unlike "abra app deploy", chaos operations are not supported here. Only recipe
 | 
			
		||||
versions are supported values for "[version]".
 | 
			
		||||
 | 
			
		||||
It is possible to "--force/-f" an upgrade if you want to re-deploy a specific
 | 
			
		||||
version.
 | 
			
		||||
 | 
			
		||||
Only the deployed version is consulted when trying to determine what upgrades
 | 
			
		||||
are available. The live deployment version is the "source of truth" in this
 | 
			
		||||
case. The stored .env version is not consulted.
 | 
			
		||||
 | 
			
		||||
An upgrade can be destructive, please ensure you have a copy of your app data
 | 
			
		||||
beforehand.`,
 | 
			
		||||
beforehand. See "abra app backup" for more.`),
 | 
			
		||||
	Args: cobra.RangeArgs(1, 2),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
		toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		toComplete string,
 | 
			
		||||
	) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		switch l := len(args); l {
 | 
			
		||||
		case 0:
 | 
			
		||||
			return autocomplete.AppNameComplete()
 | 
			
		||||
		case 1:
 | 
			
		||||
			app, err := appPkg.Get(args[0])
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				errMsg := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
				return []string{errMsg}, cobra.ShellCompDirectiveError
 | 
			
		||||
				return []string{i18n.G("autocomplete failed: %s", err)}, cobra.ShellCompDirectiveError
 | 
			
		||||
			}
 | 
			
		||||
			return autocomplete.RecipeVersionComplete(app.Recipe.Name)
 | 
			
		||||
		default:
 | 
			
		||||
@ -49,22 +68,32 @@ beforehand.`,
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		var warnMessages []string
 | 
			
		||||
		var (
 | 
			
		||||
			upgradeWarnMessages []string
 | 
			
		||||
			chosenUpgrade       string
 | 
			
		||||
			availableUpgrades   []string
 | 
			
		||||
			upgradeReleaseNotes string
 | 
			
		||||
		)
 | 
			
		||||
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
		stackName := app.StackName()
 | 
			
		||||
 | 
			
		||||
		var specificVersion string
 | 
			
		||||
		if len(args) == 2 {
 | 
			
		||||
			specificVersion = args[1]
 | 
			
		||||
		if err := app.Recipe.Ensure(recipe.EnsureContext{
 | 
			
		||||
			Chaos:   internal.Chaos,
 | 
			
		||||
			Offline: internal.Offline,
 | 
			
		||||
			// Ignore the env version for now, to make sure we are at the latest commit.
 | 
			
		||||
			// This enables us to get release notes, that were added after a release.
 | 
			
		||||
			IgnoreEnvVersion: true,
 | 
			
		||||
		}); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if specificVersion != "" {
 | 
			
		||||
			log.Debugf("overriding env file version (%s) with %s", app.Recipe.Version, specificVersion)
 | 
			
		||||
			app.Recipe.Version = specificVersion
 | 
			
		||||
		cl, err := client.New(app.Server)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		deployMeta, err := ensureDeployed(cl, app)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -72,151 +101,82 @@ beforehand.`,
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("checking whether %s is already deployed", stackName)
 | 
			
		||||
 | 
			
		||||
		cl, err := client.New(app.Server)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		deployMeta, err := stack.IsDeployed(context.Background(), cl, stackName)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !deployMeta.IsDeployed {
 | 
			
		||||
			log.Fatalf("%s is not deployed?", app.Name)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		versions, err := app.Recipe.Tags()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var availableUpgrades []string
 | 
			
		||||
		if deployMeta.Version == "unknown" {
 | 
			
		||||
		// NOTE(d1): we've no idea what the live deployment version is, so every
 | 
			
		||||
		// possible upgrade can be shown. it's up to the user to make the choice
 | 
			
		||||
		if deployMeta.Version == config.UNKNOWN_DEFAULT {
 | 
			
		||||
			availableUpgrades = versions
 | 
			
		||||
			warnMessages = append(warnMessages, fmt.Sprintf("failed to determine deployed version of %s", app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if specificVersion != "" {
 | 
			
		||||
			parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
 | 
			
		||||
		if len(args) == 2 && args[1] != "" {
 | 
			
		||||
			chosenUpgrade = args[1]
 | 
			
		||||
 | 
			
		||||
			if err := validateUpgradeVersionArg(chosenUpgrade, app, deployMeta); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			availableUpgrades = append(availableUpgrades, chosenUpgrade)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if deployMeta.Version != config.UNKNOWN_DEFAULT && chosenUpgrade == "" {
 | 
			
		||||
			upgradeAvailable, err := ensureUpgradesAvailable(app, versions, &availableUpgrades, deployMeta)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatalf("'%s' is not a known version for %s", deployMeta.Version, app.Recipe.Name)
 | 
			
		||||
			}
 | 
			
		||||
			parsedSpecificVersion, err := tagcmp.Parse(specificVersion)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatalf("'%s' is not a known version for %s", specificVersion, app.Recipe.Name)
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if parsedSpecificVersion.IsLessThan(parsedDeployedVersion) && !parsedSpecificVersion.Equals(parsedDeployedVersion) {
 | 
			
		||||
				log.Fatalf("%s is not an upgrade for %s?", deployMeta.Version, specificVersion)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if parsedSpecificVersion.Equals(parsedDeployedVersion) && !internal.Force {
 | 
			
		||||
				log.Fatalf("%s is not an upgrade for %s?", deployMeta.Version, specificVersion)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			availableUpgrades = append(availableUpgrades, specificVersion)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if deployMeta.Version != "unknown" && specificVersion == "" {
 | 
			
		||||
			if deployMeta.IsChaos {
 | 
			
		||||
				warnMessages = append(warnMessages, fmt.Sprintf("attempting to upgrade a chaos deployment"))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for _, version := range versions {
 | 
			
		||||
				parsedVersion, err := tagcmp.Parse(version)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
				if parsedVersion.IsGreaterThan(parsedDeployedVersion) && !(parsedVersion.Equals(parsedDeployedVersion)) {
 | 
			
		||||
					availableUpgrades = append(availableUpgrades, version)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if len(availableUpgrades) == 0 && !internal.Force {
 | 
			
		||||
				log.Info("no available upgrades")
 | 
			
		||||
			if !upgradeAvailable {
 | 
			
		||||
				log.Info(i18n.G("no available upgrades"))
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var chosenUpgrade string
 | 
			
		||||
		if len(availableUpgrades) > 0 {
 | 
			
		||||
			if internal.Force || internal.NoInput || specificVersion != "" {
 | 
			
		||||
		if internal.Force || internal.NoInput || chosenUpgrade != "" {
 | 
			
		||||
			if len(availableUpgrades) > 0 {
 | 
			
		||||
				chosenUpgrade = availableUpgrades[len(availableUpgrades)-1]
 | 
			
		||||
				log.Debugf("choosing %s as version to upgrade to", chosenUpgrade)
 | 
			
		||||
			} else {
 | 
			
		||||
				msg := fmt.Sprintf("please select an upgrade (version: %s):", deployMeta.Version)
 | 
			
		||||
				if deployMeta.IsChaos {
 | 
			
		||||
					msg = fmt.Sprintf("please select an upgrade (version: %s, chaosVersion: %s):", deployMeta.Version, deployMeta.ChaosVersion)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				prompt := &survey.Select{
 | 
			
		||||
					Message: msg,
 | 
			
		||||
					Options: internal.SortVersionsDesc(availableUpgrades),
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if err := survey.AskOne(prompt, &chosenUpgrade); err != nil {
 | 
			
		||||
					return
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			if err := chooseUpgrade(availableUpgrades, deployMeta, &chosenUpgrade); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if internal.Force && chosenUpgrade == "" {
 | 
			
		||||
			warnMessages = append(warnMessages, fmt.Sprintf("%s is already upgraded to latest", app.Name))
 | 
			
		||||
		if internal.Force &&
 | 
			
		||||
			chosenUpgrade == "" &&
 | 
			
		||||
			deployMeta.Version != config.UNKNOWN_DEFAULT {
 | 
			
		||||
			chosenUpgrade = deployMeta.Version
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// if release notes written after git tag published, read them before we
 | 
			
		||||
		// check out the tag and then they'll appear to be missing. this covers
 | 
			
		||||
		// when we obviously will forget to write release notes before publishing
 | 
			
		||||
		var releaseNotes string
 | 
			
		||||
		if chosenUpgrade != "" {
 | 
			
		||||
			parsedChosenUpgrade, err := tagcmp.Parse(chosenUpgrade)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
			for _, version := range versions {
 | 
			
		||||
				parsedVersion, err := tagcmp.Parse(version)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
				if parsedVersion.IsGreaterThan(parsedDeployedVersion) && parsedVersion.IsLessThan(parsedChosenUpgrade) {
 | 
			
		||||
					note, err := app.Recipe.GetReleaseNotes(version)
 | 
			
		||||
					if err != nil {
 | 
			
		||||
						log.Fatal(err)
 | 
			
		||||
					}
 | 
			
		||||
					if note != "" {
 | 
			
		||||
						releaseNotes += fmt.Sprintf("%s\n", note)
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		if chosenUpgrade == "" {
 | 
			
		||||
			log.Fatal(i18n.G("unknown deployed version, unable to upgrade"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debug(i18n.G("choosing %s as version to upgrade", chosenUpgrade))
 | 
			
		||||
 | 
			
		||||
		// Get the release notes before checking out the new version in the
 | 
			
		||||
		// recipe. This enables us to get release notes, that were added after
 | 
			
		||||
		// a release.
 | 
			
		||||
		if err := getReleaseNotes(app, versions, chosenUpgrade, deployMeta, &upgradeReleaseNotes); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("choosing %s as version to upgrade", chosenUpgrade)
 | 
			
		||||
		if _, err := app.Recipe.EnsureVersion(chosenUpgrade); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		abraShEnv, err := envfile.ReadAbraShEnvVars(app.Recipe.AbraShPath)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
		if err := deploy.MergeAbraShEnv(app.Recipe, app.Env); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		for k, v := range abraShEnv {
 | 
			
		||||
			app.Env[k] = v
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		stackName := app.StackName()
 | 
			
		||||
		deployOpts := stack.Deploy{
 | 
			
		||||
			Composefiles: composeFiles,
 | 
			
		||||
			Namespace:    stackName,
 | 
			
		||||
@ -233,8 +193,9 @@ beforehand.`,
 | 
			
		||||
		appPkg.ExposeAllEnv(stackName, compose, app.Env)
 | 
			
		||||
		appPkg.SetRecipeLabel(compose, stackName, app.Recipe.Name)
 | 
			
		||||
		appPkg.SetChaosLabel(compose, stackName, internal.Chaos)
 | 
			
		||||
		appPkg.SetChaosVersionLabel(compose, stackName, chosenUpgrade)
 | 
			
		||||
		appPkg.SetUpdateLabel(compose, stackName, app.Env)
 | 
			
		||||
		if internal.Chaos {
 | 
			
		||||
			appPkg.SetChaosVersionLabel(compose, stackName, chosenUpgrade)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		envVars, err := appPkg.CheckEnv(app)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
@ -243,30 +204,57 @@ beforehand.`,
 | 
			
		||||
 | 
			
		||||
		for _, envVar := range envVars {
 | 
			
		||||
			if !envVar.Present {
 | 
			
		||||
				warnMessages = append(warnMessages,
 | 
			
		||||
					fmt.Sprintf("env var %s missing from %s.env, present in recipe .env.sample", envVar.Name, app.Domain),
 | 
			
		||||
				upgradeWarnMessages = append(upgradeWarnMessages,
 | 
			
		||||
					i18n.G("%s missing from %s.env", envVar.Name, app.Domain),
 | 
			
		||||
				)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Gather secrets
 | 
			
		||||
		secretInfo, err := deploy.GatherSecretsForDeploy(cl, app, internal.ShowUnchanged)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Gather configs
 | 
			
		||||
		configInfo, err := deploy.GatherConfigsForDeploy(cl, app, compose, app.Env, internal.ShowUnchanged)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Gather images
 | 
			
		||||
		imageInfo, err := deploy.GatherImagesForDeploy(cl, app, compose, internal.ShowUnchanged)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if showReleaseNotes {
 | 
			
		||||
			fmt.Print(releaseNotes)
 | 
			
		||||
			fmt.Print(upgradeReleaseNotes)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		chaosVersion := config.CHAOS_DEFAULT
 | 
			
		||||
		if deployMeta.IsChaos {
 | 
			
		||||
			chaosVersion = deployMeta.ChaosVersion
 | 
			
		||||
		if upgradeReleaseNotes == "" {
 | 
			
		||||
			upgradeWarnMessages = append(
 | 
			
		||||
				upgradeWarnMessages,
 | 
			
		||||
				fmt.Sprintf("no release notes available for %s", chosenUpgrade),
 | 
			
		||||
			)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := internal.NewVersionOverview(
 | 
			
		||||
		deployedVersion := deployMeta.Version
 | 
			
		||||
		if deployMeta.IsChaos {
 | 
			
		||||
			deployedVersion = deployMeta.ChaosVersion
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := internal.DeployOverview(
 | 
			
		||||
			app,
 | 
			
		||||
			warnMessages,
 | 
			
		||||
			"upgrade",
 | 
			
		||||
			deployMeta.Version,
 | 
			
		||||
			chaosVersion,
 | 
			
		||||
			deployedVersion,
 | 
			
		||||
			chosenUpgrade,
 | 
			
		||||
			releaseNotes); err != nil {
 | 
			
		||||
			upgradeReleaseNotes,
 | 
			
		||||
			upgradeWarnMessages,
 | 
			
		||||
			secretInfo,
 | 
			
		||||
			configInfo,
 | 
			
		||||
			imageInfo,
 | 
			
		||||
		); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -274,61 +262,234 @@ beforehand.`,
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		log.Debugf("set waiting timeout to %d s", stack.WaitTimeout)
 | 
			
		||||
 | 
			
		||||
		if err := stack.RunDeploy(cl, deployOpts, compose, stackName, internal.DontWaitConverge); err != nil {
 | 
			
		||||
		serviceNames, err := appPkg.GetAppServiceNames(app.Name)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		f, err := app.Filters(true, false, serviceNames...)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := stack.RunDeploy(
 | 
			
		||||
			cl,
 | 
			
		||||
			deployOpts,
 | 
			
		||||
			compose,
 | 
			
		||||
			stackName,
 | 
			
		||||
			app.Server,
 | 
			
		||||
			internal.DontWaitConverge,
 | 
			
		||||
			f,
 | 
			
		||||
		); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		postDeployCmds, ok := app.Env["POST_UPGRADE_CMDS"]
 | 
			
		||||
		if ok && !internal.DontWaitConverge {
 | 
			
		||||
			log.Debugf("run the following post-deploy commands: %s", postDeployCmds)
 | 
			
		||||
			log.Debug(i18n.G("run the following post-deploy commands: %s", postDeployCmds))
 | 
			
		||||
 | 
			
		||||
			if err := internal.PostCmds(cl, app, postDeployCmds); err != nil {
 | 
			
		||||
				log.Fatalf("attempting to run post deploy commands, saw: %s", err)
 | 
			
		||||
				log.Fatal(i18n.G("attempting to run post deploy commands, saw: %s", err))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		app.Recipe.Version = chosenUpgrade
 | 
			
		||||
		log.Debugf("choosing %s as version to save to env file", app.Recipe.Version)
 | 
			
		||||
		if err := app.WriteRecipeVersion(app.Recipe.Version, false); err != nil {
 | 
			
		||||
			log.Fatalf("writing new recipe version in env file: %s", err)
 | 
			
		||||
		if err := app.WriteRecipeVersion(chosenUpgrade, false); err != nil {
 | 
			
		||||
			log.Fatal(i18n.G("writing recipe version failed: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	showReleaseNotes bool
 | 
			
		||||
)
 | 
			
		||||
// chooseUpgrade prompts the user to choose an upgrade interactively.
 | 
			
		||||
func chooseUpgrade(
 | 
			
		||||
	availableUpgrades []string,
 | 
			
		||||
	deployMeta stack.DeployMeta,
 | 
			
		||||
	chosenUpgrade *string,
 | 
			
		||||
) error {
 | 
			
		||||
	msg := i18n.G("please select an upgrade (version: %s):", deployMeta.Version)
 | 
			
		||||
 | 
			
		||||
	if deployMeta.IsChaos {
 | 
			
		||||
		chaosVersion := formatter.BoldDirtyDefault(deployMeta.ChaosVersion)
 | 
			
		||||
 | 
			
		||||
		msg = i18n.G(
 | 
			
		||||
			"please select an upgrade (version: %s, chaos: %s):",
 | 
			
		||||
			deployMeta.Version,
 | 
			
		||||
			chaosVersion,
 | 
			
		||||
		)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	prompt := &survey.Select{
 | 
			
		||||
		Message: msg,
 | 
			
		||||
		Options: internal.SortVersionsDesc(availableUpgrades),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := survey.AskOne(prompt, chosenUpgrade); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getReleaseNotes(
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	versions []string,
 | 
			
		||||
	chosenUpgrade string,
 | 
			
		||||
	deployMeta stack.DeployMeta,
 | 
			
		||||
	upgradeReleaseNotes *string,
 | 
			
		||||
) error {
 | 
			
		||||
	parsedChosenUpgrade, err := tagcmp.Parse(chosenUpgrade)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.New(i18n.G("parsing chosen upgrade version failed: %s", err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.New(i18n.G("parsing deployment version failed: %s", err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, version := range internal.SortVersionsDesc(versions) {
 | 
			
		||||
		parsedVersion, err := tagcmp.Parse(version)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return errors.New(i18n.G("parsing recipe version failed: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if parsedVersion.IsGreaterThan(parsedDeployedVersion) &&
 | 
			
		||||
			parsedVersion.IsLessThan(parsedChosenUpgrade) {
 | 
			
		||||
			note, err := app.Recipe.GetReleaseNotes(version, app.Domain)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if note != "" {
 | 
			
		||||
				// NOTE(d1): trim any final newline on the end of the note itself before
 | 
			
		||||
				//           we manually handle newlines (for multiple release notes and
 | 
			
		||||
				//           ensuring space between the warning messages)
 | 
			
		||||
				note = strings.TrimSuffix(note, "\n")
 | 
			
		||||
 | 
			
		||||
				*upgradeReleaseNotes += fmt.Sprintf("%s\n", note)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ensureUpgradesAvailable ensures that there are available upgrades.
 | 
			
		||||
func ensureUpgradesAvailable(
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	versions []string,
 | 
			
		||||
	availableUpgrades *[]string,
 | 
			
		||||
	deployMeta stack.DeployMeta,
 | 
			
		||||
) (bool, error) {
 | 
			
		||||
	parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, errors.New(i18n.G("parsing deployed version failed: %s", err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, version := range versions {
 | 
			
		||||
		parsedVersion, err := tagcmp.Parse(version)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return false, errors.New(i18n.G("parsing recipe version failed: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if parsedVersion.IsGreaterThan(parsedDeployedVersion) &&
 | 
			
		||||
			!(parsedVersion.Equals(parsedDeployedVersion)) {
 | 
			
		||||
			*availableUpgrades = append(*availableUpgrades, version)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(*availableUpgrades) == 0 && !internal.Force {
 | 
			
		||||
		return false, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return true, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// validateUpgradeVersionArg validates the specific version.
 | 
			
		||||
func validateUpgradeVersionArg(
 | 
			
		||||
	specificVersion string,
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	deployMeta stack.DeployMeta,
 | 
			
		||||
) error {
 | 
			
		||||
	parsedSpecificVersion, err := tagcmp.Parse(specificVersion)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.New(i18n.G("'%s' is not a known version for %s", specificVersion, app.Recipe.Name))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.New(i18n.G("'%s' is not a known version", deployMeta.Version))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if parsedSpecificVersion.IsLessThan(parsedDeployedVersion) &&
 | 
			
		||||
		!parsedSpecificVersion.Equals(parsedDeployedVersion) {
 | 
			
		||||
		return errors.New(i18n.G("%s is not an upgrade for %s?", deployMeta.Version, specificVersion))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if parsedSpecificVersion.Equals(parsedDeployedVersion) && !internal.Force {
 | 
			
		||||
		return errors.New(i18n.G("%s is not an upgrade for %s?", deployMeta.Version, specificVersion))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ensureDeployed ensures the app is deployed and if so, returns deployment
 | 
			
		||||
// meta info.
 | 
			
		||||
func ensureDeployed(cl *dockerClient.Client, app appPkg.App) (stack.DeployMeta, error) {
 | 
			
		||||
	log.Debug(i18n.G("checking whether %s is already deployed", app.StackName()))
 | 
			
		||||
 | 
			
		||||
	deployMeta, err := stack.IsDeployed(context.Background(), cl, app.StackName())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return stack.DeployMeta{}, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !deployMeta.IsDeployed {
 | 
			
		||||
		return stack.DeployMeta{}, errors.New(i18n.G("%s is not deployed?", app.Name))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return deployMeta, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var showReleaseNotes bool
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppUpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Force,
 | 
			
		||||
		"force",
 | 
			
		||||
		"f",
 | 
			
		||||
		i18n.G("force"),
 | 
			
		||||
		i18n.G("f"),
 | 
			
		||||
		false,
 | 
			
		||||
		"perform action without further prompt",
 | 
			
		||||
		i18n.G("perform action without further prompt"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppUpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.NoDomainChecks,
 | 
			
		||||
		"no-domain-checks",
 | 
			
		||||
		"D",
 | 
			
		||||
		i18n.G("no-domain-checks"),
 | 
			
		||||
		i18n.G("D"),
 | 
			
		||||
		false,
 | 
			
		||||
		"disable public DNS checks",
 | 
			
		||||
		i18n.G("disable public DNS checks"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppUpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.DontWaitConverge, "no-converge-checks",
 | 
			
		||||
		"c",
 | 
			
		||||
		&internal.DontWaitConverge,
 | 
			
		||||
		i18n.G("no-converge-checks"),
 | 
			
		||||
		i18n.G("c"),
 | 
			
		||||
		false,
 | 
			
		||||
		"do not wait for converge logic checks",
 | 
			
		||||
		i18n.G("disable converge logic checks"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppUpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&showReleaseNotes,
 | 
			
		||||
		"releasenotes",
 | 
			
		||||
		"r",
 | 
			
		||||
		i18n.G("releasenotes"),
 | 
			
		||||
		i18n.G("r"),
 | 
			
		||||
		false,
 | 
			
		||||
		"only show release notes",
 | 
			
		||||
		i18n.G("only show release notes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	AppUpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.ShowUnchanged,
 | 
			
		||||
		i18n.G("show-unchanged"),
 | 
			
		||||
		i18n.G("U"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("show all configs & images, including unchanged ones"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,22 +2,31 @@ package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra app volume list` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appVolumeListAliases = i18n.G("ls")
 | 
			
		||||
 | 
			
		||||
var AppVolumeListCommand = &cobra.Command{
 | 
			
		||||
	Use:     "list <app> [flags]",
 | 
			
		||||
	Aliases: []string{"ls"},
 | 
			
		||||
	Short:   "List volumes associated with an app",
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	// translators: `app volume list` command
 | 
			
		||||
	Use:     i18n.G("list <domain> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appVolumeListAliases, ","),
 | 
			
		||||
	// translators: Short description for `app list` command
 | 
			
		||||
	Short: i18n.G("List volumes associated with an app"),
 | 
			
		||||
	Args:  cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -42,7 +51,7 @@ var AppVolumeListCommand = &cobra.Command{
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		headers := []string{"NAME", "ON SERVER"}
 | 
			
		||||
		headers := []string{i18n.G("NAME"), i18n.G("ON SERVER")}
 | 
			
		||||
 | 
			
		||||
		table, err := formatter.CreateTable()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
@ -66,24 +75,35 @@ var AppVolumeListCommand = &cobra.Command{
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Warnf("no volumes created for %s", app.Name)
 | 
			
		||||
		log.Warn(i18n.G("no volumes created for %s", app.Name))
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra app volume remove` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appVolumeRemoveAliases = i18n.G("rm")
 | 
			
		||||
 | 
			
		||||
var AppVolumeRemoveCommand = &cobra.Command{
 | 
			
		||||
	Use:   "remove <app> [flags]",
 | 
			
		||||
	Short: "Remove volume(s) associated with an app",
 | 
			
		||||
	Long: `Remove volumes associated with an app.
 | 
			
		||||
	// translators: `app volume remove` command
 | 
			
		||||
	Use: i18n.G("remove <domain> [volume] [flags]"),
 | 
			
		||||
	// translators: Short description for `app volume remove` command
 | 
			
		||||
	Short: i18n.G("Remove volume(s) associated with an app"),
 | 
			
		||||
	Long: i18n.G(`Remove volumes associated with an app.
 | 
			
		||||
 | 
			
		||||
The app in question must be undeployed before you try to remove volumes. See
 | 
			
		||||
"abra app undeploy <app>" for more.
 | 
			
		||||
"abra app undeploy <domain>" for more.
 | 
			
		||||
 | 
			
		||||
The command is interactive and will show a multiple select input which allows
 | 
			
		||||
you to make a seclection. Use the "?" key to see more help on navigating this
 | 
			
		||||
interface.
 | 
			
		||||
 | 
			
		||||
Passing "--force/-f" will select all volumes for removal. Be careful.`,
 | 
			
		||||
	Aliases: []string{"rm"},
 | 
			
		||||
Passing "--force/-f" will select all volumes for removal. Be careful.`),
 | 
			
		||||
	Example: i18n.G(`  # delete volumes interactively
 | 
			
		||||
  abra app volume rm 1312.net
 | 
			
		||||
 | 
			
		||||
  # delete specific volume
 | 
			
		||||
  abra app volume rm 1312.net my_volume`),
 | 
			
		||||
	Aliases: strings.Split(appVolumeRemoveAliases, ","),
 | 
			
		||||
	Args:    cobra.MinimumNArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -94,6 +114,11 @@ Passing "--force/-f" will select all volumes for removal. Be careful.`,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		app := internal.ValidateApp(args)
 | 
			
		||||
 | 
			
		||||
		var volumeToDelete string
 | 
			
		||||
		if len(args) == 2 {
 | 
			
		||||
			volumeToDelete = args[1]
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cl, err := client.New(app.Server)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
@ -105,7 +130,7 @@ Passing "--force/-f" will select all volumes for removal. Be careful.`,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if deployMeta.IsDeployed {
 | 
			
		||||
			log.Fatalf("%s is still deployed. Run \"abra app undeploy %s\"", app.Name, app.Name)
 | 
			
		||||
			log.Fatal(i18n.G("%s is still deployed. Run \"abra app undeploy %s\"", app.Name, app.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		filters, err := app.Filters(false, true)
 | 
			
		||||
@ -119,11 +144,35 @@ Passing "--force/-f" will select all volumes for removal. Be careful.`,
 | 
			
		||||
		}
 | 
			
		||||
		volumeNames := client.GetVolumeNames(volumeList)
 | 
			
		||||
 | 
			
		||||
		if volumeToDelete != "" {
 | 
			
		||||
			var exactMatch bool
 | 
			
		||||
 | 
			
		||||
			fullVolumeToDeleteName := fmt.Sprintf("%s_%s", app.StackName(), volumeToDelete)
 | 
			
		||||
			for _, volName := range volumeNames {
 | 
			
		||||
				if volName == fullVolumeToDeleteName {
 | 
			
		||||
					exactMatch = true
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if !exactMatch {
 | 
			
		||||
				log.Fatal(i18n.G("unable to remove volume: no volume with name '%s'?", volumeToDelete))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			err := client.RemoveVolumes(cl, context.Background(), []string{fullVolumeToDeleteName}, internal.Force, 5)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(i18n.G("removing volume %s failed: %s", volumeToDelete, err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Info(i18n.G("volume %s removed successfully", volumeToDelete))
 | 
			
		||||
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var volumesToRemove []string
 | 
			
		||||
		if !internal.Force && !internal.NoInput {
 | 
			
		||||
			volumesPrompt := &survey.MultiSelect{
 | 
			
		||||
				Message: "which volumes do you want to remove?",
 | 
			
		||||
				Help:    "'x' indicates selected, enter / return to confirm, ctrl-c to exit, vim mode is enabled",
 | 
			
		||||
				Message: i18n.G("which volumes do you want to remove?"),
 | 
			
		||||
				Help:    i18n.G("'x' indicates selected, enter / return to confirm, ctrl-c to exit, vim mode is enabled"),
 | 
			
		||||
				VimMode: true,
 | 
			
		||||
				Options: volumeNames,
 | 
			
		||||
				Default: volumeNames,
 | 
			
		||||
@ -140,28 +189,33 @@ Passing "--force/-f" will select all volumes for removal. Be careful.`,
 | 
			
		||||
		if len(volumesToRemove) > 0 {
 | 
			
		||||
			err := client.RemoveVolumes(cl, context.Background(), volumesToRemove, internal.Force, 5)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatalf("removing volumes failed: %s", err)
 | 
			
		||||
				log.Fatal(i18n.G("removing volumes failed: %s", err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Infof("%d volumes removed successfully", len(volumesToRemove))
 | 
			
		||||
			log.Info(i18n.G("%d volumes removed successfully", len(volumesToRemove)))
 | 
			
		||||
		} else {
 | 
			
		||||
			log.Info("no volumes removed")
 | 
			
		||||
			log.Info(i18n.G("no volumes removed"))
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra app volume` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appVolumeAliases = i18n.G("vl")
 | 
			
		||||
 | 
			
		||||
var AppVolumeCommand = &cobra.Command{
 | 
			
		||||
	Use:     "volume [cmd] [args] [flags]",
 | 
			
		||||
	Aliases: []string{"vl"},
 | 
			
		||||
	Short:   "Manage app volumes",
 | 
			
		||||
	// translators: `app volume` command group
 | 
			
		||||
	Use:     i18n.G("volume [cmd] [args] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appVolumeAliases, ","),
 | 
			
		||||
	Short:   i18n.G("Manage app volumes"),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppVolumeRemoveCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Force,
 | 
			
		||||
		"force",
 | 
			
		||||
		"f",
 | 
			
		||||
		i18n.G("force"),
 | 
			
		||||
		i18n.G("f"),
 | 
			
		||||
		false,
 | 
			
		||||
		"perform action without further prompt",
 | 
			
		||||
		i18n.G("perform action without further prompt"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,10 @@ import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
	"slices"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
@ -12,28 +15,72 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	gitPkg "coopcloud.tech/abra/pkg/git"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"github.com/go-git/go-git/v5"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra catalogue sync` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appCatalogueSyncAliases = i18n.G("s")
 | 
			
		||||
 | 
			
		||||
var CatalogueSyncCommand = &cobra.Command{
 | 
			
		||||
	// translators: `catalogue sync` command
 | 
			
		||||
	Use:     i18n.G("sync [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appCatalogueSyncAliases, ","),
 | 
			
		||||
	// translators: Short description for `catalogue sync` command
 | 
			
		||||
	Short: i18n.G("Sync recipe catalogue for latest changes"),
 | 
			
		||||
	Args:  cobra.NoArgs,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		if err := catalogue.EnsureCatalogue(); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := catalogue.EnsureUpToDate(); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Info(i18n.G("catalogue successfully synced"))
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra catalogue` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var appCatalogueAliases = i18n.G("g")
 | 
			
		||||
 | 
			
		||||
var CatalogueGenerateCommand = &cobra.Command{
 | 
			
		||||
	Use:     "generate [recipe] [flags]",
 | 
			
		||||
	Aliases: []string{"g"},
 | 
			
		||||
	Short:   "Generate the recipe catalogue",
 | 
			
		||||
	Long: `Generate a new copy of the recipe catalogue.
 | 
			
		||||
	// translators: `catalogue generate` command
 | 
			
		||||
	Use:     i18n.G("generate [recipe] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(appCatalogueAliases, ","),
 | 
			
		||||
	// translators: Short description for `catalogue generate` command
 | 
			
		||||
	Short: i18n.G("Generate the recipe catalogue"),
 | 
			
		||||
	Long: i18n.G(`Generate a new copy of the recipe catalogue.
 | 
			
		||||
 | 
			
		||||
N.B. this command **will** wipe local unstaged changes from your local recipes
 | 
			
		||||
if present. "--chaos/-C" on this command refers to the catalogue repository
 | 
			
		||||
("$ABRA_DIR/catalogue") and not the recipes. Please take care not to lose your
 | 
			
		||||
changes.
 | 
			
		||||
 | 
			
		||||
It is possible to generate new metadata for a single recipe by passing
 | 
			
		||||
[recipe]. The existing local catalogue will be updated, not overwritten.
 | 
			
		||||
 | 
			
		||||
It is quite easy to get rate limited by Docker Hub when running this command.
 | 
			
		||||
If you have a Hub account you can have Abra log you in to avoid this. Pass
 | 
			
		||||
"--user" and "--pass".
 | 
			
		||||
If you have a Hub account you can "docker login" and Abra will automatically
 | 
			
		||||
use those details.
 | 
			
		||||
 | 
			
		||||
Push your new release to git.coopcloud.tech with "--publish/-p". This requires
 | 
			
		||||
that you have permission to git push to these repositories and have your SSH
 | 
			
		||||
keys configured on your account.`,
 | 
			
		||||
Publish your new release to git.coopcloud.tech with "--publish/-p". This
 | 
			
		||||
requires that you have permission to git push to these repositories and have
 | 
			
		||||
your SSH keys configured on your account. Enable ssh-agent and make sure to add
 | 
			
		||||
your private key and enter your passphrase beforehand.
 | 
			
		||||
 | 
			
		||||
    eval ` + "`ssh-agent`" + `
 | 
			
		||||
    ssh-add ~/.ssh/<my-ssh-private-key-for-git-coopcloud-tech>`),
 | 
			
		||||
	Example: `  # publish catalogue
 | 
			
		||||
  eval ` + "`ssh-agent`" + `
 | 
			
		||||
  ssh-add ~/.ssh/id_ed25519
 | 
			
		||||
  abra catalogue generate -p`,
 | 
			
		||||
	Args: cobra.RangeArgs(0, 1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -47,56 +94,66 @@ keys configured on your account.`,
 | 
			
		||||
			recipeName = args[0]
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		r := recipe.Get(recipeName)
 | 
			
		||||
		if os.Getenv("SSH_AUTH_SOCK") == "" {
 | 
			
		||||
			log.Warn(i18n.G("ssh: SSH_AUTH_SOCK missing, --publish/-p will fail. see \"abra catalogue generate --help\""))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if recipeName != "" {
 | 
			
		||||
			internal.ValidateRecipe(args, cmd.Name())
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := catalogue.EnsureCatalogue(); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !internal.Chaos {
 | 
			
		||||
			if err := catalogue.EnsureIsClean(); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		repos, err := recipe.ReadReposMetadata()
 | 
			
		||||
		repos, err := recipe.ReadReposMetadata(internal.Debug)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var barLength int
 | 
			
		||||
		var logMsg string
 | 
			
		||||
		barLength := len(repos)
 | 
			
		||||
		if recipeName != "" {
 | 
			
		||||
			barLength = 1
 | 
			
		||||
			logMsg = fmt.Sprintf("ensuring %v recipe is cloned & up-to-date", barLength)
 | 
			
		||||
		} else {
 | 
			
		||||
			barLength = len(repos)
 | 
			
		||||
			logMsg = fmt.Sprintf("ensuring %v recipes are cloned & up-to-date, this could take some time...", barLength)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !skipUpdates {
 | 
			
		||||
			log.Warn(logMsg)
 | 
			
		||||
			if err := recipe.UpdateRepositories(repos, recipeName); err != nil {
 | 
			
		||||
			if err := recipe.UpdateRepositories(repos, recipeName, internal.Debug); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var warnings []string
 | 
			
		||||
		catl := make(recipe.RecipeCatalogue)
 | 
			
		||||
		catlBar := formatter.CreateProgressbar(barLength, "generating catalogue metadata...")
 | 
			
		||||
		catlBar := formatter.CreateProgressbar(barLength, i18n.G("collecting catalogue metadata"))
 | 
			
		||||
		for _, recipeMeta := range repos {
 | 
			
		||||
			if recipeName != "" && recipeName != recipeMeta.Name {
 | 
			
		||||
				catlBar.Add(1)
 | 
			
		||||
				if !internal.Debug {
 | 
			
		||||
					catlBar.Add(1)
 | 
			
		||||
				}
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			versions, err := r.GetRecipeVersions()
 | 
			
		||||
			r := recipe.Get(recipeMeta.Name)
 | 
			
		||||
			versions, warnMsgs, err := r.GetRecipeVersions()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Warn(err)
 | 
			
		||||
				warnings = append(warnings, err.Error())
 | 
			
		||||
			}
 | 
			
		||||
			if len(warnMsgs) > 0 {
 | 
			
		||||
				warnings = append(warnings, warnMsgs...)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			features, category, err := recipe.GetRecipeFeaturesAndCategory(r)
 | 
			
		||||
			features, category, warnMsgs, err := recipe.GetRecipeFeaturesAndCategory(r)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Warn(err)
 | 
			
		||||
				warnings = append(warnings, err.Error())
 | 
			
		||||
			}
 | 
			
		||||
			if len(warnMsgs) > 0 {
 | 
			
		||||
				warnings = append(warnings, warnMsgs...)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			catl[recipeMeta.Name] = recipe.RecipeMeta{
 | 
			
		||||
@ -112,7 +169,24 @@ keys configured on your account.`,
 | 
			
		||||
				Features:      features,
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			catlBar.Add(1)
 | 
			
		||||
			if !internal.Debug {
 | 
			
		||||
				catlBar.Add(1)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := catlBar.Close(); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var uniqueWarnings []string
 | 
			
		||||
		for _, w := range warnings {
 | 
			
		||||
			if !slices.Contains(uniqueWarnings, w) {
 | 
			
		||||
				uniqueWarnings = append(uniqueWarnings, w)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, warnMsg := range uniqueWarnings {
 | 
			
		||||
			log.Warn(warnMsg)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		recipesJSON, err := json.MarshalIndent(catl, "", "    ")
 | 
			
		||||
@ -142,7 +216,7 @@ keys configured on your account.`,
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Infof("generated new recipe catalogue in %s", config.RECIPES_JSON)
 | 
			
		||||
		log.Info(i18n.G("generated recipe catalogue: %s", config.RECIPES_JSON))
 | 
			
		||||
 | 
			
		||||
		cataloguePath := path.Join(config.ABRA_DIR, "catalogue")
 | 
			
		||||
		if publishChanges {
 | 
			
		||||
@ -154,11 +228,11 @@ keys configured on your account.`,
 | 
			
		||||
 | 
			
		||||
			if isClean {
 | 
			
		||||
				if !internal.Dry {
 | 
			
		||||
					log.Fatalf("no changes discovered in %s, nothing to publish?", cataloguePath)
 | 
			
		||||
					log.Fatal(i18n.G("no changes discovered in %s, nothing to publish?", cataloguePath))
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			msg := "chore: publish new catalogue release changes"
 | 
			
		||||
			msg := i18n.G("chore: publish new catalogue release changes")
 | 
			
		||||
			if err := gitPkg.Commit(cataloguePath, msg, internal.Dry); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
@ -168,7 +242,7 @@ keys configured on your account.`,
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			sshURL := fmt.Sprintf(config.SSH_URL_TEMPLATE, config.CATALOGUE_JSON_REPO_NAME)
 | 
			
		||||
			sshURL := fmt.Sprintf(config.TOOLSHED_SSH_URL_TEMPLATE, config.CATALOGUE_JSON_REPO_NAME)
 | 
			
		||||
			if err := gitPkg.CreateRemote(repo, "origin-ssh", sshURL, internal.Dry); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
@ -190,19 +264,21 @@ keys configured on your account.`,
 | 
			
		||||
 | 
			
		||||
		if !internal.Dry && publishChanges {
 | 
			
		||||
			url := fmt.Sprintf("%s/%s/commit/%s", config.REPOS_BASE_URL, config.CATALOGUE_JSON_REPO_NAME, head.Hash())
 | 
			
		||||
			log.Infof("new changes published: %s", url)
 | 
			
		||||
			log.Info(i18n.G("new changes published: %s", url))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if internal.Dry {
 | 
			
		||||
			log.Info("dry run: no changes published")
 | 
			
		||||
			log.Info(i18n.G("dry run: no changes published"))
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CatalogueCommand defines the `abra catalogue` command and sub-commands.
 | 
			
		||||
var CatalogueCommand = &cobra.Command{
 | 
			
		||||
	Use:     "catalogue [cmd] [args] [flags]",
 | 
			
		||||
	Short:   "Manage the recipe catalogue",
 | 
			
		||||
	// translators: `catalogue` command group
 | 
			
		||||
	Use: i18n.G("catalogue [cmd] [args] [flags]"),
 | 
			
		||||
	// translators: Short description for `catalogue` command group
 | 
			
		||||
	Short:   i18n.G("Manage the recipe catalogue"),
 | 
			
		||||
	Aliases: []string{"c"},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -214,33 +290,33 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	CatalogueGenerateCommand.Flags().BoolVarP(
 | 
			
		||||
		&publishChanges,
 | 
			
		||||
		"publish",
 | 
			
		||||
		"p",
 | 
			
		||||
		i18n.G("publish"),
 | 
			
		||||
		i18n.G("p"),
 | 
			
		||||
		false,
 | 
			
		||||
		"publish changes to git.coopcloud.tech",
 | 
			
		||||
		i18n.G("publish changes to git.coopcloud.tech"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	CatalogueGenerateCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Dry,
 | 
			
		||||
		"dry-run",
 | 
			
		||||
		"r",
 | 
			
		||||
		i18n.G("dry-run"),
 | 
			
		||||
		i18n.G("r"),
 | 
			
		||||
		false,
 | 
			
		||||
		"report changes that would be made",
 | 
			
		||||
		i18n.G("report changes that would be made"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	CatalogueGenerateCommand.Flags().BoolVarP(
 | 
			
		||||
		&skipUpdates,
 | 
			
		||||
		"skip-updates",
 | 
			
		||||
		"s",
 | 
			
		||||
		i18n.G("skip-updates"),
 | 
			
		||||
		i18n.G("s"),
 | 
			
		||||
		false,
 | 
			
		||||
		"skip updating recipe repositories",
 | 
			
		||||
		i18n.G("skip updating recipe repositories"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	CatalogueGenerateCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,27 +2,35 @@ package cli
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra autocomplete` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var autocompleteAliases = i18n.G("ac")
 | 
			
		||||
 | 
			
		||||
var AutocompleteCommand = &cobra.Command{
 | 
			
		||||
	Use:   "autocomplete [bash|zsh|fish|powershell]",
 | 
			
		||||
	Short: "Generate autocompletion script",
 | 
			
		||||
	Long: `To load completions:
 | 
			
		||||
	// translators: `autocomplete` command
 | 
			
		||||
	Use:     i18n.G("autocomplete [bash|zsh|fish|powershell]"),
 | 
			
		||||
	Aliases: strings.Split(autocompleteAliases, ","),
 | 
			
		||||
	// translators: Short description for `autocomplete` command
 | 
			
		||||
	Short: i18n.G("Generate autocompletion script"),
 | 
			
		||||
	Long: i18n.G(`To load completions:
 | 
			
		||||
 | 
			
		||||
Bash:
 | 
			
		||||
 | 
			
		||||
  # Load autocompletion for the current Bash session
 | 
			
		||||
  $ source <(abra autocomplete bash)
 | 
			
		||||
 | 
			
		||||
  # To load autocompletion for each session, execute once:
 | 
			
		||||
  # Linux:
 | 
			
		||||
  $ abra autocomplete bash > /etc/bash_completion.d/abra
 | 
			
		||||
  $ abra autocomplete bash | sudo tee /etc/bash_completion.d/abra
 | 
			
		||||
  # macOS:
 | 
			
		||||
  $ abra autocomplete bash > $(brew --prefix)/etc/bash_completion.d/abra
 | 
			
		||||
  $ abra autocomplete bash | sudo tee $(brew --prefix)/etc/bash_completion.d/abra
 | 
			
		||||
 | 
			
		||||
Zsh:
 | 
			
		||||
 | 
			
		||||
  # If shell autocompletion is not already enabled in your environment,
 | 
			
		||||
  # you will need to enable it.  You can execute the following once:
 | 
			
		||||
 | 
			
		||||
@ -34,19 +42,17 @@ Zsh:
 | 
			
		||||
  # You will need to start a new shell for this setup to take effect.
 | 
			
		||||
 | 
			
		||||
fish:
 | 
			
		||||
 | 
			
		||||
  $ abra autocomplete fish | source
 | 
			
		||||
 | 
			
		||||
  # To load autocompletions for each session, execute once:
 | 
			
		||||
  $ abra autocomplete fish > ~/.config/fish/completions/abra.fish
 | 
			
		||||
 | 
			
		||||
PowerShell:
 | 
			
		||||
 | 
			
		||||
  PS> abra autocomplete powershell | Out-String | Invoke-Expression
 | 
			
		||||
 | 
			
		||||
  # To load autocompletions for every new session, run:
 | 
			
		||||
  PS> abra autocomplete powershell > abra.ps1
 | 
			
		||||
  # and source this file from your PowerShell profile.`,
 | 
			
		||||
  # and source this file from your PowerShell profile.`),
 | 
			
		||||
	DisableFlagsInUseLine: true,
 | 
			
		||||
	ValidArgs:             []string{"bash", "zsh", "fish", "powershell"},
 | 
			
		||||
	Args:                  cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
 | 
			
		||||
 | 
			
		||||
@ -2,16 +2,18 @@ package internal
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"io"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	containerPkg "coopcloud.tech/abra/pkg/container"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/service"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/container"
 | 
			
		||||
	"github.com/docker/cli/cli/command"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	containertypes "github.com/docker/docker/api/types/container"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
)
 | 
			
		||||
@ -21,10 +23,10 @@ func RetrieveBackupBotContainer(cl *dockerClient.Client) (types.Container, error
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	chosenService, err := service.GetServiceByLabel(ctx, cl, config.BackupbotLabel, NoInput)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return types.Container{}, fmt.Errorf("no backupbot discovered, is it deployed?")
 | 
			
		||||
		return types.Container{}, errors.New(i18n.G("no backupbot discovered, is it deployed?"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("retrieved %s as backup enabled service", chosenService.Spec.Name)
 | 
			
		||||
	log.Debug(i18n.G("retrieved %s as backup enabled service", chosenService.Spec.Name))
 | 
			
		||||
 | 
			
		||||
	filters := filters.NewArgs()
 | 
			
		||||
	filters.Add("name", chosenService.Spec.Name)
 | 
			
		||||
@ -47,7 +49,7 @@ func RunBackupCmdRemote(
 | 
			
		||||
	backupCmd string,
 | 
			
		||||
	containerID string,
 | 
			
		||||
	execEnv []string) (io.Writer, error) {
 | 
			
		||||
	execBackupListOpts := types.ExecConfig{
 | 
			
		||||
	execBackupListOpts := containertypes.ExecOptions{
 | 
			
		||||
		AttachStderr: true,
 | 
			
		||||
		AttachStdin:  true,
 | 
			
		||||
		AttachStdout: true,
 | 
			
		||||
@ -57,7 +59,7 @@ func RunBackupCmdRemote(
 | 
			
		||||
		Tty:          true,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("running backup %s on %s with exec config %v", backupCmd, containerID, execBackupListOpts)
 | 
			
		||||
	log.Debug(i18n.G("running backup %s on %s with exec config %v", backupCmd, containerID, execBackupListOpts))
 | 
			
		||||
 | 
			
		||||
	// FIXME: avoid instantiating a new CLI
 | 
			
		||||
	dcli, err := command.NewDockerCli()
 | 
			
		||||
 | 
			
		||||
@ -5,9 +5,12 @@ var (
 | 
			
		||||
	Debug   bool
 | 
			
		||||
	NoInput bool
 | 
			
		||||
	Offline bool
 | 
			
		||||
	Help    bool
 | 
			
		||||
	Version bool
 | 
			
		||||
 | 
			
		||||
	// NOTE(d1): sub-command specific
 | 
			
		||||
	Chaos            bool
 | 
			
		||||
	DeployLatest     bool
 | 
			
		||||
	DontWaitConverge bool
 | 
			
		||||
	Dry              bool
 | 
			
		||||
	Force            bool
 | 
			
		||||
@ -16,4 +19,5 @@ var (
 | 
			
		||||
	Minor            bool
 | 
			
		||||
	NoDomainChecks   bool
 | 
			
		||||
	Patch            bool
 | 
			
		||||
	ShowUnchanged    bool
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@ package internal
 | 
			
		||||
import (
 | 
			
		||||
	"bufio"
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"os/exec"
 | 
			
		||||
@ -11,10 +12,11 @@ import (
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	containerPkg "coopcloud.tech/abra/pkg/container"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/container"
 | 
			
		||||
	"github.com/docker/cli/cli/command"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	containertypes "github.com/docker/docker/api/types/container"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/docker/docker/pkg/archive"
 | 
			
		||||
@ -24,7 +26,7 @@ import (
 | 
			
		||||
func RunCmdRemote(
 | 
			
		||||
	cl *dockerClient.Client,
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	requestTTY bool,
 | 
			
		||||
	disableTTY bool,
 | 
			
		||||
	abraSh, serviceName, cmdName, cmdArgs, remoteUser string) error {
 | 
			
		||||
	filters := filters.NewArgs()
 | 
			
		||||
	filters.Add("name", fmt.Sprintf("^%s_%s", app.StackName(), serviceName))
 | 
			
		||||
@ -34,7 +36,7 @@ func RunCmdRemote(
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("retrieved %s as target container on %s", formatter.ShortenID(targetContainer.ID), app.Server)
 | 
			
		||||
	log.Debug(i18n.G("retrieved %s as target container on %s", formatter.ShortenID(targetContainer.ID), app.Server))
 | 
			
		||||
 | 
			
		||||
	toTarOpts := &archive.TarOptions{NoOverwriteDirNonDir: true, Compression: archive.Gzip}
 | 
			
		||||
	content, err := archive.TarWithOptions(abraSh, toTarOpts)
 | 
			
		||||
@ -42,7 +44,7 @@ func RunCmdRemote(
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	copyOpts := types.CopyToContainerOptions{AllowOverwriteDirWithFile: false, CopyUIDGID: false}
 | 
			
		||||
	copyOpts := containertypes.CopyToContainerOptions{AllowOverwriteDirWithFile: false, CopyUIDGID: false}
 | 
			
		||||
	if err := cl.CopyToContainer(context.Background(), targetContainer.ID, "/tmp", content, copyOpts); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
@ -55,7 +57,7 @@ func RunCmdRemote(
 | 
			
		||||
 | 
			
		||||
	shell := "/bin/bash"
 | 
			
		||||
	findShell := []string{"test", "-e", shell}
 | 
			
		||||
	execCreateOpts := types.ExecConfig{
 | 
			
		||||
	execCreateOpts := containertypes.ExecOptions{
 | 
			
		||||
		AttachStderr: true,
 | 
			
		||||
		AttachStdin:  true,
 | 
			
		||||
		AttachStdout: true,
 | 
			
		||||
@ -65,7 +67,7 @@ func RunCmdRemote(
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, err := container.RunExec(dcli, cl, targetContainer.ID, &execCreateOpts); err != nil {
 | 
			
		||||
		log.Infof("%s does not exist for %s, use /bin/sh as fallback", shell, app.Name)
 | 
			
		||||
		log.Info(i18n.G("%s does not exist for %s, use /bin/sh as fallback", shell, app.Name))
 | 
			
		||||
		shell = "/bin/sh"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -76,17 +78,19 @@ func RunCmdRemote(
 | 
			
		||||
		cmd = []string{shell, "-c", fmt.Sprintf("TARGET=%s; APP_NAME=%s; STACK_NAME=%s; . /tmp/abra.sh; %s", serviceName, app.Name, app.StackName(), cmdName)}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("running command: %s", strings.Join(cmd, " "))
 | 
			
		||||
	log.Debug(i18n.G("running command: %s", strings.Join(cmd, " ")))
 | 
			
		||||
 | 
			
		||||
	if remoteUser != "" {
 | 
			
		||||
		log.Debugf("running command with user %s", remoteUser)
 | 
			
		||||
		log.Debug(i18n.G("running command with user %s", remoteUser))
 | 
			
		||||
		execCreateOpts.User = remoteUser
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	execCreateOpts.Cmd = cmd
 | 
			
		||||
	execCreateOpts.Tty = requestTTY
 | 
			
		||||
	if !requestTTY {
 | 
			
		||||
		log.Debugf("not requesting a remote TTY")
 | 
			
		||||
 | 
			
		||||
	execCreateOpts.Tty = true
 | 
			
		||||
	if disableTTY {
 | 
			
		||||
		execCreateOpts.Tty = false
 | 
			
		||||
		log.Debug(i18n.G("not requesting a remote TTY"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, err := container.RunExec(dcli, cl, targetContainer.ID, &execCreateOpts); err != nil {
 | 
			
		||||
@ -103,7 +107,7 @@ func EnsureCommand(abraSh, recipeName, execCmd string) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !strings.Contains(string(bytes), execCmd) {
 | 
			
		||||
		return fmt.Errorf("%s doesn't have a %s function", recipeName, execCmd)
 | 
			
		||||
		return errors.New(i18n.G("%s doesn't have a %s function", recipeName, execCmd))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
package internal
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"sort"
 | 
			
		||||
@ -9,6 +10,7 @@ import (
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/tagcmp"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
@ -37,88 +39,24 @@ func horizontal(left, mid, right string) string {
 | 
			
		||||
	return lipgloss.JoinHorizontal(lipgloss.Left, left, mid, right)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewVersionOverview shows an upgrade or downgrade overview
 | 
			
		||||
func NewVersionOverview(
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	warnMessages []string,
 | 
			
		||||
	kind,
 | 
			
		||||
	deployedVersion,
 | 
			
		||||
	deployedChaosVersion,
 | 
			
		||||
	toDeployVersion,
 | 
			
		||||
	releaseNotes string) error {
 | 
			
		||||
	deployConfig := "compose.yml"
 | 
			
		||||
	if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
 | 
			
		||||
		deployConfig = composeFiles
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	server := app.Server
 | 
			
		||||
	if app.Server == "default" {
 | 
			
		||||
		server = "local"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	domain := app.Domain
 | 
			
		||||
	if domain == "" {
 | 
			
		||||
		domain = config.NO_DOMAIN_DEFAULT
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rows := [][]string{
 | 
			
		||||
		[]string{"APP", domain},
 | 
			
		||||
		[]string{"RECIPE", app.Recipe.Name},
 | 
			
		||||
		[]string{"SERVER", server},
 | 
			
		||||
		[]string{"DEPLOYED", deployedVersion},
 | 
			
		||||
		[]string{"CURRENT CHAOS ", deployedChaosVersion},
 | 
			
		||||
		[]string{fmt.Sprintf("TO %s", strings.ToUpper(kind)), toDeployVersion},
 | 
			
		||||
		[]string{"CONFIG", deployConfig},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	overview := formatter.CreateOverview(
 | 
			
		||||
		fmt.Sprintf("%s OVERVIEW", strings.ToUpper(kind)),
 | 
			
		||||
		rows,
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	fmt.Println(overview)
 | 
			
		||||
 | 
			
		||||
	if releaseNotes != "" && toDeployVersion != "" {
 | 
			
		||||
		fmt.Print(releaseNotes)
 | 
			
		||||
	} else {
 | 
			
		||||
		warnMessages = append(
 | 
			
		||||
			warnMessages,
 | 
			
		||||
			fmt.Sprintf("no release notes available for %s", toDeployVersion),
 | 
			
		||||
		)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, msg := range warnMessages {
 | 
			
		||||
		log.Warn(msg)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if NoInput {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	response := false
 | 
			
		||||
	prompt := &survey.Confirm{Message: "proceed?"}
 | 
			
		||||
	if err := survey.AskOne(prompt, &response); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !response {
 | 
			
		||||
		log.Fatal("deployment cancelled")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
func formatComposeFiles(composeFiles string) string {
 | 
			
		||||
	return strings.ReplaceAll(composeFiles, ":", "\n")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DeployOverview shows a deployment overview
 | 
			
		||||
func DeployOverview(
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	warnMessages []string,
 | 
			
		||||
	deployedVersion string,
 | 
			
		||||
	deployedChaosVersion string,
 | 
			
		||||
	toDeployVersion,
 | 
			
		||||
	toDeployChaosVersion string) error {
 | 
			
		||||
	toDeployVersion string,
 | 
			
		||||
	releaseNotes string,
 | 
			
		||||
	warnMessages []string,
 | 
			
		||||
	secrets []string,
 | 
			
		||||
	configs []string,
 | 
			
		||||
	images []string,
 | 
			
		||||
) error {
 | 
			
		||||
	deployConfig := "compose.yml"
 | 
			
		||||
	if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
 | 
			
		||||
		deployConfig = composeFiles
 | 
			
		||||
		deployConfig = formatComposeFiles(composeFiles)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	server := app.Server
 | 
			
		||||
@ -128,24 +66,58 @@ func DeployOverview(
 | 
			
		||||
 | 
			
		||||
	domain := app.Domain
 | 
			
		||||
	if domain == "" {
 | 
			
		||||
		domain = config.NO_DOMAIN_DEFAULT
 | 
			
		||||
		domain = config.MISSING_DEFAULT
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	envVersion := app.Recipe.EnvVersionRaw
 | 
			
		||||
	if envVersion == "" {
 | 
			
		||||
		envVersion = config.MISSING_DEFAULT
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rows := [][]string{
 | 
			
		||||
		[]string{"APP", domain},
 | 
			
		||||
		[]string{"RECIPE", app.Recipe.Name},
 | 
			
		||||
		[]string{"SERVER", server},
 | 
			
		||||
		[]string{"DEPLOYED", deployedVersion},
 | 
			
		||||
		[]string{"CURRENT CHAOS ", deployedChaosVersion},
 | 
			
		||||
		[]string{"TO DEPLOY", toDeployVersion},
 | 
			
		||||
		[]string{"NEW CHAOS", toDeployChaosVersion},
 | 
			
		||||
		[]string{"CONFIG", deployConfig},
 | 
			
		||||
		{i18n.G("DOMAIN"), domain},
 | 
			
		||||
		{i18n.G("RECIPE"), app.Recipe.Name},
 | 
			
		||||
		{i18n.G("SERVER"), server},
 | 
			
		||||
		{i18n.G("CONFIG"), deployConfig},
 | 
			
		||||
		{"", ""},
 | 
			
		||||
		{i18n.G("CURRENT DEPLOYMENT"), formatter.BoldDirtyDefault(deployedVersion)},
 | 
			
		||||
		{i18n.G("ENV VERSION"), formatter.BoldDirtyDefault(envVersion)},
 | 
			
		||||
		{i18n.G("NEW DEPLOYMENT"), formatter.BoldDirtyDefault(toDeployVersion)},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	overview := formatter.CreateOverview("DEPLOY OVERVIEW", rows)
 | 
			
		||||
	if len(images) > 0 {
 | 
			
		||||
		imageRows := [][]string{
 | 
			
		||||
			{"", ""},
 | 
			
		||||
			{i18n.G("IMAGES"), strings.Join(images, "\n")},
 | 
			
		||||
		}
 | 
			
		||||
		rows = append(rows, imageRows...)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(secrets) > 0 {
 | 
			
		||||
		secretsRows := [][]string{
 | 
			
		||||
			{"", ""},
 | 
			
		||||
			{i18n.G("SECRETS"), strings.Join(secrets, "\n")},
 | 
			
		||||
		}
 | 
			
		||||
		rows = append(rows, secretsRows...)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(configs) > 0 {
 | 
			
		||||
		configsRows := [][]string{
 | 
			
		||||
			{"", ""},
 | 
			
		||||
			{i18n.G("CONFIGS"), strings.Join(configs, "\n")},
 | 
			
		||||
		}
 | 
			
		||||
		rows = append(rows, configsRows...)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	deployType := getDeployType(deployedVersion, toDeployVersion)
 | 
			
		||||
	overview := formatter.CreateOverview(i18n.G("%s OVERVIEW", deployType), rows)
 | 
			
		||||
 | 
			
		||||
	fmt.Println(overview)
 | 
			
		||||
 | 
			
		||||
	if releaseNotes != "" {
 | 
			
		||||
		fmt.Print(releaseNotes)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, msg := range warnMessages {
 | 
			
		||||
		log.Warn(msg)
 | 
			
		||||
	}
 | 
			
		||||
@ -161,22 +133,57 @@ func DeployOverview(
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !response {
 | 
			
		||||
		log.Fatal("deployment cancelled")
 | 
			
		||||
		log.Fatal(i18n.G("deployment cancelled"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UndeployOverview shows an undeployment overview
 | 
			
		||||
func UndeployOverview(
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	version,
 | 
			
		||||
	chaosVersion string) error {
 | 
			
		||||
	deployConfig := "compose.yml"
 | 
			
		||||
	if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
 | 
			
		||||
		deployConfig = composeFiles
 | 
			
		||||
func getDeployType(currentVersion, newVersion string) string {
 | 
			
		||||
	if newVersion == config.MISSING_DEFAULT {
 | 
			
		||||
		return i18n.G("UNDEPLOY")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if strings.Contains(newVersion, "+U") {
 | 
			
		||||
		return i18n.G("CHAOS DEPLOY")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if strings.Contains(currentVersion, "+U") {
 | 
			
		||||
		return i18n.G("UNCHAOS DEPLOY")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if currentVersion == newVersion {
 | 
			
		||||
		return ("REDEPLOY")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if currentVersion == config.MISSING_DEFAULT {
 | 
			
		||||
		return i18n.G("NEW DEPLOY")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	currentParsed, err := tagcmp.Parse(currentVersion)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return i18n.G("DEPLOY")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	newParsed, err := tagcmp.Parse(newVersion)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return i18n.G("DEPLOY")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if currentParsed.IsLessThan(newParsed) {
 | 
			
		||||
		return i18n.G("UPGRADE")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return i18n.G("DOWNGRADE")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MoveOverview shows a overview before moving an app to a different server
 | 
			
		||||
func MoveOverview(
 | 
			
		||||
	app appPkg.App,
 | 
			
		||||
	newServer string,
 | 
			
		||||
	secrets []string,
 | 
			
		||||
	volumes []string,
 | 
			
		||||
) {
 | 
			
		||||
	server := app.Server
 | 
			
		||||
	if app.Server == "default" {
 | 
			
		||||
		server = "local"
 | 
			
		||||
@ -184,34 +191,50 @@ func UndeployOverview(
 | 
			
		||||
 | 
			
		||||
	domain := app.Domain
 | 
			
		||||
	if domain == "" {
 | 
			
		||||
		domain = config.NO_DOMAIN_DEFAULT
 | 
			
		||||
		domain = config.MISSING_DEFAULT
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	secretsOverview := strings.Join(secrets, "\n")
 | 
			
		||||
	if len(secrets) == 0 {
 | 
			
		||||
		secretsOverview = config.MISSING_DEFAULT
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	volumesOverview := strings.Join(volumes, "\n")
 | 
			
		||||
	if len(volumes) == 0 {
 | 
			
		||||
		volumesOverview = config.MISSING_DEFAULT
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rows := [][]string{
 | 
			
		||||
		[]string{"APP", domain},
 | 
			
		||||
		[]string{"RECIPE", app.Recipe.Name},
 | 
			
		||||
		[]string{"SERVER", server},
 | 
			
		||||
		[]string{"DEPLOYED", version},
 | 
			
		||||
		[]string{"CHAOS", chaosVersion},
 | 
			
		||||
		[]string{"CONFIG", deployConfig},
 | 
			
		||||
		{i18n.G("DOMAIN"), domain},
 | 
			
		||||
		{i18n.G("RECIPE"), app.Recipe.Name},
 | 
			
		||||
		{i18n.G("OLD SERVER"), server},
 | 
			
		||||
		{i18n.G("NEW SERVER"), newServer},
 | 
			
		||||
		{i18n.G("SECRETS"), secretsOverview},
 | 
			
		||||
		{i18n.G("VOLUMES"), volumesOverview},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	overview := formatter.CreateOverview("UNDEPLOY OVERVIEW", rows)
 | 
			
		||||
	overview := formatter.CreateOverview(i18n.G("MOVE OVERVIEW"), rows)
 | 
			
		||||
 | 
			
		||||
	fmt.Println(overview)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func PromptProcced() error {
 | 
			
		||||
	if NoInput {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if Dry {
 | 
			
		||||
		return errors.New(i18n.G("dry run"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	response := false
 | 
			
		||||
	prompt := &survey.Confirm{Message: "proceed?"}
 | 
			
		||||
	prompt := &survey.Confirm{Message: i18n.G("proceed?")}
 | 
			
		||||
	if err := survey.AskOne(prompt, &response); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !response {
 | 
			
		||||
		log.Fatal("undeploy cancelled")
 | 
			
		||||
		return errors.New(i18n.G("cancelled"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
@ -223,7 +246,7 @@ func UndeployOverview(
 | 
			
		||||
func PostCmds(cl *dockerClient.Client, app appPkg.App, commands string) error {
 | 
			
		||||
	if _, err := os.Stat(app.Recipe.AbraShPath); err != nil {
 | 
			
		||||
		if os.IsNotExist(err) {
 | 
			
		||||
			return fmt.Errorf(fmt.Sprintf("%s does not exist for %s?", app.Recipe.AbraShPath, app.Name))
 | 
			
		||||
			return errors.New(i18n.G("%s does not exist for %s?", app.Recipe.AbraShPath, app.Name))
 | 
			
		||||
		}
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
@ -231,7 +254,7 @@ func PostCmds(cl *dockerClient.Client, app appPkg.App, commands string) error {
 | 
			
		||||
	for _, command := range strings.Split(commands, "|") {
 | 
			
		||||
		commandParts := strings.Split(command, " ")
 | 
			
		||||
		if len(commandParts) < 2 {
 | 
			
		||||
			return fmt.Errorf(fmt.Sprintf("not enough arguments: %s", command))
 | 
			
		||||
			return errors.New(i18n.G("not enough arguments: %s", command))
 | 
			
		||||
		}
 | 
			
		||||
		targetServiceName := commandParts[0]
 | 
			
		||||
		cmdName := commandParts[1]
 | 
			
		||||
@ -239,7 +262,7 @@ func PostCmds(cl *dockerClient.Client, app appPkg.App, commands string) error {
 | 
			
		||||
		if len(commandParts) > 2 {
 | 
			
		||||
			parsedCmdArgs = fmt.Sprintf("%s ", strings.Join(commandParts[2:], " "))
 | 
			
		||||
		}
 | 
			
		||||
		log.Infof("running post-command '%s %s' in container %s", cmdName, parsedCmdArgs, targetServiceName)
 | 
			
		||||
		log.Info(i18n.G("running post-command '%s %s' in container %s", cmdName, parsedCmdArgs, targetServiceName))
 | 
			
		||||
 | 
			
		||||
		if err := EnsureCommand(app.Recipe.AbraShPath, app.Recipe.Name, cmdName); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
@ -258,10 +281,10 @@ func PostCmds(cl *dockerClient.Client, app appPkg.App, commands string) error {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !matchingServiceName {
 | 
			
		||||
			return fmt.Errorf(fmt.Sprintf("no service %s for %s?", targetServiceName, app.Name))
 | 
			
		||||
			return fmt.Errorf("no service %s for %s?", targetServiceName, app.Name)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("running command %s %s within the context of %s_%s", cmdName, parsedCmdArgs, app.StackName(), targetServiceName)
 | 
			
		||||
		log.Debug(i18n.G("running command %s %s within the context of %s_%s", cmdName, parsedCmdArgs, app.StackName(), targetServiceName))
 | 
			
		||||
 | 
			
		||||
		requestTTY := true
 | 
			
		||||
		if err := RunCmdRemote(
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								cli/internal/deploy_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								cli/internal/deploy_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
package internal
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestSortVersionsDesc(t *testing.T) {
 | 
			
		||||
	versions := SortVersionsDesc([]string{
 | 
			
		||||
		"0.2.3+1.2.2",
 | 
			
		||||
		"1.0.0+2.2.2",
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	assert.Equal(t, "1.0.0+2.2.2", versions[0])
 | 
			
		||||
	assert.Equal(t, "0.2.3+1.2.2", versions[1])
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								cli/internal/ensure.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								cli/internal/ensure.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
package internal
 | 
			
		||||
 | 
			
		||||
import "coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
 | 
			
		||||
func GetEnsureContext() recipe.EnsureContext {
 | 
			
		||||
	return recipe.EnsureContext{
 | 
			
		||||
		Chaos,
 | 
			
		||||
		Offline,
 | 
			
		||||
		DeployLatest,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -1,18 +0,0 @@
 | 
			
		||||
package internal
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/urfave/cli/v3"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ShowSubcommandHelpAndError exits the program on error, logs the error to the
 | 
			
		||||
// terminal, and shows the help command.
 | 
			
		||||
func ShowSubcommandHelpAndError(cmd *cli.Command, err interface{}) {
 | 
			
		||||
	if err2 := cli.ShowSubcommandHelp(cmd); err2 != nil {
 | 
			
		||||
		log.Error(err2)
 | 
			
		||||
	}
 | 
			
		||||
	log.Error(err)
 | 
			
		||||
	os.Exit(1)
 | 
			
		||||
}
 | 
			
		||||
@ -1,9 +1,11 @@
 | 
			
		||||
package internal
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
@ -11,9 +13,9 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// PromptBumpType prompts for version bump type
 | 
			
		||||
func PromptBumpType(tagString, latestRelease string) error {
 | 
			
		||||
func PromptBumpType(tagString, latestRelease, changeOverview string) error {
 | 
			
		||||
	if (!Major && !Minor && !Patch) && tagString == "" {
 | 
			
		||||
		fmt.Printf(`
 | 
			
		||||
		fmt.Print(i18n.G(`
 | 
			
		||||
You need to make a decision about what kind of an update this new recipe
 | 
			
		||||
version is. If someone else performs this upgrade, do they have to do some
 | 
			
		||||
migration work or take care of some breaking changes? This can be signaled in
 | 
			
		||||
@ -22,6 +24,8 @@ version.
 | 
			
		||||
 | 
			
		||||
The latest published version is %s.
 | 
			
		||||
 | 
			
		||||
%s
 | 
			
		||||
 | 
			
		||||
Here is a semver cheat sheet (more on https://semver.org):
 | 
			
		||||
 | 
			
		||||
    major: new features/bug fixes, backwards incompatible (e.g 1.0.0 -> 2.0.0).
 | 
			
		||||
@ -36,12 +40,12 @@ Here is a semver cheat sheet (more on https://semver.org):
 | 
			
		||||
           should also Just Work and is mostly to do with minor bug fixes
 | 
			
		||||
           and/or security patches. "nothing to worry about".
 | 
			
		||||
 | 
			
		||||
`, latestRelease)
 | 
			
		||||
`, latestRelease, changeOverview))
 | 
			
		||||
 | 
			
		||||
		var chosenBumpType string
 | 
			
		||||
		prompt := &survey.Select{
 | 
			
		||||
			Message: fmt.Sprintf("select recipe version increment type"),
 | 
			
		||||
			Options: []string{"major", "minor", "patch"},
 | 
			
		||||
			Options: []string{i18n.G("major"), i18n.G("minor"), i18n.G("patch")},
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := survey.AskOne(prompt, &chosenBumpType); err != nil {
 | 
			
		||||
@ -59,13 +63,13 @@ func GetBumpType() string {
 | 
			
		||||
	var bumpType string
 | 
			
		||||
 | 
			
		||||
	if Major {
 | 
			
		||||
		bumpType = "major"
 | 
			
		||||
		bumpType = i18n.G("major")
 | 
			
		||||
	} else if Minor {
 | 
			
		||||
		bumpType = "minor"
 | 
			
		||||
		bumpType = i18n.G("minor")
 | 
			
		||||
	} else if Patch {
 | 
			
		||||
		bumpType = "patch"
 | 
			
		||||
		bumpType = i18n.G("patch")
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Fatal("no version bump type specififed?")
 | 
			
		||||
		log.Fatal(i18n.G("no version bump type specififed?"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return bumpType
 | 
			
		||||
@ -73,14 +77,14 @@ func GetBumpType() string {
 | 
			
		||||
 | 
			
		||||
// SetBumpType figures out which bump type is specified
 | 
			
		||||
func SetBumpType(bumpType string) {
 | 
			
		||||
	if bumpType == "major" {
 | 
			
		||||
	if bumpType == i18n.G("major") {
 | 
			
		||||
		Major = true
 | 
			
		||||
	} else if bumpType == "minor" {
 | 
			
		||||
	} else if bumpType == i18n.G("minor") {
 | 
			
		||||
		Minor = true
 | 
			
		||||
	} else if bumpType == "patch" {
 | 
			
		||||
	} else if bumpType == i18n.G("patch") {
 | 
			
		||||
		Patch = true
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Fatal("no version bump type specififed?")
 | 
			
		||||
		log.Fatal(i18n.G("no version bump type specififed?"))
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -107,7 +111,7 @@ func GetMainAppImage(recipe recipe.Recipe) (string, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if path == "" {
 | 
			
		||||
		return path, fmt.Errorf("%s has no main 'app' service?", recipe.Name)
 | 
			
		||||
		return path, errors.New(i18n.G("%s has no main 'app' service?", recipe.Name))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return path, nil
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@ import (
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
@ -17,36 +18,36 @@ func ValidateRecipe(args []string, cmdName string) recipe.Recipe {
 | 
			
		||||
		recipeName = args[0]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if recipeName == "" && !NoInput {
 | 
			
		||||
		var recipes []string
 | 
			
		||||
	var recipes []string
 | 
			
		||||
 | 
			
		||||
		catl, err := recipe.ReadRecipeCatalogue(Offline)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
	catl, err := recipe.ReadRecipeCatalogue(Offline)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		knownRecipes := make(map[string]bool)
 | 
			
		||||
		for name := range catl {
 | 
			
		||||
			knownRecipes[name] = true
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		localRecipes, err := recipe.GetRecipesLocal()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
	knownRecipes := make(map[string]bool)
 | 
			
		||||
	for name := range catl {
 | 
			
		||||
		knownRecipes[name] = true
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	localRecipes, err := recipe.GetRecipesLocal()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Debug(i18n.G("can't read local recipes: %s", err))
 | 
			
		||||
	} else {
 | 
			
		||||
		for _, recipeLocal := range localRecipes {
 | 
			
		||||
			if _, ok := knownRecipes[recipeLocal]; !ok {
 | 
			
		||||
				knownRecipes[recipeLocal] = true
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		for recipeName := range knownRecipes {
 | 
			
		||||
			recipes = append(recipes, recipeName)
 | 
			
		||||
		}
 | 
			
		||||
	for recipeName := range knownRecipes {
 | 
			
		||||
		recipes = append(recipes, recipeName)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if recipeName == "" && !NoInput {
 | 
			
		||||
		prompt := &survey.Select{
 | 
			
		||||
			Message: "Select recipe",
 | 
			
		||||
			Message: i18n.G("Select recipe"),
 | 
			
		||||
			Options: recipes,
 | 
			
		||||
		}
 | 
			
		||||
		if err := survey.AskOne(prompt, &recipeName); err != nil {
 | 
			
		||||
@ -55,30 +56,36 @@ func ValidateRecipe(args []string, cmdName string) recipe.Recipe {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if recipeName == "" {
 | 
			
		||||
		log.Fatal("no recipe name provided")
 | 
			
		||||
		log.Fatal(i18n.G("no recipe name provided"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, ok := knownRecipes[recipeName]; !ok {
 | 
			
		||||
		if !strings.Contains(recipeName, "/") {
 | 
			
		||||
			log.Fatal(i18n.G("no recipe '%s' exists?", recipeName))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	chosenRecipe := recipe.Get(recipeName)
 | 
			
		||||
	err := chosenRecipe.EnsureExists()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
	if err := chosenRecipe.EnsureExists(); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_, err = chosenRecipe.GetComposeConfig(nil)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if cmdName == "generate" {
 | 
			
		||||
		if cmdName == i18n.G("generate") {
 | 
			
		||||
			if strings.Contains(err.Error(), "missing a compose") {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
			log.Warn(err)
 | 
			
		||||
		} else {
 | 
			
		||||
			if strings.Contains(err.Error(), "template_driver is not allowed") {
 | 
			
		||||
				log.Warnf("ensure %s recipe compose.* files include \"version: '3.8'\"", recipeName)
 | 
			
		||||
				log.Warn(i18n.G("ensure %s recipe compose.* files include \"version: '3.8'\"", recipeName))
 | 
			
		||||
			}
 | 
			
		||||
			log.Fatalf("unable to validate recipe: %s", err)
 | 
			
		||||
			log.Fatal(i18n.G("unable to validate recipe: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("validated %s as recipe argument", recipeName)
 | 
			
		||||
	log.Debug(i18n.G("validated %s as recipe argument", recipeName))
 | 
			
		||||
 | 
			
		||||
	return chosenRecipe
 | 
			
		||||
}
 | 
			
		||||
@ -86,7 +93,7 @@ func ValidateRecipe(args []string, cmdName string) recipe.Recipe {
 | 
			
		||||
// ValidateApp ensures the app name arg is valid.
 | 
			
		||||
func ValidateApp(args []string) app.App {
 | 
			
		||||
	if len(args) == 0 {
 | 
			
		||||
		log.Fatal("no app provided")
 | 
			
		||||
		log.Fatal(i18n.G("no app provided"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	appName := args[0]
 | 
			
		||||
@ -96,7 +103,7 @@ func ValidateApp(args []string) app.App {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("validated %s as app argument", appName)
 | 
			
		||||
	log.Debug(i18n.G("validated %s as app argument", appName))
 | 
			
		||||
 | 
			
		||||
	return app
 | 
			
		||||
}
 | 
			
		||||
@ -110,8 +117,8 @@ func ValidateDomain(args []string) string {
 | 
			
		||||
 | 
			
		||||
	if domainName == "" && !NoInput {
 | 
			
		||||
		prompt := &survey.Input{
 | 
			
		||||
			Message: "Specify a domain name",
 | 
			
		||||
			Default: "example.com",
 | 
			
		||||
			Message: i18n.G("Specify a domain name"),
 | 
			
		||||
			Default: "1312.net",
 | 
			
		||||
		}
 | 
			
		||||
		if err := survey.AskOne(prompt, &domainName); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
@ -119,10 +126,10 @@ func ValidateDomain(args []string) string {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if domainName == "" {
 | 
			
		||||
		log.Fatal("no domain provided")
 | 
			
		||||
		log.Fatal(i18n.G("no domain provided"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("validated %s as domain argument", domainName)
 | 
			
		||||
	log.Debug(i18n.G("validated %s as domain argument", domainName))
 | 
			
		||||
 | 
			
		||||
	return domainName
 | 
			
		||||
}
 | 
			
		||||
@ -141,7 +148,7 @@ func ValidateServer(args []string) string {
 | 
			
		||||
 | 
			
		||||
	if serverName == "" && !NoInput {
 | 
			
		||||
		prompt := &survey.Select{
 | 
			
		||||
			Message: "Specify a server name",
 | 
			
		||||
			Message: i18n.G("Specify a server name"),
 | 
			
		||||
			Options: serverNames,
 | 
			
		||||
		}
 | 
			
		||||
		if err := survey.AskOne(prompt, &serverName); err != nil {
 | 
			
		||||
@ -157,14 +164,14 @@ func ValidateServer(args []string) string {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if serverName == "" {
 | 
			
		||||
		log.Fatal("no server provided")
 | 
			
		||||
		log.Fatal(i18n.G("no server provided"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !matched {
 | 
			
		||||
		log.Fatal("server doesn't exist?")
 | 
			
		||||
		log.Fatal(i18n.G("server doesn't exist?"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("validated %s as server argument", serverName)
 | 
			
		||||
	log.Debug(i18n.G("validated %s as server argument", serverName))
 | 
			
		||||
 | 
			
		||||
	return serverName
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,19 +1,28 @@
 | 
			
		||||
package recipe
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	gitPkg "coopcloud.tech/abra/pkg/git"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe diff` aliases. use a comma separated list of aliases
 | 
			
		||||
// with no spaces in between
 | 
			
		||||
var recipeDiffAliases = i18n.G("d")
 | 
			
		||||
 | 
			
		||||
var RecipeDiffCommand = &cobra.Command{
 | 
			
		||||
	Use:     "diff <recipe> [flags]",
 | 
			
		||||
	Aliases: []string{"d"},
 | 
			
		||||
	Short:   "Show unstaged changes in recipe config",
 | 
			
		||||
	Long:    "This command requires /usr/bin/git.",
 | 
			
		||||
	Args:    cobra.MinimumNArgs(1),
 | 
			
		||||
	// translators: `recipe diff` command
 | 
			
		||||
	Use:     i18n.G("diff <recipe> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(recipeDiffAliases, ","),
 | 
			
		||||
	// translators: Short description for `recipe diff` command
 | 
			
		||||
	Short: i18n.G("Show unstaged changes in recipe config"),
 | 
			
		||||
	Long:  i18n.G("This command requires /usr/bin/git."),
 | 
			
		||||
	Args:  cobra.MinimumNArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
 | 
			
		||||
@ -1,19 +1,40 @@
 | 
			
		||||
package recipe
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"github.com/go-git/go-git/v5"
 | 
			
		||||
	gitCfg "github.com/go-git/go-git/v5/config"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe fetch` aliases. use a comma separated list of aliases
 | 
			
		||||
// with no spaces in between
 | 
			
		||||
var recipeFetchAliases = i18n.G("f")
 | 
			
		||||
 | 
			
		||||
var RecipeFetchCommand = &cobra.Command{
 | 
			
		||||
	Use:     "fetch [recipe | --all] [flags]",
 | 
			
		||||
	Aliases: []string{"f"},
 | 
			
		||||
	Short:   "Clone recipe(s) locally",
 | 
			
		||||
	Args:    cobra.RangeArgs(0, 1),
 | 
			
		||||
	// translators: `recipe fetch` command
 | 
			
		||||
	Use:     i18n.G("fetch [recipe | --all] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(recipeFetchAliases, ","),
 | 
			
		||||
	// translators: Short description for `recipe fetch` command
 | 
			
		||||
	Short: i18n.G("Clone recipe(s) locally"),
 | 
			
		||||
	Long:  i18n.G(`Using "--force/-f" Git syncs an existing recipe. It does not erase unstaged changes.`),
 | 
			
		||||
	Args:  cobra.RangeArgs(0, 1),
 | 
			
		||||
	Example: i18n.G(`  # fetch from recipe catalogue
 | 
			
		||||
  abra recipe fetch gitea
 | 
			
		||||
 | 
			
		||||
  # fetch from remote recipe
 | 
			
		||||
  abra recipe fetch git.foo.org/recipes/myrecipe
 | 
			
		||||
 | 
			
		||||
  # fetch with ssh remote for hacking
 | 
			
		||||
  abra recipe fetch gitea --ssh`),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -27,18 +48,47 @@ var RecipeFetchCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if recipeName == "" && !fetchAllRecipes {
 | 
			
		||||
			log.Fatal("missing [recipe] or --all/-a")
 | 
			
		||||
			log.Fatal(i18n.G("missing [recipe] or --all/-a"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if recipeName != "" && fetchAllRecipes {
 | 
			
		||||
			log.Fatal("cannot use [recipe] and --all/-a together")
 | 
			
		||||
			log.Fatal(i18n.G("cannot use [recipe] and --all/-a together"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if recipeName != "" {
 | 
			
		||||
			r := internal.ValidateRecipe(args, cmd.Name())
 | 
			
		||||
			if err := r.Ensure(false, false); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			r := recipe.Get(recipeName)
 | 
			
		||||
			if _, err := os.Stat(r.Dir); !os.IsNotExist(err) {
 | 
			
		||||
				if !force {
 | 
			
		||||
					log.Warn(i18n.G("%s is already fetched", r.Name))
 | 
			
		||||
					return
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			r = internal.ValidateRecipe(args, cmd.Name())
 | 
			
		||||
 | 
			
		||||
			if sshRemote {
 | 
			
		||||
				if r.SSHURL == "" {
 | 
			
		||||
					log.Warn(i18n.G("unable to discover SSH remote for %s", r.Name))
 | 
			
		||||
					return
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				repo, err := git.PlainOpen(r.Dir)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(i18n.G("unable to open %s: %s", r.Dir, err))
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if err = repo.DeleteRemote("origin"); err != nil {
 | 
			
		||||
					log.Fatal(i18n.G("unable to remove default remote in %s: %s", r.Dir, err))
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if _, err := repo.CreateRemote(&gitCfg.RemoteConfig{
 | 
			
		||||
					Name: "origin",
 | 
			
		||||
					URLs: []string{r.SSHURL},
 | 
			
		||||
				}); err != nil {
 | 
			
		||||
					log.Fatal(i18n.G("unable to set SSH remote in %s: %s", r.Dir, err))
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -47,10 +97,11 @@ var RecipeFetchCommand = &cobra.Command{
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		catlBar := formatter.CreateProgressbar(len(catalogue), "fetching latest recipes...")
 | 
			
		||||
		catlBar := formatter.CreateProgressbar(len(catalogue), i18n.G("fetching latest recipes..."))
 | 
			
		||||
		ensureCtx := internal.GetEnsureContext()
 | 
			
		||||
		for recipeName := range catalogue {
 | 
			
		||||
			r := recipe.Get(recipeName)
 | 
			
		||||
			if err := r.Ensure(false, false); err != nil {
 | 
			
		||||
			if err := r.Ensure(ensureCtx); err != nil {
 | 
			
		||||
				log.Error(err)
 | 
			
		||||
			}
 | 
			
		||||
			catlBar.Add(1)
 | 
			
		||||
@ -60,14 +111,32 @@ var RecipeFetchCommand = &cobra.Command{
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	fetchAllRecipes bool
 | 
			
		||||
	sshRemote       bool
 | 
			
		||||
	force           bool
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	RecipeFetchCommand.Flags().BoolVarP(
 | 
			
		||||
		&fetchAllRecipes,
 | 
			
		||||
		"all",
 | 
			
		||||
		"a",
 | 
			
		||||
		i18n.G("all"),
 | 
			
		||||
		i18n.GC("a", "recipe fetch"),
 | 
			
		||||
		false,
 | 
			
		||||
		"fetch all recipes",
 | 
			
		||||
		i18n.G("fetch all recipes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeFetchCommand.Flags().BoolVarP(
 | 
			
		||||
		&sshRemote,
 | 
			
		||||
		i18n.G("ssh"),
 | 
			
		||||
		i18n.G("s"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("automatically set ssh remote"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeFetchCommand.Flags().BoolVarP(
 | 
			
		||||
		&force,
 | 
			
		||||
		i18n.G("force"),
 | 
			
		||||
		i18n.G("f"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("force re-fetch"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,18 +1,27 @@
 | 
			
		||||
package recipe
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/lint"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe lint` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var recipeLintAliases = i18n.G("l")
 | 
			
		||||
 | 
			
		||||
var RecipeLintCommand = &cobra.Command{
 | 
			
		||||
	Use:     "lint <recipe> [flags]",
 | 
			
		||||
	Short:   "Lint a recipe",
 | 
			
		||||
	Aliases: []string{"l"},
 | 
			
		||||
	// translators: `recipe lint` command
 | 
			
		||||
	Use: i18n.G("lint <recipe> [flags]"),
 | 
			
		||||
	// translators: Short description for `recipe lint` command
 | 
			
		||||
	Short:   i18n.G("Lint a recipe"),
 | 
			
		||||
	Aliases: strings.Split(recipeLintAliases, ","),
 | 
			
		||||
	Args:    cobra.MinimumNArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -23,17 +32,17 @@ var RecipeLintCommand = &cobra.Command{
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		recipe := internal.ValidateRecipe(args, cmd.Name())
 | 
			
		||||
 | 
			
		||||
		if err := recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		headers := []string{
 | 
			
		||||
			"ref",
 | 
			
		||||
			"rule",
 | 
			
		||||
			"severity",
 | 
			
		||||
			"satisfied",
 | 
			
		||||
			"skipped",
 | 
			
		||||
			"resolve",
 | 
			
		||||
			i18n.G("ref"),
 | 
			
		||||
			i18n.G("rule"),
 | 
			
		||||
			i18n.G("severity"),
 | 
			
		||||
			i18n.G("satisfied"),
 | 
			
		||||
			i18n.G("skipped"),
 | 
			
		||||
			i18n.G("resolve"),
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		table, err := formatter.CreateTable()
 | 
			
		||||
@ -49,7 +58,7 @@ var RecipeLintCommand = &cobra.Command{
 | 
			
		||||
		for level := range lint.LintRules {
 | 
			
		||||
			for _, rule := range lint.LintRules[level] {
 | 
			
		||||
				if onlyError && rule.Level != "error" {
 | 
			
		||||
					log.Debugf("skipping %s, does not have level \"error\"", rule.Ref)
 | 
			
		||||
					log.Debug(i18n.G("skipping %s, does not have level \"error\"", rule.Ref))
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
@ -70,7 +79,7 @@ var RecipeLintCommand = &cobra.Command{
 | 
			
		||||
						warnMessages = append(warnMessages, err.Error())
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					if !ok && rule.Level == "error" {
 | 
			
		||||
					if !ok && rule.Level == i18n.G("error") {
 | 
			
		||||
						hasError = true
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
@ -111,7 +120,7 @@ var RecipeLintCommand = &cobra.Command{
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if hasError {
 | 
			
		||||
				log.Warnf("critical errors present in %s config", recipe.Name)
 | 
			
		||||
				log.Warn(i18n.G("critical errors present in %s config", recipe.Name))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
@ -124,17 +133,17 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	RecipeLintCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		i18n.G("chaos"),
 | 
			
		||||
		i18n.G("C"),
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
		i18n.G("ignore uncommitted recipes changes"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeLintCommand.Flags().BoolVarP(
 | 
			
		||||
		&onlyError,
 | 
			
		||||
		"error",
 | 
			
		||||
		"e",
 | 
			
		||||
		i18n.G("error"),
 | 
			
		||||
		i18n.G("e"),
 | 
			
		||||
		false,
 | 
			
		||||
		"only show errors",
 | 
			
		||||
		i18n.G("only show errors"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -8,15 +8,22 @@ import (
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe list` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var recipeListAliases = i18n.G("ls")
 | 
			
		||||
 | 
			
		||||
var RecipeListCommand = &cobra.Command{
 | 
			
		||||
	Use:     "list",
 | 
			
		||||
	Short:   "List recipes",
 | 
			
		||||
	Aliases: []string{"ls"},
 | 
			
		||||
	// translators: `recipe list` command
 | 
			
		||||
	Use: i18n.G("list"),
 | 
			
		||||
	// translators: Short description for `recipe list` command
 | 
			
		||||
	Short:   i18n.G("List recipes"),
 | 
			
		||||
	Aliases: strings.Split(recipeListAliases, ","),
 | 
			
		||||
	Args:    cobra.NoArgs,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		catl, err := recipe.ReadRecipeCatalogue(internal.Offline)
 | 
			
		||||
@ -33,14 +40,14 @@ var RecipeListCommand = &cobra.Command{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		headers := []string{
 | 
			
		||||
			"name",
 | 
			
		||||
			"category",
 | 
			
		||||
			"status",
 | 
			
		||||
			"healthcheck",
 | 
			
		||||
			"backups",
 | 
			
		||||
			"email",
 | 
			
		||||
			"tests",
 | 
			
		||||
			"SSO",
 | 
			
		||||
			i18n.G("name"),
 | 
			
		||||
			i18n.G("category"),
 | 
			
		||||
			i18n.G("status"),
 | 
			
		||||
			i18n.G("healthcheck"),
 | 
			
		||||
			i18n.G("backups"),
 | 
			
		||||
			i18n.G("email"),
 | 
			
		||||
			i18n.G("tests"),
 | 
			
		||||
			i18n.G("SSO"),
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		table.Headers(headers...)
 | 
			
		||||
@ -73,7 +80,7 @@ var RecipeListCommand = &cobra.Command{
 | 
			
		||||
			if internal.MachineReadable {
 | 
			
		||||
				out, err := formatter.ToJSON(headers, rows)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal("unable to render to JSON: %s", err)
 | 
			
		||||
					log.Fatal(i18n.G("unable to render to JSON: %s", err))
 | 
			
		||||
				}
 | 
			
		||||
				fmt.Println(out)
 | 
			
		||||
				return
 | 
			
		||||
@ -93,17 +100,17 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	RecipeListCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.MachineReadable,
 | 
			
		||||
		"machine",
 | 
			
		||||
		"m",
 | 
			
		||||
		i18n.G("machine"),
 | 
			
		||||
		i18n.G("m"),
 | 
			
		||||
		false,
 | 
			
		||||
		"print machine-readable output",
 | 
			
		||||
		i18n.G("print machine-readable output"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeListCommand.Flags().StringVarP(
 | 
			
		||||
		&pattern,
 | 
			
		||||
		"pattern",
 | 
			
		||||
		"p",
 | 
			
		||||
		i18n.G("pattern"),
 | 
			
		||||
		i18n.G("p"),
 | 
			
		||||
		"",
 | 
			
		||||
		"filter by recipe",
 | 
			
		||||
		i18n.G("filter by recipe"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -5,11 +5,13 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"text/template"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/git"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
@ -29,12 +31,18 @@ type recipeMetadata struct {
 | 
			
		||||
	SSO         string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe new` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var recipeNewAliases = i18n.G("n")
 | 
			
		||||
 | 
			
		||||
var RecipeNewCommand = &cobra.Command{
 | 
			
		||||
	Use:     "new <recipe> [flags]",
 | 
			
		||||
	Aliases: []string{"n"},
 | 
			
		||||
	Short:   "Create a new recipe",
 | 
			
		||||
	Long:    `A community managed recipe template is used.`,
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	// translators: `recipe new` command
 | 
			
		||||
	Use:     i18n.G("new <recipe> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(recipeNewAliases, ","),
 | 
			
		||||
	// translators: Short description for `abra recipe new` command
 | 
			
		||||
	Short: i18n.G("Create a new recipe"),
 | 
			
		||||
	Long:  i18n.G(`A community managed recipe template is used.`),
 | 
			
		||||
	Args:  cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -46,10 +54,10 @@ var RecipeNewCommand = &cobra.Command{
 | 
			
		||||
 | 
			
		||||
		r := recipe.Get(recipeName)
 | 
			
		||||
		if _, err := os.Stat(r.Dir); !os.IsNotExist(err) {
 | 
			
		||||
			log.Fatalf("%s recipe directory already exists?", r.Dir)
 | 
			
		||||
			log.Fatal(i18n.G("%s recipe directory already exists?", r.Dir))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		url := fmt.Sprintf("%s/example.git", config.REPOS_BASE_URL)
 | 
			
		||||
		url := i18n.G("%s/example.git", config.REPOS_BASE_URL)
 | 
			
		||||
		if err := git.Clone(r.Dir, url); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
@ -58,7 +66,7 @@ var RecipeNewCommand = &cobra.Command{
 | 
			
		||||
		if err := os.RemoveAll(gitRepo); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		log.Debugf("removed example git repo in %s", gitRepo)
 | 
			
		||||
		log.Debug(i18n.G("removed .git repo in %s", gitRepo))
 | 
			
		||||
 | 
			
		||||
		meta := newRecipeMeta(recipeName)
 | 
			
		||||
 | 
			
		||||
@ -76,15 +84,14 @@ var RecipeNewCommand = &cobra.Command{
 | 
			
		||||
			if err := os.WriteFile(path, templated.Bytes(), 0o644); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := git.Init(r.Dir, true, gitName, gitEmail); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Infof("new recipe '%s' created: %s", recipeName, path.Join(r.Dir))
 | 
			
		||||
		log.Info("happy hacking 🎉")
 | 
			
		||||
		log.Info(i18n.G("new recipe '%s' created: %s", recipeName, path.Join(r.Dir)))
 | 
			
		||||
		log.Info(i18n.G("happy hacking 🎉"))
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -112,17 +119,17 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	RecipeNewCommand.Flags().StringVarP(
 | 
			
		||||
		&gitName,
 | 
			
		||||
		"git-name",
 | 
			
		||||
		"N",
 | 
			
		||||
		i18n.G("git-name"),
 | 
			
		||||
		i18n.G("N"),
 | 
			
		||||
		"",
 | 
			
		||||
		"Git (user) name to do commits with",
 | 
			
		||||
		i18n.G("Git (user) name to do commits with"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeNewCommand.Flags().StringVarP(
 | 
			
		||||
		&gitEmail,
 | 
			
		||||
		"git-email",
 | 
			
		||||
		"e",
 | 
			
		||||
		i18n.G("git-email"),
 | 
			
		||||
		i18n.G("e"),
 | 
			
		||||
		"",
 | 
			
		||||
		"Git email name to do commits with",
 | 
			
		||||
		i18n.G("Git email name to do commits with"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,24 @@
 | 
			
		||||
package recipe
 | 
			
		||||
 | 
			
		||||
import "github.com/spf13/cobra"
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe` aliases. use a comma separated list of aliases
 | 
			
		||||
// with no spaces in between
 | 
			
		||||
var recipeAliases = i18n.G("r")
 | 
			
		||||
 | 
			
		||||
// RecipeCommand defines all recipe related sub-commands.
 | 
			
		||||
var RecipeCommand = &cobra.Command{
 | 
			
		||||
	Use:     "recipe [cmd] [args] [flags]",
 | 
			
		||||
	Aliases: []string{"r"},
 | 
			
		||||
	Short:   "Manage recipes",
 | 
			
		||||
	Long: `A recipe is a blueprint for an app.
 | 
			
		||||
	// translators: `recipe` command group
 | 
			
		||||
	Use:     i18n.G("recipe [cmd] [args] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(recipeAliases, ","),
 | 
			
		||||
	// translators: Short description for `recipe` command group
 | 
			
		||||
	Short: i18n.G("Manage recipes"),
 | 
			
		||||
	Long: i18n.G(`A recipe is a blueprint for an app.
 | 
			
		||||
 | 
			
		||||
It is a bunch of config files which describe how to deploy and maintain an app.
 | 
			
		||||
Recipes are maintained by the Co-op Cloud community and you can use Abra to
 | 
			
		||||
@ -15,5 +26,5 @@ read them, deploy them and create apps for you.
 | 
			
		||||
 | 
			
		||||
Anyone who uses a recipe can become a maintainer. Maintainers typically make
 | 
			
		||||
sure the recipe is in good working order and the config upgraded in a timely
 | 
			
		||||
manner.`,
 | 
			
		||||
manner.`),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -12,20 +12,28 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	gitPkg "coopcloud.tech/abra/pkg/git"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"coopcloud.tech/tagcmp"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
	"github.com/distribution/reference"
 | 
			
		||||
	"github.com/go-git/go-git/v5"
 | 
			
		||||
	"github.com/go-git/go-git/v5/plumbing"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe release` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var recipeReleaseAliases = i18n.G("rl")
 | 
			
		||||
 | 
			
		||||
var RecipeReleaseCommand = &cobra.Command{
 | 
			
		||||
	Use:     "release <recipe> [version] [flags]",
 | 
			
		||||
	Aliases: []string{"rl"},
 | 
			
		||||
	Short:   "Release a new recipe version",
 | 
			
		||||
	Long: `Create a new version of a recipe.
 | 
			
		||||
	// translators: `recipe release` command
 | 
			
		||||
	Use:     i18n.G("release <recipe> [version] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(recipeReleaseAliases, ","),
 | 
			
		||||
	// translators: Short description for `recipe release` command
 | 
			
		||||
	Short: i18n.G("Release a new recipe version"),
 | 
			
		||||
	Long: i18n.G(`Create a new version of a recipe.
 | 
			
		||||
 | 
			
		||||
These versions are then published on the Co-op Cloud recipe catalogue. These
 | 
			
		||||
versions take the following form:
 | 
			
		||||
@ -44,7 +52,15 @@ major and therefore require intervention while doing the upgrade work.
 | 
			
		||||
 | 
			
		||||
Publish your new release to git.coopcloud.tech with "--publish/-p". This
 | 
			
		||||
requires that you have permission to git push to these repositories and have
 | 
			
		||||
your SSH keys configured on your account.`,
 | 
			
		||||
your SSH keys configured on your account. Enable ssh-agent and make sure to add
 | 
			
		||||
your private key and enter your passphrase beforehand.
 | 
			
		||||
 | 
			
		||||
    eval ` + "`ssh-agent`" + `
 | 
			
		||||
    ssh-add ~/.ssh/<my-ssh-private-key-for-git-coopcloud-tech>`),
 | 
			
		||||
	Example: `  # publish release
 | 
			
		||||
  eval ` + "`ssh-agent`" + `
 | 
			
		||||
  ssh-add ~/.ssh/id_ed25519
 | 
			
		||||
  abra recipe release gitea -p`,
 | 
			
		||||
	Args: cobra.RangeArgs(1, 2),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -62,7 +78,7 @@ your SSH keys configured on your account.`,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		recipe := internal.ValidateRecipe(args, cmd.Name())
 | 
			
		||||
 | 
			
		||||
		imagesTmp, err := getImageVersions(recipe)
 | 
			
		||||
		imagesTmp, err := GetImageVersions(recipe)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
@ -74,7 +90,7 @@ your SSH keys configured on your account.`,
 | 
			
		||||
 | 
			
		||||
		mainAppVersion := imagesTmp[mainApp]
 | 
			
		||||
		if mainAppVersion == "" {
 | 
			
		||||
			log.Fatalf("main app service version for %s is empty?", recipe.Name)
 | 
			
		||||
			log.Fatal(i18n.G("main app service version for %s is empty?", recipe.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var tagString string
 | 
			
		||||
@ -84,16 +100,32 @@ your SSH keys configured on your account.`,
 | 
			
		||||
 | 
			
		||||
		if tagString != "" {
 | 
			
		||||
			if _, err := tagcmp.Parse(tagString); err != nil {
 | 
			
		||||
				log.Fatalf("cannot parse %s, invalid tag specified?", tagString)
 | 
			
		||||
				log.Fatal(i18n.G("cannot parse %s, invalid tag specified?", tagString))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (internal.Major || internal.Minor || internal.Patch) && tagString != "" {
 | 
			
		||||
			log.Fatal("cannot specify tag and bump type at the same time")
 | 
			
		||||
			log.Fatal(i18n.G("cannot specify tag and bump type at the same time"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		repo, err := git.PlainOpen(recipe.Dir)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		preCommitHead, err := repo.Head()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if tagString != "" {
 | 
			
		||||
			if err := createReleaseFromTag(recipe, tagString, mainAppVersion); err != nil {
 | 
			
		||||
				if cleanErr := cleanTag(recipe, tagString); cleanErr != nil {
 | 
			
		||||
					log.Fatal(cleanErr)
 | 
			
		||||
				}
 | 
			
		||||
				if cleanErr := cleanCommit(recipe, preCommitHead); cleanErr != nil {
 | 
			
		||||
					log.Fatal(cleanErr)
 | 
			
		||||
				}
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@ -103,37 +135,56 @@ your SSH keys configured on your account.`,
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if tagString == "" && (!internal.Major && !internal.Minor && !internal.Patch) {
 | 
			
		||||
			var err error
 | 
			
		||||
			tagString, err = getLabelVersion(recipe, false)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
		labelVersion, err := getLabelVersion(recipe, false)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, tag := range tags {
 | 
			
		||||
			previousTagLeftHand := strings.Split(tag, "+")[0]
 | 
			
		||||
			newTagStringLeftHand := strings.Split(labelVersion, "+")[0]
 | 
			
		||||
			if previousTagLeftHand == newTagStringLeftHand {
 | 
			
		||||
				log.Fatal(i18n.G("%s+... conflicts with a previous release: %s", newTagStringLeftHand, tag))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if tagString == "" && (!internal.Major && !internal.Minor && !internal.Patch) {
 | 
			
		||||
			tagString = labelVersion
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		isClean, err := gitPkg.IsClean(recipe.Dir)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !isClean {
 | 
			
		||||
			log.Infof("%s currently has these unstaged changes 👇", recipe.Name)
 | 
			
		||||
			log.Info(i18n.G("%s currently has these unstaged changes 👇", recipe.Name))
 | 
			
		||||
			if err := gitPkg.DiffUnstaged(recipe.Dir); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(tags) > 0 {
 | 
			
		||||
			log.Warnf("previous git tags detected, assuming this is a new semver release")
 | 
			
		||||
			log.Warn(i18n.G("previous git tags detected, assuming new semver release"))
 | 
			
		||||
 | 
			
		||||
			if err := createReleaseFromPreviousTag(tagString, mainAppVersion, recipe, tags); err != nil {
 | 
			
		||||
				if cleanErr := cleanTag(recipe, tagString); cleanErr != nil {
 | 
			
		||||
					log.Fatal(cleanErr)
 | 
			
		||||
				}
 | 
			
		||||
				if cleanErr := cleanCommit(recipe, preCommitHead); cleanErr != nil {
 | 
			
		||||
					log.Fatal(cleanErr)
 | 
			
		||||
				}
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			log.Warnf("no tag specified and no previous tag available for %s, assuming this is the initial release", recipe.Name)
 | 
			
		||||
			log.Warn(i18n.G("no tag specified and no previous tag available for %s, assuming initial release", recipe.Name))
 | 
			
		||||
 | 
			
		||||
			if err := createReleaseFromTag(recipe, tagString, mainAppVersion); err != nil {
 | 
			
		||||
				if cleanUpErr := cleanUpTag(recipe, tagString); err != nil {
 | 
			
		||||
					log.Fatal(cleanUpErr)
 | 
			
		||||
				if cleanErr := cleanTag(recipe, tagString); cleanErr != nil {
 | 
			
		||||
					log.Fatal(cleanErr)
 | 
			
		||||
				}
 | 
			
		||||
				if cleanErr := cleanCommit(recipe, preCommitHead); cleanErr != nil {
 | 
			
		||||
					log.Fatal(cleanErr)
 | 
			
		||||
				}
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
@ -143,8 +194,8 @@ your SSH keys configured on your account.`,
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getImageVersions retrieves image versions for a recipe
 | 
			
		||||
func getImageVersions(recipe recipe.Recipe) (map[string]string, error) {
 | 
			
		||||
// GetImageVersions retrieves image versions for a recipe
 | 
			
		||||
func GetImageVersions(recipe recipe.Recipe) (map[string]string, error) {
 | 
			
		||||
	services := make(map[string]string)
 | 
			
		||||
 | 
			
		||||
	config, err := recipe.GetComposeConfig(nil)
 | 
			
		||||
@ -181,7 +232,7 @@ func getImageVersions(recipe recipe.Recipe) (map[string]string, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if missingTag {
 | 
			
		||||
		return services, fmt.Errorf("app service is missing image tag?")
 | 
			
		||||
		return services, errors.New(i18n.G("app service is missing image tag?"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return services, nil
 | 
			
		||||
@ -216,19 +267,19 @@ func createReleaseFromTag(recipe recipe.Recipe, tagString, mainAppVersion string
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := addReleaseNotes(recipe, tagString); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
		return errors.New(i18n.G("failed to add release notes: %s", err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := commitRelease(recipe, tagString); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
		return errors.New(i18n.G("failed to commit changes: %s", err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := tagRelease(tagString, repo); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
		return errors.New(i18n.G("failed to tag release: %s", err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := pushRelease(recipe, tagString); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
		return errors.New(i18n.G("failed to publish new release: %s", err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
@ -245,7 +296,7 @@ func btoi(b bool) int {
 | 
			
		||||
 | 
			
		||||
// getTagCreateOptions constructs git tag create options
 | 
			
		||||
func getTagCreateOptions(tag string) (git.CreateTagOptions, error) {
 | 
			
		||||
	msg := fmt.Sprintf("chore: publish %s release", tag)
 | 
			
		||||
	msg := i18n.G("chore: publish %s release", tag)
 | 
			
		||||
	return git.CreateTagOptions{Message: msg}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -267,52 +318,53 @@ func addReleaseNotes(recipe recipe.Recipe, tag string) error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var addNextAsReleaseNotes bool
 | 
			
		||||
 | 
			
		||||
	nextReleaseNotePath := path.Join(releaseDir, "next")
 | 
			
		||||
	if _, err := os.Stat(nextReleaseNotePath); err == nil {
 | 
			
		||||
		// release/next note exists. Move it to release/<tag>
 | 
			
		||||
		if internal.Dry {
 | 
			
		||||
			log.Debugf("dry run: move release note from 'next' to %s", tag)
 | 
			
		||||
			log.Debug(i18n.G("dry run: move release note from 'next' to %s", tag))
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !internal.NoInput {
 | 
			
		||||
			prompt := &survey.Input{
 | 
			
		||||
				Message: "Use release note in release/next?",
 | 
			
		||||
			prompt := &survey.Confirm{
 | 
			
		||||
				Message: i18n.G("use release note in release/next?"),
 | 
			
		||||
			}
 | 
			
		||||
			var addReleaseNote bool
 | 
			
		||||
			if err := survey.AskOne(prompt, &addReleaseNote); err != nil {
 | 
			
		||||
 | 
			
		||||
			if err := survey.AskOne(prompt, &addNextAsReleaseNotes); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
			if !addReleaseNote {
 | 
			
		||||
 | 
			
		||||
			if !addNextAsReleaseNotes {
 | 
			
		||||
				return nil
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		err := os.Rename(nextReleaseNotePath, tagReleaseNotePath)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
		if err := os.Rename(nextReleaseNotePath, tagReleaseNotePath); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		err = gitPkg.Add(recipe.Dir, path.Join("release", "next"), internal.Dry)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
		if err := gitPkg.Add(recipe.Dir, path.Join("release", "next"), internal.Dry); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		err = gitPkg.Add(recipe.Dir, path.Join("release", tag), internal.Dry)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
		if err := gitPkg.Add(recipe.Dir, path.Join("release", tag), internal.Dry); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	} else if !errors.Is(err, os.ErrNotExist) {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// No release note exists for the current release.
 | 
			
		||||
	if internal.NoInput {
 | 
			
		||||
	// NOTE(d1): No release note exists for the current release. Or, we've
 | 
			
		||||
	// already used release/next as the release note
 | 
			
		||||
	if internal.NoInput || addNextAsReleaseNotes {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	prompt := &survey.Input{
 | 
			
		||||
		Message: "Release Note (leave empty for no release note)",
 | 
			
		||||
		Message: i18n.G("add release note? (leave empty to skip)"),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var releaseNote string
 | 
			
		||||
@ -337,7 +389,7 @@ func addReleaseNotes(recipe recipe.Recipe, tag string) error {
 | 
			
		||||
 | 
			
		||||
func commitRelease(recipe recipe.Recipe, tag string) error {
 | 
			
		||||
	if internal.Dry {
 | 
			
		||||
		log.Debugf("dry run: no changes committed")
 | 
			
		||||
		log.Debug(i18n.G("dry run: no changes committed"))
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -348,7 +400,7 @@ func commitRelease(recipe recipe.Recipe, tag string) error {
 | 
			
		||||
 | 
			
		||||
	if isClean {
 | 
			
		||||
		if !internal.Dry {
 | 
			
		||||
			return fmt.Errorf("no changes discovered in %s, nothing to publish?", recipe.Dir)
 | 
			
		||||
			return errors.New(i18n.G("no changes discovered in %s, nothing to publish?", recipe.Dir))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -362,7 +414,7 @@ func commitRelease(recipe recipe.Recipe, tag string) error {
 | 
			
		||||
 | 
			
		||||
func tagRelease(tagString string, repo *git.Repository) error {
 | 
			
		||||
	if internal.Dry {
 | 
			
		||||
		log.Debugf("dry run: no git tag created (%s)", tagString)
 | 
			
		||||
		log.Debug(i18n.G("dry run: no git tag created (%s)", tagString))
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -382,20 +434,20 @@ func tagRelease(tagString string, repo *git.Repository) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	hash := formatter.SmallSHA(head.Hash().String())
 | 
			
		||||
	log.Debugf(fmt.Sprintf("created tag %s at %s", tagString, hash))
 | 
			
		||||
	log.Debug(i18n.G("created tag %s at %s", tagString, hash))
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func pushRelease(recipe recipe.Recipe, tagString string) error {
 | 
			
		||||
	if internal.Dry {
 | 
			
		||||
		log.Info("dry run: no changes published")
 | 
			
		||||
		log.Info(i18n.G("dry run: no changes published"))
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !publish && !internal.NoInput {
 | 
			
		||||
		prompt := &survey.Confirm{
 | 
			
		||||
			Message: "publish new release?",
 | 
			
		||||
			Message: i18n.G("publish new release?"),
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := survey.AskOne(prompt, &publish); err != nil {
 | 
			
		||||
@ -404,13 +456,18 @@ func pushRelease(recipe recipe.Recipe, tagString string) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if publish {
 | 
			
		||||
		if os.Getenv("SSH_AUTH_SOCK") == "" {
 | 
			
		||||
			return errors.New(i18n.G("ssh-agent not found. see \"abra recipe release --help\" and try again"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := recipe.Push(internal.Dry); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		url := fmt.Sprintf("%s/src/tag/%s", recipe.GitURL, tagString)
 | 
			
		||||
		log.Infof("new release published: %s", url)
 | 
			
		||||
		log.Info(i18n.G("new release published: %s", url))
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Info("no -p/--publish passed, not publishing")
 | 
			
		||||
		log.Info(i18n.G("no -p/--publish passed, not publishing"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
@ -425,7 +482,7 @@ func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recip
 | 
			
		||||
	bumpType := btoi(internal.Major)*4 + btoi(internal.Minor)*2 + btoi(internal.Patch)
 | 
			
		||||
	if bumpType != 0 {
 | 
			
		||||
		if (bumpType & (bumpType - 1)) != 0 {
 | 
			
		||||
			return fmt.Errorf("you can only use one of: --major, --minor, --patch")
 | 
			
		||||
			return errors.New(i18n.G("you can only use one of: --major, --minor, --patch"))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -470,69 +527,86 @@ func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recip
 | 
			
		||||
		newTag.Major = strconv.Itoa(now + 1)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if tagString == "" {
 | 
			
		||||
		if err := internal.PromptBumpType(tagString, lastGitTag.String()); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if internal.Major || internal.Minor || internal.Patch {
 | 
			
		||||
		newTag.Metadata = mainAppVersion
 | 
			
		||||
		tagString = newTag.String()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if lastGitTag.String() == tagString {
 | 
			
		||||
		log.Fatalf("latest git tag (%s) and synced label (%s) are the same?", lastGitTag, tagString)
 | 
			
		||||
		return errors.New(i18n.G("latest git tag (%s) and synced label (%s) are the same?", lastGitTag, tagString))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !internal.NoInput {
 | 
			
		||||
		prompt := &survey.Confirm{
 | 
			
		||||
			Message: fmt.Sprintf("current: %s, new: %s, correct?", lastGitTag, tagString),
 | 
			
		||||
			Message: i18n.G("current: %s, new: %s, correct?", lastGitTag, tagString),
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var ok bool
 | 
			
		||||
		if err := survey.AskOne(prompt, &ok); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !ok {
 | 
			
		||||
			log.Fatal("exiting as requested")
 | 
			
		||||
			return errors.New(i18n.G("exiting as requested"))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := addReleaseNotes(recipe, tagString); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
		return errors.New(i18n.G("failed to add release notes: %s", err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := commitRelease(recipe, tagString); err != nil {
 | 
			
		||||
		log.Fatalf("failed to commit changes: %s", err.Error())
 | 
			
		||||
		return errors.New(i18n.G("failed to commit changes: %s", err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := tagRelease(tagString, repo); err != nil {
 | 
			
		||||
		log.Fatalf("failed to tag release: %s", err.Error())
 | 
			
		||||
		return errors.New(i18n.G("failed to tag release: %s", err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := pushRelease(recipe, tagString); err != nil {
 | 
			
		||||
		log.Fatalf("failed to publish new release: %s", err.Error())
 | 
			
		||||
		return errors.New(i18n.G("failed to publish new release: %s", err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// cleanUpTag removes a freshly created tag
 | 
			
		||||
func cleanUpTag(recipe recipe.Recipe, tag string) error {
 | 
			
		||||
// cleanCommit soft removes the latest release commit. No change are lost the
 | 
			
		||||
// the commit itself is removed. This is the equivalent of `git reset HEAD~1`.
 | 
			
		||||
func cleanCommit(recipe recipe.Recipe, head *plumbing.Reference) error {
 | 
			
		||||
	repo, err := git.PlainOpen(recipe.Dir)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
		return errors.New(i18n.G("unable to open repo in %s: %s", recipe.Dir, err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	worktree, err := repo.Worktree()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.New(i18n.G("unable to open work tree in %s: %s", recipe.Dir, err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	opts := &git.ResetOptions{Commit: head.Hash(), Mode: git.MixedReset}
 | 
			
		||||
	if err := worktree.Reset(opts); err != nil {
 | 
			
		||||
		return errors.New(i18n.G("unable to soft reset %s: %s", recipe.Dir, err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debug(i18n.G("removed freshly created commit"))
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// cleanTag removes a freshly created tag
 | 
			
		||||
func cleanTag(recipe recipe.Recipe, tag string) error {
 | 
			
		||||
	repo, err := git.PlainOpen(recipe.Dir)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.New(i18n.G("unable to open repo in %s: %s", recipe.Dir, err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := repo.DeleteTag(tag); err != nil {
 | 
			
		||||
		if !strings.Contains(err.Error(), "not found") {
 | 
			
		||||
			return err
 | 
			
		||||
			return errors.New(i18n.G("unable to delete tag %s: %s", tag, err))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("removed freshly created tag %s", tag)
 | 
			
		||||
	log.Debug(i18n.G("removed freshly created tag %s", tag))
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
@ -544,20 +618,20 @@ func getLabelVersion(recipe recipe.Recipe, prompt bool) (string, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if initTag == "" {
 | 
			
		||||
		log.Fatalf("unable to read version for %s from synced label. Did you try running \"abra recipe sync %s\" already?", recipe.Name, recipe.Name)
 | 
			
		||||
		return "", errors.New(i18n.G("unable to read version for %s from synced label. Did you try running \"abra recipe sync %s\" already?", recipe.Name, recipe.Name))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Warnf("discovered %s as currently synced recipe label", initTag)
 | 
			
		||||
	log.Warn(i18n.G("discovered %s as currently synced recipe label", initTag))
 | 
			
		||||
 | 
			
		||||
	if prompt && !internal.NoInput {
 | 
			
		||||
		var response bool
 | 
			
		||||
		prompt := &survey.Confirm{Message: fmt.Sprintf("use %s as the new version?", initTag)}
 | 
			
		||||
		prompt := &survey.Confirm{Message: i18n.G("use %s as the new version?", initTag)}
 | 
			
		||||
		if err := survey.AskOne(prompt, &response); err != nil {
 | 
			
		||||
			return "", err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !response {
 | 
			
		||||
			return "", fmt.Errorf("please fix your synced label for %s and re-run this command", recipe.Name)
 | 
			
		||||
			return "", errors.New(i18n.G("please fix your synced label for %s and re-run this command", recipe.Name))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -571,42 +645,41 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	RecipeReleaseCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Dry,
 | 
			
		||||
		"dry-run",
 | 
			
		||||
		"r",
 | 
			
		||||
		i18n.G("dry-run"),
 | 
			
		||||
		i18n.G("r"),
 | 
			
		||||
		false,
 | 
			
		||||
		"report changes that would be made",
 | 
			
		||||
		i18n.G("report changes that would be made"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeReleaseCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Major,
 | 
			
		||||
		"major",
 | 
			
		||||
		"x",
 | 
			
		||||
		i18n.G("major"),
 | 
			
		||||
		i18n.G("x"),
 | 
			
		||||
		false,
 | 
			
		||||
		"increase the major part of the version",
 | 
			
		||||
		i18n.G("increase the major part of the version"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeReleaseCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Minor,
 | 
			
		||||
		"minor",
 | 
			
		||||
		"y",
 | 
			
		||||
		i18n.G("minor"),
 | 
			
		||||
		i18n.G("y"),
 | 
			
		||||
		false,
 | 
			
		||||
		"increase the minor part of the version",
 | 
			
		||||
		i18n.G("increase the minor part of the version"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeReleaseCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Patch,
 | 
			
		||||
		"patch",
 | 
			
		||||
		"z",
 | 
			
		||||
		i18n.G("patch"),
 | 
			
		||||
		i18n.G("z"),
 | 
			
		||||
		false,
 | 
			
		||||
		"increase the patch part of the version",
 | 
			
		||||
		i18n.G("increase the patch part of the version"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeReleaseCommand.Flags().BoolVarP(
 | 
			
		||||
		&publish,
 | 
			
		||||
		"publish",
 | 
			
		||||
		"p",
 | 
			
		||||
		i18n.G("publish"),
 | 
			
		||||
		i18n.G("p"),
 | 
			
		||||
		false,
 | 
			
		||||
		"publish changes to git.coopcloud.tech",
 | 
			
		||||
		i18n.G("publish changes to git.coopcloud.tech"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,19 +1,28 @@
 | 
			
		||||
package recipe
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/go-git/go-git/v5"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe reset` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var recipeResetAliases = i18n.G("rs")
 | 
			
		||||
 | 
			
		||||
var RecipeResetCommand = &cobra.Command{
 | 
			
		||||
	Use:     "reset <recipe> [flags]",
 | 
			
		||||
	Aliases: []string{"rs"},
 | 
			
		||||
	Short:   "Remove all unstaged changes from recipe config",
 | 
			
		||||
	Long:    "WARNING: this will delete your changes. Be Careful.",
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	// translators: `recipe reset` command
 | 
			
		||||
	Use:     i18n.G("reset <recipe> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(recipeResetAliases, ","),
 | 
			
		||||
	// translators: Short description for `recipe reset` command
 | 
			
		||||
	Short: i18n.G("Remove all unstaged changes from recipe config"),
 | 
			
		||||
	Long:  i18n.G("WARNING: this will delete your changes. Be Careful."),
 | 
			
		||||
	Args:  cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
 | 
			
		||||
@ -3,11 +3,15 @@ package recipe
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	gitPkg "coopcloud.tech/abra/pkg/git"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	recipePkg "coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"coopcloud.tech/tagcmp"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
	"github.com/go-git/go-git/v5"
 | 
			
		||||
@ -15,11 +19,17 @@ import (
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe reset` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var recipeSyncAliases = i18n.G("s")
 | 
			
		||||
 | 
			
		||||
var RecipeSyncCommand = &cobra.Command{
 | 
			
		||||
	Use:     "sync <recipe> [version] [flags]",
 | 
			
		||||
	Aliases: []string{"s"},
 | 
			
		||||
	Short:   "Sync recipe version label",
 | 
			
		||||
	Long: `Generate labels for the main recipe service.
 | 
			
		||||
	// translators: `recipe sync` command
 | 
			
		||||
	Use:     i18n.G("sync <recipe> [version] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(recipeSyncAliases, ","),
 | 
			
		||||
	// translators: Short description for `recipe sync` command
 | 
			
		||||
	Short: i18n.G("Sync recipe version label"),
 | 
			
		||||
	Long: i18n.G(`Generate labels for the main recipe service.
 | 
			
		||||
 | 
			
		||||
By convention, the service named "app" using the following format:
 | 
			
		||||
 | 
			
		||||
@ -27,7 +37,7 @@ By convention, the service named "app" using the following format:
 | 
			
		||||
 | 
			
		||||
Where [version] can be specifed on the command-line or Abra can attempt to
 | 
			
		||||
auto-generate it for you. The <recipe> configuration will be updated on the
 | 
			
		||||
local file system.`,
 | 
			
		||||
local file system.`),
 | 
			
		||||
	Args: cobra.RangeArgs(1, 2),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -50,7 +60,7 @@ local file system.`,
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		imagesTmp, err := getImageVersions(recipe)
 | 
			
		||||
		imagesTmp, err := GetImageVersions(recipe)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
@ -68,11 +78,11 @@ local file system.`,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(tags) == 0 && nextTag == "" {
 | 
			
		||||
			log.Warnf("no git tags found for %s", recipe.Name)
 | 
			
		||||
			log.Warn(i18n.G("no git tags found for %s", recipe.Name))
 | 
			
		||||
			if internal.NoInput {
 | 
			
		||||
				log.Fatalf("unable to continue, input required for initial version")
 | 
			
		||||
				log.Fatal(i18n.G("unable to continue, input required for initial version"))
 | 
			
		||||
			}
 | 
			
		||||
			fmt.Println(fmt.Sprintf(`
 | 
			
		||||
			fmt.Println(i18n.G(`
 | 
			
		||||
The following options are two types of initial semantic version that you can
 | 
			
		||||
pick for %s that will be published in the recipe catalogue. This follows the
 | 
			
		||||
semver convention (more on https://semver.org), here is a short cheatsheet
 | 
			
		||||
@ -92,7 +102,7 @@ likely to change.
 | 
			
		||||
`, recipe.Name, recipe.Name))
 | 
			
		||||
			var chosenVersion string
 | 
			
		||||
			edPrompt := &survey.Select{
 | 
			
		||||
				Message: "which version do you want to begin with?",
 | 
			
		||||
				Message: i18n.G("which version do you want to begin with?"),
 | 
			
		||||
				Options: []string{"0.1.0", "1.0.0"},
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -104,8 +114,48 @@ likely to change.
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if nextTag == "" && (!internal.Major && !internal.Minor && !internal.Patch) {
 | 
			
		||||
			var changeOverview string
 | 
			
		||||
 | 
			
		||||
			catl, err := recipePkg.ReadRecipeCatalogue(false)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			versions, err := recipePkg.GetRecipeCatalogueVersions(recipe.Name, catl)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			changesTable, err := formatter.CreateTable()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			latestRelease := tags[len(tags)-1]
 | 
			
		||||
			if err := internal.PromptBumpType("", latestRelease); err != nil {
 | 
			
		||||
			changesTable.Headers(i18n.G("SERVICE"), latestRelease, i18n.G("PROPOSED CHANGES"))
 | 
			
		||||
 | 
			
		||||
			latestRecipeVersion := versions[len(versions)-1]
 | 
			
		||||
			allRecipeVersions := catl[recipe.Name].Versions
 | 
			
		||||
			for _, recipeVersion := range allRecipeVersions {
 | 
			
		||||
				if serviceVersions, ok := recipeVersion[latestRecipeVersion]; ok {
 | 
			
		||||
					for serviceName := range serviceVersions {
 | 
			
		||||
						serviceMeta := serviceVersions[serviceName]
 | 
			
		||||
 | 
			
		||||
						existingImageTag := fmt.Sprintf("%s:%s", serviceMeta.Image, serviceMeta.Tag)
 | 
			
		||||
						newImageTag := fmt.Sprintf("%s:%s", serviceMeta.Image, imagesTmp[serviceMeta.Image])
 | 
			
		||||
 | 
			
		||||
						if existingImageTag == newImageTag {
 | 
			
		||||
							continue
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
						changesTable.Row([]string{serviceName, existingImageTag, newImageTag}...)
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			changeOverview = changesTable.Render()
 | 
			
		||||
 | 
			
		||||
			if err := internal.PromptBumpType("", latestRelease, changeOverview); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@ -125,7 +175,7 @@ likely to change.
 | 
			
		||||
			if err := iter.ForEach(func(ref *plumbing.Reference) error {
 | 
			
		||||
				obj, err := repo.TagObject(ref.Hash())
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal("Tag at commit ", ref.Hash(), " is unannotated or otherwise broken. Please fix it.")
 | 
			
		||||
					log.Fatal(i18n.G("tag at commit %s is unannotated or otherwise broken", ref.Hash()))
 | 
			
		||||
					return err
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
@ -150,7 +200,7 @@ likely to change.
 | 
			
		||||
			if bumpType != 0 {
 | 
			
		||||
				// a bitwise check if the number is a power of 2
 | 
			
		||||
				if (bumpType & (bumpType - 1)) != 0 {
 | 
			
		||||
					log.Fatal("you can only use one version flag: --major, --minor or --patch")
 | 
			
		||||
					log.Fatal(i18n.G("you can only use one version flag: --major, --minor or --patch"))
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -184,22 +234,22 @@ likely to change.
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			newTag.Metadata = mainAppVersion
 | 
			
		||||
			log.Debugf("choosing %s as new version for %s", newTag.String(), recipe.Name)
 | 
			
		||||
			log.Debug(i18n.G("choosing %s as new version for %s", newTag.String(), recipe.Name))
 | 
			
		||||
			nextTag = newTag.String()
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if _, err := tagcmp.Parse(nextTag); err != nil {
 | 
			
		||||
			log.Fatalf("invalid version %s specified", nextTag)
 | 
			
		||||
			log.Fatal(i18n.G("invalid version %s specified", nextTag))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		mainService := "app"
 | 
			
		||||
		label := fmt.Sprintf("coop-cloud.${STACK_NAME}.version=%s", nextTag)
 | 
			
		||||
		label := i18n.G("coop-cloud.${STACK_NAME}.version=%s", nextTag)
 | 
			
		||||
		if !internal.Dry {
 | 
			
		||||
			if err := recipe.UpdateLabel("compose.y*ml", mainService, label); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			log.Infof("dry run: not syncing label %s for recipe %s", nextTag, recipe.Name)
 | 
			
		||||
			log.Info(i18n.G("dry run: not syncing label %s for recipe %s", nextTag, recipe.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		isClean, err := gitPkg.IsClean(recipe.Dir)
 | 
			
		||||
@ -207,7 +257,7 @@ likely to change.
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		if !isClean {
 | 
			
		||||
			log.Infof("%s currently has these unstaged changes 👇", recipe.Name)
 | 
			
		||||
			log.Info(i18n.G("%s currently has these unstaged changes 👇", recipe.Name))
 | 
			
		||||
			if err := gitPkg.DiffUnstaged(recipe.Dir); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
@ -218,33 +268,33 @@ likely to change.
 | 
			
		||||
func init() {
 | 
			
		||||
	RecipeSyncCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Dry,
 | 
			
		||||
		"dry-run",
 | 
			
		||||
		"r",
 | 
			
		||||
		i18n.G("dry-run"),
 | 
			
		||||
		i18n.G("r"),
 | 
			
		||||
		false,
 | 
			
		||||
		"report changes that would be made",
 | 
			
		||||
		i18n.G("report changes that would be made"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeSyncCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Major,
 | 
			
		||||
		"major",
 | 
			
		||||
		"x",
 | 
			
		||||
		i18n.G("major"),
 | 
			
		||||
		i18n.G("x"),
 | 
			
		||||
		false,
 | 
			
		||||
		"increase the major part of the version",
 | 
			
		||||
		i18n.G("increase the major part of the version"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeSyncCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Minor,
 | 
			
		||||
		"minor",
 | 
			
		||||
		"y",
 | 
			
		||||
		i18n.G("minor"),
 | 
			
		||||
		i18n.G("y"),
 | 
			
		||||
		false,
 | 
			
		||||
		"increase the minor part of the version",
 | 
			
		||||
		i18n.G("increase the minor part of the version"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeSyncCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Patch,
 | 
			
		||||
		"patch",
 | 
			
		||||
		"z",
 | 
			
		||||
		i18n.G("patch"),
 | 
			
		||||
		i18n.G("z"),
 | 
			
		||||
		false,
 | 
			
		||||
		"increase the patch part of the version",
 | 
			
		||||
		i18n.G("increase the patch part of the version"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -14,6 +14,7 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	gitPkg "coopcloud.tech/abra/pkg/git"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	recipePkg "coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"coopcloud.tech/tagcmp"
 | 
			
		||||
@ -36,11 +37,17 @@ type anUpgrade struct {
 | 
			
		||||
	UpgradeTags []string `json:"upgrades"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe upgrade` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var recipeUpgradeAliases = i18n.G("u")
 | 
			
		||||
 | 
			
		||||
var RecipeUpgradeCommand = &cobra.Command{
 | 
			
		||||
	Use:     "upgrade <recipe> [flags]",
 | 
			
		||||
	Aliases: []string{"u"},
 | 
			
		||||
	Short:   "Upgrade recipe image tags",
 | 
			
		||||
	Long: `Upgrade a given <recipe> configuration.
 | 
			
		||||
	// translators: `recipe upgrade` command
 | 
			
		||||
	Use:     i18n.G("upgrade <recipe> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(recipeUpgradeAliases, ","),
 | 
			
		||||
	// translators: Short description for `recipe upgrade` command
 | 
			
		||||
	Short: i18n.G("Upgrade recipe image tags"),
 | 
			
		||||
	Long: i18n.G(`Upgrade a given <recipe> configuration.
 | 
			
		||||
 | 
			
		||||
It will update the relevant compose file tags on the local file system.
 | 
			
		||||
 | 
			
		||||
@ -52,7 +59,7 @@ The command is interactive and will show a select input which allows you to
 | 
			
		||||
make a seclection. Use the "?" key to see more help on navigating this
 | 
			
		||||
interface.
 | 
			
		||||
 | 
			
		||||
You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
You may invoke this command in "wizard" mode and be prompted for input.`),
 | 
			
		||||
	Args: cobra.RangeArgs(0, 1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -63,7 +70,7 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		recipe := internal.ValidateRecipe(args, cmd.Name())
 | 
			
		||||
 | 
			
		||||
		if err := recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
 | 
			
		||||
		if err := recipe.Ensure(internal.GetEnsureContext()); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -71,7 +78,7 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
		if bumpType != 0 {
 | 
			
		||||
			// a bitwise check if the number is a power of 2
 | 
			
		||||
			if (bumpType & (bumpType - 1)) != 0 {
 | 
			
		||||
				log.Fatal("you can only use one of: --major, --minor, --patch.")
 | 
			
		||||
				log.Fatal(i18n.G("you can only use one of: --major, --minor, --patch."))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -87,7 +94,7 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
		versionsPath := path.Join(recipe.Dir, "versions")
 | 
			
		||||
		servicePins := make(map[string]imgPin)
 | 
			
		||||
		if _, err := os.Stat(versionsPath); err == nil {
 | 
			
		||||
			log.Debugf("found versions file for %s", recipe.Name)
 | 
			
		||||
			log.Debug(i18n.G("found versions file for %s", recipe.Name))
 | 
			
		||||
			file, err := os.Open(versionsPath)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
@ -97,7 +104,7 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
				line := scanner.Text()
 | 
			
		||||
				splitLine := strings.Split(line, " ")
 | 
			
		||||
				if splitLine[0] != "pin" || len(splitLine) != 3 {
 | 
			
		||||
					log.Fatalf("malformed version pin specification: %s", line)
 | 
			
		||||
					log.Fatal(i18n.G("malformed version pin specification: %s", line))
 | 
			
		||||
				}
 | 
			
		||||
				pinSlice := strings.Split(splitLine[2], ":")
 | 
			
		||||
				pinTag, err := tagcmp.Parse(pinSlice[1])
 | 
			
		||||
@ -115,7 +122,7 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
			}
 | 
			
		||||
			versionsPresent = true
 | 
			
		||||
		} else {
 | 
			
		||||
			log.Debugf("did not find versions file for %s", recipe.Name)
 | 
			
		||||
			log.Debug(i18n.G("did not find versions file for %s", recipe.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		config, err := recipe.GetComposeConfig(nil)
 | 
			
		||||
@ -135,26 +142,26 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			image := reference.Path(img)
 | 
			
		||||
			log.Debugf("retrieved %s from remote registry for %s", regVersions, image)
 | 
			
		||||
			log.Debug(i18n.G("retrieved %s from remote registry for %s", regVersions, image))
 | 
			
		||||
			image = formatter.StripTagMeta(image)
 | 
			
		||||
 | 
			
		||||
			switch img.(type) {
 | 
			
		||||
			case reference.NamedTagged:
 | 
			
		||||
				if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) {
 | 
			
		||||
					log.Debugf("%s not considered semver-like", img.(reference.NamedTagged).Tag())
 | 
			
		||||
					log.Debug(i18n.G("%s not considered semver-like", img.(reference.NamedTagged).Tag()))
 | 
			
		||||
				}
 | 
			
		||||
			default:
 | 
			
		||||
				log.Warnf("unable to read tag for image %s, is it missing? skipping upgrade for %s", image, service.Name)
 | 
			
		||||
				log.Warn(i18n.G("unable to read tag for image %s, is it missing? skipping upgrade for %s", image, service.Name))
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			tag, err := tagcmp.Parse(img.(reference.NamedTagged).Tag())
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Warnf("unable to parse %s, error was: %s, skipping upgrade for %s", image, err.Error(), service.Name)
 | 
			
		||||
				log.Warn(i18n.G("unable to parse %s, error was: %s, skipping upgrade for %s", image, err.Error(), service.Name))
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debugf("parsed %s for %s", tag, service.Name)
 | 
			
		||||
			log.Debug(i18n.G("parsed %s for %s", tag, service.Name))
 | 
			
		||||
 | 
			
		||||
			var compatible []tagcmp.Tag
 | 
			
		||||
			for _, regVersion := range regVersions {
 | 
			
		||||
@ -168,12 +175,12 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debugf("detected potential upgradable tags %s for %s", compatible, service.Name)
 | 
			
		||||
			log.Debug(i18n.G("detected potential upgradable tags %s for %s", compatible, service.Name))
 | 
			
		||||
 | 
			
		||||
			sort.Sort(tagcmp.ByTagDesc(compatible))
 | 
			
		||||
 | 
			
		||||
			if len(compatible) == 0 && !allTags {
 | 
			
		||||
				log.Info(fmt.Sprintf("no new versions available for %s, assuming %s is the latest (use -a/--all-tags to see all anyway)", image, tag))
 | 
			
		||||
				log.Info(i18n.G("no new versions available for %s, assuming %s is the latest (use -a/--all-tags to see all anyway)", image, tag))
 | 
			
		||||
				continue // skip on to the next tag and don't update any compose files
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -195,7 +202,7 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debugf("detected compatible upgradable tags %s for %s", compatibleStrings, service.Name)
 | 
			
		||||
			log.Debug(i18n.G("detected compatible upgradable tags %s for %s", compatibleStrings, service.Name))
 | 
			
		||||
 | 
			
		||||
			var upgradeTag string
 | 
			
		||||
			_, ok := servicePins[service.Name]
 | 
			
		||||
@ -212,13 +219,13 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					if contains {
 | 
			
		||||
						log.Infof("upgrading service %s from %s to %s (pinned tag: %s)", service.Name, tag.String(), upgradeTag, pinnedTagString)
 | 
			
		||||
						log.Info(i18n.G("upgrading service %s from %s to %s (pinned tag: %s)", service.Name, tag.String(), upgradeTag, pinnedTagString))
 | 
			
		||||
					} else {
 | 
			
		||||
						log.Infof("service %s, image %s pinned to %s, no compatible upgrade found", service.Name, servicePins[service.Name].image, pinnedTagString)
 | 
			
		||||
						log.Info(i18n.G("service %s, image %s pinned to %s, no compatible upgrade found", service.Name, servicePins[service.Name].image, pinnedTagString))
 | 
			
		||||
						continue
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
					log.Fatalf("service %s is at version %s, but pinned to %s, please correct your compose.yml file manually!", service.Name, tag.String(), pinnedTag.String())
 | 
			
		||||
					log.Fatal(i18n.G("service %s is at version %s, but pinned to %s, please correct your compose.yml file manually!", service.Name, tag.String(), pinnedTag.String()))
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
@ -235,17 +242,17 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					if upgradeTag == "" {
 | 
			
		||||
						log.Warnf("not upgrading from %s to %s for %s, because the upgrade type is more serious than what user wants", tag.String(), compatible[0].String(), image)
 | 
			
		||||
						log.Warn(i18n.G("not upgrading from %s to %s for %s, because the upgrade type is more serious than what user wants", tag.String(), compatible[0].String(), image))
 | 
			
		||||
						continue
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
					msg := fmt.Sprintf("upgrade to which tag? (service: %s, image: %s, tag: %s)", service.Name, image, tag)
 | 
			
		||||
					msg := i18n.G("upgrade to which tag? (service: %s, image: %s, tag: %s)", service.Name, image, tag)
 | 
			
		||||
					if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) || allTags {
 | 
			
		||||
						tag := img.(reference.NamedTagged).Tag()
 | 
			
		||||
						if !allTags {
 | 
			
		||||
							log.Warn(fmt.Sprintf("unable to determine versioning semantics of %s, listing all tags", tag))
 | 
			
		||||
							log.Warn(i18n.G("unable to determine versioning semantics of %s, listing all tags", tag))
 | 
			
		||||
						}
 | 
			
		||||
						msg = fmt.Sprintf("upgrade to which tag? (service: %s, tag: %s)", service.Name, tag)
 | 
			
		||||
						msg = i18n.G("upgrade to which tag? (service: %s, tag: %s)", service.Name, tag)
 | 
			
		||||
						compatibleStrings = []string{"skip"}
 | 
			
		||||
						for _, regVersion := range regVersions {
 | 
			
		||||
							compatibleStrings = append(compatibleStrings, regVersion)
 | 
			
		||||
@ -276,7 +283,7 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
					} else {
 | 
			
		||||
						prompt := &survey.Select{
 | 
			
		||||
							Message: msg,
 | 
			
		||||
							Help:    "enter / return to confirm, choose 'skip' to not upgrade this tag, vim mode is enabled",
 | 
			
		||||
							Help:    i18n.G("enter / return to confirm, choose 'skip' to not upgrade this tag, vim mode is enabled"),
 | 
			
		||||
							VimMode: true,
 | 
			
		||||
							Options: compatibleStrings,
 | 
			
		||||
						}
 | 
			
		||||
@ -292,11 +299,11 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
				if ok {
 | 
			
		||||
					log.Infof("tag upgraded from %s to %s for %s", tag.String(), upgradeTag, image)
 | 
			
		||||
					log.Info(i18n.G("tag upgraded from %s to %s for %s", tag.String(), upgradeTag, image))
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				if !internal.NoInput {
 | 
			
		||||
					log.Warnf("not upgrading %s, skipping as requested", image)
 | 
			
		||||
					log.Warn(i18n.G("not upgrading %s, skipping as requested", image))
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@ -314,7 +321,7 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for _, upgrade := range upgradeList {
 | 
			
		||||
				log.Infof("can upgrade service: %s, image: %s, tag: %s ::", upgrade.Service, upgrade.Image, upgrade.Tag)
 | 
			
		||||
				log.Info(i18n.G("can upgrade service: %s, image: %s, tag: %s ::", upgrade.Service, upgrade.Image, upgrade.Tag))
 | 
			
		||||
				for _, utag := range upgrade.UpgradeTags {
 | 
			
		||||
					log.Infof("    %s", utag)
 | 
			
		||||
				}
 | 
			
		||||
@ -326,7 +333,7 @@ You may invoke this command in "wizard" mode and be prompted for input.`,
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		if !isClean {
 | 
			
		||||
			log.Infof("%s currently has these unstaged changes 👇", recipe.Name)
 | 
			
		||||
			log.Info(i18n.G("%s currently has these unstaged changes 👇", recipe.Name))
 | 
			
		||||
			if err := gitPkg.DiffUnstaged(recipe.Dir); err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
@ -341,41 +348,41 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	RecipeUpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Major,
 | 
			
		||||
		"major",
 | 
			
		||||
		"x",
 | 
			
		||||
		i18n.G("major"),
 | 
			
		||||
		i18n.G("x"),
 | 
			
		||||
		false,
 | 
			
		||||
		"increase the major part of the version",
 | 
			
		||||
		i18n.G("increase the major part of the version"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeUpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Minor,
 | 
			
		||||
		"minor",
 | 
			
		||||
		"y",
 | 
			
		||||
		i18n.G("minor"),
 | 
			
		||||
		i18n.G("y"),
 | 
			
		||||
		false,
 | 
			
		||||
		"increase the minor part of the version",
 | 
			
		||||
		i18n.G("increase the minor part of the version"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeUpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Patch,
 | 
			
		||||
		"patch",
 | 
			
		||||
		"z",
 | 
			
		||||
		i18n.G("patch"),
 | 
			
		||||
		i18n.G("z"),
 | 
			
		||||
		false,
 | 
			
		||||
		"increase the patch part of the version",
 | 
			
		||||
		i18n.G("increase the patch part of the version"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeUpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.MachineReadable,
 | 
			
		||||
		"machine",
 | 
			
		||||
		"m",
 | 
			
		||||
		i18n.G("machine"),
 | 
			
		||||
		i18n.G("m"),
 | 
			
		||||
		false,
 | 
			
		||||
		"print machine-readable output",
 | 
			
		||||
		i18n.G("print machine-readable output"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	RecipeUpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&allTags,
 | 
			
		||||
		"all-tags",
 | 
			
		||||
		"a",
 | 
			
		||||
		i18n.G("all-tags"),
 | 
			
		||||
		i18n.GC("a", "recipe upgrade"),
 | 
			
		||||
		false,
 | 
			
		||||
		"list all tags, not just upgrades",
 | 
			
		||||
		i18n.G("list all tags, not just upgrades"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,20 +3,28 @@ package recipe
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	recipePkg "coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra recipe versions` aliases. use a comma separated list of aliases
 | 
			
		||||
// with no spaces in between
 | 
			
		||||
var recipeVersionsAliases = i18n.G("v")
 | 
			
		||||
 | 
			
		||||
var RecipeVersionCommand = &cobra.Command{
 | 
			
		||||
	Use:     "versions <recipe> [flags]",
 | 
			
		||||
	Aliases: []string{"v"},
 | 
			
		||||
	Short:   "List recipe versions",
 | 
			
		||||
	Args:    cobra.ExactArgs(1),
 | 
			
		||||
	// translators: `recipe versions` command
 | 
			
		||||
	Use:     i18n.G("versions <recipe> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(recipeVersionsAliases, ","),
 | 
			
		||||
	// translators: Short description for `recipe versions` command
 | 
			
		||||
	Short: i18n.G("List recipe versions"),
 | 
			
		||||
	Args:  cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
		args []string,
 | 
			
		||||
@ -35,18 +43,21 @@ var RecipeVersionCommand = &cobra.Command{
 | 
			
		||||
 | 
			
		||||
		recipeMeta, ok := catl[recipe.Name]
 | 
			
		||||
		if !ok {
 | 
			
		||||
			warnMessages = append(warnMessages, "retrieved versions from local recipe repository")
 | 
			
		||||
			warnMessages = append(warnMessages, i18n.G("retrieved versions from local recipe repository"))
 | 
			
		||||
 | 
			
		||||
			recipeVersions, err := recipe.GetRecipeVersions()
 | 
			
		||||
			recipeVersions, warnMsg, err := recipe.GetRecipeVersions()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				warnMessages = append(warnMessages, err.Error())
 | 
			
		||||
			}
 | 
			
		||||
			if len(warnMsg) > 0 {
 | 
			
		||||
				warnMessages = append(warnMessages, warnMsg...)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			recipeMeta = recipePkg.RecipeMeta{Versions: recipeVersions}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(recipeMeta.Versions) == 0 {
 | 
			
		||||
			log.Fatalf("%s has no published versions?", recipe.Name)
 | 
			
		||||
			log.Fatal(i18n.G("%s has no published versions?", recipe.Name))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for i := len(recipeMeta.Versions) - 1; i >= 0; i-- {
 | 
			
		||||
@ -55,7 +66,7 @@ var RecipeVersionCommand = &cobra.Command{
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			table.Headers("SERVICE", "IMAGE", "TAG", "VERSION")
 | 
			
		||||
			table.Headers(i18n.G("SERVICE"), i18n.G("IMAGE"), i18n.G("TAG"), i18n.G("VERSION"))
 | 
			
		||||
 | 
			
		||||
			for version, meta := range recipeMeta.Versions[i] {
 | 
			
		||||
				var allRows [][]string
 | 
			
		||||
@ -96,10 +107,10 @@ var RecipeVersionCommand = &cobra.Command{
 | 
			
		||||
 | 
			
		||||
				if internal.MachineReadable {
 | 
			
		||||
					sort.Slice(allRows, sortServiceByName(allRows))
 | 
			
		||||
					headers := []string{"VERSION", "SERVICE", "NAME", "TAG"}
 | 
			
		||||
					headers := []string{i18n.G("VERSION"), i18n.G("SERVICE"), i18n.G("NAME"), i18n.G("TAG")}
 | 
			
		||||
					out, err := formatter.ToJSON(headers, allRows)
 | 
			
		||||
					if err != nil {
 | 
			
		||||
						log.Fatal("unable to render to JSON: %s", err)
 | 
			
		||||
						log.Fatal(i18n.G("unable to render to JSON: %s", err))
 | 
			
		||||
					}
 | 
			
		||||
					fmt.Println(out)
 | 
			
		||||
					continue
 | 
			
		||||
@ -124,9 +135,9 @@ func sortServiceByName(versions [][]string) func(i, j int) bool {
 | 
			
		||||
func init() {
 | 
			
		||||
	RecipeVersionCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.MachineReadable,
 | 
			
		||||
		"machine",
 | 
			
		||||
		"m",
 | 
			
		||||
		i18n.G("machine"),
 | 
			
		||||
		i18n.G("m"),
 | 
			
		||||
		false,
 | 
			
		||||
		"print machine-readable output",
 | 
			
		||||
		i18n.G("print machine-readable output"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										196
									
								
								cli/run.go
									
									
									
									
									
								
							
							
						
						
									
										196
									
								
								cli/run.go
									
									
									
									
									
								
							@ -1,8 +1,10 @@
 | 
			
		||||
package cli
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/app"
 | 
			
		||||
	"coopcloud.tech/abra/cli/catalogue"
 | 
			
		||||
@ -10,70 +12,159 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/cli/recipe"
 | 
			
		||||
	"coopcloud.tech/abra/cli/server"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	charmLog "github.com/charmbracelet/log"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
	"github.com/spf13/cobra/doc"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	// translators: `abra` usage template. please translate only words like
 | 
			
		||||
	// "Aliases" and "Example" and nothing inside the {{ ... }}
 | 
			
		||||
	usageTemplate = i18n.G(`Usage:{{if .Runnable}}
 | 
			
		||||
  {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
 | 
			
		||||
  {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
 | 
			
		||||
 | 
			
		||||
Aliases:
 | 
			
		||||
  {{.NameAndAliases}}{{end}}{{if .HasExample}}
 | 
			
		||||
 | 
			
		||||
Examples:
 | 
			
		||||
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
 | 
			
		||||
 | 
			
		||||
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
 | 
			
		||||
  {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
 | 
			
		||||
 | 
			
		||||
Flags:
 | 
			
		||||
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
 | 
			
		||||
 | 
			
		||||
Global Flags:
 | 
			
		||||
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
 | 
			
		||||
 | 
			
		||||
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
 | 
			
		||||
  {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
 | 
			
		||||
 | 
			
		||||
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
 | 
			
		||||
`)
 | 
			
		||||
 | 
			
		||||
	helpCmd = &cobra.Command{
 | 
			
		||||
		Use: i18n.G("help [command]"),
 | 
			
		||||
		// translators: Short description for `help` command
 | 
			
		||||
		Short: i18n.G("Help about any command"),
 | 
			
		||||
		Long: i18n.G(`Help provides help for any command in the application.
 | 
			
		||||
Simply type abra help [path to command] for full details.`),
 | 
			
		||||
		Run: func(c *cobra.Command, args []string) {
 | 
			
		||||
			cmd, _, e := c.Root().Find(args)
 | 
			
		||||
			if cmd == nil || e != nil {
 | 
			
		||||
				c.Print(i18n.G("unknown help topic %#q\n", args))
 | 
			
		||||
				if err := c.Root().Usage(); err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				cmd.InitDefaultHelpFlag()
 | 
			
		||||
				cmd.InitDefaultVersionFlag()
 | 
			
		||||
				if err := cmd.Help(); err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func Run(version, commit string) {
 | 
			
		||||
	rootCmd := &cobra.Command{
 | 
			
		||||
		Use:     "abra [cmd] [args] [flags]",
 | 
			
		||||
		Short:   "The Co-op Cloud command-line utility belt 🎩🐇",
 | 
			
		||||
		// translators: `abra` binary name
 | 
			
		||||
		Use: i18n.G("abra [cmd] [args] [flags]"),
 | 
			
		||||
		// translators: Short description for `abra` binary
 | 
			
		||||
		Short: i18n.G("The Co-op Cloud command-line utility belt 🎩🐇"),
 | 
			
		||||
		// translators: Long description for `abra` binary. This needs to be
 | 
			
		||||
		// translated in the same way as the Short description so that everything
 | 
			
		||||
		// matches up
 | 
			
		||||
		Long: i18n.G(`The Co-op Cloud command-line utility belt 🎩🐇
 | 
			
		||||
 | 
			
		||||
Config:
 | 
			
		||||
  $ABRA_DIR: %s`, config.ABRA_DIR),
 | 
			
		||||
		Version: fmt.Sprintf("%s-%s", version, commit[:7]),
 | 
			
		||||
		ValidArgs: []string{
 | 
			
		||||
			"app",
 | 
			
		||||
			"autocomplete",
 | 
			
		||||
			"catalogue",
 | 
			
		||||
			"man",
 | 
			
		||||
			"recipe",
 | 
			
		||||
			"server",
 | 
			
		||||
			"upgrade",
 | 
			
		||||
			// translators: `abra app` command for autocompletion
 | 
			
		||||
			i18n.G("app"),
 | 
			
		||||
			// translators: `abra autocomplete` command for autocompletion
 | 
			
		||||
			i18n.G("autocomplete"),
 | 
			
		||||
			// translators: `abra catalogue` command for autocompletion
 | 
			
		||||
			i18n.G("catalogue"),
 | 
			
		||||
			// translators: `abra man` command for autocompletion
 | 
			
		||||
			i18n.G("man"),
 | 
			
		||||
			// translators: `abra recipe` command for autocompletion
 | 
			
		||||
			i18n.G("recipe"),
 | 
			
		||||
			// translators: `abra server` command for autocompletion
 | 
			
		||||
			i18n.G("server"),
 | 
			
		||||
			// translators: `abra upgrade` command for autocompletion
 | 
			
		||||
			i18n.G("upgrade"),
 | 
			
		||||
		},
 | 
			
		||||
		PersistentPreRun: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
			paths := []string{
 | 
			
		||||
				config.ABRA_DIR,
 | 
			
		||||
				config.SERVERS_DIR,
 | 
			
		||||
				config.RECIPES_DIR,
 | 
			
		||||
				config.VENDOR_DIR, // TODO(d1): remove > 0.9.x
 | 
			
		||||
				config.BACKUP_DIR, // TODO(d1): remove > 0.9.x
 | 
			
		||||
		PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
 | 
			
		||||
			dirs := []map[string]os.FileMode{
 | 
			
		||||
				{config.ABRA_DIR: 0764},
 | 
			
		||||
				{config.SERVERS_DIR: 0700},
 | 
			
		||||
				{config.RECIPES_DIR: 0764},
 | 
			
		||||
				{config.LOGS_DIR: 0764},
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for _, path := range paths {
 | 
			
		||||
				if err := os.Mkdir(path, 0764); err != nil {
 | 
			
		||||
					if !os.IsExist(err) {
 | 
			
		||||
						log.Fatal(err)
 | 
			
		||||
			for _, dir := range dirs {
 | 
			
		||||
				for path, perm := range dir {
 | 
			
		||||
					if err := os.Mkdir(path, perm); err != nil {
 | 
			
		||||
						if !os.IsExist(err) {
 | 
			
		||||
							return errors.New(i18n.G("unable to create %s: %s", path, err))
 | 
			
		||||
						}
 | 
			
		||||
						continue
 | 
			
		||||
					}
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Logger.SetStyles(log.Styles())
 | 
			
		||||
			log.Logger.SetStyles(charmLog.DefaultStyles())
 | 
			
		||||
			charmLog.SetDefault(log.Logger)
 | 
			
		||||
 | 
			
		||||
			if internal.MachineReadable {
 | 
			
		||||
				log.SetOutput(os.Stderr)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if internal.Debug {
 | 
			
		||||
				log.SetLevel(log.DebugLevel)
 | 
			
		||||
				log.SetOutput(os.Stderr)
 | 
			
		||||
				log.SetReportCaller(true)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debugf("abra version %s, commit %s", version, commit)
 | 
			
		||||
			log.Debug(i18n.G(
 | 
			
		||||
				"abra version: %s, commit: %s, lang: %s",
 | 
			
		||||
				version, formatter.SmallSHA(commit), i18n.Locale,
 | 
			
		||||
			))
 | 
			
		||||
 | 
			
		||||
			return nil
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rootCmd.CompletionOptions.DisableDefaultCmd = true
 | 
			
		||||
	rootCmd.SetUsageTemplate(usageTemplate)
 | 
			
		||||
	rootCmd.SetHelpCommand(helpCmd)
 | 
			
		||||
 | 
			
		||||
	// translators: `abra man` aliases. use a comma separated list of aliases
 | 
			
		||||
	// with no spaces in between
 | 
			
		||||
	manAliases := i18n.G("m")
 | 
			
		||||
 | 
			
		||||
	manCommand := &cobra.Command{
 | 
			
		||||
		Use:     "man [flags]",
 | 
			
		||||
		Aliases: []string{"m"},
 | 
			
		||||
		Short:   "Generate manpage",
 | 
			
		||||
		Example: `  # generate the man pages into /usr/local/share/man/man1
 | 
			
		||||
  sudo abra man
 | 
			
		||||
		// translators: `man` command
 | 
			
		||||
		Use:     i18n.G("man [flags]"),
 | 
			
		||||
		Aliases: strings.Split(manAliases, ","),
 | 
			
		||||
		// translators: Short description for `man` command
 | 
			
		||||
		Short: i18n.G("Generate manpage"),
 | 
			
		||||
		Example: i18n.G(`  # generate the man pages into /usr/local/share/man/man1
 | 
			
		||||
  abra_path=$(which abra)  # pass abra absolute path to sudo below
 | 
			
		||||
  sudo $abra_path man
 | 
			
		||||
  sudo mandb
 | 
			
		||||
 | 
			
		||||
  # read the man pages
 | 
			
		||||
  man abra
 | 
			
		||||
  man abra-app-deploy`,
 | 
			
		||||
  man abra-app-deploy`),
 | 
			
		||||
		Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
			header := &doc.GenManHeader{
 | 
			
		||||
				Title:   "ABRA",
 | 
			
		||||
@ -82,7 +173,7 @@ func Run(version, commit string) {
 | 
			
		||||
 | 
			
		||||
			manDir := "/usr/local/share/man/man1"
 | 
			
		||||
			if _, err := os.Stat(manDir); os.IsNotExist(err) {
 | 
			
		||||
				log.Fatalf("unable to proceed, '%s' does not exist?")
 | 
			
		||||
				log.Fatal(i18n.G("unable to proceed, %s does not exist?", manDir))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			err := doc.GenManTree(rootCmd, header, manDir)
 | 
			
		||||
@ -90,27 +181,53 @@ func Run(version, commit string) {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Info("don't forget to run 'sudo mandb'")
 | 
			
		||||
			log.Info(i18n.G("don't forget to run 'sudo mandb'"))
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rootCmd.PersistentFlags().BoolVarP(
 | 
			
		||||
		&internal.Debug, "debug", "d", false,
 | 
			
		||||
		"show debug messages",
 | 
			
		||||
		&internal.Debug,
 | 
			
		||||
		"debug",
 | 
			
		||||
		"d",
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("show debug messages"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	rootCmd.PersistentFlags().BoolVarP(
 | 
			
		||||
		&internal.NoInput, "no-input", "n", false,
 | 
			
		||||
		"toggle non-interactive mode",
 | 
			
		||||
		&internal.NoInput,
 | 
			
		||||
		"no-input",
 | 
			
		||||
		"n",
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("toggle non-interactive mode"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	rootCmd.PersistentFlags().BoolVarP(
 | 
			
		||||
		&internal.Offline, "offline", "o", false,
 | 
			
		||||
		"prefer offline & filesystem access",
 | 
			
		||||
		&internal.Offline,
 | 
			
		||||
		"offline",
 | 
			
		||||
		"o",
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("prefer offline & filesystem access"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	rootCmd.PersistentFlags().BoolVarP(
 | 
			
		||||
		&internal.Help,
 | 
			
		||||
		i18n.G("help"),
 | 
			
		||||
		i18n.G("h"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("help for abra"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	rootCmd.Flags().BoolVarP(
 | 
			
		||||
		&internal.Version,
 | 
			
		||||
		i18n.G("version"),
 | 
			
		||||
		i18n.G("v"),
 | 
			
		||||
		false,
 | 
			
		||||
		i18n.G("version for abra"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	catalogue.CatalogueCommand.AddCommand(
 | 
			
		||||
		catalogue.CatalogueGenerateCommand,
 | 
			
		||||
		catalogue.CatalogueSyncCommand,
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	server.ServerCommand.AddCommand(
 | 
			
		||||
@ -181,15 +298,18 @@ func Run(version, commit string) {
 | 
			
		||||
		app.AppRestartCommand,
 | 
			
		||||
		app.AppRestoreCommand,
 | 
			
		||||
		app.AppRollbackCommand,
 | 
			
		||||
		app.AppMoveCommand,
 | 
			
		||||
		app.AppRunCommand,
 | 
			
		||||
		app.AppSecretCommand,
 | 
			
		||||
		app.AppServicesCommand,
 | 
			
		||||
		app.AppUndeployCommand,
 | 
			
		||||
		app.AppUpgradeCommand,
 | 
			
		||||
		app.AppVolumeCommand,
 | 
			
		||||
		app.AppLabelsCommand,
 | 
			
		||||
		app.AppEnvCommand,
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	if err := rootCmd.Execute(); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
		os.Exit(1)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@ package server
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
@ -10,17 +11,24 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	contextPkg "coopcloud.tech/abra/pkg/context"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/dns"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/server"
 | 
			
		||||
	sshPkg "coopcloud.tech/abra/pkg/ssh"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra server add` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var serverAddAliases = i18n.GC("a", "server add")
 | 
			
		||||
 | 
			
		||||
var ServerAddCommand = &cobra.Command{
 | 
			
		||||
	Use:     "add [[server] | --local] [flags]",
 | 
			
		||||
	Aliases: []string{"a"},
 | 
			
		||||
	Short:   "Add a new server",
 | 
			
		||||
	Long: `Add a new server to your configuration so that it can be managed by Abra.
 | 
			
		||||
	// translators: `server add` command
 | 
			
		||||
	Use:     i18n.G("add [[server] | --local] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(serverAddAliases, ","),
 | 
			
		||||
	// translators: Short description for `server add` command
 | 
			
		||||
	Short: i18n.G("Add a new server"),
 | 
			
		||||
	Long: i18n.G(`Add a new server to your configuration so that it can be managed by Abra.
 | 
			
		||||
 | 
			
		||||
Abra relies on the standard SSH command-line and ~/.ssh/config for client
 | 
			
		||||
connection details. You must configure an entry per-host in your ~/.ssh/config
 | 
			
		||||
@ -35,8 +43,8 @@ for each server:
 | 
			
		||||
If "--local" is passed, then Abra assumes that the current local server is
 | 
			
		||||
intended as the target server. This is useful when you want to have your entire
 | 
			
		||||
Co-op Cloud config located on the server itself, and not on your local
 | 
			
		||||
developer machine. The domain is then set to "default".`,
 | 
			
		||||
	Example: "  abra server add 1312.net",
 | 
			
		||||
developer machine. The domain is then set to "default".`),
 | 
			
		||||
	Example: i18n.G("  abra server add 1312.net"),
 | 
			
		||||
	Args:    cobra.RangeArgs(0, 1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -49,11 +57,11 @@ developer machine. The domain is then set to "default".`,
 | 
			
		||||
	},
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		if len(args) > 0 && local {
 | 
			
		||||
			log.Fatal("cannot use [server] and --local together")
 | 
			
		||||
			log.Fatal(i18n.G("cannot use [server] and --local together"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(args) == 0 && !local {
 | 
			
		||||
			log.Fatal("missing argument or --local/-l flag")
 | 
			
		||||
			log.Fatal(i18n.G("missing argument or --local/-l flag"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		name := "default"
 | 
			
		||||
@ -72,7 +80,7 @@ developer machine. The domain is then set to "default".`,
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debugf("attempting to create client for %s", name)
 | 
			
		||||
			log.Debug(i18n.G("attempting to create client for %s", name))
 | 
			
		||||
 | 
			
		||||
			if _, err := client.New(name, timeout); err != nil {
 | 
			
		||||
				cleanUp(name)
 | 
			
		||||
@ -80,9 +88,9 @@ developer machine. The domain is then set to "default".`,
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if created {
 | 
			
		||||
				log.Info("local server successfully added")
 | 
			
		||||
				log.Info(i18n.G("local server successfully added"))
 | 
			
		||||
			} else {
 | 
			
		||||
				log.Warn("local server already exists")
 | 
			
		||||
				log.Warn(i18n.G("local server already exists"))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return
 | 
			
		||||
@ -96,28 +104,27 @@ developer machine. The domain is then set to "default".`,
 | 
			
		||||
		created, err := newContext(name)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			cleanUp(name)
 | 
			
		||||
			log.Fatalf("unable to create local context: %s", err)
 | 
			
		||||
			log.Fatal(i18n.G("unable to create local context: %s", err))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("attempting to create client for %s", name)
 | 
			
		||||
		log.Debug(i18n.G("attempting to create client for %s", name))
 | 
			
		||||
 | 
			
		||||
		if _, err := client.New(name, timeout); err != nil {
 | 
			
		||||
			cleanUp(name)
 | 
			
		||||
			log.Debugf("ssh %s error: %s", name, sshPkg.Fatal(name, err))
 | 
			
		||||
			log.Fatalf("can't ssh to %s, make sure \"ssh %s\" works", name, name)
 | 
			
		||||
			log.Fatal(i18n.G("ssh %s error: %s", name, sshPkg.Fatal(name, err)))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if created {
 | 
			
		||||
			log.Infof("%s successfully added", name)
 | 
			
		||||
			log.Info(i18n.G("%s successfully added", name))
 | 
			
		||||
 | 
			
		||||
			if _, err := dns.EnsureIPv4(name); err != nil {
 | 
			
		||||
				log.Warnf("unable to resolve IPv4 for %s", name)
 | 
			
		||||
				log.Warn(i18n.G("unable to resolve IPv4 for %s", name))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Warnf("%s already exists", name)
 | 
			
		||||
		log.Warn(i18n.G("%s already exists", name))
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -125,7 +132,7 @@ developer machine. The domain is then set to "default".`,
 | 
			
		||||
// "server add" attempt.
 | 
			
		||||
func cleanUp(name string) {
 | 
			
		||||
	if name != "default" {
 | 
			
		||||
		log.Debugf("serverAdd: cleanUp: cleaning up context for %s", name)
 | 
			
		||||
		log.Debug(i18n.G("serverAdd: cleanUp: cleaning up context for %s", name))
 | 
			
		||||
		if err := client.DeleteContext(name); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
@ -134,16 +141,16 @@ func cleanUp(name string) {
 | 
			
		||||
	serverDir := filepath.Join(config.SERVERS_DIR, name)
 | 
			
		||||
	files, err := config.GetAllFilesInDirectory(serverDir)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatalf("serverAdd: cleanUp: unable to list files in %s: %s", serverDir, err)
 | 
			
		||||
		log.Fatal(i18n.G("serverAdd: cleanUp: unable to list files in %s: %s", serverDir, err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(files) > 0 {
 | 
			
		||||
		log.Debugf("serverAdd: cleanUp: %s is not empty, aborting cleanup", serverDir)
 | 
			
		||||
		log.Debug(i18n.G("serverAdd: cleanUp: %s is not empty, aborting cleanup", serverDir))
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := os.RemoveAll(serverDir); err != nil {
 | 
			
		||||
		log.Fatalf("serverAdd: cleanUp: failed to remove %s: %s", serverDir, err)
 | 
			
		||||
		log.Fatal(i18n.G("serverAdd: cleanUp: failed to remove %s: %s", serverDir, err))
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -160,12 +167,12 @@ func newContext(name string) (bool, error) {
 | 
			
		||||
 | 
			
		||||
	for _, context := range contexts {
 | 
			
		||||
		if context.Name == name {
 | 
			
		||||
			log.Debugf("context for %s already exists", name)
 | 
			
		||||
			log.Debug(i18n.G("context for %s already exists", name))
 | 
			
		||||
			return false, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("creating context with domain %s", name)
 | 
			
		||||
	log.Debugf(i18n.G("creating context with domain %s", name))
 | 
			
		||||
 | 
			
		||||
	if err := client.CreateContext(name); err != nil {
 | 
			
		||||
		return false, nil
 | 
			
		||||
@ -181,7 +188,7 @@ func createServerDir(name string) (bool, error) {
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("server dir for %s already created", name)
 | 
			
		||||
		log.Debug(i18n.G("server dir for %s already created", name))
 | 
			
		||||
 | 
			
		||||
		return false, nil
 | 
			
		||||
	}
 | 
			
		||||
@ -196,9 +203,9 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	ServerAddCommand.Flags().BoolVarP(
 | 
			
		||||
		&local,
 | 
			
		||||
		"local",
 | 
			
		||||
		"l",
 | 
			
		||||
		i18n.G("local"),
 | 
			
		||||
		i18n.G("l"),
 | 
			
		||||
		false,
 | 
			
		||||
		"use local server",
 | 
			
		||||
		i18n.G("use local server"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -8,16 +8,23 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	contextPkg "coopcloud.tech/abra/pkg/context"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/docker/cli/cli/connhelper/ssh"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra server list` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var serverListAliases = i18n.G("ls")
 | 
			
		||||
 | 
			
		||||
var ServerListCommand = &cobra.Command{
 | 
			
		||||
	Use:     "list [flags]",
 | 
			
		||||
	Aliases: []string{"ls"},
 | 
			
		||||
	Short:   "List managed servers",
 | 
			
		||||
	Args:    cobra.NoArgs,
 | 
			
		||||
	// translators: `server list` command
 | 
			
		||||
	Use:     i18n.G("list [flags]"),
 | 
			
		||||
	Aliases: strings.Split(serverListAliases, ","),
 | 
			
		||||
	// translators: Short description for `server list` command
 | 
			
		||||
	Short: i18n.G("List managed servers"),
 | 
			
		||||
	Args:  cobra.NoArgs,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		dockerContextStore := contextPkg.NewDefaultDockerContextStore()
 | 
			
		||||
		contexts, err := dockerContextStore.Store.List()
 | 
			
		||||
@ -30,7 +37,7 @@ var ServerListCommand = &cobra.Command{
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		headers := []string{"NAME", "HOST"}
 | 
			
		||||
		headers := []string{i18n.G("NAME"), i18n.G("HOST")}
 | 
			
		||||
		table.Headers(headers...)
 | 
			
		||||
 | 
			
		||||
		serverNames, err := config.ReadServerNames()
 | 
			
		||||
@ -55,7 +62,7 @@ var ServerListCommand = &cobra.Command{
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					if sp.Host == "" {
 | 
			
		||||
						sp.Host = "unknown"
 | 
			
		||||
						sp.Host = i18n.G("unknown")
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					row = []string{serverName, sp.Host}
 | 
			
		||||
@ -65,9 +72,9 @@ var ServerListCommand = &cobra.Command{
 | 
			
		||||
 | 
			
		||||
			if len(row) == 0 {
 | 
			
		||||
				if serverName == "default" {
 | 
			
		||||
					row = []string{serverName, "local"}
 | 
			
		||||
					row = []string{serverName, i18n.G("local")}
 | 
			
		||||
				} else {
 | 
			
		||||
					row = []string{serverName, "unknown"}
 | 
			
		||||
					row = []string{serverName, i18n.G("unknown")}
 | 
			
		||||
				}
 | 
			
		||||
				rows = append(rows, row)
 | 
			
		||||
			}
 | 
			
		||||
@ -78,7 +85,7 @@ var ServerListCommand = &cobra.Command{
 | 
			
		||||
		if internal.MachineReadable {
 | 
			
		||||
			out, err := formatter.ToJSON(headers, rows)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal("unable to render to JSON: %s", err)
 | 
			
		||||
				log.Fatal(i18n.G("unable to render to JSON: %s", err))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			fmt.Println(out)
 | 
			
		||||
@ -95,9 +102,9 @@ var ServerListCommand = &cobra.Command{
 | 
			
		||||
func init() {
 | 
			
		||||
	ServerListCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.MachineReadable,
 | 
			
		||||
		"machine",
 | 
			
		||||
		"m",
 | 
			
		||||
		i18n.G("machine"),
 | 
			
		||||
		i18n.G("m"),
 | 
			
		||||
		false,
 | 
			
		||||
		"print machine-readable output",
 | 
			
		||||
		i18n.G("print machine-readable output"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,23 +1,32 @@
 | 
			
		||||
package server
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra server prune` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var serverPruneliases = i18n.G("p")
 | 
			
		||||
 | 
			
		||||
var ServerPruneCommand = &cobra.Command{
 | 
			
		||||
	Use:     "prune <server> [flags]",
 | 
			
		||||
	Aliases: []string{"p"},
 | 
			
		||||
	Short:   "Prune resources on a server",
 | 
			
		||||
	Long: `Prunes unused containers, networks, and dangling images.
 | 
			
		||||
	// translators: `server prune` command
 | 
			
		||||
	Use:     i18n.G("prune <server> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(serverPruneliases, ","),
 | 
			
		||||
	// translators: Short description for `server prune` command
 | 
			
		||||
	Short: i18n.G("Prune resources on a server"),
 | 
			
		||||
	Long: i18n.G(`Prunes unused containers, networks, and dangling images.
 | 
			
		||||
 | 
			
		||||
Use "--volumes/-v" to remove volumes that are not associated with a deployed
 | 
			
		||||
app. This can result in unwanted data loss if not used carefully.`,
 | 
			
		||||
app. This can result in unwanted data loss if not used carefully.`),
 | 
			
		||||
	Args: cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -41,18 +50,18 @@ app. This can result in unwanted data loss if not used carefully.`,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cntSpaceReclaimed := formatter.ByteCountSI(cr.SpaceReclaimed)
 | 
			
		||||
		log.Infof("containers pruned: %d; space reclaimed: %s", len(cr.ContainersDeleted), cntSpaceReclaimed)
 | 
			
		||||
		log.Info(i18n.G("containers pruned: %d; space reclaimed: %s", len(cr.ContainersDeleted), cntSpaceReclaimed))
 | 
			
		||||
 | 
			
		||||
		nr, err := cl.NetworksPrune(cmd.Context(), filterArgs)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Infof("networks pruned: %d", len(nr.NetworksDeleted))
 | 
			
		||||
		log.Info(i18n.G("networks pruned: %d", len(nr.NetworksDeleted)))
 | 
			
		||||
 | 
			
		||||
		pruneFilters := filters.NewArgs()
 | 
			
		||||
		if allFilter {
 | 
			
		||||
			log.Debugf("removing all images, not only dangling ones")
 | 
			
		||||
			log.Debug(i18n.G("removing all images, not only dangling ones"))
 | 
			
		||||
			pruneFilters.Add("dangling", "false")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -62,7 +71,7 @@ app. This can result in unwanted data loss if not used carefully.`,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		imgSpaceReclaimed := formatter.ByteCountSI(ir.SpaceReclaimed)
 | 
			
		||||
		log.Infof("images pruned: %d; space reclaimed: %s", len(ir.ImagesDeleted), imgSpaceReclaimed)
 | 
			
		||||
		log.Info(i18n.G("images pruned: %d; space reclaimed: %s", len(ir.ImagesDeleted), imgSpaceReclaimed))
 | 
			
		||||
 | 
			
		||||
		if volumesFilter {
 | 
			
		||||
			vr, err := cl.VolumesPrune(cmd.Context(), filterArgs)
 | 
			
		||||
@ -71,7 +80,7 @@ app. This can result in unwanted data loss if not used carefully.`,
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			volSpaceReclaimed := formatter.ByteCountSI(vr.SpaceReclaimed)
 | 
			
		||||
			log.Infof("volumes pruned: %d; space reclaimed: %s", len(vr.VolumesDeleted), volSpaceReclaimed)
 | 
			
		||||
			log.Info(i18n.G("volumes pruned: %d; space reclaimed: %s", len(vr.VolumesDeleted), volSpaceReclaimed))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return
 | 
			
		||||
@ -86,17 +95,17 @@ var (
 | 
			
		||||
func init() {
 | 
			
		||||
	ServerPruneCommand.Flags().BoolVarP(
 | 
			
		||||
		&allFilter,
 | 
			
		||||
		"all",
 | 
			
		||||
		"a",
 | 
			
		||||
		i18n.G("all"),
 | 
			
		||||
		i18n.GC("a", "server prune"),
 | 
			
		||||
		false,
 | 
			
		||||
		"remove all unused images",
 | 
			
		||||
		i18n.G("remove all unused images"),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	ServerPruneCommand.Flags().BoolVarP(
 | 
			
		||||
		&volumesFilter,
 | 
			
		||||
		"volumes",
 | 
			
		||||
		"v",
 | 
			
		||||
		i18n.G("volumes"),
 | 
			
		||||
		i18n.G("v"),
 | 
			
		||||
		false,
 | 
			
		||||
		"remove volumes",
 | 
			
		||||
		i18n.G("remove volumes"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,24 +3,32 @@ package server
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/autocomplete"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra server remove` aliases. use a comma separated list of
 | 
			
		||||
// aliases with no spaces in between
 | 
			
		||||
var serverRemoveAliases = i18n.G("rm")
 | 
			
		||||
 | 
			
		||||
var ServerRemoveCommand = &cobra.Command{
 | 
			
		||||
	Use:     "remove <server> [flags]",
 | 
			
		||||
	Aliases: []string{"rm"},
 | 
			
		||||
	Short:   "Remove a managed server",
 | 
			
		||||
	Long: `Remove a managed server.
 | 
			
		||||
	// translators: `server remove` command
 | 
			
		||||
	Use:     i18n.G("remove <server> [flags]"),
 | 
			
		||||
	Aliases: strings.Split(serverRemoveAliases, ","),
 | 
			
		||||
	// translators: Short description for `server remove` command
 | 
			
		||||
	Short: i18n.G("Remove a managed server"),
 | 
			
		||||
	Long: i18n.G(`Remove a managed server.
 | 
			
		||||
 | 
			
		||||
Abra will remove the internal bookkeeping ($ABRA_DIR/servers/...) and
 | 
			
		||||
underlying client connection context. This server will then be lost in time,
 | 
			
		||||
like tears in rain.`,
 | 
			
		||||
like tears in rain.`),
 | 
			
		||||
	Args: cobra.ExactArgs(1),
 | 
			
		||||
	ValidArgsFunction: func(
 | 
			
		||||
		cmd *cobra.Command,
 | 
			
		||||
@ -39,7 +47,7 @@ like tears in rain.`,
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Infof("%s is now lost in time, like tears in rain", serverName)
 | 
			
		||||
		log.Info(i18n.G("%s is now lost in time, like tears in rain", serverName))
 | 
			
		||||
 | 
			
		||||
		return
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,21 @@
 | 
			
		||||
package server
 | 
			
		||||
 | 
			
		||||
import "github.com/spf13/cobra"
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra server` aliases. use a comma separated list of aliases
 | 
			
		||||
// with no spaces in between
 | 
			
		||||
var serverAliases = i18n.G("s")
 | 
			
		||||
 | 
			
		||||
// ServerCommand defines the `abra server` command and its subcommands
 | 
			
		||||
var ServerCommand = &cobra.Command{
 | 
			
		||||
	Use:     "server [cmd] [args] [flags]",
 | 
			
		||||
	Aliases: []string{"s"},
 | 
			
		||||
	Short:   "Manage servers",
 | 
			
		||||
	// translators: `server` command group
 | 
			
		||||
	Use:     i18n.G("server [cmd] [args] [flags]"),
 | 
			
		||||
	Aliases: strings.Split(serverAliases, ","),
 | 
			
		||||
	// translators: Short description for `server` command group
 | 
			
		||||
	Short: i18n.G("Manage servers"),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,532 +0,0 @@
 | 
			
		||||
package updater
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/client"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/envfile"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/lint"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/convert"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
	"coopcloud.tech/tagcmp"
 | 
			
		||||
	charmLog "github.com/charmbracelet/log"
 | 
			
		||||
	composetypes "github.com/docker/cli/cli/compose/types"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
	dockerclient "github.com/docker/docker/client"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const SERVER = "localhost"
 | 
			
		||||
 | 
			
		||||
// NotifyCommand checks for available upgrades.
 | 
			
		||||
var NotifyCommand = &cobra.Command{
 | 
			
		||||
	Use:     "notify [flags]",
 | 
			
		||||
	Aliases: []string{"n"},
 | 
			
		||||
	Short:   "Check for available upgrades",
 | 
			
		||||
	Long: `Notify on new versions for deployed apps.
 | 
			
		||||
 | 
			
		||||
If a new patch/minor version is available, a notification is printed.
 | 
			
		||||
 | 
			
		||||
Use "--major/-m" to include new major versions.`,
 | 
			
		||||
	Args: cobra.NoArgs,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		cl, err := client.New("default")
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		stacks, err := stack.GetStacks(cl)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, stackInfo := range stacks {
 | 
			
		||||
			stackName := stackInfo.Name
 | 
			
		||||
			recipeName, err := getLabel(cl, stackName, "recipe")
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if recipeName != "" {
 | 
			
		||||
				_, err = getLatestUpgrade(cl, stackName, recipeName)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UpgradeCommand upgrades apps.
 | 
			
		||||
var UpgradeCommand = &cobra.Command{
 | 
			
		||||
	Use:     "upgrade [[stack] [recipe] | --all] [flags]",
 | 
			
		||||
	Aliases: []string{"u"},
 | 
			
		||||
	Short:   "Upgrade apps",
 | 
			
		||||
	Long: `Upgrade an app by specifying stack name and recipe. 
 | 
			
		||||
 | 
			
		||||
Use "--all" to upgrade every deployed app.
 | 
			
		||||
 | 
			
		||||
For each app with auto updates enabled, the deployed version is compared with
 | 
			
		||||
the current recipe catalogue version. If a new patch/minor version is
 | 
			
		||||
available, the app is upgraded.
 | 
			
		||||
 | 
			
		||||
To include major versions use the "--major/-m" flag. You probably don't want
 | 
			
		||||
that as it will break things. Only apps that are not deployed with "--chaos/-C"
 | 
			
		||||
are upgraded, to update chaos deployments use the "--chaos/-C" flag. Use it
 | 
			
		||||
with care.`,
 | 
			
		||||
	Args: cobra.RangeArgs(0, 2),
 | 
			
		||||
	// TODO(d1): complete stack/recipe
 | 
			
		||||
	// ValidArgsFunction: func(
 | 
			
		||||
	// 	cmd *cobra.Command,
 | 
			
		||||
	// 	args []string,
 | 
			
		||||
	// 	toComplete string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
	// },
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		cl, err := client.New("default")
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !updateAll && len(args) != 2 {
 | 
			
		||||
			log.Fatal("missing arguments or --all/-a flag")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !updateAll {
 | 
			
		||||
			stackName := args[0]
 | 
			
		||||
			recipeName := args[1]
 | 
			
		||||
 | 
			
		||||
			err = tryUpgrade(cl, stackName, recipeName)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		stacks, err := stack.GetStacks(cl)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, stackInfo := range stacks {
 | 
			
		||||
			stackName := stackInfo.Name
 | 
			
		||||
			recipeName, err := getLabel(cl, stackName, "recipe")
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			err = tryUpgrade(cl, stackName, recipeName)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getLabel reads docker labels from running services in the format of "coop-cloud.${STACK_NAME}.${LABEL}".
 | 
			
		||||
func getLabel(cl *dockerclient.Client, stackName string, label string) (string, error) {
 | 
			
		||||
	filter := filters.NewArgs()
 | 
			
		||||
	filter.Add("label", fmt.Sprintf("%s=%s", convert.LabelNamespace, stackName))
 | 
			
		||||
 | 
			
		||||
	services, err := cl.ServiceList(context.Background(), types.ServiceListOptions{Filters: filter})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, service := range services {
 | 
			
		||||
		labelKey := fmt.Sprintf("coop-cloud.%s.%s", stackName, label)
 | 
			
		||||
		if labelValue, ok := service.Spec.Labels[labelKey]; ok {
 | 
			
		||||
			return labelValue, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("no %s label found for %s", label, stackName)
 | 
			
		||||
 | 
			
		||||
	return "", nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getBoolLabel reads a boolean docker label from running services
 | 
			
		||||
func getBoolLabel(cl *dockerclient.Client, stackName string, label string) (bool, error) {
 | 
			
		||||
	lableValue, err := getLabel(cl, stackName, label)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if lableValue != "" {
 | 
			
		||||
		value, err := strconv.ParseBool(lableValue)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return value, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("boolean label %s could not be found for %s, set default to false.", label, stackName)
 | 
			
		||||
 | 
			
		||||
	return false, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getEnv reads env variables from docker services.
 | 
			
		||||
func getEnv(cl *dockerclient.Client, stackName string) (envfile.AppEnv, error) {
 | 
			
		||||
	envMap := make(map[string]string)
 | 
			
		||||
	filter := filters.NewArgs()
 | 
			
		||||
	filter.Add("label", fmt.Sprintf("%s=%s", convert.LabelNamespace, stackName))
 | 
			
		||||
 | 
			
		||||
	services, err := cl.ServiceList(context.Background(), types.ServiceListOptions{Filters: filter})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, service := range services {
 | 
			
		||||
		envList := service.Spec.TaskTemplate.ContainerSpec.Env
 | 
			
		||||
		for _, envString := range envList {
 | 
			
		||||
			splitString := strings.SplitN(envString, "=", 2)
 | 
			
		||||
			if len(splitString) != 2 {
 | 
			
		||||
				log.Debugf("can't separate key from value: %s (this variable is probably unset)", envString)
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			k := splitString[0]
 | 
			
		||||
			v := splitString[1]
 | 
			
		||||
			log.Debugf("for %s read env %s with value: %s from docker service", stackName, k, v)
 | 
			
		||||
			envMap[k] = v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return envMap, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getLatestUpgrade returns the latest available version for an app respecting
 | 
			
		||||
// the "--major" flag if it is newer than the currently deployed version.
 | 
			
		||||
func getLatestUpgrade(cl *dockerclient.Client, stackName string, recipeName string) (string, error) {
 | 
			
		||||
	deployedVersion, err := getDeployedVersion(cl, stackName, recipeName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	availableUpgrades, err := getAvailableUpgrades(cl, stackName, recipeName, deployedVersion)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(availableUpgrades) == 0 {
 | 
			
		||||
		log.Debugf("no available upgrades for %s", stackName)
 | 
			
		||||
		return "", nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var chosenUpgrade string
 | 
			
		||||
	if len(availableUpgrades) > 0 {
 | 
			
		||||
		chosenUpgrade = availableUpgrades[len(availableUpgrades)-1]
 | 
			
		||||
		log.Infof("%s (%s) can be upgraded from version %s to %s", stackName, recipeName, deployedVersion, chosenUpgrade)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return chosenUpgrade, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getDeployedVersion returns the currently deployed version of an app.
 | 
			
		||||
func getDeployedVersion(cl *dockerclient.Client, stackName string, recipeName string) (string, error) {
 | 
			
		||||
	log.Debugf("retrieve deployed version whether %s is already deployed", stackName)
 | 
			
		||||
 | 
			
		||||
	deployMeta, err := stack.IsDeployed(context.Background(), cl, stackName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !deployMeta.IsDeployed {
 | 
			
		||||
		return "", fmt.Errorf("%s is not deployed?", stackName)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if deployMeta.Version == "unknown" {
 | 
			
		||||
		return "", fmt.Errorf("failed to determine deployed version of %s", stackName)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return deployMeta.Version, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getAvailableUpgrades returns all available versions of an app that are newer
 | 
			
		||||
// than the deployed version. It only includes major upgrades if the "--major"
 | 
			
		||||
// flag is set.
 | 
			
		||||
func getAvailableUpgrades(cl *dockerclient.Client, stackName string, recipeName string,
 | 
			
		||||
	deployedVersion string) ([]string, error) {
 | 
			
		||||
	catl, err := recipe.ReadRecipeCatalogue(internal.Offline)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	versions, err := recipe.GetRecipeCatalogueVersions(recipeName, catl)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(versions) == 0 {
 | 
			
		||||
		log.Warnf("no published releases for %s in the recipe catalogue?", recipeName)
 | 
			
		||||
		return nil, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var availableUpgrades []string
 | 
			
		||||
	for _, version := range versions {
 | 
			
		||||
		parsedDeployedVersion, err := tagcmp.Parse(deployedVersion)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		parsedVersion, err := tagcmp.Parse(version)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		versionDelta, err := parsedDeployedVersion.UpgradeDelta(parsedVersion)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if 0 < versionDelta.UpgradeType() && (versionDelta.UpgradeType() < 4 || includeMajorUpdates) {
 | 
			
		||||
			availableUpgrades = append(availableUpgrades, version)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("available updates for %s: %s", stackName, availableUpgrades)
 | 
			
		||||
 | 
			
		||||
	return availableUpgrades, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// processRecipeRepoVersion clones, pulls, checks out the version and lints the
 | 
			
		||||
// recipe repository.
 | 
			
		||||
func processRecipeRepoVersion(r recipe.Recipe, version string) error {
 | 
			
		||||
	if err := r.EnsureExists(); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := r.EnsureUpToDate(); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, err := r.EnsureVersion(version); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := lint.LintForErrors(r); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// mergeAbraShEnv merges abra.sh env vars into the app env vars.
 | 
			
		||||
func mergeAbraShEnv(recipe recipe.Recipe, env envfile.AppEnv) error {
 | 
			
		||||
	abraShEnv, err := envfile.ReadAbraShEnvVars(recipe.AbraShPath)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for k, v := range abraShEnv {
 | 
			
		||||
		log.Debugf("read v:%s k: %s", v, k)
 | 
			
		||||
		env[k] = v
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// createDeployConfig merges and enriches the compose config for the deployment.
 | 
			
		||||
func createDeployConfig(r recipe.Recipe, stackName string, env envfile.AppEnv) (*composetypes.Config, stack.Deploy, error) {
 | 
			
		||||
	env["STACK_NAME"] = stackName
 | 
			
		||||
 | 
			
		||||
	deployOpts := stack.Deploy{
 | 
			
		||||
		Namespace:    stackName,
 | 
			
		||||
		Prune:        false,
 | 
			
		||||
		ResolveImage: stack.ResolveImageAlways,
 | 
			
		||||
		Detach:       false,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	composeFiles, err := r.GetComposeFiles(env)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, deployOpts, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	deployOpts.Composefiles = composeFiles
 | 
			
		||||
	compose, err := appPkg.GetAppComposeConfig(stackName, deployOpts, env)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, deployOpts, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	appPkg.ExposeAllEnv(stackName, compose, env)
 | 
			
		||||
 | 
			
		||||
	// after the upgrade the deployment won't be in chaos state anymore
 | 
			
		||||
	appPkg.SetChaosLabel(compose, stackName, false)
 | 
			
		||||
	appPkg.SetRecipeLabel(compose, stackName, r.Name)
 | 
			
		||||
	appPkg.SetUpdateLabel(compose, stackName, env)
 | 
			
		||||
 | 
			
		||||
	return compose, deployOpts, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// tryUpgrade performs the upgrade if all the requirements are fulfilled.
 | 
			
		||||
func tryUpgrade(cl *dockerclient.Client, stackName, recipeName string) error {
 | 
			
		||||
	if recipeName == "" {
 | 
			
		||||
		log.Debugf("don't update %s due to missing recipe name", stackName)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	chaos, err := getBoolLabel(cl, stackName, "chaos")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if chaos && !internal.Chaos {
 | 
			
		||||
		log.Debugf("don't update %s due to chaos deployment", stackName)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	updatesEnabled, err := getBoolLabel(cl, stackName, "autoupdate")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !updatesEnabled {
 | 
			
		||||
		log.Debugf("don't update %s due to disabled auto updates or missing ENABLE_AUTO_UPDATE env", stackName)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	upgradeVersion, err := getLatestUpgrade(cl, stackName, recipeName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if upgradeVersion == "" {
 | 
			
		||||
		log.Debugf("don't update %s due to no new version", stackName)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = upgrade(cl, stackName, recipeName, upgradeVersion)
 | 
			
		||||
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// upgrade performs all necessary steps to upgrade an app.
 | 
			
		||||
func upgrade(cl *dockerclient.Client, stackName, recipeName, upgradeVersion string) error {
 | 
			
		||||
	env, err := getEnv(cl, stackName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	app := appPkg.App{
 | 
			
		||||
		Name:   stackName,
 | 
			
		||||
		Recipe: recipe.Get(recipeName),
 | 
			
		||||
		Server: SERVER,
 | 
			
		||||
		Env:    env,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	r := recipe.Get(recipeName)
 | 
			
		||||
 | 
			
		||||
	if err = processRecipeRepoVersion(r, upgradeVersion); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err = mergeAbraShEnv(app.Recipe, app.Env); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	compose, deployOpts, err := createDeployConfig(r, stackName, app.Env)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Infof("upgrade %s (%s) to version %s", stackName, recipeName, upgradeVersion)
 | 
			
		||||
 | 
			
		||||
	err = stack.RunDeploy(cl, deployOpts, compose, stackName, true)
 | 
			
		||||
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newKadabraApp(version, commit string) *cobra.Command {
 | 
			
		||||
	rootCmd := &cobra.Command{
 | 
			
		||||
		Use:     "kadabra [cmd] [flags]",
 | 
			
		||||
		Version: fmt.Sprintf("%s-%s", version, commit[:7]),
 | 
			
		||||
		Short:   "The Co-op Cloud auto-updater 🤖 🚀",
 | 
			
		||||
		PersistentPreRun: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
			log.Logger.SetStyles(log.Styles())
 | 
			
		||||
			charmLog.SetDefault(log.Logger)
 | 
			
		||||
 | 
			
		||||
			if internal.Debug {
 | 
			
		||||
				log.SetLevel(log.DebugLevel)
 | 
			
		||||
				log.SetOutput(os.Stderr)
 | 
			
		||||
				log.SetReportCaller(true)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debugf("kadabra version %s, commit %s", version, commit)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rootCmd.PersistentFlags().BoolVarP(
 | 
			
		||||
		&internal.Debug, "debug", "d", false,
 | 
			
		||||
		"show debug messages",
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	rootCmd.PersistentFlags().BoolVarP(
 | 
			
		||||
		&internal.NoInput, "no-input", "n", false,
 | 
			
		||||
		"toggle non-interactive mode",
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	rootCmd.AddCommand(
 | 
			
		||||
		NotifyCommand,
 | 
			
		||||
		UpgradeCommand,
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	return rootCmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RunApp runs CLI abra app.
 | 
			
		||||
func RunApp(version, commit string) {
 | 
			
		||||
	app := newKadabraApp(version, commit)
 | 
			
		||||
 | 
			
		||||
	if err := app.Execute(); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	includeMajorUpdates bool
 | 
			
		||||
	updateAll           bool
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	NotifyCommand.Flags().BoolVarP(
 | 
			
		||||
		&includeMajorUpdates,
 | 
			
		||||
		"major",
 | 
			
		||||
		"m",
 | 
			
		||||
		false,
 | 
			
		||||
		"check for major updates",
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	UpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
		"chaos",
 | 
			
		||||
		"C",
 | 
			
		||||
		false,
 | 
			
		||||
		"ignore uncommitted recipes changes",
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	UpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&includeMajorUpdates,
 | 
			
		||||
		"major",
 | 
			
		||||
		"m",
 | 
			
		||||
		false,
 | 
			
		||||
		"check for major updates",
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	UpgradeCommand.Flags().BoolVarP(
 | 
			
		||||
		&updateAll,
 | 
			
		||||
		"all",
 | 
			
		||||
		"a",
 | 
			
		||||
		false,
 | 
			
		||||
		"update all deployed apps",
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
@ -4,25 +4,33 @@ package cli
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os/exec"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/internal"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// translators: `abra upgrade` aliases. use a comma separated list of aliases with
 | 
			
		||||
// no spaces in between
 | 
			
		||||
var upgradeAliases = i18n.G("u")
 | 
			
		||||
 | 
			
		||||
// UpgradeCommand upgrades abra in-place.
 | 
			
		||||
var UpgradeCommand = &cobra.Command{
 | 
			
		||||
	Use:     "upgrade [flags]",
 | 
			
		||||
	Aliases: []string{"u"},
 | 
			
		||||
	Short:   "Upgrade abra",
 | 
			
		||||
	Long: `Upgrade abra in-place with the latest stable or release candidate.
 | 
			
		||||
	// translators: `upgrade` command
 | 
			
		||||
	Use:     i18n.G("upgrade [flags]"),
 | 
			
		||||
	Aliases: strings.Split(upgradeAliases, ","),
 | 
			
		||||
	// translators: Short description for `upgrade` command
 | 
			
		||||
	Short: i18n.G("Upgrade abra"),
 | 
			
		||||
	Long: i18n.G(`Upgrade abra in-place with the latest stable or release candidate.
 | 
			
		||||
 | 
			
		||||
By default, the latest stable release is downloaded.
 | 
			
		||||
 | 
			
		||||
Use "--rc/-r" to install the latest release candidate. Please bear in mind that
 | 
			
		||||
it may contain absolutely catastrophic deal-breaker bugs. Thank you very much
 | 
			
		||||
for the testing efforts 💗`,
 | 
			
		||||
	Example: "  abra upgrade --rc",
 | 
			
		||||
for the testing efforts 💗`),
 | 
			
		||||
	Example: i18n.G("  abra upgrade --rc"),
 | 
			
		||||
	Args:    cobra.NoArgs,
 | 
			
		||||
	Run: func(cmd *cobra.Command, args []string) {
 | 
			
		||||
		mainURL := "https://install.abra.coopcloud.tech"
 | 
			
		||||
@ -33,7 +41,7 @@ for the testing efforts 💗`,
 | 
			
		||||
			c = exec.Command("bash", "-c", fmt.Sprintf("wget -q -O- %s | bash -s -- --rc", releaseCandidateURL))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("attempting to run %s", c)
 | 
			
		||||
		log.Debugf(i18n.G("attempting to run %s", c))
 | 
			
		||||
 | 
			
		||||
		if err := internal.RunCmd(c); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
@ -51,6 +59,6 @@ func init() {
 | 
			
		||||
		"rc",
 | 
			
		||||
		"r",
 | 
			
		||||
		false,
 | 
			
		||||
		"install release candidate (may contain bugs)",
 | 
			
		||||
		i18n.G("install release candidate (may contain bugs)"),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,23 +0,0 @@
 | 
			
		||||
// Package main provides the command-line entrypoint.
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"coopcloud.tech/abra/cli/updater"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Version is the current version of Kadabra.
 | 
			
		||||
var Version string
 | 
			
		||||
 | 
			
		||||
// Commit is the current git commit of Kadabra.
 | 
			
		||||
var Commit string
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	if Version == "" {
 | 
			
		||||
		Version = "dev"
 | 
			
		||||
	}
 | 
			
		||||
	if Commit == "" {
 | 
			
		||||
		Commit = "       "
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	updater.RunApp(Version, Commit)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										170
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										170
									
								
								go.mod
									
									
									
									
									
								
							@ -1,129 +1,141 @@
 | 
			
		||||
module coopcloud.tech/abra
 | 
			
		||||
 | 
			
		||||
go 1.22.7
 | 
			
		||||
go 1.24.0
 | 
			
		||||
 | 
			
		||||
toolchain go1.23.1
 | 
			
		||||
 | 
			
		||||
replace github.com/urfave/cli/v3 => github.com/urfave/cli/v3 v3.0.0-alpha9.1.0.20241019193437-5053ec708a44
 | 
			
		||||
toolchain go1.24.1
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	coopcloud.tech/tagcmp v0.0.0-20230809071031-eb3e7758d4eb
 | 
			
		||||
	git.coopcloud.tech/coop-cloud/godotenv v1.5.2-0.20231130100509-01bff8284355
 | 
			
		||||
	coopcloud.tech/tagcmp v0.0.0-20250818180036-0ec1b205b5ca
 | 
			
		||||
	git.coopcloud.tech/toolshed/godotenv v1.5.2-0.20250103171850-4d0ca41daa5c
 | 
			
		||||
	github.com/AlecAivazis/survey/v2 v2.3.7
 | 
			
		||||
	github.com/charmbracelet/lipgloss v1.0.0
 | 
			
		||||
	github.com/charmbracelet/log v0.4.0
 | 
			
		||||
	github.com/charmbracelet/bubbles v0.21.0
 | 
			
		||||
	github.com/charmbracelet/bubbletea v1.3.10
 | 
			
		||||
	github.com/charmbracelet/lipgloss v1.1.0
 | 
			
		||||
	github.com/charmbracelet/log v0.4.2
 | 
			
		||||
	github.com/distribution/reference v0.6.0
 | 
			
		||||
	github.com/docker/cli v27.4.1+incompatible
 | 
			
		||||
	github.com/docker/docker v27.4.1+incompatible
 | 
			
		||||
	github.com/docker/cli v28.4.0+incompatible
 | 
			
		||||
	github.com/docker/docker v28.4.0+incompatible
 | 
			
		||||
	github.com/docker/go-units v0.5.0
 | 
			
		||||
	github.com/go-git/go-git/v5 v5.12.0
 | 
			
		||||
	github.com/google/go-cmp v0.6.0
 | 
			
		||||
	github.com/evertras/bubble-table v0.19.2
 | 
			
		||||
	github.com/go-git/go-git/v5 v5.16.2
 | 
			
		||||
	github.com/google/go-cmp v0.7.0
 | 
			
		||||
	github.com/leonelquinteros/gotext v1.7.2
 | 
			
		||||
	github.com/moby/sys/signal v0.7.1
 | 
			
		||||
	github.com/moby/term v0.5.0
 | 
			
		||||
	github.com/moby/term v0.5.2
 | 
			
		||||
	github.com/pkg/errors v0.9.1
 | 
			
		||||
	github.com/schollz/progressbar/v3 v3.17.1
 | 
			
		||||
	github.com/urfave/cli/v3 v3.0.0-alpha9
 | 
			
		||||
	golang.org/x/term v0.27.0
 | 
			
		||||
	github.com/schollz/progressbar/v3 v3.18.0
 | 
			
		||||
	golang.org/x/term v0.35.0
 | 
			
		||||
	gopkg.in/yaml.v3 v3.0.1
 | 
			
		||||
	gotest.tools/v3 v3.5.1
 | 
			
		||||
	gotest.tools/v3 v3.5.2
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	dario.cat/mergo v1.0.1 // indirect
 | 
			
		||||
	github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
 | 
			
		||||
	github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
 | 
			
		||||
	github.com/BurntSushi/toml v1.4.0 // indirect
 | 
			
		||||
	dario.cat/mergo v1.0.2 // indirect
 | 
			
		||||
	github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
 | 
			
		||||
	github.com/BurntSushi/toml v1.5.0 // indirect
 | 
			
		||||
	github.com/Microsoft/go-winio v0.6.2 // indirect
 | 
			
		||||
	github.com/ProtonMail/go-crypto v1.1.3 // indirect
 | 
			
		||||
	github.com/ProtonMail/go-crypto v1.3.0 // indirect
 | 
			
		||||
	github.com/atotto/clipboard v0.1.4 // indirect
 | 
			
		||||
	github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
 | 
			
		||||
	github.com/beorn7/perks v1.0.1 // indirect
 | 
			
		||||
	github.com/cenkalti/backoff/v4 v4.3.0 // indirect
 | 
			
		||||
	github.com/cenkalti/backoff/v5 v5.0.3 // indirect
 | 
			
		||||
	github.com/cespare/xxhash/v2 v2.3.0 // indirect
 | 
			
		||||
	github.com/charmbracelet/x/ansi v0.6.0 // indirect
 | 
			
		||||
	github.com/cloudflare/circl v1.5.0 // indirect
 | 
			
		||||
	github.com/charmbracelet/colorprofile v0.3.2 // indirect
 | 
			
		||||
	github.com/charmbracelet/x/ansi v0.10.2 // indirect
 | 
			
		||||
	github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
 | 
			
		||||
	github.com/charmbracelet/x/term v0.2.1 // indirect
 | 
			
		||||
	github.com/clipperhouse/uax29/v2 v2.2.0 // indirect
 | 
			
		||||
	github.com/cloudflare/circl v1.6.1 // indirect
 | 
			
		||||
	github.com/containerd/errdefs v1.0.0 // indirect
 | 
			
		||||
	github.com/containerd/errdefs/pkg v0.3.0 // indirect
 | 
			
		||||
	github.com/containerd/log v0.1.0 // indirect
 | 
			
		||||
	github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
 | 
			
		||||
	github.com/cyphar/filepath-securejoin v0.3.6 // indirect
 | 
			
		||||
	github.com/containerd/platforms v0.2.1 // indirect
 | 
			
		||||
	github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
 | 
			
		||||
	github.com/cyphar/filepath-securejoin v0.5.0 // indirect
 | 
			
		||||
	github.com/davecgh/go-spew v1.1.1 // indirect
 | 
			
		||||
	github.com/docker/distribution v2.8.3+incompatible // indirect
 | 
			
		||||
	github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
 | 
			
		||||
	github.com/docker/go-connections v0.5.0 // indirect
 | 
			
		||||
	github.com/docker/go-connections v0.6.0 // indirect
 | 
			
		||||
	github.com/docker/go-metrics v0.0.1 // indirect
 | 
			
		||||
	github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
 | 
			
		||||
	github.com/emirpasic/gods v1.18.1 // indirect
 | 
			
		||||
	github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
 | 
			
		||||
	github.com/felixge/httpsnoop v1.0.4 // indirect
 | 
			
		||||
	github.com/fsnotify/fsnotify v1.6.0 // indirect
 | 
			
		||||
	github.com/ghodss/yaml v1.0.0 // indirect
 | 
			
		||||
	github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
 | 
			
		||||
	github.com/go-git/go-billy/v5 v5.6.0 // indirect
 | 
			
		||||
	github.com/go-git/go-billy/v5 v5.6.2 // indirect
 | 
			
		||||
	github.com/go-logfmt/logfmt v0.6.0 // indirect
 | 
			
		||||
	github.com/go-logr/logr v1.4.2 // indirect
 | 
			
		||||
	github.com/go-logr/logr v1.4.3 // indirect
 | 
			
		||||
	github.com/go-logr/stdr v1.2.2 // indirect
 | 
			
		||||
	github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
 | 
			
		||||
	github.com/gogo/protobuf v1.3.2 // indirect
 | 
			
		||||
	github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
 | 
			
		||||
	github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
 | 
			
		||||
	github.com/google/uuid v1.6.0 // indirect
 | 
			
		||||
	github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
 | 
			
		||||
	github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
 | 
			
		||||
	github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
 | 
			
		||||
	github.com/inconshreveable/mousetrap v1.1.0 // indirect
 | 
			
		||||
	github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
 | 
			
		||||
	github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
 | 
			
		||||
	github.com/kevinburke/ssh_config v1.2.0 // indirect
 | 
			
		||||
	github.com/klauspost/compress v1.17.11 // indirect
 | 
			
		||||
	github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
 | 
			
		||||
	github.com/mattn/go-colorable v0.1.13 // indirect
 | 
			
		||||
	github.com/kevinburke/ssh_config v1.4.0 // indirect
 | 
			
		||||
	github.com/klauspost/compress v1.18.0 // indirect
 | 
			
		||||
	github.com/klauspost/cpuid/v2 v2.3.0 // indirect
 | 
			
		||||
	github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
 | 
			
		||||
	github.com/mattn/go-colorable v0.1.14 // indirect
 | 
			
		||||
	github.com/mattn/go-isatty v0.0.20 // indirect
 | 
			
		||||
	github.com/mattn/go-runewidth v0.0.16 // indirect
 | 
			
		||||
	github.com/mattn/go-localereader v0.0.1 // indirect
 | 
			
		||||
	github.com/mattn/go-runewidth v0.0.19 // indirect
 | 
			
		||||
	github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
 | 
			
		||||
	github.com/miekg/pkcs11 v1.1.1 // indirect
 | 
			
		||||
	github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
 | 
			
		||||
	github.com/mitchellh/mapstructure v1.5.0 // indirect
 | 
			
		||||
	github.com/moby/docker-image-spec v1.3.1 // indirect
 | 
			
		||||
	github.com/moby/sys/mountinfo v0.6.2 // indirect
 | 
			
		||||
	github.com/moby/sys/user v0.3.0 // indirect
 | 
			
		||||
	github.com/moby/go-archive v0.1.0 // indirect
 | 
			
		||||
	github.com/moby/sys/atomicwriter v0.1.0 // indirect
 | 
			
		||||
	github.com/moby/sys/user v0.4.0 // indirect
 | 
			
		||||
	github.com/moby/sys/userns v0.1.0 // indirect
 | 
			
		||||
	github.com/morikuni/aec v1.0.0 // indirect
 | 
			
		||||
	github.com/muesli/termenv v0.15.2 // indirect
 | 
			
		||||
	github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
 | 
			
		||||
	github.com/muesli/cancelreader v0.2.2 // indirect
 | 
			
		||||
	github.com/muesli/reflow v0.3.0 // indirect
 | 
			
		||||
	github.com/muesli/termenv v0.16.0 // indirect
 | 
			
		||||
	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
 | 
			
		||||
	github.com/opencontainers/go-digest v1.0.0 // indirect
 | 
			
		||||
	github.com/opencontainers/runc v1.1.13 // indirect
 | 
			
		||||
	github.com/opencontainers/runtime-spec v1.1.0 // indirect
 | 
			
		||||
	github.com/pelletier/go-toml v1.9.5 // indirect
 | 
			
		||||
	github.com/pjbgf/sha1cd v0.3.0 // indirect
 | 
			
		||||
	github.com/pjbgf/sha1cd v0.5.0 // indirect
 | 
			
		||||
	github.com/pmezard/go-difflib v1.0.0 // indirect
 | 
			
		||||
	github.com/prometheus/client_model v0.6.1 // indirect
 | 
			
		||||
	github.com/prometheus/common v0.61.0 // indirect
 | 
			
		||||
	github.com/prometheus/procfs v0.15.1 // indirect
 | 
			
		||||
	github.com/prometheus/client_model v0.6.2 // indirect
 | 
			
		||||
	github.com/prometheus/common v0.66.1 // indirect
 | 
			
		||||
	github.com/prometheus/procfs v0.17.0 // indirect
 | 
			
		||||
	github.com/rivo/uniseg v0.4.7 // indirect
 | 
			
		||||
	github.com/russross/blackfriday/v2 v2.1.0 // indirect
 | 
			
		||||
	github.com/sirupsen/logrus v1.9.3 // indirect
 | 
			
		||||
	github.com/skeema/knownhosts v1.3.0 // indirect
 | 
			
		||||
	github.com/spf13/pflag v1.0.5 // indirect
 | 
			
		||||
	github.com/skeema/knownhosts v1.3.1 // indirect
 | 
			
		||||
	github.com/spf13/pflag v1.0.10 // indirect
 | 
			
		||||
	github.com/xanzy/ssh-agent v0.3.3 // indirect
 | 
			
		||||
	github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
 | 
			
		||||
	github.com/xeipuuv/gojsonschema v1.2.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/auto/sdk v1.1.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel v1.33.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.33.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 // indirect
 | 
			
		||||
	github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
 | 
			
		||||
	go.opentelemetry.io/auto/sdk v1.2.1 // indirect
 | 
			
		||||
	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel v1.38.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.38.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/metric v1.33.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/sdk v1.33.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/sdk/metric v1.33.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/trace v1.33.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/proto/otlp v1.4.0 // indirect
 | 
			
		||||
	golang.org/x/crypto v0.31.0 // indirect
 | 
			
		||||
	golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect
 | 
			
		||||
	golang.org/x/net v0.33.0 // indirect
 | 
			
		||||
	golang.org/x/sync v0.10.0 // indirect
 | 
			
		||||
	golang.org/x/text v0.21.0 // indirect
 | 
			
		||||
	golang.org/x/time v0.8.0 // indirect
 | 
			
		||||
	google.golang.org/genproto/googleapis/api v0.0.0-20241223144023-3abc09e42ca8 // indirect
 | 
			
		||||
	google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
 | 
			
		||||
	google.golang.org/grpc v1.69.2 // indirect
 | 
			
		||||
	google.golang.org/protobuf v1.36.1 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/metric v1.38.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/sdk v1.38.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/otel/trace v1.38.0 // indirect
 | 
			
		||||
	go.opentelemetry.io/proto/otlp v1.8.0 // indirect
 | 
			
		||||
	go.yaml.in/yaml/v2 v2.4.3 // indirect
 | 
			
		||||
	golang.org/x/crypto v0.42.0 // indirect
 | 
			
		||||
	golang.org/x/exp v0.0.0-20250911091902-df9299821621 // indirect
 | 
			
		||||
	golang.org/x/net v0.44.0 // indirect
 | 
			
		||||
	golang.org/x/text v0.29.0 // indirect
 | 
			
		||||
	golang.org/x/time v0.13.0 // indirect
 | 
			
		||||
	google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4 // indirect
 | 
			
		||||
	google.golang.org/genproto/googleapis/rpc v0.0.0-20250929231259-57b25ae835d4 // indirect
 | 
			
		||||
	google.golang.org/grpc v1.75.1 // indirect
 | 
			
		||||
	google.golang.org/protobuf v1.36.9 // indirect
 | 
			
		||||
	gopkg.in/warnings.v0 v0.1.2 // indirect
 | 
			
		||||
	gopkg.in/yaml.v2 v2.4.0 // indirect
 | 
			
		||||
)
 | 
			
		||||
@ -132,19 +144,19 @@ require (
 | 
			
		||||
	github.com/containers/image v3.0.2+incompatible
 | 
			
		||||
	github.com/containers/storage v1.38.2 // indirect
 | 
			
		||||
	github.com/decentral1se/passgen v1.0.1
 | 
			
		||||
	github.com/docker/docker-credential-helpers v0.8.2 // indirect
 | 
			
		||||
	github.com/docker/docker-credential-helpers v0.9.3 // indirect
 | 
			
		||||
	github.com/fvbommel/sortorder v1.1.0 // indirect
 | 
			
		||||
	github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
 | 
			
		||||
	github.com/gorilla/mux v1.8.1 // indirect
 | 
			
		||||
	github.com/hashicorp/go-retryablehttp v0.7.7
 | 
			
		||||
	github.com/hashicorp/go-retryablehttp v0.7.8
 | 
			
		||||
	github.com/moby/patternmatcher v0.6.0 // indirect
 | 
			
		||||
	github.com/moby/sys/sequential v0.6.0 // indirect
 | 
			
		||||
	github.com/opencontainers/image-spec v1.1.0 // indirect
 | 
			
		||||
	github.com/prometheus/client_golang v1.20.5 // indirect
 | 
			
		||||
	github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
 | 
			
		||||
	github.com/spf13/cobra v1.8.1
 | 
			
		||||
	github.com/stretchr/testify v1.10.0
 | 
			
		||||
	github.com/opencontainers/image-spec v1.1.1 // indirect
 | 
			
		||||
	github.com/prometheus/client_golang v1.23.2 // indirect
 | 
			
		||||
	github.com/sergi/go-diff v1.4.0 // indirect
 | 
			
		||||
	github.com/spf13/cobra v1.10.1
 | 
			
		||||
	github.com/stretchr/testify v1.11.1
 | 
			
		||||
	github.com/theupdateframework/notary v0.7.0 // indirect
 | 
			
		||||
	github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
 | 
			
		||||
	golang.org/x/sys v0.28.0
 | 
			
		||||
	golang.org/x/sys v0.36.0
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										431
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										431
									
								
								go.sum
									
									
									
									
									
								
							@ -22,21 +22,21 @@ cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIA
 | 
			
		||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
 | 
			
		||||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
 | 
			
		||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
 | 
			
		||||
coopcloud.tech/tagcmp v0.0.0-20230809071031-eb3e7758d4eb h1:Ws6WEwKXeaYEkfdkX6AqX1XLPuaCeyStEtxbmEJPllk=
 | 
			
		||||
coopcloud.tech/tagcmp v0.0.0-20230809071031-eb3e7758d4eb/go.mod h1:ESVm0wQKcbcFi06jItF3rI7enf4Jt2PvbkWpDDHk1DQ=
 | 
			
		||||
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
 | 
			
		||||
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
 | 
			
		||||
coopcloud.tech/tagcmp v0.0.0-20250818180036-0ec1b205b5ca h1:gSD53tBAsbIGq4SnFfq+mEep6foekQ2a5ea7b38qkm0=
 | 
			
		||||
coopcloud.tech/tagcmp v0.0.0-20250818180036-0ec1b205b5ca/go.mod h1:ESVm0wQKcbcFi06jItF3rI7enf4Jt2PvbkWpDDHk1DQ=
 | 
			
		||||
dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
 | 
			
		||||
dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
 | 
			
		||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
 | 
			
		||||
git.coopcloud.tech/coop-cloud/godotenv v1.5.2-0.20231130100509-01bff8284355 h1:tCv2B4qoN6RMheKDnCzIafOkWS5BB1h7hwhmo+9bVeE=
 | 
			
		||||
git.coopcloud.tech/coop-cloud/godotenv v1.5.2-0.20231130100509-01bff8284355/go.mod h1:Q8V1zbtPAlzYSr/Dvky3wS6x58IQAl3rot2me1oSO2Q=
 | 
			
		||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
 | 
			
		||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
 | 
			
		||||
git.coopcloud.tech/toolshed/godotenv v1.5.2-0.20250103171850-4d0ca41daa5c h1:oeKnUB79PKYD8D0/unYuu7MRcWryQQWOns8+JL+acrs=
 | 
			
		||||
git.coopcloud.tech/toolshed/godotenv v1.5.2-0.20250103171850-4d0ca41daa5c/go.mod h1:fQuhwrpg6qb9NlFXKYi/LysWu1wxjraS8sxyW12CUF0=
 | 
			
		||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk=
 | 
			
		||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
 | 
			
		||||
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
 | 
			
		||||
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
 | 
			
		||||
github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
 | 
			
		||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
 | 
			
		||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
 | 
			
		||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
 | 
			
		||||
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg=
 | 
			
		||||
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
 | 
			
		||||
github.com/Azure/go-autorest v10.8.1+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
 | 
			
		||||
github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
 | 
			
		||||
github.com/Azure/go-autorest/autorest v0.11.1/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw=
 | 
			
		||||
@ -49,8 +49,8 @@ github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ
 | 
			
		||||
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
 | 
			
		||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 | 
			
		||||
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
 | 
			
		||||
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
 | 
			
		||||
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
 | 
			
		||||
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
 | 
			
		||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
 | 
			
		||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
 | 
			
		||||
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
 | 
			
		||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
 | 
			
		||||
@ -79,14 +79,13 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0
 | 
			
		||||
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
 | 
			
		||||
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
 | 
			
		||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
 | 
			
		||||
github.com/ProtonMail/go-crypto v1.1.3 h1:nRBOetoydLeUb4nHajyO2bKqMLfWQ/ZPwkXqXxPxCFk=
 | 
			
		||||
github.com/ProtonMail/go-crypto v1.1.3/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
 | 
			
		||||
github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw=
 | 
			
		||||
github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE=
 | 
			
		||||
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
 | 
			
		||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
 | 
			
		||||
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
 | 
			
		||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
 | 
			
		||||
github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ=
 | 
			
		||||
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs=
 | 
			
		||||
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ=
 | 
			
		||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 | 
			
		||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 | 
			
		||||
@ -100,6 +99,8 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5
 | 
			
		||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
 | 
			
		||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
 | 
			
		||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
 | 
			
		||||
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
 | 
			
		||||
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
 | 
			
		||||
github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
 | 
			
		||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
 | 
			
		||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
 | 
			
		||||
@ -121,31 +122,37 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dR
 | 
			
		||||
github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk=
 | 
			
		||||
github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
 | 
			
		||||
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
 | 
			
		||||
github.com/bugsnag/bugsnag-go v1.0.5-0.20150529004307-13fd6b8acda0 h1:s7+5BfS4WFJoVF9pnB8kBk03S7pZXRdKamnV0FOl5Sc=
 | 
			
		||||
github.com/bugsnag/bugsnag-go v1.0.5-0.20150529004307-13fd6b8acda0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
 | 
			
		||||
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ=
 | 
			
		||||
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50=
 | 
			
		||||
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o=
 | 
			
		||||
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
 | 
			
		||||
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
 | 
			
		||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
 | 
			
		||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
 | 
			
		||||
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
 | 
			
		||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
 | 
			
		||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
 | 
			
		||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
 | 
			
		||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
 | 
			
		||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 | 
			
		||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
 | 
			
		||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 | 
			
		||||
github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg=
 | 
			
		||||
github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo=
 | 
			
		||||
github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM=
 | 
			
		||||
github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM=
 | 
			
		||||
github.com/charmbracelet/x/ansi v0.5.2 h1:dEa1x2qdOZXD/6439s+wF7xjV+kZLu/iN00GuXXrU9E=
 | 
			
		||||
github.com/charmbracelet/x/ansi v0.5.2/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q=
 | 
			
		||||
github.com/charmbracelet/x/ansi v0.6.0 h1:qOznutrb93gx9oMiGf7caF7bqqubh6YIM0SWKyA08pA=
 | 
			
		||||
github.com/charmbracelet/x/ansi v0.6.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q=
 | 
			
		||||
github.com/charmbracelet/x/exp/golden v0.0.0-20240806155701-69247e0abc2a h1:G99klV19u0QnhiizODirwVksQB91TJKV/UaTnACcG30=
 | 
			
		||||
github.com/charmbracelet/x/exp/golden v0.0.0-20240806155701-69247e0abc2a/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
 | 
			
		||||
github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs=
 | 
			
		||||
github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg=
 | 
			
		||||
github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
 | 
			
		||||
github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
 | 
			
		||||
github.com/charmbracelet/colorprofile v0.3.2 h1:9J27WdztfJQVAQKX2WOlSSRB+5gaKqqITmrvb1uTIiI=
 | 
			
		||||
github.com/charmbracelet/colorprofile v0.3.2/go.mod h1:mTD5XzNeWHj8oqHb+S1bssQb7vIHbepiebQ2kPKVKbI=
 | 
			
		||||
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
 | 
			
		||||
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
 | 
			
		||||
github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig=
 | 
			
		||||
github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw=
 | 
			
		||||
github.com/charmbracelet/x/ansi v0.10.2 h1:ith2ArZS0CJG30cIUfID1LXN7ZFXRCww6RUvAPA+Pzw=
 | 
			
		||||
github.com/charmbracelet/x/ansi v0.10.2/go.mod h1:HbLdJjQH4UH4AqA2HpRWuWNluRE6zxJH/yteYEYCFa8=
 | 
			
		||||
github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k=
 | 
			
		||||
github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
 | 
			
		||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
 | 
			
		||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
 | 
			
		||||
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
 | 
			
		||||
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
 | 
			
		||||
github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw=
 | 
			
		||||
github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M=
 | 
			
		||||
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
 | 
			
		||||
@ -161,10 +168,11 @@ github.com/cilium/ebpf v0.4.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJ
 | 
			
		||||
github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs=
 | 
			
		||||
github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA=
 | 
			
		||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
 | 
			
		||||
github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004 h1:lkAMpLVBDaj17e85keuznYcH5rqI438v41pKcBl4ZxQ=
 | 
			
		||||
github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY=
 | 
			
		||||
github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
 | 
			
		||||
github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA=
 | 
			
		||||
github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys=
 | 
			
		||||
github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
 | 
			
		||||
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
 | 
			
		||||
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
 | 
			
		||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
 | 
			
		||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
 | 
			
		||||
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
 | 
			
		||||
@ -210,6 +218,10 @@ github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe/go.mod h1:cE
 | 
			
		||||
github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7/go.mod h1:kR3BEg7bDFaEddKm54WSmrol1fKWDU1nKYkgrcgZT7Y=
 | 
			
		||||
github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ=
 | 
			
		||||
github.com/containerd/continuity v0.1.0/go.mod h1:ICJu0PwR54nI0yPEnJ6jcS+J7CZAUXrLh8lPo2knzsM=
 | 
			
		||||
github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI=
 | 
			
		||||
github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
 | 
			
		||||
github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE=
 | 
			
		||||
github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk=
 | 
			
		||||
github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
 | 
			
		||||
github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
 | 
			
		||||
github.com/containerd/fifo v0.0.0-20200410184934-f15a3290365b/go.mod h1:jPQ2IAeZRCYxpS/Cm1495vGFww6ecHmMk1YJH2Q5ln0=
 | 
			
		||||
@ -232,6 +244,8 @@ github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3
 | 
			
		||||
github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164/go.mod h1:+2wGSDGFYfE5+So4M5syatU0N0f0LbWpuqyMi4/BE8c=
 | 
			
		||||
github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY=
 | 
			
		||||
github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY=
 | 
			
		||||
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
 | 
			
		||||
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
 | 
			
		||||
github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM=
 | 
			
		||||
github.com/containerd/stargz-snapshotter/estargz v0.11.0/go.mod h1:/KsZXsJRllMbTKFfG0miFQWViQKdI9+9aSXs+HN0+ac=
 | 
			
		||||
github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
 | 
			
		||||
@ -278,10 +292,9 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc
 | 
			
		||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
 | 
			
		||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
 | 
			
		||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
 | 
			
		||||
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
 | 
			
		||||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
 | 
			
		||||
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
 | 
			
		||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
 | 
			
		||||
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
 | 
			
		||||
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
 | 
			
		||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
 | 
			
		||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
 | 
			
		||||
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
 | 
			
		||||
@ -289,10 +302,8 @@ github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
 | 
			
		||||
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
 | 
			
		||||
github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4=
 | 
			
		||||
github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
 | 
			
		||||
github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8=
 | 
			
		||||
github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM=
 | 
			
		||||
github.com/cyphar/filepath-securejoin v0.3.6 h1:4d9N5ykBnSp5Xn2JkhocYDkOpURL/18CYMpo6xB9uWM=
 | 
			
		||||
github.com/cyphar/filepath-securejoin v0.3.6/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
 | 
			
		||||
github.com/cyphar/filepath-securejoin v0.5.0 h1:hIAhkRBMQ8nIeuVwcAoymp7MY4oherZdAxD+m0u9zaw=
 | 
			
		||||
github.com/cyphar/filepath-securejoin v0.5.0/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
 | 
			
		||||
github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1SMSibvLzxjeJLnrYEVLULFNiHY9YfQ=
 | 
			
		||||
github.com/d2g/dhcp4client v1.0.0/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW34z5W5s=
 | 
			
		||||
github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5/go.mod h1:Eo87+Kg/IX2hfWJfwxMzLyuSZyxSoAug2nGa1G2QAi8=
 | 
			
		||||
@ -311,28 +322,24 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr
 | 
			
		||||
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
 | 
			
		||||
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
 | 
			
		||||
github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
 | 
			
		||||
github.com/docker/cli v27.3.1+incompatible h1:qEGdFBF3Xu6SCvCYhc7CzaQTlBmqDuzxPDpigSyeKQQ=
 | 
			
		||||
github.com/docker/cli v27.3.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
 | 
			
		||||
github.com/docker/cli v27.4.1+incompatible h1:VzPiUlRJ/xh+otB75gva3r05isHMo5wXDfPRi5/b4hI=
 | 
			
		||||
github.com/docker/cli v27.4.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
 | 
			
		||||
github.com/docker/cli v28.4.0+incompatible h1:RBcf3Kjw2pMtwui5V0DIMdyeab8glEw5QY0UUU4C9kY=
 | 
			
		||||
github.com/docker/cli v28.4.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
 | 
			
		||||
github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY=
 | 
			
		||||
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
 | 
			
		||||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
 | 
			
		||||
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
 | 
			
		||||
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
 | 
			
		||||
github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 | 
			
		||||
github.com/docker/docker v27.3.1+incompatible h1:KttF0XoteNTicmUtBO0L2tP+J7FGRFTjaEF4k6WdhfI=
 | 
			
		||||
github.com/docker/docker v27.3.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 | 
			
		||||
github.com/docker/docker v27.4.1+incompatible h1:ZJvcY7gfwHn1JF48PfbyXg7Jyt9ZCWDW+GGXOIxEwp4=
 | 
			
		||||
github.com/docker/docker v27.4.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 | 
			
		||||
github.com/docker/docker v28.4.0+incompatible h1:KVC7bz5zJY/4AZe/78BIvCnPsLaC9T/zh72xnlrTTOk=
 | 
			
		||||
github.com/docker/docker v28.4.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 | 
			
		||||
github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y=
 | 
			
		||||
github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo=
 | 
			
		||||
github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
 | 
			
		||||
github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8=
 | 
			
		||||
github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
 | 
			
		||||
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
 | 
			
		||||
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c/go.mod h1:CADgU4DSXK5QUlFslkQu2yW2TKzFZcXq/leZfM0UH5Q=
 | 
			
		||||
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
 | 
			
		||||
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
 | 
			
		||||
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
 | 
			
		||||
github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94=
 | 
			
		||||
github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE=
 | 
			
		||||
github.com/docker/go-events v0.0.0-20170721190031-9461782956ad/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA=
 | 
			
		||||
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA=
 | 
			
		||||
github.com/docker/go-metrics v0.0.0-20180209012529-399ea8c73916/go.mod h1:/u0gXw0Gay3ceNrsHubL3BtdOL2fHf93USgMTe0W5dI=
 | 
			
		||||
@ -350,8 +357,8 @@ github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:Htrtb
 | 
			
		||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
 | 
			
		||||
github.com/dvsekhvalnov/jose2go v0.0.0-20170216131308-f21a8cedbbae/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM=
 | 
			
		||||
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
 | 
			
		||||
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
 | 
			
		||||
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
 | 
			
		||||
github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o=
 | 
			
		||||
github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE=
 | 
			
		||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
 | 
			
		||||
github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
 | 
			
		||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
 | 
			
		||||
@ -362,8 +369,12 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
 | 
			
		||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
 | 
			
		||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
 | 
			
		||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
 | 
			
		||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
 | 
			
		||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
 | 
			
		||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
 | 
			
		||||
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
 | 
			
		||||
github.com/evertras/bubble-table v0.19.2 h1:u77oiM6JlRR+CvS5FZc3Hz+J6iEsvEDcR5kO8OFb1Yw=
 | 
			
		||||
github.com/evertras/bubble-table v0.19.2/go.mod h1:ifHujS1YxwnYSOgcR2+m3GnJ84f7CVU/4kUOxUCjEbQ=
 | 
			
		||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
 | 
			
		||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
 | 
			
		||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
 | 
			
		||||
@ -373,8 +384,6 @@ github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoD
 | 
			
		||||
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
 | 
			
		||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
 | 
			
		||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
 | 
			
		||||
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
 | 
			
		||||
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
 | 
			
		||||
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA=
 | 
			
		||||
github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQmYw=
 | 
			
		||||
github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0=
 | 
			
		||||
@ -382,16 +391,16 @@ github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYis
 | 
			
		||||
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
 | 
			
		||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
 | 
			
		||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
 | 
			
		||||
github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE=
 | 
			
		||||
github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8=
 | 
			
		||||
github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
 | 
			
		||||
github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
 | 
			
		||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
 | 
			
		||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
 | 
			
		||||
github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8=
 | 
			
		||||
github.com/go-git/go-billy/v5 v5.6.0/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM=
 | 
			
		||||
github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM=
 | 
			
		||||
github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU=
 | 
			
		||||
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
 | 
			
		||||
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
 | 
			
		||||
github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys=
 | 
			
		||||
github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY=
 | 
			
		||||
github.com/go-git/go-git/v5 v5.16.2 h1:fT6ZIOjE5iEnkzKyxTHK1W4HGAsPhqEqiSAssSO77hM=
 | 
			
		||||
github.com/go-git/go-git/v5 v5.16.2/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
 | 
			
		||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
 | 
			
		||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
 | 
			
		||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
 | 
			
		||||
@ -405,8 +414,8 @@ github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KE
 | 
			
		||||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
 | 
			
		||||
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
 | 
			
		||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
 | 
			
		||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
 | 
			
		||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
 | 
			
		||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
 | 
			
		||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
 | 
			
		||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
 | 
			
		||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
 | 
			
		||||
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
 | 
			
		||||
@ -420,11 +429,10 @@ github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8
 | 
			
		||||
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
 | 
			
		||||
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
 | 
			
		||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
 | 
			
		||||
github.com/go-sql-driver/mysql v1.3.0 h1:pgwjLi/dvffoP9aabwkT3AKpXQM93QARkjFhDDqC1UE=
 | 
			
		||||
github.com/go-sql-driver/mysql v1.3.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
 | 
			
		||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
 | 
			
		||||
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
 | 
			
		||||
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
 | 
			
		||||
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
 | 
			
		||||
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
 | 
			
		||||
github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
 | 
			
		||||
github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
 | 
			
		||||
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
 | 
			
		||||
@ -439,7 +447,6 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV
 | 
			
		||||
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
 | 
			
		||||
github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
 | 
			
		||||
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
 | 
			
		||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
 | 
			
		||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
 | 
			
		||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
 | 
			
		||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
 | 
			
		||||
@ -476,7 +483,6 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
 | 
			
		||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
 | 
			
		||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 | 
			
		||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 | 
			
		||||
github.com/google/certificate-transparency-go v1.0.10-0.20180222191210-5ab67e519c93 h1:jc2UWq7CbdszqeH6qu1ougXMIUBfSy8Pbh/anURYbGI=
 | 
			
		||||
github.com/google/certificate-transparency-go v1.0.10-0.20180222191210-5ab67e519c93/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg=
 | 
			
		||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
 | 
			
		||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 | 
			
		||||
@ -488,8 +494,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
 | 
			
		||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
			
		||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
			
		||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
			
		||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
 | 
			
		||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 | 
			
		||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
 | 
			
		||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
 | 
			
		||||
github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0=
 | 
			
		||||
github.com/google/go-intervals v0.0.2/go.mod h1:MkaR3LNRfeKLPmqgJYs4E66z5InYjmCjbbr4TQlcT6Y=
 | 
			
		||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 | 
			
		||||
@ -529,13 +535,9 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de
 | 
			
		||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 h1:TmHmbvxPmaegwhDubVz0lICL0J5Ka2vwTzhoePEXsGE=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0/go.mod h1:qztMSjm835F2bXf+5HKAPIS5qsmQDqZna/PgVt4rWtI=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ=
 | 
			
		||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnVTyacbefKhmbLhIhU=
 | 
			
		||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
 | 
			
		||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
 | 
			
		||||
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
 | 
			
		||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
 | 
			
		||||
@ -546,11 +548,10 @@ github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH
 | 
			
		||||
github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
 | 
			
		||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
 | 
			
		||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
 | 
			
		||||
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
 | 
			
		||||
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
 | 
			
		||||
github.com/hashicorp/go-retryablehttp v0.7.8 h1:ylXZWnqa7Lhqpk0L1P1LzDtGcCR0rPVUrx/c8Unxc48=
 | 
			
		||||
github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3iS0jrZ7LvzFGFmuKbw=
 | 
			
		||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
 | 
			
		||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
 | 
			
		||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
 | 
			
		||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
 | 
			
		||||
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
 | 
			
		||||
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
 | 
			
		||||
@ -567,9 +568,7 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf
 | 
			
		||||
github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA=
 | 
			
		||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
 | 
			
		||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
 | 
			
		||||
github.com/jinzhu/gorm v0.0.0-20170222002820-5409931a1bb8 h1:CZkYfurY6KGhVtlalI4QwQ6T0Cu6iuY3e0x5RLu96WE=
 | 
			
		||||
github.com/jinzhu/gorm v0.0.0-20170222002820-5409931a1bb8/go.mod h1:Vla75njaFJ8clLU1W44h34PjIkijhjHIYnZxMqCdxqo=
 | 
			
		||||
github.com/jinzhu/inflection v0.0.0-20170102125226-1c35d901db3d h1:jRQLvyVGL+iVtDElaEIDdKwpPqUIZJfzkNLV34htpEc=
 | 
			
		||||
github.com/jinzhu/inflection v0.0.0-20170102125226-1c35d901db3d/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
 | 
			
		||||
github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
 | 
			
		||||
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
 | 
			
		||||
@ -587,8 +586,8 @@ github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVE
 | 
			
		||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
 | 
			
		||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
 | 
			
		||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
 | 
			
		||||
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
 | 
			
		||||
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
 | 
			
		||||
github.com/kevinburke/ssh_config v1.4.0 h1:6xxtP5bZ2E4NF5tuQulISpTO2z8XbtH8cg1PWkxoFkQ=
 | 
			
		||||
github.com/kevinburke/ssh_config v1.4.0/go.mod h1:q2RIzfka+BXARoNexmF9gkxEX7DmvbW9P4hIVx2Kg4M=
 | 
			
		||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
 | 
			
		||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
 | 
			
		||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
 | 
			
		||||
@ -596,8 +595,10 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
 | 
			
		||||
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
 | 
			
		||||
github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
 | 
			
		||||
github.com/klauspost/compress v1.14.2/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
 | 
			
		||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
 | 
			
		||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
 | 
			
		||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
 | 
			
		||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
 | 
			
		||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
 | 
			
		||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
 | 
			
		||||
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
 | 
			
		||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 | 
			
		||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 | 
			
		||||
@ -615,12 +616,13 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 | 
			
		||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
 | 
			
		||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
 | 
			
		||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
 | 
			
		||||
github.com/leonelquinteros/gotext v1.7.2 h1:bDPndU8nt+/kRo1m4l/1OXiiy2v7Z7dfPQ9+YP7G1Mc=
 | 
			
		||||
github.com/leonelquinteros/gotext v1.7.2/go.mod h1:9/haCkm5P7Jay1sxKDGJ5WIg4zkz8oZKw4ekNpALob8=
 | 
			
		||||
github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
 | 
			
		||||
github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo=
 | 
			
		||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
 | 
			
		||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
 | 
			
		||||
github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
 | 
			
		||||
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
 | 
			
		||||
github.com/magiconair/properties v1.5.3/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
 | 
			
		||||
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
 | 
			
		||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
 | 
			
		||||
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
 | 
			
		||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
 | 
			
		||||
@ -629,16 +631,18 @@ github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7
 | 
			
		||||
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
 | 
			
		||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
 | 
			
		||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
 | 
			
		||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
 | 
			
		||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
 | 
			
		||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
 | 
			
		||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
 | 
			
		||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
 | 
			
		||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
 | 
			
		||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
 | 
			
		||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 | 
			
		||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
 | 
			
		||||
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
 | 
			
		||||
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
 | 
			
		||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
 | 
			
		||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
 | 
			
		||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
 | 
			
		||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
 | 
			
		||||
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
 | 
			
		||||
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
 | 
			
		||||
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
 | 
			
		||||
github.com/mattn/go-shellwords v1.0.6/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
 | 
			
		||||
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
 | 
			
		||||
@ -659,31 +663,33 @@ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0
 | 
			
		||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
 | 
			
		||||
github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 | 
			
		||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 | 
			
		||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
 | 
			
		||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
 | 
			
		||||
github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A=
 | 
			
		||||
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
 | 
			
		||||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
 | 
			
		||||
github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=
 | 
			
		||||
github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo=
 | 
			
		||||
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
 | 
			
		||||
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
 | 
			
		||||
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
 | 
			
		||||
github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw=
 | 
			
		||||
github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs=
 | 
			
		||||
github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
 | 
			
		||||
github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
 | 
			
		||||
github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU=
 | 
			
		||||
github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78=
 | 
			
		||||
github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI=
 | 
			
		||||
github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg=
 | 
			
		||||
github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4=
 | 
			
		||||
github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU=
 | 
			
		||||
github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko=
 | 
			
		||||
github.com/moby/sys/signal v0.7.1 h1:PrQxdvxcGijdo6UXXo/lU/TvHUWyPhj7UOpSo8tuvk0=
 | 
			
		||||
github.com/moby/sys/signal v0.7.1/go.mod h1:Se1VGehYokAkrSQwL4tDzHvETwUZlnY7S5XtQ50mQp8=
 | 
			
		||||
github.com/moby/sys/symlink v0.1.0/go.mod h1:GGDODQmbFOjFsXvfLVn3+ZRxkch54RkSiGqsZeMYowQ=
 | 
			
		||||
github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo=
 | 
			
		||||
github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs=
 | 
			
		||||
github.com/moby/sys/user v0.4.0 h1:jhcMKit7SA80hivmFJcbB1vqmw//wU61Zdui2eQXuMs=
 | 
			
		||||
github.com/moby/sys/user v0.4.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs=
 | 
			
		||||
github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g=
 | 
			
		||||
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
 | 
			
		||||
github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo=
 | 
			
		||||
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
 | 
			
		||||
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
 | 
			
		||||
github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ=
 | 
			
		||||
github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc=
 | 
			
		||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 | 
			
		||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 | 
			
		||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 | 
			
		||||
@ -692,8 +698,14 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
 | 
			
		||||
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
 | 
			
		||||
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
 | 
			
		||||
github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
 | 
			
		||||
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
 | 
			
		||||
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
 | 
			
		||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
 | 
			
		||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
 | 
			
		||||
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
 | 
			
		||||
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
 | 
			
		||||
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
 | 
			
		||||
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
 | 
			
		||||
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
 | 
			
		||||
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
 | 
			
		||||
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
 | 
			
		||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
 | 
			
		||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
 | 
			
		||||
@ -730,8 +742,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
 | 
			
		||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
 | 
			
		||||
github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
 | 
			
		||||
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
 | 
			
		||||
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
 | 
			
		||||
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
 | 
			
		||||
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
 | 
			
		||||
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
 | 
			
		||||
github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
 | 
			
		||||
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
 | 
			
		||||
github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
 | 
			
		||||
@ -754,15 +766,12 @@ github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqi
 | 
			
		||||
github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3ogry1nUQF8Evvo=
 | 
			
		||||
github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8=
 | 
			
		||||
github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
 | 
			
		||||
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
 | 
			
		||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
 | 
			
		||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
 | 
			
		||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
 | 
			
		||||
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
 | 
			
		||||
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
 | 
			
		||||
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
 | 
			
		||||
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
 | 
			
		||||
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
 | 
			
		||||
github.com/pjbgf/sha1cd v0.5.0 h1:a+UkboSi1znleCDUNT3M5YxjOnN1fz2FhN48FlwCxs0=
 | 
			
		||||
github.com/pjbgf/sha1cd v0.5.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
 | 
			
		||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
			
		||||
github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
			
		||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
			
		||||
@ -778,25 +787,23 @@ github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDf
 | 
			
		||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
 | 
			
		||||
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
 | 
			
		||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
 | 
			
		||||
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
 | 
			
		||||
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
 | 
			
		||||
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
 | 
			
		||||
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
 | 
			
		||||
github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
 | 
			
		||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
 | 
			
		||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 | 
			
		||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 | 
			
		||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 | 
			
		||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
 | 
			
		||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
 | 
			
		||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
 | 
			
		||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
 | 
			
		||||
github.com/prometheus/common v0.0.0-20180110214958-89604d197083/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
 | 
			
		||||
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
 | 
			
		||||
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
 | 
			
		||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
 | 
			
		||||
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
 | 
			
		||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
 | 
			
		||||
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
 | 
			
		||||
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
 | 
			
		||||
github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFSRQQ=
 | 
			
		||||
github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s=
 | 
			
		||||
github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
 | 
			
		||||
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
 | 
			
		||||
github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
 | 
			
		||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
 | 
			
		||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
 | 
			
		||||
@ -808,30 +815,30 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx
 | 
			
		||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
 | 
			
		||||
github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
 | 
			
		||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
 | 
			
		||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
 | 
			
		||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
 | 
			
		||||
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
 | 
			
		||||
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
 | 
			
		||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
 | 
			
		||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
 | 
			
		||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
 | 
			
		||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
 | 
			
		||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
 | 
			
		||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
 | 
			
		||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
 | 
			
		||||
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
 | 
			
		||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
 | 
			
		||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 | 
			
		||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
 | 
			
		||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 | 
			
		||||
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
 | 
			
		||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
 | 
			
		||||
github.com/schollz/progressbar/v3 v3.17.1 h1:bI1MTaoQO+v5kzklBjYNRQLoVpe0zbyRZNK6DFkVC5U=
 | 
			
		||||
github.com/schollz/progressbar/v3 v3.17.1/go.mod h1:RzqpnsPQNjUyIgdglUjRLgD7sVnxN1wpmBMV+UiEbL4=
 | 
			
		||||
github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQmCN62HpA=
 | 
			
		||||
github.com/schollz/progressbar/v3 v3.18.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec=
 | 
			
		||||
github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
 | 
			
		||||
github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
 | 
			
		||||
github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
 | 
			
		||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
 | 
			
		||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
 | 
			
		||||
github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
 | 
			
		||||
github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
 | 
			
		||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 | 
			
		||||
github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
 | 
			
		||||
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
 | 
			
		||||
@ -843,36 +850,34 @@ github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic
 | 
			
		||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
 | 
			
		||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
 | 
			
		||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
 | 
			
		||||
github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY=
 | 
			
		||||
github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M=
 | 
			
		||||
github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8=
 | 
			
		||||
github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY=
 | 
			
		||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
 | 
			
		||||
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
 | 
			
		||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
 | 
			
		||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 | 
			
		||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
 | 
			
		||||
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
 | 
			
		||||
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
 | 
			
		||||
github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg=
 | 
			
		||||
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
 | 
			
		||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
 | 
			
		||||
github.com/spf13/cobra v0.0.1/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
 | 
			
		||||
github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
 | 
			
		||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
 | 
			
		||||
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
 | 
			
		||||
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
 | 
			
		||||
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
 | 
			
		||||
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
 | 
			
		||||
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
 | 
			
		||||
github.com/spf13/jwalterweatherman v0.0.0-20141219030609-3d60171a6431/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
 | 
			
		||||
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
 | 
			
		||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
 | 
			
		||||
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 | 
			
		||||
github.com/spf13/pflag v1.0.0/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 | 
			
		||||
github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 | 
			
		||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 | 
			
		||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 | 
			
		||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
 | 
			
		||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 | 
			
		||||
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 | 
			
		||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
 | 
			
		||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 | 
			
		||||
github.com/spf13/viper v0.0.0-20150530192845-be5ff3e4840c/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
 | 
			
		||||
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
 | 
			
		||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
 | 
			
		||||
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8=
 | 
			
		||||
github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
			
		||||
@ -886,8 +891,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
 | 
			
		||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
 | 
			
		||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
			
		||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
			
		||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
 | 
			
		||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
 | 
			
		||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
 | 
			
		||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
 | 
			
		||||
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
 | 
			
		||||
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
 | 
			
		||||
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
 | 
			
		||||
@ -905,8 +910,6 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb
 | 
			
		||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
 | 
			
		||||
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
 | 
			
		||||
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
 | 
			
		||||
github.com/urfave/cli/v3 v3.0.0-alpha9.1.0.20241019193437-5053ec708a44 h1:BeSTAZEDkDVNv9EOrycIGCkEg+6EhRRgSsbdc93Q3OM=
 | 
			
		||||
github.com/urfave/cli/v3 v3.0.0-alpha9.1.0.20241019193437-5053ec708a44/go.mod h1:FnIeEMYu+ko8zP1F9Ypr3xkZMIDqW3DR92yUtY39q1Y=
 | 
			
		||||
github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI=
 | 
			
		||||
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
 | 
			
		||||
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
 | 
			
		||||
@ -927,6 +930,8 @@ github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf
 | 
			
		||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
 | 
			
		||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
 | 
			
		||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
 | 
			
		||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
 | 
			
		||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
 | 
			
		||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
 | 
			
		||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
			
		||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
			
		||||
@ -945,57 +950,39 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
 | 
			
		||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
 | 
			
		||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 | 
			
		||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 | 
			
		||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
 | 
			
		||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
 | 
			
		||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0 h1:DheMAlT6POBP+gh8RUH19EOTnQIor5QE0uSRPtzCpSw=
 | 
			
		||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0/go.mod h1:wZcGmeVO9nzP67aYSLDqXNWK87EZWhi7JWj1v7ZXf94=
 | 
			
		||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 h1:yd02MEjBdJkG3uabWP9apV+OuWRIXGDuJEUJbOHmCFU=
 | 
			
		||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0/go.mod h1:umTcuxiv1n/s/S6/c2AT/g2CQ7u5C59sHDNmfSwgz7Q=
 | 
			
		||||
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
 | 
			
		||||
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
 | 
			
		||||
go.opentelemetry.io/otel v1.33.0 h1:/FerN9bax5LoK51X/sI0SVYrjSE0/yUL7DpxW4K3FWw=
 | 
			
		||||
go.opentelemetry.io/otel v1.33.0/go.mod h1:SUUkR6csvUQl+yjReHu5uM3EtVV7MBm5FHKRlNx4I8I=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0 h1:j7ZSD+5yn+lo3sGV69nW04rRR0jhYnBwjuX3r0HvnK0=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0/go.mod h1:WXbYJTUaZXAbYd8lbgGuvih0yuCfOFC5RJoYnoLcGz8=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.33.0 h1:7F29RDmnlqk6B5d+sUqemt8TBfDqxryYW5gX6L74RFA=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.33.0/go.mod h1:ZiGDq7xwDMKmWDrN1XsXAj0iC7hns+2DhxBFSncNHSE=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 h1:IJFEoHiytixx8cMiVAO+GmHR6Frwu+u5Ur8njpFO6Ac=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0/go.mod h1:3rHrKNtLIoS0oZwkY2vxi+oJcwFRWdtUyRII+so45p8=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 h1:Vh5HayB/0HHfOQA7Ctx69E/Y/DcQSMPpKANYVMQ7fBA=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0/go.mod h1:cpgtDBaqD/6ok/UG0jT15/uKjAY8mRA53diogHBg3UI=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 h1:9kV11HXBHZAvuPUZxmMWrH8hZn/6UnHX4K0mu36vNsU=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0/go.mod h1:JyA0FHXe22E1NeNiHmVp7kFHglnexDQ7uRWDiiJ1hKQ=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 h1:5pojmb1U1AogINhN3SurB+zm/nIcusopeBNp42f45QM=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0/go.mod h1:57gTHJSE5S1tqg+EKsLPlTWhpHMsWlVmer+LA926XiA=
 | 
			
		||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
 | 
			
		||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
 | 
			
		||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18=
 | 
			
		||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0/go.mod h1:h06DGIukJOevXaj/xrNjhi/2098RZzcLTbc0jDAUbsg=
 | 
			
		||||
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
 | 
			
		||||
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.38.0 h1:vl9obrcoWVKp/lwl8tRE33853I8Xru9HFbw/skNeLs8=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.38.0/go.mod h1:GAXRxmLJcVM3u22IjTg74zWBrRCKq8BnOqUVLodpcpw=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0 h1:lwI4Dc5leUqENgGuQImwLo4WnuXFPetmPpkLi2IrX54=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0/go.mod h1:Kz/oCE7z5wuyhPxsXDuaPteSWqjSBD5YaSdbxZYGbGk=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg=
 | 
			
		||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU=
 | 
			
		||||
go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M=
 | 
			
		||||
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
 | 
			
		||||
go.opentelemetry.io/otel/metric v1.33.0 h1:r+JOocAyeRVXD8lZpjdQjzMadVZp2M4WmQ+5WtEnklQ=
 | 
			
		||||
go.opentelemetry.io/otel/metric v1.33.0/go.mod h1:L9+Fyctbp6HFTddIxClbQkjtubW6O9QS3Ann/M82u6M=
 | 
			
		||||
go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4=
 | 
			
		||||
go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU=
 | 
			
		||||
go.opentelemetry.io/otel/sdk v1.33.0 h1:iax7M131HuAm9QkZotNHEfstof92xM+N8sr3uHXc2IM=
 | 
			
		||||
go.opentelemetry.io/otel/sdk v1.33.0/go.mod h1:A1Q5oi7/9XaMlIWzPSxLRWOI8nG3FnzHJNbiENQuihM=
 | 
			
		||||
go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU=
 | 
			
		||||
go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ=
 | 
			
		||||
go.opentelemetry.io/otel/sdk/metric v1.33.0 h1:Gs5VK9/WUJhNXZgn8MR6ITatvAmKeIuCtNbsP3JkNqU=
 | 
			
		||||
go.opentelemetry.io/otel/sdk/metric v1.33.0/go.mod h1:dL5ykHZmm1B1nVRk9dDjChwDmt81MjVp3gLkQRwKf/Q=
 | 
			
		||||
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
 | 
			
		||||
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
 | 
			
		||||
go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qqW2d/s=
 | 
			
		||||
go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37CbGV4fr1f2nBck=
 | 
			
		||||
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
 | 
			
		||||
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
 | 
			
		||||
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
 | 
			
		||||
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
 | 
			
		||||
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
 | 
			
		||||
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
 | 
			
		||||
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
 | 
			
		||||
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
 | 
			
		||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
 | 
			
		||||
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
 | 
			
		||||
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
 | 
			
		||||
go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg=
 | 
			
		||||
go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY=
 | 
			
		||||
go.opentelemetry.io/proto/otlp v1.8.0 h1:fRAZQDcAFHySxpJ1TwlA1cJ4tvcrw7nXl9xWWC8N5CE=
 | 
			
		||||
go.opentelemetry.io/proto/otlp v1.8.0/go.mod h1:tIeYOeNBU4cvmPqpaji1P+KbB4Oloai8wN4rWzRrFF0=
 | 
			
		||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
 | 
			
		||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
 | 
			
		||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
 | 
			
		||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
 | 
			
		||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
 | 
			
		||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
 | 
			
		||||
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
 | 
			
		||||
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 | 
			
		||||
@ -1014,10 +1001,8 @@ golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWP
 | 
			
		||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 | 
			
		||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
 | 
			
		||||
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
 | 
			
		||||
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
 | 
			
		||||
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
 | 
			
		||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
 | 
			
		||||
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
 | 
			
		||||
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
 | 
			
		||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 | 
			
		||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 | 
			
		||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
 | 
			
		||||
@ -1028,10 +1013,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
 | 
			
		||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
 | 
			
		||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
 | 
			
		||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
 | 
			
		||||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
 | 
			
		||||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
 | 
			
		||||
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo=
 | 
			
		||||
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c=
 | 
			
		||||
golang.org/x/exp v0.0.0-20250911091902-df9299821621 h1:2id6c1/gto0kaHYyrixvknJ8tUK/Qs5IsmBtrc+FtgU=
 | 
			
		||||
golang.org/x/exp v0.0.0-20250911091902-df9299821621/go.mod h1:TwQYMMnGpvZyc+JpB/UAuTNIsVJifOlSkrZkhcvpVUk=
 | 
			
		||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
 | 
			
		||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
 | 
			
		||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
 | 
			
		||||
@ -1095,10 +1078,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
 | 
			
		||||
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 | 
			
		||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 | 
			
		||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
 | 
			
		||||
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
 | 
			
		||||
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
 | 
			
		||||
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
 | 
			
		||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
 | 
			
		||||
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
 | 
			
		||||
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
 | 
			
		||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 | 
			
		||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 | 
			
		||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 | 
			
		||||
@ -1116,10 +1097,6 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
 | 
			
		||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
			
		||||
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
 | 
			
		||||
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 | 
			
		||||
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
 | 
			
		||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 | 
			
		||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
@ -1189,6 +1166,7 @@ golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7w
 | 
			
		||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
@ -1196,20 +1174,14 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc
 | 
			
		||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
 | 
			
		||||
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 | 
			
		||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
 | 
			
		||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 | 
			
		||||
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
 | 
			
		||||
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
 | 
			
		||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
 | 
			
		||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 | 
			
		||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 | 
			
		||||
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
 | 
			
		||||
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
 | 
			
		||||
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
 | 
			
		||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
 | 
			
		||||
golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ=
 | 
			
		||||
golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA=
 | 
			
		||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
			
		||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
			
		||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
			
		||||
@ -1219,18 +1191,16 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
			
		||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
			
		||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
 | 
			
		||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
 | 
			
		||||
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
 | 
			
		||||
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
 | 
			
		||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
 | 
			
		||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
 | 
			
		||||
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
 | 
			
		||||
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
 | 
			
		||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
			
		||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
			
		||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
			
		||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
			
		||||
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
			
		||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
			
		||||
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
 | 
			
		||||
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
 | 
			
		||||
golang.org/x/time v0.13.0 h1:eUlYslOIt32DgYD6utsuUeHs4d7AsEYLuIAdg7FlYgI=
 | 
			
		||||
golang.org/x/time v0.13.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
 | 
			
		||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
			
		||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
			
		||||
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
			
		||||
@ -1280,6 +1250,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
 | 
			
		||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
			
		||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
			
		||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
			
		||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
 | 
			
		||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
 | 
			
		||||
google.golang.org/api v0.0.0-20160322025152-9bf6e6e569ff/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
 | 
			
		||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
 | 
			
		||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
 | 
			
		||||
@ -1324,14 +1296,10 @@ google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfG
 | 
			
		||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
 | 
			
		||||
google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
 | 
			
		||||
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
 | 
			
		||||
google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 h1:pgr/4QbFyktUv9CtQ/Fq4gzEE6/Xs7iCXbktaGzLHbQ=
 | 
			
		||||
google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697/go.mod h1:+D9ySVjN8nY8YCVjc5O7PZDIdZporIDY3KaGfJunh88=
 | 
			
		||||
google.golang.org/genproto/googleapis/api v0.0.0-20241223144023-3abc09e42ca8 h1:st3LcW/BPi75W4q1jJTEor/QWwbNlPlDG0JTn6XhZu0=
 | 
			
		||||
google.golang.org/genproto/googleapis/api v0.0.0-20241223144023-3abc09e42ca8/go.mod h1:klhJGKFyG8Tn50enBn7gizg4nXGXJ+jqEREdCWaPcV4=
 | 
			
		||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 h1:LWZqQOEjDyONlF1H6afSWpAL/znlREo2tHfLoe+8LMA=
 | 
			
		||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
 | 
			
		||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 h1:TqExAhdPaB60Ux47Cn0oLV07rGnxZzIsaRhQaqS666A=
 | 
			
		||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8/go.mod h1:lcTa1sDdWEIHMWlITnIczmw5w60CF9ffkb8Z+DVmmjA=
 | 
			
		||||
google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4 h1:8XJ4pajGwOlasW+L13MnEGA8W4115jJySQtVfS2/IBU=
 | 
			
		||||
google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4/go.mod h1:NnuHhy+bxcg30o7FnVAZbXsPHUDQ9qKWAQKCD7VxFtk=
 | 
			
		||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250929231259-57b25ae835d4 h1:i8QOKZfYg6AbGVZzUAY3LrNWCKF8O6zFisU9Wl9RER4=
 | 
			
		||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250929231259-57b25ae835d4/go.mod h1:HSkG/KdJWusxU1F6CNrwNDjBMgisKxGnc5dAZfT0mjQ=
 | 
			
		||||
google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
 | 
			
		||||
google.golang.org/grpc v1.0.5/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
 | 
			
		||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
 | 
			
		||||
@ -1351,10 +1319,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp
 | 
			
		||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
 | 
			
		||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
 | 
			
		||||
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
 | 
			
		||||
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
 | 
			
		||||
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
 | 
			
		||||
google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU=
 | 
			
		||||
google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
 | 
			
		||||
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
 | 
			
		||||
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
 | 
			
		||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
 | 
			
		||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
 | 
			
		||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
 | 
			
		||||
@ -1368,13 +1334,10 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
 | 
			
		||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
 | 
			
		||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
 | 
			
		||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
 | 
			
		||||
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
 | 
			
		||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
 | 
			
		||||
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
 | 
			
		||||
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
 | 
			
		||||
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
 | 
			
		||||
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
 | 
			
		||||
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
 | 
			
		||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
 | 
			
		||||
gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII=
 | 
			
		||||
gopkg.in/cenkalti/backoff.v2 v2.2.1/go.mod h1:S0QdOvT2AlerfSBkp0O+dk+bbIMaNbEmVk876gPCthU=
 | 
			
		||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
			
		||||
gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
			
		||||
@ -1390,7 +1353,6 @@ gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKW
 | 
			
		||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
 | 
			
		||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
 | 
			
		||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
 | 
			
		||||
gopkg.in/rethinkdb/rethinkdb-go.v6 v6.2.1 h1:d4KQkxAaAiRY2h5Zqis161Pv91A37uZyJOx73duwUwM=
 | 
			
		||||
gopkg.in/rethinkdb/rethinkdb-go.v6 v6.2.1/go.mod h1:WbjuEoo1oadwzQ4apSDU+JTvmllEHtsNHS6y7vFc7iw=
 | 
			
		||||
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
 | 
			
		||||
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
 | 
			
		||||
@ -1411,12 +1373,11 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
 | 
			
		||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 | 
			
		||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 | 
			
		||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 | 
			
		||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
 | 
			
		||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
 | 
			
		||||
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
 | 
			
		||||
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
 | 
			
		||||
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
 | 
			
		||||
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
 | 
			
		||||
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
 | 
			
		||||
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
 | 
			
		||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 | 
			
		||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 | 
			
		||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										135
									
								
								pkg/app/app.go
									
									
									
									
									
								
							
							
						
						
									
										135
									
								
								pkg/app/app.go
									
									
									
									
									
								
							@ -2,6 +2,7 @@ package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bufio"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
@ -13,6 +14,7 @@ import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/envfile"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/convert"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
@ -36,7 +38,7 @@ func Get(appName string) (App, error) {
 | 
			
		||||
		return App{}, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("retrieved %s for %s", app, appName)
 | 
			
		||||
	log.Debug(i18n.G("loaded app %s: %s", appName, app))
 | 
			
		||||
 | 
			
		||||
	return app, nil
 | 
			
		||||
}
 | 
			
		||||
@ -47,7 +49,7 @@ func Get(appName string) (App, error) {
 | 
			
		||||
func GetApp(apps AppFiles, name AppName) (App, error) {
 | 
			
		||||
	appFile, exists := apps[name]
 | 
			
		||||
	if !exists {
 | 
			
		||||
		return App{}, fmt.Errorf("cannot find app with name %s", name)
 | 
			
		||||
		return App{}, errors.New(i18n.G("cannot find app with name %s", name))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	app, err := ReadAppEnvFile(appFile, name)
 | 
			
		||||
@ -91,6 +93,17 @@ type App struct {
 | 
			
		||||
	Path   string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// String outputs a human-friendly string representation.
 | 
			
		||||
func (a App) String() string {
 | 
			
		||||
	out := fmt.Sprintf("{name: %s, ", a.Name)
 | 
			
		||||
	out += fmt.Sprintf("recipe: %s, ", a.Recipe)
 | 
			
		||||
	out += fmt.Sprintf("domain: %s, ", a.Domain)
 | 
			
		||||
	out += fmt.Sprintf("env %s, ", a.Env)
 | 
			
		||||
	out += fmt.Sprintf("server %s, ", a.Server)
 | 
			
		||||
	out += fmt.Sprintf("path %s}", a.Path)
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Type aliases to make code hints easier to understand
 | 
			
		||||
 | 
			
		||||
// AppName is AppName
 | 
			
		||||
@ -125,7 +138,7 @@ func StackName(appName string) string {
 | 
			
		||||
	stackName := SanitiseAppName(appName)
 | 
			
		||||
 | 
			
		||||
	if len(stackName) > config.MAX_SANITISED_APP_NAME_LENGTH {
 | 
			
		||||
		log.Debugf("trimming %s to %s to avoid runtime limits", stackName, stackName[:config.MAX_SANITISED_APP_NAME_LENGTH])
 | 
			
		||||
		log.Debug(i18n.G("trimming %s to %s to avoid runtime limits", stackName, stackName[:config.MAX_SANITISED_APP_NAME_LENGTH]))
 | 
			
		||||
		stackName = stackName[:config.MAX_SANITISED_APP_NAME_LENGTH]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -232,14 +245,12 @@ func (a ByName) Less(i, j int) bool {
 | 
			
		||||
func ReadAppEnvFile(appFile AppFile, name AppName) (App, error) {
 | 
			
		||||
	env, err := envfile.ReadEnv(appFile.Path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return App{}, fmt.Errorf("env file for %s couldn't be read: %s", name, err.Error())
 | 
			
		||||
		return App{}, errors.New(i18n.G("env file for %s couldn't be read: %s", name, err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("read env %s from %s", env, appFile.Path)
 | 
			
		||||
 | 
			
		||||
	app, err := NewApp(env, name, appFile)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return App{}, fmt.Errorf("env file for %s has issues: %s", name, err.Error())
 | 
			
		||||
		return App{}, errors.New(i18n.G("env file for %s has issues: %s", name, err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return app, nil
 | 
			
		||||
@ -253,7 +264,7 @@ func NewApp(env envfile.AppEnv, name string, appFile AppFile) (App, error) {
 | 
			
		||||
	if !exists {
 | 
			
		||||
		recipeName, exists = env["TYPE"]
 | 
			
		||||
		if !exists {
 | 
			
		||||
			return App{}, fmt.Errorf("%s is missing the TYPE env var?", name)
 | 
			
		||||
			return App{}, errors.New(i18n.G("%s is missing the TYPE env var?", name))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -281,13 +292,13 @@ func LoadAppFiles(servers ...string) (AppFiles, error) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("collecting metadata from %v servers: %s", len(servers), strings.Join(servers, ", "))
 | 
			
		||||
	log.Debug(i18n.G("collecting metadata from %v servers: %s", len(servers), strings.Join(servers, ", ")))
 | 
			
		||||
 | 
			
		||||
	for _, server := range servers {
 | 
			
		||||
		serverDir := path.Join(config.SERVERS_DIR, server)
 | 
			
		||||
		files, err := config.GetAllFilesInDirectory(serverDir)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return appFiles, fmt.Errorf("server %s doesn't exist? Run \"abra server ls\" to check", server)
 | 
			
		||||
			return appFiles, errors.New(i18n.G("server %s doesn't exist? Run \"abra server ls\" to check", server))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, file := range files {
 | 
			
		||||
@ -366,7 +377,7 @@ func TemplateAppEnvSample(r recipe.Recipe, appName, server, domain string) error
 | 
			
		||||
 | 
			
		||||
	appEnvPath := path.Join(config.ABRA_DIR, "servers", server, fmt.Sprintf("%s.env", appName))
 | 
			
		||||
	if _, err := os.Stat(appEnvPath); !os.IsNotExist(err) {
 | 
			
		||||
		return fmt.Errorf("%s already exists?", appEnvPath)
 | 
			
		||||
		return errors.New(i18n.G("%s already exists?", appEnvPath))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = os.WriteFile(appEnvPath, envSample, 0o664)
 | 
			
		||||
@ -379,14 +390,19 @@ func TemplateAppEnvSample(r recipe.Recipe, appName, server, domain string) error
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	newContents := strings.Replace(string(read), r.Name+".example.com", domain, -1)
 | 
			
		||||
	newContents := strings.Replace(
 | 
			
		||||
		string(read),
 | 
			
		||||
		fmt.Sprintf("%s.example.com", r.Name),
 | 
			
		||||
		domain,
 | 
			
		||||
		-1,
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	err = os.WriteFile(appEnvPath, []byte(newContents), 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("copied & templated %s to %s", r.SampleEnvPath, appEnvPath)
 | 
			
		||||
	log.Debug(i18n.G("copied & templated %s to %s", r.SampleEnvPath, appEnvPath))
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
@ -410,14 +426,16 @@ func GetAppStatuses(apps []App, MachineReadable bool) (map[string]map[string]str
 | 
			
		||||
 | 
			
		||||
	var bar *progressbar.ProgressBar
 | 
			
		||||
	if !MachineReadable {
 | 
			
		||||
		bar = formatter.CreateProgressbar(len(servers), "querying remote servers...")
 | 
			
		||||
		bar = formatter.CreateProgressbar(len(servers), i18n.G("querying remote servers..."))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ch := make(chan stack.StackStatus, len(servers))
 | 
			
		||||
	for server := range servers {
 | 
			
		||||
		cl, err := client.New(server)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return statuses, err
 | 
			
		||||
			log.Warn(err)
 | 
			
		||||
			ch <- stack.StackStatus{}
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		go func(s string) {
 | 
			
		||||
@ -453,13 +471,6 @@ func GetAppStatuses(apps []App, MachineReadable bool) (map[string]map[string]str
 | 
			
		||||
				result["chaosVersion"] = chaosVersion
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			labelKey = fmt.Sprintf("coop-cloud.%s.autoupdate", name)
 | 
			
		||||
			if autoUpdate, ok := service.Spec.Labels[labelKey]; ok {
 | 
			
		||||
				result["autoUpdate"] = autoUpdate
 | 
			
		||||
			} else {
 | 
			
		||||
				result["autoUpdate"] = "false"
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			labelKey = fmt.Sprintf("coop-cloud.%s.version", name)
 | 
			
		||||
			if version, ok := service.Spec.Labels[labelKey]; ok {
 | 
			
		||||
				result["version"] = version
 | 
			
		||||
@ -471,7 +482,7 @@ func GetAppStatuses(apps []App, MachineReadable bool) (map[string]map[string]str
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("retrieved app statuses: %s", statuses)
 | 
			
		||||
	log.Debug(i18n.G("retrieved app statuses: %s", statuses))
 | 
			
		||||
 | 
			
		||||
	return statuses, nil
 | 
			
		||||
}
 | 
			
		||||
@ -485,7 +496,7 @@ func GetAppComposeConfig(recipe string, opts stack.Deploy, appEnv envfile.AppEnv
 | 
			
		||||
		return &composetypes.Config{}, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("retrieved %s for %s", compose.Filename, recipe)
 | 
			
		||||
	log.Debug(i18n.G("retrieved %s for %s", compose.Filename, recipe))
 | 
			
		||||
 | 
			
		||||
	return compose, nil
 | 
			
		||||
}
 | 
			
		||||
@ -494,13 +505,13 @@ func GetAppComposeConfig(recipe string, opts stack.Deploy, appEnv envfile.AppEnv
 | 
			
		||||
func ExposeAllEnv(stackName string, compose *composetypes.Config, appEnv envfile.AppEnv) {
 | 
			
		||||
	for _, service := range compose.Services {
 | 
			
		||||
		if service.Name == "app" {
 | 
			
		||||
			log.Debugf("add the following environment to the app service config of %s:", stackName)
 | 
			
		||||
			log.Debug(i18n.G("adding env vars to %s service config", stackName))
 | 
			
		||||
			for k, v := range appEnv {
 | 
			
		||||
				_, exists := service.Environment[k]
 | 
			
		||||
				if !exists {
 | 
			
		||||
					value := v
 | 
			
		||||
					service.Environment[k] = &value
 | 
			
		||||
					log.Debugf("add env var: %s value: %s to %s", k, value, stackName)
 | 
			
		||||
					log.Debug(i18n.G("%s: %s: %s", stackName, k, value))
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@ -561,24 +572,27 @@ func ReadAbraShCmdNames(abraSh string) ([]string, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(cmdNames) > 0 {
 | 
			
		||||
		log.Debugf("read %s from %s", strings.Join(cmdNames, " "), abraSh)
 | 
			
		||||
		log.Debug(i18n.G("read %s from %s", strings.Join(cmdNames, " "), abraSh))
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Debugf("read 0 command names from %s", abraSh)
 | 
			
		||||
		log.Debug(i18n.G("read 0 command names from %s", abraSh))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return cmdNames, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a App) WriteRecipeVersion(version string, dryRun bool) error {
 | 
			
		||||
// Wipe removes the version from the app .env file.
 | 
			
		||||
func (a App) WipeRecipeVersion() error {
 | 
			
		||||
	file, err := os.Open(a.Path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer file.Close()
 | 
			
		||||
 | 
			
		||||
	skipped := false
 | 
			
		||||
	scanner := bufio.NewScanner(file)
 | 
			
		||||
	lines := []string{}
 | 
			
		||||
	var (
 | 
			
		||||
		lines   []string
 | 
			
		||||
		scanner = bufio.NewScanner(file)
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	for scanner.Scan() {
 | 
			
		||||
		line := scanner.Text()
 | 
			
		||||
		if !strings.HasPrefix(line, "RECIPE=") && !strings.HasPrefix(line, "TYPE=") {
 | 
			
		||||
@ -591,13 +605,58 @@ func (a App) WriteRecipeVersion(version string, dryRun bool) error {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if strings.Contains(line, version) {
 | 
			
		||||
		splitted := strings.Split(line, ":")
 | 
			
		||||
		lines = append(lines, splitted[0])
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := scanner.Err(); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := os.WriteFile(a.Path, []byte(strings.Join(lines, "\n")), os.ModePerm); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debug(i18n.G("version wiped from %s.env", a.Domain))
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// WriteRecipeVersion writes the recipe version to the app .env file.
 | 
			
		||||
func (a App) WriteRecipeVersion(version string, dryRun bool) error {
 | 
			
		||||
	file, err := os.Open(a.Path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer file.Close()
 | 
			
		||||
 | 
			
		||||
	var (
 | 
			
		||||
		dirtyVersion string
 | 
			
		||||
		skipped      bool
 | 
			
		||||
		lines        []string
 | 
			
		||||
		scanner      = bufio.NewScanner(file)
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	for scanner.Scan() {
 | 
			
		||||
		line := scanner.Text()
 | 
			
		||||
		if !strings.HasPrefix(line, "RECIPE=") && !strings.HasPrefix(line, "TYPE=") {
 | 
			
		||||
			lines = append(lines, line)
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if strings.HasPrefix(line, "#") {
 | 
			
		||||
			lines = append(lines, line)
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if strings.Contains(line, version) && !a.Recipe.Dirty && !strings.HasSuffix(line, config.DIRTY_DEFAULT) {
 | 
			
		||||
			skipped = true
 | 
			
		||||
			lines = append(lines, line)
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		splitted := strings.Split(line, ":")
 | 
			
		||||
 | 
			
		||||
		line = fmt.Sprintf("%s:%s", splitted[0], version)
 | 
			
		||||
		lines = append(lines, line)
 | 
			
		||||
	}
 | 
			
		||||
@ -606,18 +665,22 @@ func (a App) WriteRecipeVersion(version string, dryRun bool) error {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if a.Recipe.Dirty && dirtyVersion != "" {
 | 
			
		||||
		version = dirtyVersion
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !dryRun {
 | 
			
		||||
		if err := os.WriteFile(a.Path, []byte(strings.Join(lines, "\n")), os.ModePerm); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Debugf("skipping writing version %s because dry run", version)
 | 
			
		||||
		log.Debug(i18n.G("skipping writing version %s because dry run", version))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !skipped {
 | 
			
		||||
		log.Debugf("version %s saved to %s.env", version, a.Domain)
 | 
			
		||||
		log.Debug(i18n.G("version %s saved to %s.env", version, a.Domain))
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Debugf("skipping version %s write as already exists in %s.env", version, a.Domain)
 | 
			
		||||
		log.Debug(i18n.G("skipping version %s write as already exists in %s.env", version, a.Domain))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
 | 
			
		||||
@ -198,3 +198,29 @@ func compareFilter(t *testing.T, f1 filters.Args, f2 map[string]map[string]bool)
 | 
			
		||||
		t.Errorf("filters mismatch (-want +got):\n%s", diff)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestWriteRecipeVersionOverwrite(t *testing.T) {
 | 
			
		||||
	app, err := appPkg.GetApp(testPkg.ExpectedAppFiles, testPkg.AppName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	defer t.Cleanup(func() {
 | 
			
		||||
		if err := app.WipeRecipeVersion(); err != nil {
 | 
			
		||||
			t.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	assert.Equal(t, "", app.Recipe.EnvVersion)
 | 
			
		||||
 | 
			
		||||
	if err := app.WriteRecipeVersion("foo", false); err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	app, err = appPkg.GetApp(testPkg.ExpectedAppFiles, testPkg.AppName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	assert.Equal(t, "foo", app.Recipe.EnvVersion)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,11 @@
 | 
			
		||||
package app
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/envfile"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	composetypes "github.com/docker/cli/cli/compose/types"
 | 
			
		||||
)
 | 
			
		||||
@ -14,7 +15,7 @@ import (
 | 
			
		||||
func SetRecipeLabel(compose *composetypes.Config, stackName string, recipe string) {
 | 
			
		||||
	for _, service := range compose.Services {
 | 
			
		||||
		if service.Name == "app" {
 | 
			
		||||
			log.Debugf("set recipe label 'coop-cloud.%s.recipe' to %s for %s", stackName, recipe, stackName)
 | 
			
		||||
			log.Debug(i18n.G("set recipe label 'coop-cloud.%s.recipe' to %s for %s", stackName, recipe, stackName))
 | 
			
		||||
			labelKey := fmt.Sprintf("coop-cloud.%s.recipe", stackName)
 | 
			
		||||
			service.Deploy.Labels[labelKey] = recipe
 | 
			
		||||
		}
 | 
			
		||||
@ -26,7 +27,7 @@ func SetRecipeLabel(compose *composetypes.Config, stackName string, recipe strin
 | 
			
		||||
func SetChaosLabel(compose *composetypes.Config, stackName string, chaos bool) {
 | 
			
		||||
	for _, service := range compose.Services {
 | 
			
		||||
		if service.Name == "app" {
 | 
			
		||||
			log.Debugf("set label 'coop-cloud.%s.chaos' to %v for %s", stackName, chaos, stackName)
 | 
			
		||||
			log.Debug(i18n.G("set label 'coop-cloud.%s.chaos' to %v for %s", stackName, chaos, stackName))
 | 
			
		||||
			labelKey := fmt.Sprintf("coop-cloud.%s.chaos", stackName)
 | 
			
		||||
			service.Deploy.Labels[labelKey] = strconv.FormatBool(chaos)
 | 
			
		||||
		}
 | 
			
		||||
@ -37,26 +38,19 @@ func SetChaosLabel(compose *composetypes.Config, stackName string, chaos bool) {
 | 
			
		||||
func SetChaosVersionLabel(compose *composetypes.Config, stackName string, chaosVersion string) {
 | 
			
		||||
	for _, service := range compose.Services {
 | 
			
		||||
		if service.Name == "app" {
 | 
			
		||||
			log.Debugf("set label 'coop-cloud.%s.chaos-version' to %v for %s", stackName, chaosVersion, stackName)
 | 
			
		||||
			log.Debug(i18n.G("set label 'coop-cloud.%s.chaos-version' to %v for %s", stackName, chaosVersion, stackName))
 | 
			
		||||
			labelKey := fmt.Sprintf("coop-cloud.%s.chaos-version", stackName)
 | 
			
		||||
			service.Deploy.Labels[labelKey] = chaosVersion
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SetUpdateLabel adds env ENABLE_AUTO_UPDATE as label to enable/disable the
 | 
			
		||||
// auto update process for this app. The default if this variable is not set is to disable
 | 
			
		||||
// the auto update process.
 | 
			
		||||
func SetUpdateLabel(compose *composetypes.Config, stackName string, appEnv envfile.AppEnv) {
 | 
			
		||||
func SetVersionLabel(compose *composetypes.Config, stackName string, version string) {
 | 
			
		||||
	for _, service := range compose.Services {
 | 
			
		||||
		if service.Name == "app" {
 | 
			
		||||
			enable_auto_update, exists := appEnv["ENABLE_AUTO_UPDATE"]
 | 
			
		||||
			if !exists {
 | 
			
		||||
				enable_auto_update = "false"
 | 
			
		||||
			}
 | 
			
		||||
			log.Debugf("set label 'coop-cloud.%s.autoupdate' to %s for %s", stackName, enable_auto_update, stackName)
 | 
			
		||||
			labelKey := fmt.Sprintf("coop-cloud.%s.autoupdate", stackName)
 | 
			
		||||
			service.Deploy.Labels[labelKey] = enable_auto_update
 | 
			
		||||
			log.Debug(i18n.G("set label 'coop-cloud.%s.version' to %v for %s", stackName, version, stackName))
 | 
			
		||||
			labelKey := fmt.Sprintf("coop-cloud.%s.version", stackName)
 | 
			
		||||
			service.Deploy.Labels[labelKey] = version
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -66,23 +60,31 @@ func GetLabel(compose *composetypes.Config, stackName string, label string) stri
 | 
			
		||||
	for _, service := range compose.Services {
 | 
			
		||||
		if service.Name == "app" {
 | 
			
		||||
			labelKey := fmt.Sprintf("coop-cloud.%s.%s", stackName, label)
 | 
			
		||||
			log.Debugf("get label '%s'", labelKey)
 | 
			
		||||
			log.Debug(i18n.G("get label '%s'", labelKey))
 | 
			
		||||
			if labelValue, ok := service.Deploy.Labels[labelKey]; ok {
 | 
			
		||||
				return labelValue
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	log.Debugf("no %s label found for %s", label, stackName)
 | 
			
		||||
	log.Debug(i18n.G("no %s label found for %s", label, stackName))
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetTimeoutFromLabel reads the timeout value from docker label "coop-cloud.${STACK_NAME}.TIMEOUT" and returns 50 as default value
 | 
			
		||||
// GetTimeoutFromLabel reads the timeout value from docker label
 | 
			
		||||
// `coop-cloud.${STACK_NAME}.timeout=...` if present. A value is present if the
 | 
			
		||||
// operator uses a `TIMEOUT=...` in their app env.
 | 
			
		||||
func GetTimeoutFromLabel(compose *composetypes.Config, stackName string) (int, error) {
 | 
			
		||||
	timeout := 50 // Default Timeout
 | 
			
		||||
	var err error = nil
 | 
			
		||||
	var timeout int
 | 
			
		||||
 | 
			
		||||
	if timeoutLabel := GetLabel(compose, stackName, "timeout"); timeoutLabel != "" {
 | 
			
		||||
		log.Debugf("timeout label: %s", timeoutLabel)
 | 
			
		||||
		log.Debug(i18n.G("timeout label: %s", timeoutLabel))
 | 
			
		||||
 | 
			
		||||
		var err error
 | 
			
		||||
		timeout, err = strconv.Atoi(timeoutLabel)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return timeout, errors.New(i18n.G("unable to convert timeout label %s to int: %s", timeoutLabel, err))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return timeout, err
 | 
			
		||||
 | 
			
		||||
	return timeout, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										62
									
								
								pkg/app/compose_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								pkg/app/compose_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,62 @@
 | 
			
		||||
package app_test
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	testPkg "coopcloud.tech/abra/pkg/test"
 | 
			
		||||
	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestGetTimeoutFromLabel(t *testing.T) {
 | 
			
		||||
	testPkg.MkServerAppRecipe()
 | 
			
		||||
	defer testPkg.RmServerAppRecipe()
 | 
			
		||||
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		configuredTimeout string
 | 
			
		||||
		expectedTimeout   int
 | 
			
		||||
	}{
 | 
			
		||||
		{"0", 0},
 | 
			
		||||
		{"DOESNTEXIST", 0}, // NOTE(d1): test when missing from .env
 | 
			
		||||
		{"80", 80},
 | 
			
		||||
		{"120", 120},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		app, err := appPkg.GetApp(testPkg.ExpectedAppFiles, testPkg.AppName)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			t.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if test.configuredTimeout != "DOESNTEXIST" {
 | 
			
		||||
			app.Env["TIMEOUT"] = test.configuredTimeout
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			t.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		deployOpts := stack.Deploy{
 | 
			
		||||
			Composefiles: composeFiles,
 | 
			
		||||
			Namespace:    app.StackName(),
 | 
			
		||||
			Prune:        false,
 | 
			
		||||
			ResolveImage: stack.ResolveImageAlways,
 | 
			
		||||
			Detach:       false,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		compose, err := appPkg.GetAppComposeConfig(app.Name, deployOpts, app.Env)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			t.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		timeout, err := appPkg.GetTimeoutFromLabel(compose, app.StackName())
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			t.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, timeout, test.expectedTimeout)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -1,11 +1,12 @@
 | 
			
		||||
package autocomplete
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
)
 | 
			
		||||
@ -14,7 +15,7 @@ import (
 | 
			
		||||
func AppNameComplete() ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
	appFiles, err := app.LoadAppFiles("")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		err := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
		err := i18n.G("autocomplete failed: %s", err)
 | 
			
		||||
		return []string{err}, cobra.ShellCompDirectiveError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -29,7 +30,7 @@ func AppNameComplete() ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
func ServiceNameComplete(appName string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
	serviceNames, err := app.GetAppServiceNames(appName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		err := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
		err := i18n.G("autocomplete failed: %s", err)
 | 
			
		||||
		return []string{err}, cobra.ShellCompDirectiveError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -38,9 +39,15 @@ func ServiceNameComplete(appName string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
 | 
			
		||||
// RecipeNameComplete completes recipe names.
 | 
			
		||||
func RecipeNameComplete() ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
	catl, err := recipe.ReadRecipeCatalogue(false)
 | 
			
		||||
	catl, err := recipe.ReadRecipeCatalogue(true)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		err := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
		err := i18n.G("autocomplete failed: %s", err)
 | 
			
		||||
		return []string{err}, cobra.ShellCompDirectiveError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	localRecipes, err := recipe.GetRecipesLocal()
 | 
			
		||||
	if err != nil && !strings.Contains(err.Error(), "empty") {
 | 
			
		||||
		err := i18n.G("autocomplete failed: %s", err)
 | 
			
		||||
		return []string{err}, cobra.ShellCompDirectiveError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -49,14 +56,18 @@ func RecipeNameComplete() ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
		recipeNames = append(recipeNames, name)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, recipeLocal := range localRecipes {
 | 
			
		||||
		recipeNames = append(recipeNames, recipeLocal)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return recipeNames, cobra.ShellCompDirectiveDefault
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RecipeVersionComplete completes versions for the recipe.
 | 
			
		||||
func RecipeVersionComplete(recipeName string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
	catl, err := recipe.ReadRecipeCatalogue(false)
 | 
			
		||||
	catl, err := recipe.ReadRecipeCatalogue(true)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		err := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
		err := i18n.G("autocomplete failed: %s", err)
 | 
			
		||||
		return []string{err}, cobra.ShellCompDirectiveError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -74,7 +85,7 @@ func RecipeVersionComplete(recipeName string) ([]string, cobra.ShellCompDirectiv
 | 
			
		||||
func ServerNameComplete() ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
	files, err := app.LoadAppFiles("")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		err := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
		err := i18n.G("autocomplete failed: %s", err)
 | 
			
		||||
		return []string{err}, cobra.ShellCompDirectiveError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -90,13 +101,13 @@ func ServerNameComplete() ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
func CommandNameComplete(appName string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
	app, err := app.Get(appName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		err := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
		err := i18n.G("autocomplete failed: %s", err)
 | 
			
		||||
		return []string{err}, cobra.ShellCompDirectiveError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmdNames, err := appPkg.ReadAbraShCmdNames(app.Recipe.AbraShPath)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		err := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
		err := i18n.G("autocomplete failed: %s", err)
 | 
			
		||||
		return []string{err}, cobra.ShellCompDirectiveError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -111,7 +122,7 @@ func SecretComplete(recipeName string) ([]string, cobra.ShellCompDirective) {
 | 
			
		||||
 | 
			
		||||
	config, err := r.GetComposeConfig(nil)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		err := fmt.Sprintf("autocomplete failed: %s", err)
 | 
			
		||||
		err := i18n.G("autocomplete failed: %s", err)
 | 
			
		||||
		return []string{err}, cobra.ShellCompDirectiveError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
package catalogue
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
@ -8,6 +9,7 @@ import (
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	gitPkg "coopcloud.tech/abra/pkg/git"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/go-git/go-git/v5"
 | 
			
		||||
)
 | 
			
		||||
@ -16,13 +18,12 @@ import (
 | 
			
		||||
func EnsureCatalogue() error {
 | 
			
		||||
	catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
 | 
			
		||||
	if _, err := os.Stat(catalogueDir); err != nil && os.IsNotExist(err) {
 | 
			
		||||
		log.Warnf("local recipe catalogue is missing, retrieving now")
 | 
			
		||||
		log.Debug(i18n.G("catalogue is missing, retrieving now"))
 | 
			
		||||
 | 
			
		||||
		url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, config.CATALOGUE_JSON_REPO_NAME)
 | 
			
		||||
		if err := gitPkg.Clone(catalogueDir, url); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("cloned catalogue repository to %s", catalogueDir)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
@ -36,8 +37,7 @@ func EnsureIsClean() error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !isClean {
 | 
			
		||||
		msg := "%s has locally unstaged changes? please commit/remove your changes before proceeding"
 | 
			
		||||
		return fmt.Errorf(msg, config.CATALOGUE_DIR)
 | 
			
		||||
		return errors.New(i18n.G("%s has locally unstaged changes? please commit/remove your changes before proceeding", config.CATALOGUE_DIR))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
@ -56,8 +56,7 @@ func EnsureUpToDate() error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(remotes) == 0 {
 | 
			
		||||
		msg := "cannot ensure %s is up-to-date, no git remotes configured"
 | 
			
		||||
		log.Debugf(msg, config.CATALOGUE_DIR)
 | 
			
		||||
		log.Debug(i18n.G("cannot ensure %s is up-to-date, no git remotes configured", config.CATALOGUE_DIR))
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -82,7 +81,7 @@ func EnsureUpToDate() error {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("fetched latest git changes for %s", config.CATALOGUE_DIR)
 | 
			
		||||
	log.Debug(i18n.G("fetched latest git changes for %s", config.CATALOGUE_DIR))
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,12 +4,15 @@ package client
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	contextPkg "coopcloud.tech/abra/pkg/context"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	sshPkg "coopcloud.tech/abra/pkg/ssh"
 | 
			
		||||
	commandconnPkg "coopcloud.tech/abra/pkg/upstream/commandconn"
 | 
			
		||||
@ -38,18 +41,29 @@ func WithTimeout(timeout int) Opt {
 | 
			
		||||
func New(serverName string, opts ...Opt) (*client.Client, error) {
 | 
			
		||||
	var clientOpts []client.Opt
 | 
			
		||||
 | 
			
		||||
	if serverName != "default" {
 | 
			
		||||
		context, err := GetContext(serverName)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, fmt.Errorf("unknown server, run \"abra server add %s\"?", serverName)
 | 
			
		||||
	ctx, err := GetContext(serverName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		serverDir := path.Join(config.SERVERS_DIR, serverName)
 | 
			
		||||
		if _, err := os.Stat(serverDir); err == nil {
 | 
			
		||||
			return nil, errors.New(i18n.G("server missing context, run \"abra server add %s\"?", serverName))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		ctxEndpoint, err := contextPkg.GetContextEndpoint(context)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		return nil, errors.New(i18n.G("unknown server, run \"abra server add %s\"?", serverName))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ctxEndpoint, err := contextPkg.GetContextEndpoint(ctx)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var isUnix bool
 | 
			
		||||
	if strings.Contains(ctxEndpoint, "unix://") {
 | 
			
		||||
		isUnix = true
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if serverName != "default" && !isUnix {
 | 
			
		||||
		conf := &Conf{}
 | 
			
		||||
 | 
			
		||||
		for _, opt := range opts {
 | 
			
		||||
			opt(conf)
 | 
			
		||||
		}
 | 
			
		||||
@ -85,7 +99,7 @@ func New(serverName string, opts ...Opt) (*client.Client, error) {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("created client for %s", serverName)
 | 
			
		||||
	log.Debug(i18n.G("created client for %s", serverName))
 | 
			
		||||
 | 
			
		||||
	info, err := cl.Info(context.Background())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@ -93,11 +107,11 @@ func New(serverName string, opts ...Opt) (*client.Client, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if info.Swarm.LocalNodeState == "inactive" {
 | 
			
		||||
		if serverName != "default" {
 | 
			
		||||
			return cl, fmt.Errorf("swarm mode not enabled on %s?", serverName)
 | 
			
		||||
		if serverName != "default" && !isUnix {
 | 
			
		||||
			return cl, errors.New(i18n.G("swarm mode not enabled on %s?", serverName))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return cl, errors.New("swarm mode not enabled on local server?")
 | 
			
		||||
		return cl, errors.New(i18n.G("swarm mode not enabled on local server?"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return cl, nil
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										39
									
								
								pkg/client/configs.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								pkg/client/configs.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,39 @@
 | 
			
		||||
package client
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
	"github.com/docker/docker/api/types/swarm"
 | 
			
		||||
	"github.com/docker/docker/client"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func GetConfigs(cl *client.Client, ctx context.Context, server string, fs filters.Args) ([]swarm.Config, error) {
 | 
			
		||||
	configList, err := cl.ConfigList(ctx, swarm.ConfigListOptions{Filters: fs})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return configList, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return configList, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GetConfigNames(configs []swarm.Config) []string {
 | 
			
		||||
	var confNames []string
 | 
			
		||||
 | 
			
		||||
	for _, conf := range configs {
 | 
			
		||||
		confNames = append(confNames, conf.Spec.Name)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return confNames
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func RemoveConfigs(cl *client.Client, ctx context.Context, configNames []string, force bool) error {
 | 
			
		||||
	for _, confName := range configNames {
 | 
			
		||||
		if err := cl.ConfigRemove(context.Background(), confName); err != nil {
 | 
			
		||||
			return errors.New(i18n.G("conf %s: %s", confName, err))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
@ -5,6 +5,7 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/context"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	commandconnPkg "coopcloud.tech/abra/pkg/upstream/commandconn"
 | 
			
		||||
	dConfig "github.com/docker/cli/cli/config"
 | 
			
		||||
@ -22,7 +23,7 @@ func CreateContext(contextName string) error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("created the %s context", contextName)
 | 
			
		||||
	log.Debug(i18n.G("created the %s context", contextName))
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
@ -62,7 +63,7 @@ func createContext(name string, host string) error {
 | 
			
		||||
 | 
			
		||||
func DeleteContext(name string) error {
 | 
			
		||||
	if name == "default" {
 | 
			
		||||
		return errors.New("context 'default' cannot be removed")
 | 
			
		||||
		return errors.New(i18n.G("context 'default' cannot be removed"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, err := GetContext(name); err != nil {
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,10 @@ package client
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"github.com/containers/image/docker"
 | 
			
		||||
	"github.com/containers/image/types"
 | 
			
		||||
	"github.com/distribution/reference"
 | 
			
		||||
@ -15,7 +17,7 @@ func GetRegistryTags(img reference.Named) ([]string, error) {
 | 
			
		||||
 | 
			
		||||
	ref, err := docker.ParseReference(fmt.Sprintf("//%s", img))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return tags, fmt.Errorf("failed to parse image %s, saw: %s", img, err.Error())
 | 
			
		||||
		return tags, errors.New(i18n.G("failed to parse image %s, saw: %s", img, err.Error()))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,7 @@ import (
 | 
			
		||||
	"github.com/docker/docker/client"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func StoreSecret(cl *client.Client, secretName, secretValue, server string) error {
 | 
			
		||||
func StoreSecret(cl *client.Client, secretName, secretValue string) error {
 | 
			
		||||
	ann := swarm.Annotations{Name: secretName}
 | 
			
		||||
	spec := swarm.SecretSpec{Annotations: ann, Data: []byte(secretValue)}
 | 
			
		||||
 | 
			
		||||
@ -17,3 +17,11 @@ func StoreSecret(cl *client.Client, secretName, secretValue, server string) erro
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GetSecretNames(secrets []swarm.Secret) []string {
 | 
			
		||||
	var secretNames []string
 | 
			
		||||
	for _, secret := range secrets {
 | 
			
		||||
		secretNames = append(secretNames, secret.Spec.Name)
 | 
			
		||||
	}
 | 
			
		||||
	return secretNames
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										58
									
								
								pkg/client/secret_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								pkg/client/secret_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,58 @@
 | 
			
		||||
package client
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/docker/docker/api/types/swarm"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestGetSecretNames(t *testing.T) {
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		name        string
 | 
			
		||||
		secrets     []swarm.Secret
 | 
			
		||||
		expected    []string
 | 
			
		||||
		description string
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			name:        "empty secrets list",
 | 
			
		||||
			secrets:     []swarm.Secret{},
 | 
			
		||||
			expected:    nil,
 | 
			
		||||
			description: "should return nil for empty input",
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "single secret",
 | 
			
		||||
			secrets: []swarm.Secret{
 | 
			
		||||
				{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "database_password"}}},
 | 
			
		||||
			},
 | 
			
		||||
			expected:    []string{"database_password"},
 | 
			
		||||
			description: "should return single secret name",
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "multiple secrets",
 | 
			
		||||
			secrets: []swarm.Secret{
 | 
			
		||||
				{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "db_password"}}},
 | 
			
		||||
				{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "api_key"}}},
 | 
			
		||||
				{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "ssl_cert"}}},
 | 
			
		||||
			},
 | 
			
		||||
			expected:    []string{"db_password", "api_key", "ssl_cert"},
 | 
			
		||||
			description: "should return all secret names in order",
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "secrets with empty names",
 | 
			
		||||
			secrets: []swarm.Secret{
 | 
			
		||||
				{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: ""}}},
 | 
			
		||||
				{Spec: swarm.SecretSpec{Annotations: swarm.Annotations{Name: "valid_name"}}},
 | 
			
		||||
			},
 | 
			
		||||
			expected:    []string{"", "valid_name"},
 | 
			
		||||
			description: "should include empty names if present",
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			result := GetSecretNames(tt.secrets)
 | 
			
		||||
			assert.Equal(t, tt.expected, result, tt.description)
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -2,9 +2,10 @@ package client
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
	"github.com/docker/docker/api/types/volume"
 | 
			
		||||
@ -37,7 +38,7 @@ func RemoveVolumes(cl *client.Client, ctx context.Context, volumeNames []string,
 | 
			
		||||
			return cl.VolumeRemove(context.Background(), volName, force)
 | 
			
		||||
		})
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return fmt.Errorf("volume %s: %s", volName, err)
 | 
			
		||||
			return errors.New(i18n.G("volume %s: %s", volName, err))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
@ -54,9 +55,9 @@ func retryFunc(retries int, fn func() error) error {
 | 
			
		||||
		}
 | 
			
		||||
		if i+1 < retries {
 | 
			
		||||
			sleep := time.Duration(i+1) * time.Duration(i+1)
 | 
			
		||||
			log.Infof("%s: waiting %d seconds before next retry", err, sleep)
 | 
			
		||||
			log.Info(i18n.G("%s: waiting %d seconds before next retry", err, sleep))
 | 
			
		||||
			time.Sleep(sleep * time.Second)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Errorf("%d retries failed", retries)
 | 
			
		||||
	return errors.New(i18n.G("%d retries failed", retries))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@ import (
 | 
			
		||||
	"path"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"gopkg.in/yaml.v3"
 | 
			
		||||
)
 | 
			
		||||
@ -16,13 +17,13 @@ func LoadAbraConfig() Abra {
 | 
			
		||||
	wd, _ := os.Getwd()
 | 
			
		||||
	configFile := findAbraConfig(wd)
 | 
			
		||||
	if configFile == "" {
 | 
			
		||||
		log.Debugf("no config file found")
 | 
			
		||||
		log.Debug(i18n.G("no config file found"))
 | 
			
		||||
		return Abra{}
 | 
			
		||||
	}
 | 
			
		||||
	data, err := os.ReadFile(configFile)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		// Do nothing, when an error occurs
 | 
			
		||||
		log.Debugf("error reading config file: %s", err)
 | 
			
		||||
		log.Debug(i18n.G("error reading config file: %s", err))
 | 
			
		||||
		return Abra{}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -30,10 +31,10 @@ func LoadAbraConfig() Abra {
 | 
			
		||||
	err = yaml.Unmarshal(data, &config)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		// Do nothing, when an error occurs
 | 
			
		||||
		log.Debugf("error loading config file: %s", err)
 | 
			
		||||
		log.Debug(i18n.G("error loading config file: %s", err))
 | 
			
		||||
		return Abra{}
 | 
			
		||||
	}
 | 
			
		||||
	log.Debugf("config file loaded from: %s", configFile)
 | 
			
		||||
	log.Debug(i18n.G("config file loaded from: %s", configFile))
 | 
			
		||||
	config.configPath = filepath.Dir(configFile)
 | 
			
		||||
	return config
 | 
			
		||||
}
 | 
			
		||||
@ -73,40 +74,39 @@ type Abra struct {
 | 
			
		||||
// 3. use $HOME/.abra when above two options failed
 | 
			
		||||
func (a Abra) GetAbraDir() string {
 | 
			
		||||
	if dir, exists := os.LookupEnv("ABRA_DIR"); exists && dir != "" {
 | 
			
		||||
		log.Debug("read abra dir from $ABRA_DIR")
 | 
			
		||||
		log.Debug(i18n.G("read abra dir from $ABRA_DIR"))
 | 
			
		||||
		return dir
 | 
			
		||||
	}
 | 
			
		||||
	if a.AbraDir != "" {
 | 
			
		||||
		log.Debug("read abra dir from config file")
 | 
			
		||||
		log.Debug(i18n.G("read abra dir from config file"))
 | 
			
		||||
		if path.IsAbs(a.AbraDir) {
 | 
			
		||||
			return a.AbraDir
 | 
			
		||||
		}
 | 
			
		||||
		// Make the path absolute
 | 
			
		||||
		return path.Join(a.configPath, a.AbraDir)
 | 
			
		||||
	}
 | 
			
		||||
	log.Debug("using default abra dir")
 | 
			
		||||
	log.Debug(i18n.G("using default abra dir"))
 | 
			
		||||
	return os.ExpandEnv("$HOME/.abra")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a Abra) GetServersDir() string   { return path.Join(a.GetAbraDir(), "servers") }
 | 
			
		||||
func (a Abra) GetRecipesDir() string   { return path.Join(a.GetAbraDir(), "recipes") }
 | 
			
		||||
func (a Abra) GetVendorDir() string    { return path.Join(a.GetAbraDir(), "vendor") }
 | 
			
		||||
func (a Abra) GetBackupDir() string    { return path.Join(a.GetAbraDir(), "backups") }
 | 
			
		||||
func (a Abra) GetLogsDir() string      { return path.Join(a.GetAbraDir(), "logs") }
 | 
			
		||||
func (a Abra) GetCatalogueDir() string { return path.Join(a.GetAbraDir(), "catalogue") }
 | 
			
		||||
 | 
			
		||||
var config = LoadAbraConfig()
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	ABRA_DIR                 = config.GetAbraDir()
 | 
			
		||||
	SERVERS_DIR              = config.GetServersDir()
 | 
			
		||||
	RECIPES_DIR              = config.GetRecipesDir()
 | 
			
		||||
	VENDOR_DIR               = config.GetVendorDir()
 | 
			
		||||
	BACKUP_DIR               = config.GetBackupDir()
 | 
			
		||||
	CATALOGUE_DIR            = config.GetCatalogueDir()
 | 
			
		||||
	RECIPES_JSON             = path.Join(config.GetCatalogueDir(), "recipes.json")
 | 
			
		||||
	REPOS_BASE_URL           = "https://git.coopcloud.tech/coop-cloud"
 | 
			
		||||
	CATALOGUE_JSON_REPO_NAME = "recipes-catalogue-json"
 | 
			
		||||
	SSH_URL_TEMPLATE         = "ssh://git@git.coopcloud.tech:2222/coop-cloud/%s.git"
 | 
			
		||||
	ABRA_DIR                  = config.GetAbraDir()
 | 
			
		||||
	SERVERS_DIR               = config.GetServersDir()
 | 
			
		||||
	RECIPES_DIR               = config.GetRecipesDir()
 | 
			
		||||
	LOGS_DIR                  = config.GetLogsDir()
 | 
			
		||||
	CATALOGUE_DIR             = config.GetCatalogueDir()
 | 
			
		||||
	RECIPES_JSON              = path.Join(config.GetCatalogueDir(), "recipes.json")
 | 
			
		||||
	REPOS_BASE_URL            = "https://git.coopcloud.tech/coop-cloud"
 | 
			
		||||
	CATALOGUE_JSON_REPO_NAME  = "recipes-catalogue-json"
 | 
			
		||||
	TOOLSHED_SSH_URL_TEMPLATE = "ssh://git@git.coopcloud.tech:2222/toolshed/%s.git"
 | 
			
		||||
	RECIPES_SSH_URL_TEMPLATE  = "ssh://git@git.coopcloud.tech:2222/coop-cloud/%s.git"
 | 
			
		||||
 | 
			
		||||
	// NOTE(d1): please note, this was done purely out of laziness on our part
 | 
			
		||||
	// AFAICR. it's easy to punt the value into the label because that is what is
 | 
			
		||||
@ -114,6 +114,9 @@ var (
 | 
			
		||||
	// complained yet!
 | 
			
		||||
	CHAOS_DEFAULT = "false"
 | 
			
		||||
 | 
			
		||||
	NO_DOMAIN_DEFAULT  = "N/A"
 | 
			
		||||
	NO_VERSION_DEFAULT = "N/A"
 | 
			
		||||
	DIRTY_DEFAULT = "+U"
 | 
			
		||||
 | 
			
		||||
	MISSING_DEFAULT = "-"
 | 
			
		||||
 | 
			
		||||
	UNKNOWN_DEFAULT = "unknown"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
package config
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"io/fs"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"os"
 | 
			
		||||
@ -9,6 +9,7 @@ import (
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -26,9 +27,16 @@ func GetServers() ([]string, error) {
 | 
			
		||||
		return servers, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("retrieved %v servers: %s", len(servers), servers)
 | 
			
		||||
	var filtered []string
 | 
			
		||||
	for _, s := range servers {
 | 
			
		||||
		if !strings.HasPrefix(s, ".") {
 | 
			
		||||
			filtered = append(filtered, s)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return servers, nil
 | 
			
		||||
	log.Debug(i18n.G("retrieved %v servers: %s", len(filtered), filtered))
 | 
			
		||||
 | 
			
		||||
	return filtered, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ReadServerNames retrieves all server names.
 | 
			
		||||
@ -39,7 +47,7 @@ func ReadServerNames() ([]string, error) {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("read %s from %s", strings.Join(serverNames, ","), SERVERS_DIR)
 | 
			
		||||
	log.Debug(i18n.G("read %s from %s", strings.Join(serverNames, ","), SERVERS_DIR))
 | 
			
		||||
 | 
			
		||||
	return serverNames, nil
 | 
			
		||||
}
 | 
			
		||||
@ -63,7 +71,7 @@ func GetAllFilesInDirectory(directory string) ([]fs.FileInfo, error) {
 | 
			
		||||
 | 
			
		||||
		realPath, err := filepath.EvalSymlinks(filePath)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Warnf("broken symlink in your abra config folders: %s", filePath)
 | 
			
		||||
			log.Warn(i18n.G("broken symlink in your abra config folders: %s", filePath))
 | 
			
		||||
		} else {
 | 
			
		||||
			realFile, err := os.Stat(realPath)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
@ -87,7 +95,7 @@ func GetAllFoldersInDirectory(directory string) ([]string, error) {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	if len(files) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("directory is empty: %s", directory)
 | 
			
		||||
		return nil, errors.New(i18n.G("directory is empty: %s", directory))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, file := range files {
 | 
			
		||||
@ -96,7 +104,7 @@ func GetAllFoldersInDirectory(directory string) ([]string, error) {
 | 
			
		||||
			filePath := path.Join(directory, file.Name())
 | 
			
		||||
			realDir, err := filepath.EvalSymlinks(filePath)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Warnf("broken symlink in your abra config folders: %s", filePath)
 | 
			
		||||
				log.Warn(i18n.G("broken symlink in your abra config folders: %s", filePath))
 | 
			
		||||
			} else if stat, err := os.Stat(realDir); err == nil && stat.IsDir() {
 | 
			
		||||
				// path is a directory
 | 
			
		||||
				folders = append(folders, file.Name())
 | 
			
		||||
 | 
			
		||||
@ -2,10 +2,12 @@ package container
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/AlecAivazis/survey/v2"
 | 
			
		||||
	"github.com/docker/docker/api/types"
 | 
			
		||||
@ -26,7 +28,7 @@ func GetContainer(c context.Context, cl *client.Client, filters filters.Args, no
 | 
			
		||||
 | 
			
		||||
	if len(containers) == 0 {
 | 
			
		||||
		filter := filters.Get("name")[0]
 | 
			
		||||
		return types.Container{}, fmt.Errorf("no containers matching the %v filter found?", filter)
 | 
			
		||||
		return types.Container{}, errors.New(i18n.G("no containers matching the %v filter found?", filter))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(containers) > 1 {
 | 
			
		||||
@ -35,19 +37,19 @@ func GetContainer(c context.Context, cl *client.Client, filters filters.Args, no
 | 
			
		||||
			containerName := strings.Join(container.Names, " ")
 | 
			
		||||
			trimmed := strings.TrimPrefix(containerName, "/")
 | 
			
		||||
			created := formatter.HumanDuration(container.Created)
 | 
			
		||||
			containersRaw = append(containersRaw, fmt.Sprintf("%s (created %v)", trimmed, created))
 | 
			
		||||
			containersRaw = append(containersRaw, i18n.G("%s (created %v)", trimmed, created))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if noInput {
 | 
			
		||||
			err := fmt.Errorf("expected 1 container but found %v: %s", len(containers), strings.Join(containersRaw, " "))
 | 
			
		||||
			err := errors.New(i18n.G("expected 1 container but found %v: %s", len(containers), strings.Join(containersRaw, " ")))
 | 
			
		||||
			return types.Container{}, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Warnf("ambiguous container list received, prompting for input")
 | 
			
		||||
		log.Warnf(i18n.G("ambiguous container list received, prompting for input"))
 | 
			
		||||
 | 
			
		||||
		var response string
 | 
			
		||||
		prompt := &survey.Select{
 | 
			
		||||
			Message: "which container are you looking for?",
 | 
			
		||||
			Message: i18n.G("which container are you looking for?"),
 | 
			
		||||
			Options: containersRaw,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -64,7 +66,7 @@ func GetContainer(c context.Context, cl *client.Client, filters filters.Args, no
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Fatal("failed to match chosen container")
 | 
			
		||||
		log.Fatal(i18n.G("failed to match chosen container"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return containers[0], nil
 | 
			
		||||
@ -79,5 +81,6 @@ func GetContainerFromStackAndService(cl *client.Client, stack, service string) (
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return types.Container{}, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return container, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@ package context
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"github.com/docker/cli/cli/command"
 | 
			
		||||
	dConfig "github.com/docker/cli/cli/config"
 | 
			
		||||
	"github.com/docker/cli/cli/context"
 | 
			
		||||
@ -30,7 +31,7 @@ func NewDefaultDockerContextStore() *command.ContextStoreWithDefault {
 | 
			
		||||
func GetContextEndpoint(ctx contextStore.Metadata) (string, error) {
 | 
			
		||||
	endpointmeta, ok := ctx.Endpoints["docker"].(context.EndpointMetaBase)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		err := errors.New("context lacks Docker endpoint")
 | 
			
		||||
		err := errors.New(i18n.G("context lacks Docker endpoint"))
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	return endpointmeta.Host, nil
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										316
									
								
								pkg/deploy/utils.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										316
									
								
								pkg/deploy/utils.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,316 @@
 | 
			
		||||
package deploy
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	appPkg "coopcloud.tech/abra/pkg/app"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/envfile"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/formatter"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/recipe"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/secret"
 | 
			
		||||
 | 
			
		||||
	"github.com/distribution/reference"
 | 
			
		||||
	composetypes "github.com/docker/cli/cli/compose/types"
 | 
			
		||||
	"github.com/docker/docker/api/types/swarm"
 | 
			
		||||
	dockerClient "github.com/docker/docker/client"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// MergeAbraShEnv merges abra.sh env vars into the app env vars.
 | 
			
		||||
func MergeAbraShEnv(recipe recipe.Recipe, env envfile.AppEnv) error {
 | 
			
		||||
	abraShEnv, err := envfile.ReadAbraShEnvVars(recipe.AbraShPath)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for k, v := range abraShEnv {
 | 
			
		||||
		log.Debugf(i18n.G("read v:%s k: %s", v, k))
 | 
			
		||||
		env[k] = v
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetEntityNameAndVersion parses a full name like `app_example_com_someconf_v1` to extract name and version, ("someconf", "v1")
 | 
			
		||||
func GetEntityNameAndVersion(fullName string, stackName string) (string, string, error) {
 | 
			
		||||
	name := strings.TrimPrefix(fullName, stackName+"_")
 | 
			
		||||
	if lastUnderscore := strings.LastIndex(name, "_"); lastUnderscore != -1 {
 | 
			
		||||
		return name[0:lastUnderscore], name[lastUnderscore+1:], nil
 | 
			
		||||
	}
 | 
			
		||||
	return "", "", errors.New(i18n.G("can't parse version from '%s'", fullName))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GetSecretsForStack(cl *dockerClient.Client, app appPkg.App) (map[string]string, error) {
 | 
			
		||||
	filters, err := app.Filters(false, false)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// List all services in the stack
 | 
			
		||||
	// NOTE: we could do cl.SecretList, but we want to know which secrets are actually attached
 | 
			
		||||
	services, err := cl.ServiceList(context.Background(), swarm.ServiceListOptions{
 | 
			
		||||
		Filters: filters,
 | 
			
		||||
	})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	secrets := make(map[string]string)
 | 
			
		||||
 | 
			
		||||
	for _, service := range services {
 | 
			
		||||
		if service.Spec.TaskTemplate.ContainerSpec.Secrets != nil {
 | 
			
		||||
			for _, secretRef := range service.Spec.TaskTemplate.ContainerSpec.Secrets {
 | 
			
		||||
				secretName := secretRef.SecretName
 | 
			
		||||
				if secretName == "" {
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
				secretBaseName, secretVersion, err := GetEntityNameAndVersion(secretName, app.StackName())
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Warn(err)
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				existingSecretVersion, exists := secrets[secretBaseName]
 | 
			
		||||
				if !exists {
 | 
			
		||||
					// First time seeing this, add to map
 | 
			
		||||
					secrets[secretBaseName] = secretVersion
 | 
			
		||||
				} else {
 | 
			
		||||
					// Just make sure the versions are the same..
 | 
			
		||||
					if existingSecretVersion != secretVersion {
 | 
			
		||||
						log.Warnf(i18n.G("different versions for secret '%s', '%s' and %s'", secretBaseName, existingSecretVersion, secretVersion))
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return secrets, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetConfigsForStack retrieves all Docker configs attached to services in a given stack.
 | 
			
		||||
func GetConfigsForStack(cl *dockerClient.Client, app appPkg.App) (map[string]string, error) {
 | 
			
		||||
	filters, err := app.Filters(false, false)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// List all services in the stack
 | 
			
		||||
	services, err := cl.ServiceList(context.Background(), swarm.ServiceListOptions{
 | 
			
		||||
		Filters: filters,
 | 
			
		||||
	})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Collect unique config names with versions
 | 
			
		||||
	configs := make(map[string]string)
 | 
			
		||||
	for _, service := range services {
 | 
			
		||||
		if service.Spec.TaskTemplate.ContainerSpec != nil {
 | 
			
		||||
			for _, configRef := range service.Spec.TaskTemplate.ContainerSpec.Configs {
 | 
			
		||||
				configName := configRef.ConfigName
 | 
			
		||||
				if configName == "" {
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
				configBaseName, configVersion, err := GetEntityNameAndVersion(configName, app.StackName())
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					log.Warn(err)
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				existingConfigVersion, ok := configs[configBaseName]
 | 
			
		||||
				if !ok {
 | 
			
		||||
					// First time seeing this, add to map
 | 
			
		||||
					configs[configBaseName] = configVersion
 | 
			
		||||
				} else {
 | 
			
		||||
					// Just make sure the versions are the same..
 | 
			
		||||
					if existingConfigVersion != configVersion {
 | 
			
		||||
						log.Warnf(i18n.G("different versions for config '%s', '%s' and %s'", configBaseName, existingConfigVersion, configVersion))
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return configs, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetImagesForStack retrieves all Docker images for services in a given stack.
 | 
			
		||||
func GetImagesForStack(cl *dockerClient.Client, app appPkg.App) (map[string]string, error) {
 | 
			
		||||
	filters, err := app.Filters(false, false)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// List all services in the stack
 | 
			
		||||
	services, err := cl.ServiceList(context.Background(), swarm.ServiceListOptions{
 | 
			
		||||
		Filters: filters,
 | 
			
		||||
	})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Collect unique image names with versions
 | 
			
		||||
	images := make(map[string]string)
 | 
			
		||||
	for _, service := range services {
 | 
			
		||||
		if service.Spec.TaskTemplate.ContainerSpec != nil {
 | 
			
		||||
			imageName := service.Spec.TaskTemplate.ContainerSpec.Image
 | 
			
		||||
 | 
			
		||||
			imageParsed, err := reference.ParseNormalizedNamed(imageName)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Warn(err)
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			imageBaseName := reference.Path(imageParsed)
 | 
			
		||||
			imageTag := imageParsed.(reference.NamedTagged).Tag()
 | 
			
		||||
 | 
			
		||||
			existingImageVersion, ok := images[imageBaseName]
 | 
			
		||||
			if !ok {
 | 
			
		||||
				// First time seeing this, add to map
 | 
			
		||||
				images[imageBaseName] = imageTag
 | 
			
		||||
			} else {
 | 
			
		||||
				// Just make sure the versions are the same..
 | 
			
		||||
				if existingImageVersion != imageTag {
 | 
			
		||||
					log.Warnf(i18n.G("different versions for image '%s', '%s' and %s'", imageBaseName, existingImageVersion, imageTag))
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return images, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GatherSecretsForDeploy(cl *dockerClient.Client, app appPkg.App, showUnchanged bool) ([]string, error) {
 | 
			
		||||
	// Get current secrets from existing deployment
 | 
			
		||||
	currentSecrets, err := GetSecretsForStack(cl, app)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf(i18n.G("current secrets: %v", currentSecrets))
 | 
			
		||||
 | 
			
		||||
	newSecrets, err := secret.PollSecretsStatus(cl, app)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf(i18n.G("new secrets: %v", newSecrets))
 | 
			
		||||
 | 
			
		||||
	// Sort secrets to ensure reproducible output
 | 
			
		||||
	sort.Slice(newSecrets, func(i, j int) bool {
 | 
			
		||||
		return newSecrets[i].LocalName < newSecrets[j].LocalName
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	var secretInfo []string
 | 
			
		||||
 | 
			
		||||
	for _, newSecret := range newSecrets {
 | 
			
		||||
		if currentVersion, exists := currentSecrets[newSecret.LocalName]; exists {
 | 
			
		||||
			if currentVersion == newSecret.Version {
 | 
			
		||||
				if showUnchanged {
 | 
			
		||||
					secretInfo = append(secretInfo, i18n.G("%s: %s (unchanged)", newSecret.LocalName, newSecret.Version))
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				secretInfo = append(secretInfo, i18n.G("%s: %s → %s", newSecret.LocalName, currentVersion, newSecret.Version))
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			secretInfo = append(secretInfo, i18n.G("%s: %s (new)", newSecret.LocalName, newSecret.Version))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return secretInfo, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GatherConfigsForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, abraShEnv map[string]string, showUnchanged bool) ([]string, error) {
 | 
			
		||||
	// Get current configs from existing deployment
 | 
			
		||||
	currentConfigs, err := GetConfigsForStack(cl, app)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf(i18n.G("deployed config names: %v", currentConfigs))
 | 
			
		||||
 | 
			
		||||
	// Get new configs from the compose specification
 | 
			
		||||
	newConfigs := compose.Configs
 | 
			
		||||
 | 
			
		||||
	var configInfo []string
 | 
			
		||||
	for configName := range newConfigs {
 | 
			
		||||
		log.Debugf(i18n.G("searching abra.sh for version for %s", configName))
 | 
			
		||||
		versionKey := strings.ToUpper(configName) + "_VERSION"
 | 
			
		||||
		newVersion, exists := abraShEnv[versionKey]
 | 
			
		||||
		if !exists {
 | 
			
		||||
			log.Warnf(i18n.G("no version found for config %s", configName))
 | 
			
		||||
			configInfo = append(configInfo, i18n.G("%s: ? (missing version)", configName))
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if currentVersion, exists := currentConfigs[configName]; exists {
 | 
			
		||||
			if currentVersion == newVersion {
 | 
			
		||||
				if showUnchanged {
 | 
			
		||||
					configInfo = append(configInfo, i18n.G("%s: %s (unchanged)", configName, newVersion))
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				configInfo = append(configInfo, i18n.G("%s: %s → %s", configName, currentVersion, newVersion))
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			configInfo = append(configInfo, i18n.G("%s: %s (new)", configName, newVersion))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return configInfo, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GatherImagesForDeploy(cl *dockerClient.Client, app appPkg.App, compose *composetypes.Config, showUnchanged bool) ([]string, error) {
 | 
			
		||||
	// Get current images from existing deployment
 | 
			
		||||
	currentImages, err := GetImagesForStack(cl, app)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf(i18n.G("deployed images: %v", currentImages))
 | 
			
		||||
 | 
			
		||||
	// Proposed new images from the compose files
 | 
			
		||||
	newImages := make(map[string]string)
 | 
			
		||||
 | 
			
		||||
	for _, service := range compose.Services {
 | 
			
		||||
		imageParsed, err := reference.ParseNormalizedNamed(service.Image)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Warn(err)
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		imageBaseName := reference.Path(imageParsed)
 | 
			
		||||
		imageTag := imageParsed.(reference.NamedTagged).Tag()
 | 
			
		||||
 | 
			
		||||
		existingImageVersion, ok := newImages[imageBaseName]
 | 
			
		||||
		if !ok {
 | 
			
		||||
			// First time seeing this, add to map
 | 
			
		||||
			newImages[imageBaseName] = imageTag
 | 
			
		||||
		} else {
 | 
			
		||||
			// Just make sure the versions are the same..
 | 
			
		||||
			if existingImageVersion != imageTag {
 | 
			
		||||
				log.Warnf(i18n.G("different versions for image '%s', '%s' and %s'", imageBaseName, existingImageVersion, imageTag))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	log.Debugf(i18n.G("proposed images: %v", newImages))
 | 
			
		||||
 | 
			
		||||
	var imageInfo []string
 | 
			
		||||
	for newImageName, newImageVersion := range newImages {
 | 
			
		||||
		if currentVersion, exists := currentImages[newImageName]; exists {
 | 
			
		||||
			if currentVersion == newImageVersion {
 | 
			
		||||
				if showUnchanged {
 | 
			
		||||
					imageInfo = append(imageInfo, i18n.G("%s: %s (unchanged)", formatter.StripTagMeta(newImageName), newImageVersion))
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				imageInfo = append(imageInfo, i18n.G("%s: %s → %s", formatter.StripTagMeta(newImageName), currentVersion, newImageVersion))
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			imageInfo = append(imageInfo, i18n.G("%s: %s (new)", formatter.StripTagMeta(newImageName), newImageVersion))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return imageInfo, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										89
									
								
								pkg/deploy/utils_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								pkg/deploy/utils_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,89 @@
 | 
			
		||||
package deploy
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestGetEntityNameAndVersion(t *testing.T) {
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		name        string
 | 
			
		||||
		fullName    string
 | 
			
		||||
		stackName   string
 | 
			
		||||
		expected    string
 | 
			
		||||
		expectedVer string
 | 
			
		||||
		expectError bool
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			name:        "valid config with version",
 | 
			
		||||
			fullName:    "myapp_database_v2",
 | 
			
		||||
			stackName:   "myapp",
 | 
			
		||||
			expected:    "database",
 | 
			
		||||
			expectedVer: "v2",
 | 
			
		||||
			expectError: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:        "valid config with numeric version",
 | 
			
		||||
			fullName:    "myapp_redis_1",
 | 
			
		||||
			stackName:   "myapp",
 | 
			
		||||
			expected:    "redis",
 | 
			
		||||
			expectedVer: "1",
 | 
			
		||||
			expectError: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:        "config without underscore in name",
 | 
			
		||||
			fullName:    "myapp_db_v1",
 | 
			
		||||
			stackName:   "myapp",
 | 
			
		||||
			expected:    "db",
 | 
			
		||||
			expectedVer: "v1",
 | 
			
		||||
			expectError: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:        "config with multiple underscores",
 | 
			
		||||
			fullName:    "myapp_my_database_v3",
 | 
			
		||||
			stackName:   "myapp",
 | 
			
		||||
			expected:    "my_database",
 | 
			
		||||
			expectedVer: "v3",
 | 
			
		||||
			expectError: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:        "invalid config - no version",
 | 
			
		||||
			fullName:    "myapp_database",
 | 
			
		||||
			stackName:   "myapp",
 | 
			
		||||
			expectError: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:        "empty config name",
 | 
			
		||||
			fullName:    "myapp__v1",
 | 
			
		||||
			stackName:   "myapp",
 | 
			
		||||
			expected:    "",
 | 
			
		||||
			expectedVer: "v1",
 | 
			
		||||
			expectError: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:        "wrong stack prefix",
 | 
			
		||||
			fullName:    "otherapp_database_v1",
 | 
			
		||||
			stackName:   "myapp",
 | 
			
		||||
			expected:    "otherapp_database",
 | 
			
		||||
			expectedVer: "v1",
 | 
			
		||||
			expectError: false,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			name, version, err := GetEntityNameAndVersion(tt.fullName, tt.stackName)
 | 
			
		||||
 | 
			
		||||
			if tt.expectError {
 | 
			
		||||
				assert.Error(t, err)
 | 
			
		||||
				assert.Empty(t, name)
 | 
			
		||||
				assert.Empty(t, version)
 | 
			
		||||
			} else {
 | 
			
		||||
				assert.NoError(t, err)
 | 
			
		||||
				assert.Equal(t, tt.expected, name)
 | 
			
		||||
				assert.Equal(t, tt.expectedVer, version)
 | 
			
		||||
			}
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -1,19 +1,21 @@
 | 
			
		||||
package dns
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"net"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// EnsureIPv4 ensures that an ipv4 address is set for a domain name
 | 
			
		||||
func EnsureIPv4(domainName string) (string, error) {
 | 
			
		||||
	ipv4, err := net.ResolveIPAddr("ip4", domainName)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", fmt.Errorf("%s: unable to resolve IPv4 address: %s", domainName, err)
 | 
			
		||||
		return "", errors.New(i18n.G("%s: unable to resolve IPv4 address: %s", domainName, err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ipv4 == nil {
 | 
			
		||||
		return "", fmt.Errorf("%s: no IPv4 available", domainName)
 | 
			
		||||
		return "", errors.New(i18n.G("%s: no IPv4 available", domainName))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return ipv4.String(), nil
 | 
			
		||||
@ -33,7 +35,7 @@ func EnsureDomainsResolveSameIPv4(domainName, server string) (string, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if domainIPv4 == "" {
 | 
			
		||||
		return ipv4, fmt.Errorf("cannot resolve ipv4 for %s?", domainName)
 | 
			
		||||
		return ipv4, errors.New(i18n.G("cannot resolve ipv4 for %s?", domainName))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	serverIPv4, err := EnsureIPv4(server)
 | 
			
		||||
@ -42,12 +44,16 @@ func EnsureDomainsResolveSameIPv4(domainName, server string) (string, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if serverIPv4 == "" {
 | 
			
		||||
		return ipv4, fmt.Errorf("cannot resolve ipv4 for %s?", server)
 | 
			
		||||
		return ipv4, errors.New(i18n.G("cannot resolve ipv4 for %s?", server))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if domainIPv4 != serverIPv4 {
 | 
			
		||||
		err := "app domain %s (%s) does not appear to resolve to app server %s (%s)?"
 | 
			
		||||
		return ipv4, fmt.Errorf(err, domainName, domainIPv4, server, serverIPv4)
 | 
			
		||||
		return ipv4, errors.New(
 | 
			
		||||
			i18n.G(
 | 
			
		||||
				"app domain %s (%s) does not appear to resolve to app server %s (%s)?",
 | 
			
		||||
				domainName, domainIPv4, server, serverIPv4,
 | 
			
		||||
			),
 | 
			
		||||
		)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return ipv4, nil
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ func TestEnsureDomainsResolveSameIPv4(t *testing.T) {
 | 
			
		||||
	}{
 | 
			
		||||
		// NOTE(d1): DNS records get checked, so use something that is maintained
 | 
			
		||||
		// within the federation. if you're here because of a failing test, try
 | 
			
		||||
		// `dig +short <app>` to ensure stuff matches first! If flakyness
 | 
			
		||||
		// `dig +short <domain>` to ensure stuff matches first! If flakyness
 | 
			
		||||
		// becomes an issue we can look into mocking
 | 
			
		||||
		{"docs.coopcloud.tech", "swarm-0.coopcloud.tech", true},
 | 
			
		||||
		{"docs.coopcloud.tech", "coopcloud.tech", true},
 | 
			
		||||
@ -43,7 +43,7 @@ func TestEnsureDomainsResolveSameIPv4(t *testing.T) {
 | 
			
		||||
func TestEnsureIpv4(t *testing.T) {
 | 
			
		||||
	// NOTE(d1): DNS records get checked, so use something that is maintained
 | 
			
		||||
	// within the federation. if you're here because of a failing test, try `dig
 | 
			
		||||
	// +short <app>` to ensure stuff matches first! If flakyness becomes an
 | 
			
		||||
	// +short <domain>` to ensure stuff matches first! If flakyness becomes an
 | 
			
		||||
	// issue we can look into mocking
 | 
			
		||||
	domainName := "collabora.ostrom.collective.tools"
 | 
			
		||||
	serverName := "ostrom.collective.tools"
 | 
			
		||||
 | 
			
		||||
@ -2,20 +2,16 @@ package envfile
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bufio"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"os"
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"git.coopcloud.tech/coop-cloud/godotenv"
 | 
			
		||||
	"git.coopcloud.tech/toolshed/godotenv"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// envVarModifiers is a list of env var modifier strings. These are added to
 | 
			
		||||
// env vars as comments and modify their processing by Abra, e.g. determining
 | 
			
		||||
// how long secrets should be.
 | 
			
		||||
var envVarModifiers = []string{"length"}
 | 
			
		||||
 | 
			
		||||
// AppEnv is a map of the values in an apps env config
 | 
			
		||||
type AppEnv = map[string]string
 | 
			
		||||
 | 
			
		||||
@ -31,8 +27,6 @@ func ReadEnv(filePath string) (AppEnv, error) {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("read %s from %s", envVars, filePath)
 | 
			
		||||
 | 
			
		||||
	return envVars, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -45,7 +39,7 @@ func ReadEnvWithModifiers(filePath string) (AppEnv, AppModifiers, error) {
 | 
			
		||||
		return nil, mods, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("read %s from %s", envVars, filePath)
 | 
			
		||||
	log.Debug(i18n.G("read %s from %s", envVars, filePath))
 | 
			
		||||
 | 
			
		||||
	return envVars, mods, nil
 | 
			
		||||
}
 | 
			
		||||
@ -76,16 +70,16 @@ func ReadAbraShEnvVars(abraSh string) (map[string]string, error) {
 | 
			
		||||
			envVarDef := splitVals[len(splitVals)-1]
 | 
			
		||||
			keyVal := strings.Split(envVarDef, "=")
 | 
			
		||||
			if len(keyVal) != 2 {
 | 
			
		||||
				return envVars, fmt.Errorf("couldn't parse %s", txt)
 | 
			
		||||
				return envVars, errors.New(i18n.G("couldn't parse %s", txt))
 | 
			
		||||
			}
 | 
			
		||||
			envVars[keyVal[0]] = keyVal[1]
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(envVars) > 0 {
 | 
			
		||||
		log.Debugf("read %s from %s", envVars, abraSh)
 | 
			
		||||
		log.Debug(i18n.G("read %s from %s", envVars, abraSh))
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Debugf("read 0 env var exports from %s", abraSh)
 | 
			
		||||
		log.Debug(i18n.G("read 0 env var exports from %s", abraSh))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return envVars, nil
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestGetAllFoldersInDirectory(t *testing.T) {
 | 
			
		||||
	folders, err := config.GetAllFoldersInDirectory(testPkg.TestFolder)
 | 
			
		||||
	folders, err := config.GetAllFoldersInDirectory(testPkg.TestDir)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
@ -25,7 +25,7 @@ func TestGetAllFoldersInDirectory(t *testing.T) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestGetAllFilesInDirectory(t *testing.T) {
 | 
			
		||||
	files, err := config.GetAllFilesInDirectory(testPkg.TestFolder)
 | 
			
		||||
	files, err := config.GetAllFilesInDirectory(testPkg.TestDir)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
@ -192,7 +192,7 @@ func TestEnvVarCommentsRemoved(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	envVar, exists = envSample["SECRET_TEST_PASS_TWO_VERSION"]
 | 
			
		||||
	if !exists {
 | 
			
		||||
		t.Fatal("WITH_COMMENT env var should be present in .env.sample")
 | 
			
		||||
		t.Fatal("SECRET_TEST_PASS_TWO_VERSION env var should be present in .env.sample")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if strings.Contains(envVar, "length") {
 | 
			
		||||
 | 
			
		||||
@ -8,16 +8,21 @@ import (
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"github.com/charmbracelet/lipgloss"
 | 
			
		||||
	"github.com/charmbracelet/lipgloss/table"
 | 
			
		||||
	"github.com/docker/go-units"
 | 
			
		||||
	"golang.org/x/term"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/schollz/progressbar/v3"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var BoldStyle = lipgloss.NewStyle().
 | 
			
		||||
	Bold(true)
 | 
			
		||||
 | 
			
		||||
var BoldUnderlineStyle = lipgloss.NewStyle().
 | 
			
		||||
	Bold(true).
 | 
			
		||||
	Underline(true)
 | 
			
		||||
 | 
			
		||||
@ -38,7 +43,7 @@ func RemoveSha(str string) string {
 | 
			
		||||
func HumanDuration(timestamp int64) string {
 | 
			
		||||
	date := time.Unix(timestamp, 0)
 | 
			
		||||
	now := time.Now().UTC()
 | 
			
		||||
	return units.HumanDuration(now.Sub(date)) + " ago"
 | 
			
		||||
	return units.HumanDuration(now.Sub(date)) + i18n.G(" ago")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateTable prepares a table layout for output.
 | 
			
		||||
@ -72,7 +77,7 @@ func CreateTable() (*table.Table, error) {
 | 
			
		||||
func PrintTable(t *table.Table) error {
 | 
			
		||||
	if isAbraCI, ok := os.LookupEnv("ABRA_CI"); ok && isAbraCI == "1" {
 | 
			
		||||
		// NOTE(d1): no width limits for CI testing since we test against outputs
 | 
			
		||||
		log.Debug("detected ABRA_CI=1")
 | 
			
		||||
		log.Debug(i18n.G("detected ABRA_CI=1"))
 | 
			
		||||
		fmt.Println(t)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
@ -95,14 +100,13 @@ func PrintTable(t *table.Table) error {
 | 
			
		||||
 | 
			
		||||
// horizontal is a JoinHorizontal helper function.
 | 
			
		||||
func horizontal(left, mid, right string) string {
 | 
			
		||||
	return lipgloss.JoinHorizontal(lipgloss.Right, left, mid, right)
 | 
			
		||||
	return lipgloss.JoinHorizontal(lipgloss.Top, left, mid, right)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateOverview(header string, rows [][]string) string {
 | 
			
		||||
	var borderStyle = lipgloss.NewStyle().
 | 
			
		||||
		BorderStyle(lipgloss.ThickBorder()).
 | 
			
		||||
		Padding(0, 1, 0, 1).
 | 
			
		||||
		MaxWidth(79).
 | 
			
		||||
		BorderForeground(lipgloss.Color("63"))
 | 
			
		||||
 | 
			
		||||
	var headerStyle = lipgloss.NewStyle().
 | 
			
		||||
@ -110,9 +114,7 @@ func CreateOverview(header string, rows [][]string) string {
 | 
			
		||||
		Bold(true).
 | 
			
		||||
		PaddingBottom(1)
 | 
			
		||||
 | 
			
		||||
	var leftStyle = lipgloss.NewStyle().
 | 
			
		||||
		Bold(true)
 | 
			
		||||
 | 
			
		||||
	var leftStyle = lipgloss.NewStyle()
 | 
			
		||||
	var rightStyle = lipgloss.NewStyle()
 | 
			
		||||
 | 
			
		||||
	var longest int
 | 
			
		||||
@ -124,8 +126,12 @@ func CreateOverview(header string, rows [][]string) string {
 | 
			
		||||
 | 
			
		||||
	var renderedRows []string
 | 
			
		||||
	for _, row := range rows {
 | 
			
		||||
		if len(row) < 2 {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(row) > 2 {
 | 
			
		||||
			panic("CreateOverview: only accepts rows of len == 2")
 | 
			
		||||
			panic(i18n.G("CreateOverview: only accepts rows of len == 2"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		lenOffset := 4
 | 
			
		||||
@ -138,10 +144,21 @@ func CreateOverview(header string, rows [][]string) string {
 | 
			
		||||
			offset = offset + " "
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		renderedRows = append(
 | 
			
		||||
			renderedRows,
 | 
			
		||||
			horizontal(leftStyle.Render(row[0]), offset, rightStyle.Render(row[1])),
 | 
			
		||||
		)
 | 
			
		||||
		rendered := horizontal(leftStyle.Render(row[0]), offset, rightStyle.Render(row[1]))
 | 
			
		||||
 | 
			
		||||
		if row[1] == "---" {
 | 
			
		||||
			rendered = horizontal(
 | 
			
		||||
				leftStyle.
 | 
			
		||||
					Bold(true).
 | 
			
		||||
					Underline(true).
 | 
			
		||||
					PaddingTop(1).
 | 
			
		||||
					Render(row[0]),
 | 
			
		||||
				offset,
 | 
			
		||||
				rightStyle.Render(""),
 | 
			
		||||
			)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		renderedRows = append(renderedRows, rendered)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	body := strings.Builder{}
 | 
			
		||||
@ -201,7 +218,6 @@ func CreateProgressbar(length int, title string) *progressbar.ProgressBar {
 | 
			
		||||
		progressbar.OptionClearOnFinish(),
 | 
			
		||||
		progressbar.OptionSetPredictTime(false),
 | 
			
		||||
		progressbar.OptionShowCount(),
 | 
			
		||||
		progressbar.OptionFullWidth(),
 | 
			
		||||
		progressbar.OptionSetDescription(title),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
@ -219,7 +235,7 @@ func StripTagMeta(image string) string {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if originalImage != image {
 | 
			
		||||
		log.Debugf("stripped %s to %s for parsing", originalImage, image)
 | 
			
		||||
		log.Debug(i18n.G("stripped %s to %s for parsing", originalImage, image))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return image
 | 
			
		||||
@ -242,3 +258,18 @@ func ByteCountSI(b uint64) string {
 | 
			
		||||
 | 
			
		||||
	return fmt.Sprintf("%.1f %cB", float64(b)/float64(div), "kMGTPE"[exp])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoldDirtyDefault ensures a dirty modifier is rendered in bold.
 | 
			
		||||
func BoldDirtyDefault(v string) string {
 | 
			
		||||
	if strings.HasSuffix(v, config.DIRTY_DEFAULT) {
 | 
			
		||||
		vBold := BoldStyle.Render(config.DIRTY_DEFAULT)
 | 
			
		||||
		v = strings.Replace(v, config.DIRTY_DEFAULT, vBold, 1)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return v
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddDirtyMarker adds the dirty marker to a version string.
 | 
			
		||||
func AddDirtyMarker(v string) string {
 | 
			
		||||
	return fmt.Sprintf("%s%s", v, config.DIRTY_DEFAULT)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										11
									
								
								pkg/formatter/formatter_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								pkg/formatter/formatter_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
package formatter
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestBoldDirtyDefault(t *testing.T) {
 | 
			
		||||
	assert.Equal(t, "foo", BoldDirtyDefault("foo"))
 | 
			
		||||
}
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/go-git/go-git/v5"
 | 
			
		||||
)
 | 
			
		||||
@ -18,7 +19,7 @@ func Add(repoPath, path string, dryRun bool) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if dryRun {
 | 
			
		||||
		log.Debugf("dry run: adding %s", path)
 | 
			
		||||
		log.Debug(i18n.G("dry run: adding %s", path))
 | 
			
		||||
	} else {
 | 
			
		||||
		worktree.Add(path)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,10 @@
 | 
			
		||||
package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/go-git/go-git/v5"
 | 
			
		||||
	"github.com/go-git/go-git/v5/plumbing"
 | 
			
		||||
@ -63,7 +65,7 @@ func GetDefaultBranch(repo *git.Repository, repoPath string) (plumbing.Reference
 | 
			
		||||
 | 
			
		||||
	if !HasBranch(repo, "master") {
 | 
			
		||||
		if !HasBranch(repo, "main") {
 | 
			
		||||
			return "", fmt.Errorf("failed to select default branch in %s", repoPath)
 | 
			
		||||
			return "", errors.New(i18n.G("failed to select default branch in %s", repoPath))
 | 
			
		||||
		}
 | 
			
		||||
		branch = "main"
 | 
			
		||||
	}
 | 
			
		||||
@ -90,11 +92,11 @@ func CheckoutDefaultBranch(repo *git.Repository, repoPath string) (plumbing.Refe
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := worktree.Checkout(checkOutOpts); err != nil {
 | 
			
		||||
		log.Debugf("failed to check out %s in %s", branch, repoPath)
 | 
			
		||||
		log.Debug(i18n.G("failed to check out %s in %s", branch, repoPath))
 | 
			
		||||
		return branch, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("successfully checked out %v in %s", branch, repoPath)
 | 
			
		||||
	log.Debug(i18n.G("successfully checked out %v in %s", branch, repoPath))
 | 
			
		||||
 | 
			
		||||
	return branch, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,49 +1,107 @@
 | 
			
		||||
package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"os/signal"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/go-git/go-git/v5"
 | 
			
		||||
	"github.com/go-git/go-git/v5/plumbing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Clone runs a git clone which accounts for different default branches.
 | 
			
		||||
// gitCloneIgnoreErr checks whether we can ignore a git clone error or not.
 | 
			
		||||
func gitCloneIgnoreErr(err error) bool {
 | 
			
		||||
	if strings.Contains(err.Error(), "authentication required") {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if strings.Contains(err.Error(), "remote repository is empty") {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Clone runs a git clone which accounts for different default branches. This
 | 
			
		||||
// function respects Ctrl+C (SIGINT) calls from the user, cancelling the
 | 
			
		||||
// context and deleting the (typically) half-baked clone of the repository.
 | 
			
		||||
// This avoids broken state for future clone / recipe ops.
 | 
			
		||||
func Clone(dir, url string) error {
 | 
			
		||||
	if _, err := os.Stat(dir); os.IsNotExist(err) {
 | 
			
		||||
		log.Debugf("%s does not exist, attempting to git clone from %s", dir, url)
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx, cancelCtx := context.WithCancel(ctx)
 | 
			
		||||
 | 
			
		||||
		_, err := git.PlainClone(dir, false, &git.CloneOptions{
 | 
			
		||||
			URL:           url,
 | 
			
		||||
			Tags:          git.AllTags,
 | 
			
		||||
			ReferenceName: plumbing.ReferenceName("refs/heads/master"),
 | 
			
		||||
			SingleBranch:  true,
 | 
			
		||||
		})
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Debugf("cloning %s default branch failed, attempting from main branch", url)
 | 
			
		||||
	sigIntCh := make(chan os.Signal, 1)
 | 
			
		||||
	signal.Notify(sigIntCh, os.Interrupt)
 | 
			
		||||
	defer func() {
 | 
			
		||||
		signal.Stop(sigIntCh)
 | 
			
		||||
		cancelCtx()
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
			_, err := git.PlainClone(dir, false, &git.CloneOptions{
 | 
			
		||||
	errCh := make(chan error)
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		if _, err := os.Stat(dir); os.IsNotExist(err) {
 | 
			
		||||
			log.Debug(i18n.G("git clone: %s", url))
 | 
			
		||||
 | 
			
		||||
			_, err := git.PlainCloneContext(ctx, dir, false, &git.CloneOptions{
 | 
			
		||||
				URL:           url,
 | 
			
		||||
				Tags:          git.AllTags,
 | 
			
		||||
				ReferenceName: plumbing.ReferenceName("refs/heads/main"),
 | 
			
		||||
				SingleBranch:  true,
 | 
			
		||||
			})
 | 
			
		||||
 | 
			
		||||
			if err != nil && gitCloneIgnoreErr(err) {
 | 
			
		||||
				log.Debug(i18n.G("git clone: %s cloned successfully", dir))
 | 
			
		||||
				errCh <- nil
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if err := ctx.Err(); err != nil {
 | 
			
		||||
				errCh <- errors.New(i18n.G("git clone %s: cancelled due to interrupt", dir))
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				if strings.Contains(err.Error(), "authentication required") {
 | 
			
		||||
					name := filepath.Base(dir)
 | 
			
		||||
					return fmt.Errorf("unable to clone %s, does %s exist?", name, url)
 | 
			
		||||
				log.Debug(i18n.G("git clone: main branch failed, attempting master branch"))
 | 
			
		||||
 | 
			
		||||
				_, err := git.PlainCloneContext(ctx, dir, false, &git.CloneOptions{
 | 
			
		||||
					URL:           url,
 | 
			
		||||
					Tags:          git.AllTags,
 | 
			
		||||
					ReferenceName: plumbing.ReferenceName("refs/heads/master"),
 | 
			
		||||
					SingleBranch:  true,
 | 
			
		||||
				})
 | 
			
		||||
 | 
			
		||||
				if err != nil && gitCloneIgnoreErr(err) {
 | 
			
		||||
					log.Debug(i18n.G("git clone: %s cloned successfully", dir))
 | 
			
		||||
					errCh <- nil
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				return err
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					errCh <- err
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			log.Debug(i18n.G("git clone: %s cloned successfully", dir))
 | 
			
		||||
		} else {
 | 
			
		||||
			log.Debug(i18n.G("git clone: %s already exists", dir))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log.Debugf("%s has been git cloned successfully", dir)
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Debugf("%s already exists", dir)
 | 
			
		||||
		errCh <- nil
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	select {
 | 
			
		||||
	case <-sigIntCh:
 | 
			
		||||
		cancelCtx()
 | 
			
		||||
		fmt.Println() // NOTE(d1): newline after ^C
 | 
			
		||||
		if err := os.RemoveAll(dir); err != nil {
 | 
			
		||||
			return errors.New(i18n.G("unable to clean up git clone of %s: %s", dir, err))
 | 
			
		||||
		}
 | 
			
		||||
		return errors.New(i18n.G("git clone %s: cancelled due to interrupt", dir))
 | 
			
		||||
	case err := <-errCh:
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										48
									
								
								pkg/git/clone_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								pkg/git/clone_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,48 @@
 | 
			
		||||
package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
	"syscall"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/config"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestClone(t *testing.T) {
 | 
			
		||||
	dir := path.Join(config.RECIPES_DIR, "gitea")
 | 
			
		||||
	os.RemoveAll(dir)
 | 
			
		||||
 | 
			
		||||
	gitURL := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, "gitea")
 | 
			
		||||
	if err := Clone(dir, gitURL); err != nil {
 | 
			
		||||
		t.Fatalf("unable to git clone gitea: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
 | 
			
		||||
		t.Fatal("gitea repo was not cloned successfully")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestCancelGitClone(t *testing.T) {
 | 
			
		||||
	dir := path.Join(config.RECIPES_DIR, "gitea")
 | 
			
		||||
	os.RemoveAll(dir)
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		p, err := os.FindProcess(os.Getpid())
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			t.Fatalf("unable to find current process: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		p.Signal(syscall.SIGINT)
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	gitURL := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, "gitea")
 | 
			
		||||
	if err := Clone(dir, gitURL); err == nil {
 | 
			
		||||
		t.Fatal("cloning should have been interrupted")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, err := os.Stat(dir); err != nil && !os.IsNotExist(err) {
 | 
			
		||||
		t.Fatal("recipe repo was not deleted")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -1,8 +1,9 @@
 | 
			
		||||
package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"errors"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"coopcloud.tech/abra/pkg/log"
 | 
			
		||||
	"github.com/go-git/go-git/v5"
 | 
			
		||||
)
 | 
			
		||||
@ -10,7 +11,7 @@ import (
 | 
			
		||||
// Commit runs a git commit
 | 
			
		||||
func Commit(repoPath, commitMessage string, dryRun bool) error {
 | 
			
		||||
	if commitMessage == "" {
 | 
			
		||||
		return fmt.Errorf("no commit message specified?")
 | 
			
		||||
		return errors.New(i18n.G("no commit message specified?"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	commitRepo, err := git.PlainOpen(repoPath)
 | 
			
		||||
@ -38,9 +39,9 @@ func Commit(repoPath, commitMessage string, dryRun bool) error {
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		log.Debug("git changes commited")
 | 
			
		||||
		log.Debug(i18n.G("git changes commited"))
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Debug("dry run: no changes commited")
 | 
			
		||||
		log.Debug(i18n.G("dry run: no changes commited"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
 | 
			
		||||
@ -1,14 +1,16 @@
 | 
			
		||||
package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"os"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// EnsureGitRepo ensures a git repo .git folder exists
 | 
			
		||||
func EnsureGitRepo(repoPath string) error {
 | 
			
		||||
	if _, err := os.Stat(repoPath); os.IsNotExist(err) {
 | 
			
		||||
		return fmt.Errorf("no .git directory in %s?", repoPath)
 | 
			
		||||
		return errors.New(i18n.G("no .git directory in %s?", repoPath))
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user