Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to size 0.5, disk 512 MB when setting resources #1345

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/Command/Resources/ResourcesSetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$ensureHeader();
$new = isset($properties['resources']['profile_size']) ? 'a new' : 'a';
$profileSizes = $containerProfiles[$properties['container_profile']];
$default = isset($properties['resources']['profile_size']) ? $properties['resources']['profile_size'] : null;
$options = [];
foreach ($profileSizes as $profileSize => $sizeInfo) {
// Skip showing sizes that are below the minimum for this service.
Expand All @@ -171,11 +170,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$options[$profileSize] = $description;
}

$defaultProfileSize = '0.5'; // TODO pick this from the API when exposed
if (isset($properties['resources']['profile_size'])) {
$defaultOption = $properties['resources']['profile_size'];
} elseif (isset($options[$defaultProfileSize])) {
$defaultOption = $defaultProfileSize;
} else {
$defaultOption = null;
}

if (!isset($properties['resources']['profile_size']) && empty($options)) {
$this->stdErr->writeln(sprintf('No profile size can be found for the %s <comment>%s</comment> which satisfies its minimum resources.', $type, $name));
$errored = true;
} else {
$profileSize = $questionHelper->chooseAssoc($options, sprintf('Choose %s profile size:', $new), $default, false, false);
$profileSize = $questionHelper->chooseAssoc($options, sprintf('Choose %s profile size:', $new), $defaultOption, false, false);
if (!isset($properties['resources']['profile_size']) || $profileSize != $properties['resources']['profile_size']) {
$updates[$group][$name]['resources']['profile_size'] = $profileSize;
}
Expand Down Expand Up @@ -212,7 +221,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
} elseif ($showCompleteForm || (empty($service->disk) && $input->isInteractive())) {
$ensureHeader();
$default = $service->disk;
$default = $service->disk ?: '512';
$diskSize = $questionHelper->askInput('Enter a disk size in MB', $default, ['512', '1024', '2048'], function ($v) use ($name, $service) {
return $this->validateDiskSize($v, $name, $service);
});
Expand Down
Loading