diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..567f88e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,49 @@ +# Changelog + +## [2.3.1] - 2019-11-04 + +### Added + +* `CHANGELOG` added. +* `onDedicated` method that determines if the current environment is a Platform.sh Dedicated environment. Replaces deprecated `onEnterprise` method. + +### Changed + +* Deprecates `onEnterprise` method - which is for now made to wrap around the added `onDedicated` method. `onEnterprise` **will be removed** in a future release, so update your projects to use `onDedicated` instead as soon as possible. + +## [2.3.0] - 2019-09-19 + +### Added + +* `getPrimaryRoute` method for accessing routes marked "primary" in `routes.yaml`. +* `getUpstreamRoutes` method returns an object map that includes only those routes that point to a valid upstream. + +## [2.2.2] - 2019-04-29 + +### Changed + +* Updates `routes` method to use `routesDef` instead of `variablesDef` while checking if routes are defined in a Platform.sh environment. +* Updates `getRoute` method documentation in `README`. + +### Removed + +* Guard on the `variables` method. + +## [2.2.1] - 2019-04-25 + +### Changed + +* Improved the error handling for missing property variables. + +## [2.2.0] - 2019-04-24 + +### Changed + +* Route URL addition moved to constructor. +* Switch to more permissive checking of variable availability. + +## [2.1.0] - 2019-03-22 + +### Added + +* Adds `hasRelationship` method, which determines if a relationship is defined, and thus has credentials available. diff --git a/README.md b/README.md index 03561dc..16ef2d6 100644 --- a/README.md +++ b/README.md @@ -64,11 +64,17 @@ $config->inBuild(); $config->inRuntime(); -$config->onEnterprise(); +$config->onDedicated(); $config->onProduction(); ``` +> **Note:** +> +> Platform.sh will no longer refer to its [99.99% uptime SLA product](https://platform.sh/solutions/) as "Enterprise", but rather as "Dedicated". Configuration Reader libraries have in turn been updated to include an `onDedicated` method to replace `onEnterprise`. For now `onEnterprise` remains available. It now calls the new method and no breaking changes have been introduced. +> +> It is recommended that you update your projects to use `onDedicated` as soon as possible, as `onEnterprise` will be removed in a future version of this library. + ### Read environment variables The following magic properties return the corresponding environment variable value. See the [Platform.sh documentation](https://docs.platform.sh/development/variables.html) for a description of each. @@ -129,7 +135,7 @@ In some cases the library being used to connect to a service wants its credentia Credential Formatters can be registered on the configuration object, and a few are included out of the box. That allows 3rd party libraries to ship their own formatters that can be easily integrated into the `Config` object to allow easier use. ```php -function formatMyService(array $credentials) string +function formatMyService(array $credentials) string { return "some string based on $credentials"; } diff --git a/src/Config.php b/src/Config.php index 377071e..8fa32ea 100644 --- a/src/Config.php +++ b/src/Config.php @@ -390,20 +390,40 @@ public function application() : array } /** - * Determines if the current environment is a Platform.sh Enterprise environment. + * Determines if the current environment is a Platform.sh Dedicated environment. * * @return bool - * True on an Enterprise environment, False otherwise. + * True on an Dedicated environment, False otherwise. */ - public function onEnterprise() : bool + public function onDedicated() : bool { return $this->isValidPlatform() && $this->getValue('MODE') == 'enterprise'; } + /** + * Determines if the current environment is a Platform.sh Dedicated environment. + * + * @deprecated + * + * The Platform.sh "Enterprise" will soon be referred to exclusively as + * "Dedicated". the `onEnterprise` method remains available for now, but it + * will be removed in a future version of this library. + * + * It is recommended that you update your projects to use `onDedicated` as + * soon as possible. + * + * @return bool + * True on an Dedicated environment, False otherwise. + */ + public function onEnterprise() : bool + { + return $this->onDedicated(); + } + /** * Determines if the current environment is a production environment. * - * Note: There may be a few edge cases where this is not entirely correct on Enterprise, + * Note: There may be a few edge cases where this is not entirely correct on Dedicated, * if the production branch is not named `production`. In that case you'll need to use * your own logic. * @@ -417,7 +437,7 @@ public function onProduction() : bool return false; } - $prodBranch = $this->onEnterprise() ? 'production' : 'master'; + $prodBranch = $this->onDedicated() ? 'production' : 'master'; return $this->getValue('BRANCH') == $prodBranch; } diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 6b861b5..5f35d34 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -183,24 +183,24 @@ public function test_upstream_routes_for_app_on_dedicated() : void $this->assertEquals('https://www.{default}/', $routes['https://www.master-7rqtwti-gcpjkefjk4wc2.us-2.platformsh.site/']['original_url']); } - public function test_onenterprise_returns_true_on_enterprise() : void + public function test_ondedicated_returns_true_on_dedicated() : void { $env = $this->mockEnvironmentDeploy; $env['PLATFORM_MODE'] = 'enterprise'; $config = new Config($env); - $this->assertTrue($config->onEnterprise()); + $this->assertTrue($config->onDedicated()); } - public function test_onenterprise_returns_false_on_standard() : void + public function test_ondedicated_returns_false_on_standard() : void { $env = $this->mockEnvironmentDeploy; $config = new Config($env); - $this->assertFalse($config->onEnterprise()); + $this->assertFalse($config->onDedicated()); } - public function test_onproduction_on_enterprise_prod_is_true() : void + public function test_onproduction_on_dedicated_prod_is_true() : void { $env = $this->mockEnvironmentDeploy; $env['PLATFORM_MODE'] = 'enterprise'; @@ -210,7 +210,7 @@ public function test_onproduction_on_enterprise_prod_is_true() : void $this->assertTrue($config->onProduction()); } - public function test_onproduction_on_enterprise_stg_is_false() : void + public function test_onproduction_on_dedicated_stg_is_false() : void { $env = $this->mockEnvironmentDeploy; $env['PLATFORM_MODE'] = 'enterprise';