From 3b59ad7ca0ddc03bd315f46594060d749eb8f0c5 Mon Sep 17 00:00:00 2001 From: chadcarlson Date: Mon, 4 Nov 2019 16:56:13 -0500 Subject: [PATCH] Dedicated not Enterprise. --- CHANGELOG.md | 66 ++++++++++++++++++++++++++++++++++---- README.md | 10 ++++-- platformshconfig/config.py | 24 ++++++++++++-- setup.py | 2 +- tests/test_config.py | 12 +++---- 5 files changed, 96 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e8e120..08f46f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,65 @@ -# Version History +# Changelog -## Unreleased +## [2.3.1] - 2019-11-04 -* **Improvements** +### Added -* **Fixes** +* `CHANGELOG` added. +* `on_dedicated` method that determines if the current environment is a Platform.sh Dedicated environment. Replaces deprecated `on_enterprise` method. -* **Misc.** +### Changed -## v0.1.0 (2010-02-14) +* 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. -- Initial version. \ No newline at end of file +## [2.3.0] - 2019-09-19 + +### Added + +* `get_primary_route` method for accessing routes marked "primary" in `routes.yaml`. +* `get_upstream_routes` method returns an object map that includes only those routes that point to a valid upstream. + +## [2.2.3] - 2019-04-30 + +### Changed + +* Removes guard on `variables()` method. + +## [2.2.2] - 2019-04-29 + +### Changed + +* Refactors dynamic property access to be more permissive. + +## [2.2.1] - 2019-04-25 + +### Changed + +* More permissive check for relationships. + +## [2.2.0] - 2019-04-24 + +### Added + +* `postgresql_dsn` credential formatter; returns a DSN appropriate for PostgreSQL connection. + +## [2.1.1] - 2019-03-22 + +### Changed + +* Fixes build issues in `has_relationship()` and `routes()` methods. + +## [2.1.0] - 2019-03-22 + +### Added + +* `has_relationship` method to determine if a relationship is defined, and thus has credentials available. + +### Changed + +* Fixes `routes` method. + +## [2.0.4] - 2019-03-06 + +### Added + +* CircleCI configuration diff --git a/README.md b/README.md index 869b56c..c8065c8 100644 --- a/README.md +++ b/README.md @@ -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') @@ -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. diff --git a/platformshconfig/config.py b/platformshconfig/config.py index 113b718..12c8dcc 100644 --- a/platformshconfig/config.py +++ b/platformshconfig/config.py @@ -379,9 +379,29 @@ def application(self): def on_enterprise(self): """Determines if the current environment is a Platform.sh Enterprise 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. """ @@ -403,7 +423,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): diff --git a/setup.py b/setup.py index 0a93b5f..ed8b673 100644 --- a/setup.py +++ b/setup.py @@ -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() diff --git a/tests/test_config.py b/tests/test_config.py index 9fe8e4c..32aa38a 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -155,24 +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' @@ -182,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'