Skip to content

Commit 00c7dc3

Browse files
author
Nick Anderegg
authored
Merge pull request #29 from platformsh/DEVREL-459
is_enterprise/is_dedicated for Python
2 parents d9b04df + 0238a44 commit 00c7dc3

5 files changed

Lines changed: 92 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,65 @@
1-
# Version History
1+
# Changelog
22

3-
## Unreleased
3+
## [2.3.1] - 2019-11-04
44

5-
* **Improvements**
5+
### Added
66

7-
* **Fixes**
7+
* `CHANGELOG` added.
8+
* `on_dedicated` method that determines if the current environment is a Platform.sh Dedicated environment. Replaces deprecated `on_enterprise` method.
89

9-
* **Misc.**
10+
### Changed
1011

11-
## v0.1.0 (2010-02-14)
12+
* Deprecates `on_enterprise` method - which is for now made to wrap around the added `on_dedicated` method. `on_enterprise` **will be removed** in a future release, so update your projects to use `on_dedicated` instead as soon as possible.
1213

13-
- Initial version.
14+
## [2.3.0] - 2019-09-19
15+
16+
### Added
17+
18+
* `get_primary_route` method for accessing routes marked "primary" in `routes.yaml`.
19+
* `get_upstream_routes` method returns an object map that includes only those routes that point to a valid upstream.
20+
21+
## [2.2.3] - 2019-04-30
22+
23+
### Changed
24+
25+
* Removes guard on `variables()` method.
26+
27+
## [2.2.2] - 2019-04-29
28+
29+
### Changed
30+
31+
* Refactors dynamic property access to be more permissive.
32+
33+
## [2.2.1] - 2019-04-25
34+
35+
### Changed
36+
37+
* More permissive check for relationships.
38+
39+
## [2.2.0] - 2019-04-24
40+
41+
### Added
42+
43+
* `postgresql_dsn` credential formatter; returns a DSN appropriate for PostgreSQL connection.
44+
45+
## [2.1.1] - 2019-03-22
46+
47+
### Changed
48+
49+
* Fixes build issues in `has_relationship()` and `routes()` methods.
50+
51+
## [2.1.0] - 2019-03-22
52+
53+
### Added
54+
55+
* `has_relationship` method to determine if a relationship is defined, and thus has credentials available.
56+
57+
### Changed
58+
59+
* Fixes `routes` method.
60+
61+
## [2.0.4] - 2019-03-06
62+
63+
### Added
64+
65+
* CircleCI configuration

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,17 @@ config.in_build()
6060

6161
config.in_runtime()
6262

63-
config.on_enterprise()
63+
config.on_dedicated()
6464

6565
config.on_production()
6666
```
6767

68+
> **Note:**
69+
>
70+
> 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 `on_dedicated` method to replace `on_enterprise`. For now `on_enterprise` remains available. It now calls the new method and no breaking changes have been introduced.
71+
>
72+
> It is recommended that you update your projects to use `on_dedicated` as soon as possible, as `on_enterprise` will be removed in a future version of this library.
73+
6874
### Read environment variables
6975

7076
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.

platformshconfig/config.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,32 @@ def application(self):
376376
)
377377
return self._applicationDef
378378

379-
def on_enterprise(self):
380-
"""Determines if the current environment is a Platform.sh Enterprise environment.
379+
def on_dedicated(self):
380+
"""Determines if the current environment is a Platform.sh Dedicated environment.
381381
382382
Returns:
383383
bool:
384-
True on an Enterprise environment, False otherwise.
384+
True on an Dedicated environment, False otherwise.
385385
386386
"""
387387

388388
return self.is_valid_platform() and self['MODE'] == 'enterprise'
389389

390+
def on_enterprise(self):
391+
"""Determines if the current environment is a Platform.sh Dedicated environment.
392+
393+
@deprecated
394+
395+
The Platform.sh "Enterprise" will soon be referred to exclusively as "Dedicated". the `on_enterprise` method remains available for now, but it will be removed in a future version of this library.
396+
It is recommended that you update your projects to use `on_dedicated` as soon as possible.
397+
398+
Returns:
399+
bool:
400+
True on a Dedicated environment, False otherwise.
401+
"""
402+
403+
return self.on_dedicated()
404+
390405
def on_production(self):
391406
"""Determines if the current environment is a production environment.
392407
@@ -403,7 +418,7 @@ def on_production(self):
403418

404419
if not self.is_valid_platform() and not self.in_build():
405420
return False
406-
prod_branch = 'production' if self.on_enterprise() else 'master'
421+
prod_branch = 'production' if self.on_dedicated() else 'master'
407422
return self['BRANCH'] == prod_branch
408423

409424
def register_formatter(self, name, formatter):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
cwd = os.path.abspath(os.path.dirname(__file__))
1414

15-
VERSION = "2.3.0"
15+
VERSION = "2.3.1"
1616

1717
with open('README.md', 'r', encoding='utf-8') as f:
1818
__readme__ = f.read()

tests/test_config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,26 @@ def test_upstream_routes_for_app_on_dedicated(self):
155155
self.assertTrue("https://www.master-7rqtwti-gcpjkefjk4wc2.us-2.platformsh.site/" in routes)
156156
self.assertEqual("https://www.{default}/", routes["https://www.master-7rqtwti-gcpjkefjk4wc2.us-2.platformsh.site/"]["original_url"])
157157

158-
def test_onenterprise_returns_true_on_enterprise(self):
158+
def test_ondedicated_returns_true_on_dedicated(self):
159159

160160
env = self.mockEnvironmentDeploy
161161
env['PLATFORM_MODE'] = 'enterprise'
162162

163163
config = Config(env)
164164

165165
self.assertTrue(config.on_enterprise())
166+
self.assertTrue(config.on_dedicated())
166167

167-
def test_onenterprise_returns_false_on_standard(self):
168+
def test_ondedicated_returns_false_on_standard(self):
168169

169170
env = self.mockEnvironmentDeploy
170171

171172
config = Config(env)
172173

173174
self.assertFalse(config.on_enterprise())
175+
self.assertFalse(config.on_dedicated())
174176

175-
def test_onproduction_on_enterprise_prod_is_true(self):
177+
def test_onproduction_on_dedicated_prod_is_true(self):
176178

177179
env = self.mockEnvironmentDeploy
178180
env['PLATFORM_MODE'] = 'enterprise'
@@ -182,7 +184,7 @@ def test_onproduction_on_enterprise_prod_is_true(self):
182184

183185
self.assertTrue(config.on_production())
184186

185-
def test_onproduction_on_enterprise_stg_is_false(self):
187+
def test_onproduction_on_dedicated_stg_is_false(self):
186188

187189
env = self.mockEnvironmentDeploy
188190
env['PLATFORM_MODE'] = 'enterprise'

0 commit comments

Comments
 (0)