protected function resolveImage(
        InputInterface $input,
        OutputInterface $output
    ) {
        $service = $input->getOption('service');
        if (empty($service)) {
            $service = self::DEFAULT_SERVICE;
        }
        $version = $input->getOption('target-version');
        if (empty($version)) {
            $version = $this->detectLatestDeployedVersion(
                $service,
                $input,
                $output
            );
        }
        $output->writeln("Using service: <info>$service</info>");
        $output->writeln("Using version: <info>$version</info>");
        list($ret, $cmdOutput) = $this->gcloud->exec(
            [
                'app',
                'versions',
                'describe',
                $version,
                "--service=$service",
                "--format=json"
            ]
        );
        if ($ret !== 0) {
            $output->writeln('<error>Failed running `gcloud app versions describe`</error>');
            exit(1);
        }
        $describe = json_decode(implode(PHP_EOL, $cmdOutput), true);
        if (empty($describe)) {
            $output->writeln('<error>Could not decode the result of `gcloud app versions describe`</error>');
            exit(1);
        }
        if ($describe['env'] !== 'flexible') {
            $output->writeln('<error>The deployment must be for App Engine Flex</error>');
            exit(1);
        }
        $image = $describe['deployment']['container']['image'];
        $cloudSqlInstances = '';
        if (array_key_exists('betaSettings', $describe)
            && array_key_exists('cloud_sql_instances', $describe['betaSettings'])) {
            $cloudSqlInstances = $describe['betaSettings']['cloud_sql_instances'];
        }
        return [$image, $cloudSqlInstances];
    }