src/Utils/Flex/FlexExecCommand.php
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];
    }
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];
    }
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 ] ; }
Resolve the image name for the command execution. If the service is not
specified, it uses `default` service. If the version is not specified,
it will use the version of the latest deployment for the service.

@param InputInterface $input
@param OutputInterface $output
@return array An array with two values, the first is the image name and
the second is the Cloud SQL instance names.
Resolve the image name for the command execution . If the service is not specified it uses default service . If the version is not specified it will use the version of the latest deployment for the service .