[ARVADOS] updated: 1.3.0-1243-ga0bf8b7aa
Git user
git at public.curoverse.com
Mon Jul 1 20:35:55 UTC 2019
Summary of changes:
.../app/controllers/application_controller.rb | 8 ++--
apps/workbench/app/views/users/profile.html.erb | 29 ++++++++------
apps/workbench/config/arvados_config.rb | 20 +++++++++-
.../test/integration/user_profile_test.rb | 8 ++--
build/run-library.sh | 14 -------
lib/config/config.default.yml | 16 +++++++-
lib/config/generated_config.go | 16 +++++++-
sdk/go/arvados/config.go | 6 ++-
services/api/config/arvados_config.rb | 46 ++++++++++------------
services/api/config/config.default.yml | 1 -
10 files changed, 97 insertions(+), 67 deletions(-)
delete mode 120000 services/api/config/config.default.yml
via a0bf8b7aafa1e08cd23aa7fdca52f1035d37c907 (commit)
from 9d4fdb054e623e9413775b2c4268d90ceda7d9f3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit a0bf8b7aafa1e08cd23aa7fdca52f1035d37c907
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date: Mon Jul 1 16:35:29 2019 -0400
14812: Migrate UserProfileFormFields
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>
diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index c14f676a2..ccd0abdc3 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -759,11 +759,11 @@ class ApplicationController < ActionController::Base
profile_config = Rails.configuration.Workbench.UserProfileFormFields
if current_user && !profile_config.empty?
current_user_profile = current_user.prefs[:profile]
- profile_config.kind_of?(Array) && profile_config.andand.each do |entry|
- if entry['required']
+ profile_config.each do |k, entry|
+ if entry['Required']
if !current_user_profile ||
- !current_user_profile[entry['key'].to_sym] ||
- current_user_profile[entry['key'].to_sym].empty?
+ !current_user_profile[k] ||
+ current_user_profile[k].empty?
missing_required = true
break
end
diff --git a/apps/workbench/app/views/users/profile.html.erb b/apps/workbench/app/views/users/profile.html.erb
index 5f3a5aa61..6692196da 100644
--- a/apps/workbench/app/views/users/profile.html.erb
+++ b/apps/workbench/app/views/users/profile.html.erb
@@ -3,7 +3,14 @@
SPDX-License-Identifier: AGPL-3.0 %>
<%
- profile_config = Rails.configuration.Workbench.UserProfileFormFields
+ profile_config = []
+ Rails.configuration.Workbench.UserProfileFormFields.each do |k, v|
+ r = v.dup
+ r["Key"] = k
+ profile_config << r
+ end
+ profile_config.sort_by! { |v| v["Position"] }
+
current_user_profile = current_user.prefs[:profile]
show_save_button = false
@@ -61,29 +68,29 @@ SPDX-License-Identifier: AGPL-3.0 %>
</div>
<% profile_config.kind_of?(Array) && profile_config.andand.each do |entry| %>
- <% if entry['key'] %>
+ <% if entry['Key'] %>
<%
show_save_button = true
- label = entry['required'] ? '* ' : ''
- label += entry['form_field_title']
- value = current_user_profile[entry['key'].to_sym] if current_user_profile
+ label = entry['Required'] ? '* ' : ''
+ label += entry['FormFieldTitle']
+ value = current_user_profile[entry['Key'].to_sym] if current_user_profile
%>
<div class="form-group">
- <label for="<%=entry['key']%>"
+ <label for="<%=entry['Key']%>"
class="col-sm-3 control-label"
- style=<%="color:red" if entry['required']&&(!value||value.empty?)%>> <%=label%>
+ style=<%="color:red" if entry['Required']&&(!value||value.empty?)%>> <%=label%>
</label>
- <% if entry['type'] == 'select' %>
+ <% if entry['Type'] == 'select' %>
<div class="col-sm-8">
- <select class="form-control" name="user[prefs][profile][<%=entry['key']%>]">
- <% entry['options'].each do |option| %>
+ <select class="form-control" name="user[prefs][profile][<%=entry['Key']%>]">
+ <% entry['Options'].each do |option, _| %>
<option value="<%=option%>" <%='selected' if option==value%>><%=option%></option>
<% end %>
</select>
</div>
<% else %>
<div class="col-sm-8">
- <input type="text" class="form-control" name="user[prefs][profile][<%=entry['key']%>]" placeholder="<%=entry['form_field_description']%>" value="<%=value%>" ></input>
+ <input type="text" class="form-control" name="user[prefs][profile][<%=entry['Key']%>]" placeholder="<%=entry['FormFieldDescription']%>" value="<%=value%>" ></input>
</div>
<% end %>
</div>
diff --git a/apps/workbench/config/arvados_config.rb b/apps/workbench/config/arvados_config.rb
index d6fdedc10..d571cda09 100644
--- a/apps/workbench/config/arvados_config.rb
+++ b/apps/workbench/config/arvados_config.rb
@@ -107,11 +107,27 @@ arvcfg.declare_config "Workbench.ApplicationMimetypesWithViewIcon", Hash, :appli
arvcfg.declare_config "Workbench.RunningJobLogRecordsToFetch", Integer, :running_job_log_records_to_fetch
arvcfg.declare_config "Workbench.LogViewerMaxBytes", Integer, :log_viewer_max_bytes
arvcfg.declare_config "Workbench.TrustAllContent", Boolean, :trust_all_content
-arvcfg.declare_config "Workbench.UserProfileFormFields", Array, :user_profile_form_fields, ->(cfg, k, v) {
+arvcfg.declare_config "Workbench.UserProfileFormFields", Hash, :user_profile_form_fields, ->(cfg, k, v) {
if !v
v = []
end
- ConfigLoader.set_cfg cfg, "Workbench.UserProfileFormFields", v
+ entries = {}
+ v.each_with_index do |s,i|
+ entries[s["key"]] = {
+ "Type" => s["type"],
+ "FormFieldTitle" => s["form_field_title"],
+ "FormFieldDescription" => s["form_field_description"],
+ "Required" => s["required"],
+ "Position": i
+ }
+ if s["options"]
+ entries[s["key"]]["Options"] = {}
+ s["options"].each do |o|
+ entries[s["key"]]["Options"][o] = {}
+ end
+ end
+ end
+ ConfigLoader.set_cfg cfg, "Workbench.UserProfileFormFields", entries
}
arvcfg.declare_config "Workbench.UserProfileFormMessage", String, :user_profile_form_message
arvcfg.declare_config "Workbench.Theme", String, :arvados_theme
diff --git a/apps/workbench/test/integration/user_profile_test.rb b/apps/workbench/test/integration/user_profile_test.rb
index 9151b2ac4..547ef06a6 100644
--- a/apps/workbench/test/integration/user_profile_test.rb
+++ b/apps/workbench/test/integration/user_profile_test.rb
@@ -100,10 +100,10 @@ class UserProfileTest < ActionDispatch::IntegrationTest
required_field_title = ''
required_field_key = ''
profile_config = Rails.configuration.Workbench.UserProfileFormFields
- profile_config.each do |entry|
- if entry['required']
- required_field_key = entry['key']
- required_field_title = entry['form_field_title']
+ profile_config.each do |k, entry|
+ if entry['Required']
+ required_field_key = k.to_s
+ required_field_title = entry['FormFieldTitle']
break
end
end
diff --git a/build/run-library.sh b/build/run-library.sh
index b0068d211..ea81bbf17 100755
--- a/build/run-library.sh
+++ b/build/run-library.sh
@@ -352,15 +352,6 @@ handle_rails_package() {
if [[ "$pkgname" != "arvados-workbench" ]]; then
exclude_list+=('config/database.yml')
fi
- # for arvados-api-server, we need to dereference the
- # config/config.default.yml file. There is no fpm way to do that, sadly
- # (excluding the existing symlink and then adding the file from its source
- # path doesn't work, sadly.
- if [[ "$pkgname" == "arvados-api-server" ]]; then
- mv /arvados/services/api/config/config.default.yml /arvados/services/api/config/config.default.yml.bu
- cp -p /arvados/lib/config/config.default.yml /arvados/services/api/config/
- exclude_list+=('config/config.default.yml.bu')
- fi
for exclude in ${exclude_list[@]}; do
switches+=(-x "$exclude_root/$exclude")
done
@@ -368,11 +359,6 @@ handle_rails_package() {
-x "$exclude_root/vendor/cache-*" \
-x "$exclude_root/vendor/bundle" "$@" "$license_arg"
rm -rf "$scripts_dir"
- # Undo the deferencing we did above
- if [[ "$pkgname" == "arvados-api-server" ]]; then
- rm -f /arvados/services/api/config/config.default.yml
- mv /arvados/services/api/config/config.default.yml.bu /arvados/services/api/config/config.default.yml
- fi
}
# Build python packages with a virtualenv built-in
diff --git a/lib/config/config.default.yml b/lib/config/config.default.yml
index 6ed502be9..813799827 100644
--- a/lib/config/config.default.yml
+++ b/lib/config/config.default.yml
@@ -667,11 +667,23 @@ Clusters:
SecretKeyBase: ""
RepositoryCache: /var/www/arvados-workbench/current/tmp/git
UserProfileFormFields:
- - SAMPLE:
- - Type: text
+ SAMPLE:
+ exampleTextValue: # key that will be set in properties
+ Type: text #
FormFieldTitle: ""
FormFieldDescription: ""
Required: true
+ Position: 1
+ exampleOptionsValue:
+ Type: select
+ FormFieldTitle: ""
+ FormFieldDescription: ""
+ Required: true
+ Position: 1
+ Options:
+ red: {}
+ blue: {}
+ yellow: {}
UserProfileFormMessage: 'Welcome to Arvados. All <span style="color:red">required fields</span> must be completed before you can proceed.'
# Mimetypes of applications for which the view icon
diff --git a/lib/config/generated_config.go b/lib/config/generated_config.go
index 87bc64e58..ba576ee5b 100644
--- a/lib/config/generated_config.go
+++ b/lib/config/generated_config.go
@@ -673,11 +673,23 @@ Clusters:
SecretKeyBase: ""
RepositoryCache: /var/www/arvados-workbench/current/tmp/git
UserProfileFormFields:
- - SAMPLE:
- - Type: text
+ SAMPLE:
+ exampleTextValue: # key that will be set in properties
+ Type: text #
FormFieldTitle: ""
FormFieldDescription: ""
Required: true
+ Position: 1
+ exampleOptionsValue:
+ Type: select
+ FormFieldTitle: ""
+ FormFieldDescription: ""
+ Required: true
+ Position: 1
+ Options:
+ red: {}
+ blue: {}
+ yellow: {}
UserProfileFormMessage: 'Welcome to Arvados. All <span style="color:red">required fields</span> must be completed before you can proceed.'
# Mimetypes of applications for which the view icon
diff --git a/sdk/go/arvados/config.go b/sdk/go/arvados/config.go
index 799f2e996..2165e87f5 100644
--- a/sdk/go/arvados/config.go
+++ b/sdk/go/arvados/config.go
@@ -96,7 +96,7 @@ type Cluster struct {
Mail struct {
MailchimpAPIKey string
MailchimpListID string
- SendUserSetupNotificationEmail string
+ SendUserSetupNotificationEmail bool
IssueReporterEmailFrom string
IssueReporterEmailTo string
SupportEmailAddress string
@@ -139,7 +139,7 @@ type Cluster struct {
EnablePublicProjectsPage bool
FileViewersConfigURL string
LogViewerMaxBytes ByteSize
- MultiSiteSearch bool
+ MultiSiteSearch string
Repositories bool
RepositoryCache string
RunningJobLogRecordsToFetch int
@@ -155,6 +155,8 @@ type Cluster struct {
FormFieldTitle string
FormFieldDescription string
Required bool
+ Position int
+ Options map[string]struct{}
}
UserProfileFormMessage string
VocabularyURL string
diff --git a/services/api/config/arvados_config.rb b/services/api/config/arvados_config.rb
index 22a8fed58..74f09675b 100644
--- a/services/api/config/arvados_config.rb
+++ b/services/api/config/arvados_config.rb
@@ -17,6 +17,7 @@
# delete application.yml and database.yml.
require 'config_loader'
+require 'open3'
begin
# If secret_token.rb exists here, we need to load it first.
@@ -42,34 +43,29 @@ EOS
WARNED_OMNIAUTH_CONFIG = true
end
-# Load the defaults
-$arvados_config_defaults = ConfigLoader.load "#{::Rails.root.to_s}/config/config.default.yml"
-if $arvados_config_defaults.empty?
- raise "Missing #{::Rails.root.to_s}/config/config.default.yml"
-end
-
-def remove_sample_entries(h)
- return unless h.is_a? Hash
- h.delete("SAMPLE")
- h.each { |k, v| remove_sample_entries(v) }
+# Load the defaults, used by config:migrate and fallback loading
+# legacy application.yml
+Open3.popen2("arvados-server", "config-defaults") do |stdin, stdout, status_thread|
+ confs = YAML.load(stdout, deserialize_symbols: false)
+ clusterID, clusterConfig = confs["Clusters"].first
+ $arvados_config_defaults = clusterConfig
+ $arvados_config_defaults["ClusterID"] = clusterID
end
-remove_sample_entries($arvados_config_defaults)
-
-clusterID, clusterConfig = $arvados_config_defaults["Clusters"].first
-$arvados_config_defaults = clusterConfig
-$arvados_config_defaults["ClusterID"] = clusterID
-
-# Initialize the global config with the defaults
-$arvados_config_global = $arvados_config_defaults.deep_dup
# Load the global config file
-confs = ConfigLoader.load "/etc/arvados/config.yml"
-if !confs.empty?
- clusterID, clusterConfig = confs["Clusters"].first
- $arvados_config_global["ClusterID"] = clusterID
-
- # Copy the cluster config over the defaults
- $arvados_config_global.deep_merge!(clusterConfig)
+Open3.popen2("arvados-server", "config-dump") do |stdin, stdout, status_thread|
+ confs = YAML.load(stdout, deserialize_symbols: false)
+ if confs && !confs.empty?
+ # config-dump merges defaults with user configuration, so every
+ # key should be set.
+ clusterID, clusterConfig = confs["Clusters"].first
+ $arvados_config_global = clusterConfig
+ $arvados_config_global["ClusterID"] = clusterID
+ else
+ # config-dump failed, assume we will be loading from legacy
+ # application.yml, initialize with defaults.
+ $arvados_config_global = $arvados_config_defaults.deep_dup
+ end
end
# Now make a copy
diff --git a/services/api/config/config.default.yml b/services/api/config/config.default.yml
deleted file mode 120000
index f039aa014..000000000
--- a/services/api/config/config.default.yml
+++ /dev/null
@@ -1 +0,0 @@
-../../../lib/config/config.default.yml
\ No newline at end of file
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list