File tree Expand file tree Collapse file tree 6 files changed +20
-21
lines changed Expand file tree Collapse file tree 6 files changed +20
-21
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ class ApplyTemplate < Base # rubocop:disable Metrics/ClassLength
43
43
VALIDATIONS = %w[ config templates ] . freeze
44
44
45
45
def call # rubocop:disable Metrics/MethodLength
46
- @template_parser = TemplateParser . new ( config )
46
+ @template_parser = TemplateParser . new ( self )
47
47
@names_to_filenames = config . args . to_h do |name |
48
48
[ name , @template_parser . template_filename ( name ) ]
49
49
end
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ def call
29
29
validations = config . options [ :validations ] . split ( "," )
30
30
ensure_required_options! ( validations )
31
31
32
- doctor_service = DoctorService . new ( config )
32
+ doctor_service = DoctorService . new ( self )
33
33
doctor_service . run_validations ( validations )
34
34
end
35
35
Original file line number Diff line number Diff line change 3
3
class ValidationError < StandardError ; end
4
4
5
5
class DoctorService
6
- attr_reader :config
6
+ extend Forwardable
7
7
8
- def initialize ( config )
9
- @config = config
8
+ def_delegators :@command , :config , :progress
9
+
10
+ def initialize ( command )
11
+ @command = command
10
12
end
11
13
12
14
def run_validations ( validations , silent_if_passing : false ) # rubocop:disable Metrics/MethodLength
@@ -37,7 +39,7 @@ def validate_config
37
39
end
38
40
39
41
def validate_templates
40
- @template_parser = TemplateParser . new ( config )
42
+ @template_parser = TemplateParser . new ( @command )
41
43
filenames = Dir . glob ( "#{ @template_parser . template_dir } /*.yml" )
42
44
templates = @template_parser . parse ( filenames )
43
45
@@ -97,8 +99,4 @@ def warn_deprecated_template_variables
97
99
. join ( "\n " )
98
100
progress . puts ( "\n #{ Shell . color ( "DEPRECATED: #{ message } " , :yellow ) } \n #{ list } \n \n " )
99
101
end
100
-
101
- def progress
102
- $stderr
103
- end
104
102
end
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
- require "forwardable"
4
-
5
3
class MaintenanceMode
6
4
extend Forwardable
7
5
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
class TemplateParser
4
- attr_reader :config , :deprecated_variables
4
+ extend Forwardable
5
5
6
- def initialize ( config )
7
- @config = config
6
+ def_delegators :@command , :config , :cp
7
+
8
+ attr_reader :deprecated_variables
9
+
10
+ def initialize ( command )
11
+ @command = command
8
12
end
9
13
10
14
def template_dir
@@ -69,8 +73,4 @@ def new_variables
69
73
"APP_IMAGE" => "{{APP_IMAGE}}"
70
74
}
71
75
end
72
-
73
- def cp
74
- @cp ||= Controlplane . new ( config )
75
- end
76
76
end
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
require "date"
4
+ require "forwardable"
4
5
require "dotenv/load"
5
6
require "cgi"
6
7
require "json"
@@ -226,12 +227,14 @@ def self.process_option_params(params)
226
227
227
228
Cpflow ::Cli . show_info_header ( config ) if with_info_header
228
229
230
+ command = command_class . new ( config )
231
+
229
232
if validations . any? && ENV . fetch ( "DISABLE_VALIDATIONS" , nil ) != "true"
230
- doctor = DoctorService . new ( config )
233
+ doctor = DoctorService . new ( command )
231
234
doctor . run_validations ( validations , silent_if_passing : true )
232
235
end
233
236
234
- command_class . new ( config ) . call
237
+ command . call
235
238
rescue RuntimeError => e
236
239
::Shell . abort ( e . message )
237
240
end
You can’t perform that action at this time.
0 commit comments