From 4e796fb4a5c80512c21bb1e439431ff89a2c5691 Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Tue, 30 Jun 2020 14:19:00 +0100 Subject: [PATCH] Use the setup API to fetch the plans list in the project:create (create) command --- composer.json | 2 +- composer.lock | 12 ++++++------ src/Command/Project/ProjectCreateCommand.php | 17 ++++++----------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/composer.json b/composer.json index 2f316ee72e..ebf804d2c6 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "guzzlehttp/guzzle": "^5.3", "guzzlehttp/ringphp": "^1.1", "platformsh/console-form": ">=0.0.24 <2.0", - "platformsh/client": ">=0.33.0 <2.0", + "platformsh/client": ">=0.34.0 <2.0", "symfony/console": "^3.0 >=3.2", "symfony/yaml": "^3.0 || ^2.6", "symfony/finder": "^3.0", diff --git a/composer.lock b/composer.lock index 2fdb09b776..5f3aa35faa 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b5d3ce4e6a73d8adc7bf5699e8f3e7f2", + "content-hash": "1f6ca219be8797239470200795344e5f", "packages": [ { "name": "cocur/slugify", @@ -665,16 +665,16 @@ }, { "name": "platformsh/client", - "version": "v0.33.0", + "version": "v0.34.0", "source": { "type": "git", "url": "https://github.com/platformsh/platformsh-client-php.git", - "reference": "0b5efe375fcb1f5c23491b07b879dbab507109d9" + "reference": "d13eb8c58592280da8ac4875173bc621545267c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/0b5efe375fcb1f5c23491b07b879dbab507109d9", - "reference": "0b5efe375fcb1f5c23491b07b879dbab507109d9", + "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/d13eb8c58592280da8ac4875173bc621545267c1", + "reference": "d13eb8c58592280da8ac4875173bc621545267c1", "shasum": "" }, "require": { @@ -704,7 +704,7 @@ } ], "description": "Platform.sh API client", - "time": "2020-05-27T21:11:24+00:00" + "time": "2020-06-30T13:08:39+00:00" }, { "name": "platformsh/console-form", diff --git a/src/Command/Project/ProjectCreateCommand.php b/src/Command/Project/ProjectCreateCommand.php index 912b267107..f552a42526 100644 --- a/src/Command/Project/ProjectCreateCommand.php +++ b/src/Command/Project/ProjectCreateCommand.php @@ -243,16 +243,7 @@ protected function getAvailablePlans($runtime = false) return (array) $this->config()->get('service.available_plans'); } - $plans = []; - foreach ($this->api()->getClient()->getPlans() as $plan) { - if ($plan->hasProperty('price', false)) { - $plans[$plan->name] = sprintf('%s (%s)', $plan->label, $plan->price->__toString()); - } else { - $plans[$plan->name] = $plan->label; - } - } - - return $plans; + return $plans = $this->api()->getClient()->getSetupOptions()->plans; } /** @@ -310,7 +301,11 @@ protected function getFields() 'optionsCallback' => function () { return $this->getAvailablePlans(true); }, - 'default' => in_array('development', $this->getAvailablePlans()) ? 'development' : null, + // @todo ensure the default is based on the dynamic list and works during resolveOptions() + //'default' => 'development', + 'defaultCallback' => function() { + return in_array('development', $this->getAvailablePlans(true)) ? 'development' : null; + }, 'allowOther' => true, ]), 'environments' => new Field('Environments', [