Skip to content

Commit

Permalink
[improvement] Better listing display of environment var config (#150)
Browse files Browse the repository at this point in the history
* [improvement] Better listing display of environment var config

* Support default fallback
  • Loading branch information
sman591 authored May 20, 2019
1 parent b77fb9b commit 42a9250
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
17 changes: 17 additions & 0 deletions app/views/manage/configs/_config_row.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- secret ||= false # default value if prop not set
- default ||= nil # default value if prop not set
- value = ENV[key] || default

%p
%b= name
 
%small
%code= key
%br
- if value.present?
- if secret
%span.badge.badge-success Set
- else
%pre= value
- else
%span.badge.badge-danger Not set
49 changes: 13 additions & 36 deletions app/views/manage/configs/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
%p.text-muted= t("simple_form.hints.hackathon_config.#{key}").html_safe
- if @config[key] == ''
%p.mb-0
%em
%small
— Not set —
%span.badge.badge-secondary Not set
- else
%pre.mb-0= @config[key]

Expand All @@ -29,40 +27,19 @@
%h6.card-subtitle.mb-2.text-muted
Environment variables are configured on the production server.
%hr
%p
%b AWS S3 Bucket for Resumes:
%pre= ENV['AWS_BUCKET'] || '[No value]'
%p
%b AWS S3 Region:
%pre= ENV['AWS_REGION'] || '[No value]'
%p
%b AWS S3 Access Key ID:
%pre= ENV['AWS_ACCESS_KEY_ID'] || '[No value]'
%p
%b AWS S3 Secret Access Key:
%em= ENV['AWS_SECRET_ACCESS_KEY'].present? ? 'Set' : 'Not set'
= render 'config_row', name: 'AWS S3 Bucket for Resumes', key: 'AWS_BUCKET'
= render 'config_row', name: 'AWS S3 Region', key: 'AWS_REGION'
= render 'config_row', name: 'AWS S3 Region', key: 'AWS_REGION'
= render 'config_row', name: 'AWS S3 Access Key ID', key: 'AWS_ACCESS_KEY_ID'
= render 'config_row', name: 'AWS S3 Secret Access Key', key: 'AWS_SECRET_ACCESS_KEY', secret: true
%hr
%p
%b Domain Name:
%pre= ENV['HM_DOMAIN_NAME'] || '[No value]'
%p
%b Domain Protocol:
%pre= ENV['HM_DOMAIN_PROTOCOL'] || 'https'
= render 'config_row', name: 'Domain Name', key: 'HM_DOMAIN_NAME'
= render 'config_row', name: 'Domain Protocol', key: 'HM_DOMAIN_PROTOCOL', default: 'https'
%hr
%p
%b Sparkpost API Key:
%em= ENV['SPARKPOST_API_KEY'].present? ? 'Set' : 'Not set'
%p
%b Sparkpost Campaign ID:
%pre= ENV['SPARKPOST_CAMPAIGN_ID'] || '[No value]'
= render 'config_row', name: 'Sparkpost API Key', key: 'SPARKPOST_API_KEY', secret: true
= render 'config_row', name: 'Sparkpost Campaign ID', key: 'SPARKPOST_CAMPAIGN_ID'
%hr
%p
%b My MLH Application ID
%pre= ENV['MLH_KEY'] || '[No value]'
%p
%b My MLH Secret
%em= ENV['MLH_KEY'].present? ? 'Set' : 'Not set'
= render 'config_row', name: 'My MLH Application ID', key: 'MLH_KEY'
= render 'config_row', name: 'My MLH Secret', key: 'MLH_SECRET', secret: true
%hr
%p
%b Rollbar Access Token:
%em= ENV['ROLLBAR_ACCESS_TOKEN'].present? ? 'Set' : 'Not set'
= render 'config_row', name: 'Rollbar Access Token', key: 'ROLLBAR_ACCESS_TOKEN', secret: true

0 comments on commit 42a9250

Please sign in to comment.