From f83d6e635448d5c96be18b4d926cc99ba879bd93 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 14 May 2014 10:34:45 +0200 Subject: use hash for provider service levels We want to access service levels by means of the id stored in the user record. With a hash we don't have to loop through all elements to find the one with a given id and still can use arbitrary strings and do not rely on the order of the array. Also it's the format the webapp is expecting right now. --- provider_base/provider.json | 10 +++++----- puppet/modules/site_webapp/templates/config.yml.erb | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/provider_base/provider.json b/provider_base/provider.json index fa69318b..aa7d0513 100644 --- a/provider_base/provider.json +++ b/provider_base/provider.json @@ -15,12 +15,12 @@ "default_language": "en", "enrollment_policy": "open", "service": { - "levels": [ + "levels": { // bandwidth limit is in Bytes, storage limit is in MB. - {"id": 1, "name": "free", "storage":50}, - {"id": 2, "name": "basic", "storage":1000, "rate": ["US$10", "€10"]}, - {"id": 3, "name": "pro", "storage":10000, "rate": ["US$20", "€20"]} - ], + "1": {"name": "free", "storage":50}, + "2": {"name": "basic", "storage":1000, "rate": ["tba"]}, + "3": {"name": "pro", "storage":10000, "rate": ["tba"]} + }, "default_service_level": 1, "bandwidth_limit": 102400, "allow_free": "= provider.service.levels.select {|l| l['rate'].nil?}.any?", diff --git a/puppet/modules/site_webapp/templates/config.yml.erb b/puppet/modules/site_webapp/templates/config.yml.erb index 6461c5e8..aa8ac6ab 100644 --- a/puppet/modules/site_webapp/templates/config.yml.erb +++ b/puppet/modules/site_webapp/templates/config.yml.erb @@ -1,4 +1,3 @@ -<%- require 'json' -%> <%- cert_options = @webapp['client_certificates'] -%> production: admins: <%= @webapp['admins'].inspect %> @@ -17,4 +16,4 @@ production: unlimited_cert_prefix: "<%= cert_options['unlimited_prefix'] %>" minimum_client_version: "<%= @webapp['client_version']['min'] %>" default_service_level: "<%= @webapp['default_service_level'] %>" - service_levels: <%= @webapp['service_levels'].to_json %> + service_levels: "<%= @webapp['service_levels'].inspect %>" -- cgit v1.2.3