From c119c2b7b840a8ac3a232938b16342af95c63d58 Mon Sep 17 00:00:00 2001 From: Brian Hanson Date: Tue, 14 Apr 2020 09:13:46 -0500 Subject: [PATCH 1/2] Parse env vars for username and API key --- src/Volume.php | 5 ++++- src/templates/volumeSettings.html | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Volume.php b/src/Volume.php index a6280ae..f7347ec 100644 --- a/src/Volume.php +++ b/src/Volume.php @@ -265,7 +265,10 @@ protected function createAdapter() */ protected static function client($username, $apiKey) { - $config = ['username' => $username, 'apiKey' => $apiKey]; + $config = [ + 'username' => Craft::parseEnv($username), + 'apiKey' => Craft::parseEnv($apiKey) + ]; $client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, $config); diff --git a/src/templates/volumeSettings.html b/src/templates/volumeSettings.html index 0a89b39..87c84b2 100644 --- a/src/templates/volumeSettings.html +++ b/src/templates/volumeSettings.html @@ -1,19 +1,21 @@ {% import "_includes/forms" as forms %} -{{ forms.textField({ +{{ forms.autosuggestField({ label: "Username"|t('rackspace'), id: 'username', name: 'username', + suggestEnvVars: true, value: volume.username, errors: volume.getErrors('username'), class: 'rackspace-username', required: true }) }} -{{ forms.textField({ +{{ forms.autosuggestField({ label: "API Key"|t('rackspace'), id: 'apiKey', name: 'apiKey', + suggestEnvVars: true, value: volume.apiKey, errors: volume.getErrors('apiKey'), class: 'racskspace-api-key', From a6bd1487364f06835a2258d178de46b56350d70f Mon Sep 17 00:00:00 2001 From: Brian Hanson Date: Tue, 14 Apr 2020 12:32:37 -0500 Subject: [PATCH 2/2] Revert autosuggest fields These ended up messing with the JS on the volume settings page. --- src/templates/volumeSettings.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/templates/volumeSettings.html b/src/templates/volumeSettings.html index 87c84b2..0a89b39 100644 --- a/src/templates/volumeSettings.html +++ b/src/templates/volumeSettings.html @@ -1,21 +1,19 @@ {% import "_includes/forms" as forms %} -{{ forms.autosuggestField({ +{{ forms.textField({ label: "Username"|t('rackspace'), id: 'username', name: 'username', - suggestEnvVars: true, value: volume.username, errors: volume.getErrors('username'), class: 'rackspace-username', required: true }) }} -{{ forms.autosuggestField({ +{{ forms.textField({ label: "API Key"|t('rackspace'), id: 'apiKey', name: 'apiKey', - suggestEnvVars: true, value: volume.apiKey, errors: volume.getErrors('apiKey'), class: 'racskspace-api-key',