Skip to content

Commit 9951de0

Browse files
authored
Merge pull request #16 from platformsh/dedicated
Dedicated
2 parents 9cb8f00 + 060e9e2 commit 9951de0

4 files changed

Lines changed: 88 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Changelog
2+
3+
## [2.3.1] - 2019-11-04
4+
5+
### Added
6+
7+
* `CHANGELOG` added.
8+
* `onDedicated` method that determines if the current environment is a Platform.sh Dedicated environment. Replaces deprecated `onEnterprise` method.
9+
10+
### Changed
11+
12+
* 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.
13+
14+
## [2.3.0] - 2019-09-19
15+
16+
### Added
17+
18+
* `getPrimaryRoute` method for accessing routes marked "primary" in `routes.yaml`.
19+
* `getUpstreamRoutes` method returns an object map that includes only those routes that point to a valid upstream.
20+
21+
## [2.2.2] - 2019-04-29
22+
23+
### Changed
24+
25+
* Updates `routes` method to use `routesDef` instead of `variablesDef` while checking if routes are defined in a Platform.sh environment.
26+
* Updates `getRoute` method documentation in `README`.
27+
28+
### Removed
29+
30+
* Guard on the `variables` method.
31+
32+
## [2.2.1] - 2019-04-25
33+
34+
### Changed
35+
36+
* Improved the error handling for missing property variables.
37+
38+
## [2.2.0] - 2019-04-24
39+
40+
### Changed
41+
42+
* Route URL addition moved to constructor.
43+
* Switch to more permissive checking of variable availability.
44+
45+
## [2.1.0] - 2019-03-22
46+
47+
### Added
48+
49+
* Adds `hasRelationship` method, which determines if a relationship is defined, and thus has credentials available.

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ $config->inBuild();
6464

6565
$config->inRuntime();
6666

67-
$config->onEnterprise();
67+
$config->onDedicated();
6868

6969
$config->onProduction();
7070
```
7171

72+
> **Note:**
73+
>
74+
> 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.
75+
>
76+
> 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.
77+
7278
### Read environment variables
7379

7480
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
129135
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.
130136

131137
```php
132-
function formatMyService(array $credentials) string
138+
function formatMyService(array $credentials) string
133139
{
134140
return "some string based on $credentials";
135141
}

src/Config.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,20 +390,40 @@ public function application() : array
390390
}
391391

392392
/**
393-
* Determines if the current environment is a Platform.sh Enterprise environment.
393+
* Determines if the current environment is a Platform.sh Dedicated environment.
394394
*
395395
* @return bool
396-
* True on an Enterprise environment, False otherwise.
396+
* True on an Dedicated environment, False otherwise.
397397
*/
398-
public function onEnterprise() : bool
398+
public function onDedicated() : bool
399399
{
400400
return $this->isValidPlatform() && $this->getValue('MODE') == 'enterprise';
401401
}
402402

403+
/**
404+
* Determines if the current environment is a Platform.sh Dedicated environment.
405+
*
406+
* @deprecated
407+
*
408+
* The Platform.sh "Enterprise" will soon be referred to exclusively as
409+
* "Dedicated". the `onEnterprise` method remains available for now, but it
410+
* will be removed in a future version of this library.
411+
*
412+
* It is recommended that you update your projects to use `onDedicated` as
413+
* soon as possible.
414+
*
415+
* @return bool
416+
* True on an Dedicated environment, False otherwise.
417+
*/
418+
public function onEnterprise() : bool
419+
{
420+
return $this->onDedicated();
421+
}
422+
403423
/**
404424
* Determines if the current environment is a production environment.
405425
*
406-
* Note: There may be a few edge cases where this is not entirely correct on Enterprise,
426+
* Note: There may be a few edge cases where this is not entirely correct on Dedicated,
407427
* if the production branch is not named `production`. In that case you'll need to use
408428
* your own logic.
409429
*
@@ -417,7 +437,7 @@ public function onProduction() : bool
417437
return false;
418438
}
419439

420-
$prodBranch = $this->onEnterprise() ? 'production' : 'master';
440+
$prodBranch = $this->onDedicated() ? 'production' : 'master';
421441

422442
return $this->getValue('BRANCH') == $prodBranch;
423443
}

tests/ConfigTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,24 @@ public function test_upstream_routes_for_app_on_dedicated() : void
183183
$this->assertEquals('https://www.{default}/', $routes['https://www.master-7rqtwti-gcpjkefjk4wc2.us-2.platformsh.site/']['original_url']);
184184
}
185185

186-
public function test_onenterprise_returns_true_on_enterprise() : void
186+
public function test_ondedicated_returns_true_on_dedicated() : void
187187
{
188188
$env = $this->mockEnvironmentDeploy;
189189
$env['PLATFORM_MODE'] = 'enterprise';
190190
$config = new Config($env);
191191

192-
$this->assertTrue($config->onEnterprise());
192+
$this->assertTrue($config->onDedicated());
193193
}
194194

195-
public function test_onenterprise_returns_false_on_standard() : void
195+
public function test_ondedicated_returns_false_on_standard() : void
196196
{
197197
$env = $this->mockEnvironmentDeploy;
198198
$config = new Config($env);
199199

200-
$this->assertFalse($config->onEnterprise());
200+
$this->assertFalse($config->onDedicated());
201201
}
202202

203-
public function test_onproduction_on_enterprise_prod_is_true() : void
203+
public function test_onproduction_on_dedicated_prod_is_true() : void
204204
{
205205
$env = $this->mockEnvironmentDeploy;
206206
$env['PLATFORM_MODE'] = 'enterprise';
@@ -210,7 +210,7 @@ public function test_onproduction_on_enterprise_prod_is_true() : void
210210
$this->assertTrue($config->onProduction());
211211
}
212212

213-
public function test_onproduction_on_enterprise_stg_is_false() : void
213+
public function test_onproduction_on_dedicated_stg_is_false() : void
214214
{
215215
$env = $this->mockEnvironmentDeploy;
216216
$env['PLATFORM_MODE'] = 'enterprise';

0 commit comments

Comments
 (0)