From 7fd8435e644e3f64b11201363bf43f2a5ae8db1f Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Sat, 23 Dec 2023 15:23:24 +0000 Subject: [PATCH] Rename config api.ssh_domain_wildcards to ssh.domain_wildcards --- config-defaults.yaml | 12 ++++++------ config.yaml | 5 +++-- src/Service/Config.php | 9 +++++++-- src/Service/SshConfig.php | 4 ++-- src/Service/SshDiagnostics.php | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/config-defaults.yaml b/config-defaults.yaml index 7cd733f576..2e6f3b3b7a 100644 --- a/config-defaults.yaml +++ b/config-defaults.yaml @@ -198,12 +198,6 @@ api: ## # certifier_url: 'https://auth.example.com' - ## Wildcard domains for SSH configuration. - ## This is also used to detect whether to run diagnostics on an SSH connection error. - ## Can be replaced by a single value using the {application.env_prefix}SSH_DOMAIN_WILDCARD env var. - ## - # ssh_domain_wildcards: ['*.example.com'] - # The maximum lifetime (TTL) of objects in the local cache, in seconds. projects_ttl: 600 environments_ttl: 120 @@ -272,6 +266,12 @@ api: git_push_timeout: 3600 ssh: + ## Wildcard domains for SSH configuration. + ## This is also used to detect whether to run diagnostics on an SSH connection error. + ## Can be replaced by a single value using the {application.env_prefix}SSH_DOMAIN_WILDCARD env var. + ## + # domain_wildcards: ['*.example.com'] + # A file containing SSH host keys to install for the user. # The filename is relative to the CLI root. Note it would need to be built # into the Phar. diff --git a/config.yaml b/config.yaml index 8d47293e4e..ffa9ee8f78 100644 --- a/config.yaml +++ b/config.yaml @@ -49,8 +49,6 @@ api: auth_url: 'https://auth.api.platform.sh' oauth2_client_id: 'platform-cli' - ssh_domain_wildcards: ['*.platform.sh'] - organizations: true centralized_permissions: true user_verification: true @@ -58,6 +56,9 @@ api: vendor_filter: 'platformsh' +ssh: + domain_wildcards: ['*.platform.sh'] + detection: git_remote_name: 'platform' git_domain: 'platform.sh' # matches git.eu-5.platform.sh, etc. diff --git a/src/Service/Config.php b/src/Service/Config.php index e8950a477e..52ba283e75 100644 --- a/src/Service/Config.php +++ b/src/Service/Config.php @@ -385,9 +385,9 @@ private function applyEnvironmentOverrides() } } - // Special case: replace the list api.ssh_domain_wildcards with the value of {PREFIX}SSH_DOMAIN_WILDCARD. + // Special case: replace the list ssh.domain_wildcards with the value of {PREFIX}SSH_DOMAIN_WILDCARD. if (($value = $this->getEnv('SSH_DOMAIN_WILDCARD')) !== false) { - $this->config['api']['ssh_domain_wildcards'] = [$value]; + $this->config['ssh']['domain_wildcards'] = [$value]; } // Special case: {PREFIX}NO_LEGACY_WARNING disables the migration prompt. @@ -640,12 +640,17 @@ private function applyDynamicDefaults() if (!isset($this->config['service']['applications_config_file'])) { $this->config['service']['applications_config_file'] = $this->get('service.project_config_dir') . '/applications.yaml'; } + + // Migrate renamed config keys. if (isset($this->config['api']['add_to_ssh_agent'])) { $this->config['ssh']['add_to_agent'] = $this->config['api']['add_to_ssh_agent']; } if (isset($this->config['api']['auto_load_ssh_cert'])) { $this->config['ssh']['auto_load_cert'] = $this->config['api']['auto_load_ssh_cert']; } + if (isset($this->config['api']['ssh_domain_wildcards'])) { + $this->config['ssh']['domain_wildcards'] = $this->config['api']['ssh_domain_wildcards']; + } } private function applyUrlDefaults() diff --git a/src/Service/SshConfig.php b/src/Service/SshConfig.php index eb23edb785..cba92250c9 100644 --- a/src/Service/SshConfig.php +++ b/src/Service/SshConfig.php @@ -87,7 +87,7 @@ public function configureSessionSsh() $this->fs->remove($legacy); } - $domainWildcards = $this->config->getWithDefault('api.ssh_domain_wildcards', []); + $domainWildcards = $this->config->getWithDefault('ssh.domain_wildcards', []); if (!$domainWildcards) { return false; } @@ -247,7 +247,7 @@ public function addUserSshConfig(QuestionHelper $questionHelper) $filename = $this->getUserSshConfigFilename(); - $wildcards = $this->config->getWithDefault('api.ssh_domain_wildcards', []); + $wildcards = $this->config->getWithDefault('ssh.domain_wildcards', []); if (!$wildcards) { return false; } diff --git a/src/Service/SshDiagnostics.php b/src/Service/SshDiagnostics.php index b8076a5f9a..e1bbd94141 100644 --- a/src/Service/SshDiagnostics.php +++ b/src/Service/SshDiagnostics.php @@ -155,7 +155,7 @@ public function sshHostIsInternal($uri) return false; } // Check against the wildcard list. - foreach ($this->config->getWithDefault('api.ssh_domain_wildcards', []) as $wildcard) { + foreach ($this->config->getWithDefault('ssh.domain_wildcards', []) as $wildcard) { if (\strpos($host, \str_replace('*.', '', $wildcard)) !== false) { return true; }