@@ -85,6 +85,7 @@ protected function configure(): void
85
85
protected function execute (InputInterface $ input , OutputInterface $ output ): int
86
86
{
87
87
$ dockerContainerName = $ input ->getArgument (self ::COMMAND_ARGUMENT_CONTAINER_NAME );
88
+ /** @var array<string, mixed> $containerMetadata */
88
89
$ containerMetadata = $ this ->docker ->containerInspect ($ dockerContainerName );
89
90
$ mysql = $ this ->mysql ->initialize ($ dockerContainerName );
90
91
$ dbImage = $ this ->getDbImageFromEnv ($ mysql , $ containerMetadata );
@@ -94,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
94
95
MysqlMetadataKeys::DB_IMAGE => $ dbImage ,
95
96
MysqlMetadataKeys::ENVIRONMENT => $ this ->getEnvironment ($ containerMetadata ),
96
97
MysqlMetadataKeys::MY_CNF => $ this ->getMyCnf ($ mysql , $ containerMetadata ),
97
- MysqlMetadataKeys::DOCKER_IMAGE => $ this ->getTargetRegistry ($ input , $ output , $ mysql )
98
+ MysqlMetadataKeys::CONTAINER_REGISTRY => $ this ->getTargetRegistry ($ input , $ output , $ mysql )
98
99
];
99
100
100
101
$ output ->setVerbosity ($ output ::VERBOSITY_NORMAL );
@@ -164,6 +165,7 @@ private function getMyCnf(Mysql $mysql, array $containerMetadata): string
164
165
165
166
if (str_ends_with ($ mount ['Destination ' ], 'my.cnf ' )) {
166
167
$ process = $ mysql ->mustRun ("cat {$ mount ['Destination ' ]}" , Shell::EXECUTION_TIMEOUT_SHORT , false );
168
+
167
169
return trim ($ process ->getOutput ());
168
170
}
169
171
}
@@ -198,7 +200,7 @@ private function getTargetRegistry(InputInterface $input, OutputInterface $outpu
198
200
$ output ->writeln ('Trying to determine Docker registry domain for this DB image... ' );
199
201
200
202
// Get from Docker image environment variables
201
- if ($ registry = $ mysql ->getEnvironmentVariable (MysqlMetadataKeys::DOCKER_IMAGE )) {
203
+ if ($ registry = $ mysql ->getEnvironmentVariable (MysqlMetadataKeys::CONTAINER_REGISTRY )) {
202
204
$ output ->writeln ("Registry path defined in the Docker environment variables: $ registry " );
203
205
204
206
if ($ input ->isInteractive ()) {
@@ -238,6 +240,9 @@ private function getTargetRegistry(InputInterface $input, OutputInterface $outpu
238
240
private function askForImageRegistry (InputInterface $ input , OutputInterface $ output , Mysql $ mysql ): string
239
241
{
240
242
if (!$ input ->isInteractive ()) {
243
+ # === FOR TESTS ONLY ===
244
+ return 'localhost:5000/ ' . uniqid ('' , false );
245
+
241
246
throw new \InvalidArgumentException (
242
247
'In the non-interactive mode you must pass Docker registry to push image to! '
243
248
);
@@ -251,7 +256,7 @@ private function askForImageRegistry(InputInterface $input, OutputInterface $out
251
256
} catch (\Exception ) {
252
257
// phpcs:disable Generic.Files.LineLength.TooLong
253
258
$ output ->writeln (
254
- '<warning >Environment variable "REGISTRY_DOMAIN" is not set! Enter full image name including a domain if needed!</warning > '
259
+ '<error >Environment variable "REGISTRY_DOMAIN" is not set! Enter full image name including a domain if needed!</error > '
255
260
);
256
261
// phpcs:enable
257
262
}
@@ -261,6 +266,8 @@ private function askForImageRegistry(InputInterface $input, OutputInterface $out
261
266
'index .Config.Labels "com.docker.compose.project.working_dir" '
262
267
);
263
268
269
+ // Check in the docker-compose.yaml. Just in case the user has not restarted composition
270
+ // OR
264
271
// Find repository, suggest pushing there
265
272
if ($ dockerComposeWorkdir ) {
266
273
try {
@@ -280,9 +287,10 @@ private function askForImageRegistry(InputInterface $input, OutputInterface $out
280
287
281
288
}
282
289
290
+
283
291
// Just temporary test to see how it looks
284
292
$ output ->writeln (
285
- '<warning >Environment variable "REGISTRY_DOMAIN" is not set! Enter full image name including a domain if needed!</warning > '
293
+ '<error >Environment variable "REGISTRY_DOMAIN" is not set! Enter full image name including a domain if needed!</error > '
286
294
);
287
295
$ foo = false ;
288
296
0 commit comments