20300: Fix YAML usage.
authorTom Clegg <tom@curii.com>
Thu, 7 Sep 2023 13:37:56 +0000 (09:37 -0400)
committerTom Clegg <tom@curii.com>
Fri, 29 Sep 2023 14:14:14 +0000 (10:14 -0400)
YAML.safe_load_file does not exist until Ruby 3.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

apps/workbench/app/controllers/work_units_controller.rb
apps/workbench/app/views/workflows/_show_definition.html.erb
services/api/app/controllers/database_controller.rb
services/api/script/arvados-git-sync.rb
services/api/script/migrate-gitolite-to-uuid-storage.rb

index 86e3cdd91da779cdb52a12afaf9ca3605007a700..42dd12a4c2f4cf2678e1387710a846d6d2135bd6 100644 (file)
@@ -70,7 +70,7 @@ class WorkUnitsController < ApplicationController
       workflow = Workflow.find? template_uuid
       if workflow.definition
         begin
-          wf_json = ActiveSupport::HashWithIndifferentAccess.new YAML::load(workflow.definition)
+          wf_json = ActiveSupport::HashWithIndifferentAccess.new YAML.load(workflow.definition)
         rescue => e
           logger.error "Error converting definition yaml to json: #{e.message}"
           raise ArgumentError, "Error converting definition yaml to json: #{e.message}"
index f0e01a12ade39e76369edfad83816c0668d77dd3..9aa75ef067e2d860322b6db8c91742fc826f21d1 100644 (file)
@@ -3,7 +3,7 @@
 SPDX-License-Identifier: AGPL-3.0 %>
 
 <%
-  wf_def = ActiveSupport::HashWithIndifferentAccess.new YAML::load(@object.definition) if @object.definition
+  wf_def = ActiveSupport::HashWithIndifferentAccess.new YAML.load(@object.definition) if @object.definition
   wf_def = wf_def[:"$graph"].andand[0] || wf_def if wf_def
 
   items = {}
index 38d406fe333f785c5dbf218c5d5d84a04986e49e..8e61d16fa8686d9ffb2373efae8bc6a502696b3c 100644 (file)
@@ -18,10 +18,10 @@ class DatabaseController < ApplicationController
     user_uuids = User.
       where('email is null or (email not like ? and email not like ?)', '%@example.com', '%.example.com').
       collect(&:uuid)
-    fixture_uuids =
-      YAML::safe_load_file(File.expand_path('../../../test/fixtures/users.yml',
-                                            __FILE__)).
-      values.collect { |u| u['uuid'] }
+    fnm = File.expand_path('../../../test/fixtures/users.yml', __FILE__)
+    fixture_uuids = File.open(fnm) do |f|
+      YAML.safe_load(f, filename: fnm, permitted_classes: [Time]).values.collect { |u| u['uuid'] }
+    end
     unexpected_uuids = user_uuids - fixture_uuids
     if unexpected_uuids.any?
       logger.error("Running in test environment, but non-fixture users exist: " +
index ceebc3518a08d22586a4f6ee2b184f1d90744253..9f8f050c1096e2a030e704f9b51c5820a74e45f4 100755 (executable)
@@ -26,7 +26,9 @@ DEBUG = 1
 # if present, overriding base config parameters as specified
 path = File.absolute_path('../../config/arvados-clients.yml', __FILE__)
 if File.exist?(path) then
-  cp_config = YAML.safe_load_file(path)[ENV['RAILS_ENV']]
+  cp_config = File.open(path) do |f|
+    YAML.safe_load(f, filename: path)[ENV['RAILS_ENV']]
+  end
 else
   puts "Please create a\n #{path}\n file"
   exit 1
index d2b9a0418b71aaf1e132d0b1b22c48d33af18950..98f25ca5378f5d84ea0f19407fd878c75a8a01f2 100755 (executable)
@@ -40,7 +40,9 @@ DEBUG = 1
 # if present, overriding base config parameters as specified
 path = File.dirname(__FILE__) + '/config/arvados-clients.yml'
 if File.exist?(path) then
-  cp_config = YAML.safe_load_file(path)[ENV['RAILS_ENV']]
+  cp_config = File.open(path) do |f|
+    YAML.safe_load(f, filename: path)[ENV['RAILS_ENV']]
+  end
 else
   puts "Please create a\n " + File.dirname(__FILE__) + "/config/arvados-clients.yml\n file"
   exit 1