From 68c73ec84012fde81d20c79671bba2060d7dada9 Mon Sep 17 00:00:00 2001
From: Robin Goodall <rjg21@cam.ac.uk>
Date: Tue, 14 Mar 2023 11:36:47 +0000
Subject: [PATCH] Ignore all config files except examples and allow
 configuratio n.yaml default

---
 .gitignore                           | 11 ++++++-----
 README.md                            |  3 ++-
 api_gateway_credentials-example.json |  5 +++++
 gsuitesync/config/utils.py           |  1 +
 4 files changed, 14 insertions(+), 6 deletions(-)
 create mode 100644 api_gateway_credentials-example.json

diff --git a/.gitignore b/.gitignore
index e0638c0..1710afb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,12 +111,13 @@ venv.bak/
 credentials.json
 
 # API Gateway credentials (if instructions in README are followed)
-api_gateway_credentials.json
-api_gateway_credentials.yaml
-api_gateway_credentials.yml
+*.json
+!api_gateway_credentials-example.json
 
-# Local configuration
-gsuitesync.yaml
+# Potential local configuration files
+*.yaml
+*.yml
+!configuration-example.yaml
 
 .vscode/
 cache/
diff --git a/README.md b/README.md
index f82c9c3..eec41c7 100644
--- a/README.md
+++ b/README.md
@@ -173,7 +173,8 @@ in the domain **subject to the listed scopes**.
 ## Preparing API Gateway credentials
 
 The `api_gateway` section in the configuration file specifies where the
-credentials for accessing API Gateway can be found. These credentials must be
+credentials for accessing API Gateway can be found; see the
+[example file](api_gateway_credentials-example.json). These credentials must be
 supplied as a file in YAML/JSON format with values for the keys `base_url`,
 `client_id` and `client_secret`. The key and secret can be found on the
 [Apigee apps page](https://apigee.google.com/organizations/api-prod-a3dc87f7/apps)
diff --git a/api_gateway_credentials-example.json b/api_gateway_credentials-example.json
new file mode 100644
index 0000000..d923ab9
--- /dev/null
+++ b/api_gateway_credentials-example.json
@@ -0,0 +1,5 @@
+{
+    "client_id": "API Gateway Client ID",
+    "client_secret": "API Gateway Client Secret",
+    "base_url": "https://api.apps.cam.ac.uk/lookup/v1"
+}
\ No newline at end of file
diff --git a/gsuitesync/config/utils.py b/gsuitesync/config/utils.py
index fad7b36..0dedd6b 100644
--- a/gsuitesync/config/utils.py
+++ b/gsuitesync/config/utils.py
@@ -27,6 +27,7 @@ def load_configuration(location=None):
             paths = []
         paths.extend([
             os.path.join(os.getcwd(), 'gsuitesync.yaml'),
+            os.path.join(os.getcwd(), 'configuration.yaml'),
             os.path.expanduser('~/.gsuitesync/configuration.yaml'),
             '/etc/gsuitesync/configuration.yaml'
         ])
-- 
GitLab