@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a `bin/config set <key> --stdin < value.json` flag to make CLI configuration of complex values easier

Summary:
Depends on D19003. Ref T12677. Ref T13053. For the first time, we're requiring CLI configuration of a complex value (not just a string, integer, bool, etc) to do something fairly standard (send mail).

Users sometimes have very reasonable difficulty figuring out how to `./bin/config set key <some big JSON mess>`. Provide an easy way to handle this and make sure it gets appropriate callouts in the documentation.

(Also, hide the `cluster.mailers` value rather than just locking it, since it may have API keys or SMTP passwords.)

Test Plan: Read documentation, used old and new flags to set configuration.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13053, T12677

Differential Revision: https://secure.phabricator.com/D19004

+87 -13
+32 -12
src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php
··· 6 6 protected function didConstruct() { 7 7 $this 8 8 ->setName('set') 9 - ->setExamples('**set** __key__ __value__') 9 + ->setExamples( 10 + "**set** __key__ __value__\n". 11 + "**set** __key__ --stdin < value.json") 10 12 ->setSynopsis(pht('Set a local configuration value.')) 11 13 ->setArguments( 12 14 array( ··· 17 19 'in local configuration.'), 18 20 ), 19 21 array( 22 + 'name' => 'stdin', 23 + 'help' => pht('Read option value from stdin.'), 24 + ), 25 + array( 20 26 'name' => 'args', 21 27 'wildcard' => true, 22 28 ), ··· 31 37 pht('Specify a configuration key and a value to set it to.')); 32 38 } 33 39 40 + $is_stdin = $args->getArg('stdin'); 41 + 34 42 $key = $argv[0]; 35 43 36 - if (count($argv) == 1) { 37 - throw new PhutilArgumentUsageException( 38 - pht( 39 - "Specify a value to set the key '%s' to.", 40 - $key)); 41 - } 44 + if ($is_stdin) { 45 + if (count($argv) > 1) { 46 + throw new PhutilArgumentUsageException( 47 + pht( 48 + 'Too many arguments: expected only a key when using "--stdin".')); 49 + } 42 50 43 - $value = $argv[1]; 51 + fprintf(STDERR, tsprintf("%s\n", pht('Reading value from stdin...'))); 52 + $value = file_get_contents('php://stdin'); 53 + } else { 54 + if (count($argv) == 1) { 55 + throw new PhutilArgumentUsageException( 56 + pht( 57 + "Specify a value to set the key '%s' to.", 58 + $key)); 59 + } 44 60 45 - if (count($argv) > 2) { 46 - throw new PhutilArgumentUsageException( 47 - pht( 48 - 'Too many arguments: expected one key and one value.')); 61 + if (count($argv) > 2) { 62 + throw new PhutilArgumentUsageException( 63 + pht( 64 + 'Too many arguments: expected one key and one value.')); 65 + } 66 + 67 + $value = $argv[1]; 49 68 } 69 + 50 70 51 71 $options = PhabricatorApplicationConfigOptions::loadAllOptions(); 52 72 if (empty($options[$key])) {
+1 -1
src/applications/config/option/PhabricatorMetaMTAConfigOptions.php
··· 202 202 203 203 return array( 204 204 $this->newOption('cluster.mailers', 'cluster.mailers', null) 205 - ->setLocked(true) 205 + ->setHidden(true) 206 206 ->setDescription($mailers_description), 207 207 $this->newOption( 208 208 'metamta.default-address',
+20
src/docs/user/configuration/configuration_locked.diviner
··· 27 27 phabricator/ $ ./bin/config set <key> <value> 28 28 ``` 29 29 30 + Some configuration options take complicated values which can be difficult 31 + to escape properly for the shell. The easiest way to set these options is 32 + to use the `--stdin` flag. First, put your desired value in a `config.json` 33 + file: 34 + 35 + ```name=config.json, lang=json 36 + { 37 + "duck": "quack", 38 + "cow": "moo" 39 + } 40 + ``` 41 + 42 + Then, set it with `--stdin` like this: 43 + 44 + ``` 45 + phabricator/ $ ./bin/config set <key> --stdin < config.json 46 + ``` 47 + 30 48 A few settings have alternate CLI tools. Refer to the setting page for 31 49 details. 32 50 ··· 98 116 99 117 Continue by: 100 118 119 + - learning more about advanced options with 120 + @{Configuration User Guide: Advanced Configuration}; or 101 121 - returning to the @{article: Configuration Guide}.
+34
src/docs/user/configuration/configuring_outbound_email.diviner
··· 101 101 instructions on configuring it. 102 102 103 103 104 + Setting Complex Configuration 105 + ============================= 106 + 107 + Mailers can not be edited from the web UI. If mailers could be edited from 108 + the web UI, it would give an attacker who compromised an administrator account 109 + a lot of power: they could redirect mail to a server they control and then 110 + intercept mail for any other account, including password reset mail. 111 + 112 + For more information about locked configuration options, see 113 + @{article:Configuration Guide: Locked and Hidden Configuration}. 114 + 115 + Setting `cluster.mailers` from the command line using `bin/config set` can be 116 + tricky because of shell escaping. The easiest way to do it is to use the 117 + `--stdin` flag. First, put your desired configuration in a file like this: 118 + 119 + ```lang=json, name=mailers.json 120 + [ 121 + { 122 + "key": "test-mailer", 123 + "type": "test" 124 + } 125 + ] 126 + ``` 127 + 128 + Then set the value like this: 129 + 130 + ``` 131 + phabricator/ $ ./bin/config set --stdin < mailers.json 132 + ``` 133 + 134 + For alternatives and more information on configuration, see 135 + @{article:Configuration User Guide: Advanced Configuration} 136 + 137 + 104 138 Mailer: Mailgun 105 139 =============== 106 140