From e61bc53b160a9957dbcb63467ef4c5cec04cb0ef Mon Sep 17 00:00:00 2001 From: Carl Johnson Date: Thu, 8 Aug 2019 14:31:16 +0100 Subject: [PATCH] Throw exception when 'root' plugin setting is used by people (#105) --- plugin.yml | 2 -- python/buildkite.py | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugin.yml b/plugin.yml index a54cf7c..ba25f79 100644 --- a/plugin.yml +++ b/plugin.yml @@ -11,8 +11,6 @@ configuration: type: string p4trust: type: string - root: - type: string view: type: string stream: diff --git a/python/buildkite.py b/python/buildkite.py index 8fbbc02..20820c2 100644 --- a/python/buildkite.py +++ b/python/buildkite.py @@ -27,13 +27,17 @@ def get_env(): def get_config(): """Get configuration which will be passed directly to perforce.P4Repo as kwargs""" conf = {} - conf['root'] = os.environ.get('BUILDKITE_PLUGIN_PERFORCE_ROOT') or os.environ.get('BUILDKITE_BUILD_CHECKOUT_PATH') conf['view'] = os.environ.get('BUILDKITE_PLUGIN_PERFORCE_VIEW') or '//... ...' conf['stream'] = os.environ.get('BUILDKITE_PLUGIN_PERFORCE_STREAM') conf['sync'] = os.environ.get('BUILDKITE_PLUGIN_PERFORCE_SYNC') conf['parallel'] = os.environ.get('BUILDKITE_PLUGIN_PERFORCE_PARALLEL') or 0 conf['client_opts'] = os.environ.get('BUILDKITE_PLUGIN_PERFORCE_CLIENT_OPTIONS') + if 'BUILDKITE_PLUGIN_PERFORCE_ROOT' in os.environ and not __LOCAL_RUN__: + raise Exception("Custom P4 root is for use in unit tests only") + conf['root'] = os.environ.get('BUILDKITE_PLUGIN_PERFORCE_ROOT') or os.environ.get('BUILDKITE_BUILD_CHECKOUT_PATH') + + # Coerce view into pairs of [depot client] paths view_parts = conf['view'].split(' ') assert (len(view_parts) % 2) == 0, "Invalid view format"