DeployMarker.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\NewRelicReporting\Console\Command;
  7. use Symfony\Component\Console\Command\Command;
  8. use Symfony\Component\Console\Input\InputInterface;
  9. use Symfony\Component\Console\Output\OutputInterface;
  10. use Symfony\Component\Console\Input\InputArgument;
  11. use Magento\NewRelicReporting\Model\Apm\DeploymentsFactory;
  12. use Magento\NewRelicReporting\Model\ServiceShellUser;
  13. class DeployMarker extends Command
  14. {
  15. /**
  16. * @var DeploymentsFactory
  17. */
  18. private $deploymentsFactory;
  19. /**
  20. * @var ServiceShellUser
  21. */
  22. private $serviceShellUser;
  23. /**
  24. * Initialize dependencies.
  25. *
  26. * @param DeploymentsFactory $deploymentsFactory
  27. * @param ServiceShellUser $serviceShellUser
  28. * @param null $name
  29. */
  30. public function __construct(
  31. DeploymentsFactory $deploymentsFactory,
  32. ServiceShellUser $serviceShellUser,
  33. $name = null
  34. ) {
  35. $this->deploymentsFactory = $deploymentsFactory;
  36. $this->serviceShellUser = $serviceShellUser;
  37. parent::__construct($name);
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. protected function configure()
  43. {
  44. $this->setName("newrelic:create:deploy-marker");
  45. $this->setDescription("Check the deploy queue for entries and create an appropriate deploy marker.")
  46. ->addArgument(
  47. 'message',
  48. InputArgument::REQUIRED,
  49. 'Deploy Message?'
  50. )
  51. ->addArgument(
  52. 'change_log',
  53. InputArgument::REQUIRED,
  54. 'Change Log?'
  55. )
  56. ->addArgument(
  57. 'user',
  58. InputArgument::OPTIONAL,
  59. 'Deployment User'
  60. );
  61. parent::configure();
  62. }
  63. /**
  64. * {@inheritdoc}
  65. */
  66. protected function execute(InputInterface $input, OutputInterface $output)
  67. {
  68. $this->deploymentsFactory->create()->setDeployment(
  69. $input->getArgument('message'),
  70. $input->getArgument('change_log'),
  71. $this->serviceShellUser->get($input->getArgument('user'))
  72. );
  73. $output->writeln('<info>NewRelic deployment information sent</info>');
  74. }
  75. }