Skip to content

Commit

Permalink
Rename config api.ssh_domain_wildcards to ssh.domain_wildcards
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 23, 2023
1 parent ed9cb41 commit 7fd8435
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
12 changes: 6 additions & 6 deletions config-defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ 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
metrics: true

vendor_filter: 'platformsh'

ssh:
domain_wildcards: ['*.platform.sh']

detection:
git_remote_name: 'platform'
git_domain: 'platform.sh' # matches git.eu-5.platform.sh, etc.
Expand Down
9 changes: 7 additions & 2 deletions src/Service/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/Service/SshConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Service/SshDiagnostics.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7fd8435

Please sign in to comment.