Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@

### Added

* CircleCI configuration
* CircleCI configuration

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ config = Config()

if not config.is_valid_platform():
sys.exit("Not in a Platform.sh Environment.")

credentials = config.credentials('solr')

formatted = config.formatted_credentials('solr', 'pysolr')
Expand Down Expand Up @@ -60,11 +60,17 @@ config.in_build()

config.in_runtime()

config.on_enterprise()
config.on_dedicated()

config.on_production()
```

> **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 `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.
>
> 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.

### 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.
Expand Down
24 changes: 22 additions & 2 deletions platformshconfig/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,32 @@ def application(self):
)
return self._applicationDef

def on_dedicated(self):
"""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 `on_enterprise` 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 `on_dedicated` as
soon as possible.

Returns:
bool:
True on an Dedicated environment, False otherwise.

"""

return self.on_dedicated()

def on_dedicated(self):
"""Determines if the current environment is a Platform.sh Dedicated environment.

Returns:
bool:
True on an Enterprise environment, False otherwise.
True on an Dedicated environment, False otherwise.

"""

Expand Down Expand Up @@ -414,7 +434,7 @@ def on_production(self):

if not self.is_valid_platform() and not self.in_build():
return False
prod_branch = 'production' if self.on_enterprise() else 'master'
prod_branch = 'production' if self.on_dedicated() else 'master'
return self['BRANCH'] == prod_branch

def register_formatter(self, name, formatter):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

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

VERSION = "2.3.0"
VERSION = "2.3.1"

with open('README.md', 'r', encoding='utf-8') as f:
__readme__ = f.read()
Expand Down
10 changes: 4 additions & 6 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,26 +155,24 @@ def test_upstream_routes_for_app_on_dedicated(self):
self.assertTrue("https://www.master-7rqtwti-gcpjkefjk4wc2.us-2.platformsh.site/" in routes)
self.assertEqual("https://www.{default}/", routes["https://www.master-7rqtwti-gcpjkefjk4wc2.us-2.platformsh.site/"]["original_url"])

def test_onenterprise_returns_true_on_enterprise(self):
def test_ondedicated_returns_true_on_dedicated(self):

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

config = Config(env)

self.assertTrue(config.on_enterprise())
self.assertTrue(config.on_dedicated())

def test_onenterprise_returns_false_on_standard(self):
def test_ondedicated_returns_false_on_standard(self):

env = self.mockEnvironmentDeploy

config = Config(env)

self.assertFalse(config.on_enterprise())
self.assertFalse(config.on_dedicated())

def test_onproduction_on_enterprise_prod_is_true(self):
def test_onproduction_on_dedicated_prod_is_true(self):

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

self.assertTrue(config.on_production())

def test_onproduction_on_enterprise_stg_is_false(self):
def test_onproduction_on_dedicated_stg_is_false(self):

env = self.mockEnvironmentDeploy
env['PLATFORM_MODE'] = 'enterprise'
Expand Down