Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / lib / tasks / config.rake
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 def diff_hash base, final
6   diffed = {}
7   base.each do |k,v|
8     bk = base[k]
9     fk = final[k]
10     if bk.is_a? Hash
11       d = diff_hash bk, fk
12       if d.length > 0
13         diffed[k] = d
14       end
15     else
16       if bk.to_yaml != fk.to_yaml
17         diffed[k] = fk
18       end
19     end
20   end
21   diffed
22 end
23
24 namespace :config do
25   desc 'Print items that differ between legacy application.yml and system config.yml'
26   task diff: :environment do
27     diffed = diff_hash $arvados_config_global, $arvados_config
28     cfg = { "Clusters" => {}}
29     cfg["Clusters"][$arvados_config["ClusterID"]] = diffed.select {|k,v| k != "ClusterID"}
30     if cfg["Clusters"][$arvados_config["ClusterID"]].empty?
31       puts "No migrations required for /etc/arvados/config.yml"
32     else
33       puts cfg.to_yaml
34     end
35   end
36
37   desc 'Print config.yml after merging with legacy application.yml'
38   task migrate: :environment do
39     diffed = diff_hash $arvados_config_defaults, $arvados_config
40     cfg = { "Clusters" => {}}
41     cfg["Clusters"][$arvados_config["ClusterID"]] = diffed.select {|k,v| k != "ClusterID"}
42     puts cfg.to_yaml
43   end
44
45   desc 'Print configuration as accessed through Rails.configuration'
46   task dump: :environment do
47     combined = $arvados_config.deep_dup
48     combined.update $remaining_config
49     puts combined.to_yaml
50   end
51
52   desc 'Legacy config check task -- it is a noop now'
53   task check: :environment do
54     # This exists so that build/rails-package-scripts/postinst.sh doesn't fail.
55   end
56 end