fig 0.1.65 → 0.1.67
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +29 -0
- data/bin/fig +1 -1
- data/bin/fig-debug +1 -1
- data/lib/fig.rb +3 -0
- data/lib/fig/{applicationconfiguration.rb → application_configuration.rb} +0 -0
- data/lib/fig/{atexit.rb → at_exit.rb} +0 -0
- data/lib/fig/command.rb +190 -200
- data/lib/fig/command/action.rb +83 -0
- data/lib/fig/command/action/clean.rb +33 -0
- data/lib/fig/command/action/get.rb +48 -0
- data/lib/fig/command/action/help.rb +29 -0
- data/lib/fig/command/action/list_configs.rb +39 -0
- data/lib/fig/command/action/list_dependencies.rb +19 -0
- data/lib/fig/command/action/list_dependencies/all_configs.rb +44 -0
- data/lib/fig/command/action/list_dependencies/default.rb +40 -0
- data/lib/fig/command/action/list_dependencies/tree.rb +40 -0
- data/lib/fig/command/action/list_dependencies/tree_all_configs.rb +40 -0
- data/lib/fig/command/action/list_local.rb +29 -0
- data/lib/fig/command/action/list_remote.rb +33 -0
- data/lib/fig/command/action/list_variables.rb +23 -0
- data/lib/fig/command/action/list_variables/all_configs.rb +61 -0
- data/lib/fig/command/action/list_variables/default.rb +48 -0
- data/lib/fig/command/action/list_variables/tree.rb +20 -0
- data/lib/fig/command/action/list_variables/tree_all_configs.rb +20 -0
- data/lib/fig/command/action/publish.rb +52 -0
- data/lib/fig/command/action/publish_local.rb +29 -0
- data/lib/fig/command/action/role/has_no_sub_action.rb +10 -0
- data/lib/fig/command/action/role/has_sub_action.rb +58 -0
- data/lib/fig/command/action/role/list_all_configs.rb +14 -0
- data/lib/fig/command/action/role/list_base_config.rb +14 -0
- data/lib/fig/command/action/role/list_dependencies_flat.rb +22 -0
- data/lib/fig/command/action/role/list_dependencies_in_a_tree.rb +21 -0
- data/lib/fig/command/action/role/list_variables_in_a_tree.rb +150 -0
- data/lib/fig/command/action/role/list_walking_dependency_tree.rb +90 -0
- data/lib/fig/command/action/role/publish.rb +90 -0
- data/lib/fig/command/action/role/update.rb +46 -0
- data/lib/fig/command/action/run_command_line.rb +45 -0
- data/lib/fig/command/action/run_command_statement.rb +52 -0
- data/lib/fig/command/action/update.rb +17 -0
- data/lib/fig/command/action/update_if_missing.rb +17 -0
- data/lib/fig/command/action/version.rb +27 -0
- data/lib/fig/command/{coveragesupport.rb → coverage_support.rb} +0 -0
- data/lib/fig/command/{optionerror.rb → option_error.rb} +1 -1
- data/lib/fig/command/options.rb +185 -127
- data/lib/fig/command/package_applier.rb +140 -0
- data/lib/fig/command/package_loader.rb +124 -0
- data/lib/fig/{configfileerror.rb → config_file_error.rb} +1 -1
- data/lib/fig/{environmentvariables.rb → environment_variables.rb} +0 -0
- data/lib/fig/{environmentvariables/caseinsensitive.rb → environment_variables/case_insensitive.rb} +1 -1
- data/lib/fig/{environmentvariables/casesensitive.rb → environment_variables/case_sensitive.rb} +1 -1
- data/lib/fig/figrc.rb +3 -3
- data/lib/fig/grammar.treetop +1 -1
- data/lib/fig/{backtrace.rb → include_backtrace.rb} +7 -2
- data/lib/fig/log4r/outputter.rb +1 -1
- data/lib/fig/{log4rconfigerror.rb → log4r_config_error.rb} +1 -1
- data/lib/fig/logging.rb +2 -2
- data/lib/fig/{networkerror.rb → network_error.rb} +1 -1
- data/lib/fig/{nosuchpackageconfigerror.rb → no_such_package_config_error.rb} +2 -2
- data/lib/fig/{notfounderror.rb → not_found_error.rb} +0 -0
- data/lib/fig/{operatingsystem.rb → operating_system.rb} +5 -5
- data/lib/fig/package.rb +3 -3
- data/lib/fig/{packagecache.rb → package_cache.rb} +0 -0
- data/lib/fig/{packagedescriptor.rb → package_descriptor.rb} +1 -1
- data/lib/fig/{packagedescriptorparseerror.rb → package_descriptor_parse_error.rb} +1 -1
- data/lib/fig/{packageparseerror.rb → package_parse_error.rb} +1 -1
- data/lib/fig/parser.rb +4 -4
- data/lib/fig/{parserpackagebuildstate.rb → parser_package_build_state.rb} +1 -1
- data/lib/fig/repository.rb +17 -17
- data/lib/fig/{repositoryerror.rb → repository_error.rb} +1 -1
- data/lib/fig/{environment.rb → runtime_environment.rb} +15 -8
- data/lib/fig/statement/include.rb +1 -1
- data/lib/fig/statement/override.rb +1 -1
- data/lib/fig/{urlaccesserror.rb → url_access_error.rb} +1 -1
- data/lib/fig/{userinputerror.rb → user_input_error.rb} +0 -0
- data/lib/fig/{workingdirectorymaintainer.rb → working_directory_maintainer.rb} +4 -4
- data/lib/fig/{workingdirectorymetadata.rb → working_directory_metadata.rb} +0 -0
- metadata +88 -54
- data/VERSION +0 -1
- data/lib/fig/command/listing.rb +0 -363
- data/lib/fig/command/packageload.rb +0 -236
data/Changes
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
v0.1.67
|
2
|
+
|
3
|
+
Backwards incompatibilities:
|
4
|
+
|
5
|
+
- The --update and --update-if-missing options are always paid attention to.
|
6
|
+
(Hey, you said update; Fig endeavors to comply.) This causes problems where
|
7
|
+
these were previously ignored.
|
8
|
+
|
9
|
+
- If you specify --clean, you'll get an error about the options not
|
10
|
+
agreeing about whether the base package should be loaded.
|
11
|
+
|
12
|
+
- Publishing may fail if you have versionless includes. Workaround: don't
|
13
|
+
use versionless includes or do the update and the publish separately.
|
14
|
+
|
15
|
+
Bug fixes:
|
16
|
+
|
17
|
+
- Updating and using any of the --list-* options would delete any previously
|
18
|
+
retrieved files.
|
19
|
+
|
20
|
+
- More fixes in dealing with symlinks.
|
21
|
+
|
22
|
+
- Better error reporting for failed installations and package version
|
23
|
+
conflicts.
|
24
|
+
|
25
|
+
v0.1.66.beta.2
|
26
|
+
v0.1.66.beta.1
|
27
|
+
|
28
|
+
- Test releases
|
29
|
+
|
1
30
|
v0.1.65
|
2
31
|
|
3
32
|
Bug fixes:
|
data/bin/fig
CHANGED
data/bin/fig-debug
CHANGED
data/lib/fig.rb
ADDED
File without changes
|
File without changes
|
data/lib/fig/command.rb
CHANGED
@@ -2,131 +2,86 @@ require 'rubygems'
|
|
2
2
|
require 'net/ftp'
|
3
3
|
require 'set'
|
4
4
|
|
5
|
-
require 'fig/
|
5
|
+
require 'fig/at_exit'
|
6
|
+
require 'fig/command/action'
|
6
7
|
require 'fig/command/options'
|
7
|
-
require 'fig/
|
8
|
+
require 'fig/command/package_applier'
|
9
|
+
require 'fig/command/package_loader'
|
8
10
|
require 'fig/figrc'
|
9
11
|
require 'fig/logging'
|
10
|
-
require 'fig/
|
12
|
+
require 'fig/operating_system'
|
11
13
|
require 'fig/package'
|
12
14
|
require 'fig/parser'
|
13
15
|
require 'fig/repository'
|
14
|
-
require 'fig/
|
16
|
+
require 'fig/repository_error'
|
17
|
+
require 'fig/runtime_environment'
|
15
18
|
require 'fig/statement/configuration'
|
16
|
-
require 'fig/
|
17
|
-
require 'fig/
|
18
|
-
|
19
|
-
# The following are a break out of parts of this class simply to keep the file
|
20
|
-
# size down.
|
21
|
-
|
22
|
-
# You will need to look in this file for any stuff related to --list-* options.
|
23
|
-
require 'fig/command/listing'
|
24
|
-
|
25
|
-
# You will need to look in this file for any stuff related to loading the
|
26
|
-
# base Package object.
|
27
|
-
require 'fig/command/packageload'
|
19
|
+
require 'fig/user_input_error'
|
20
|
+
require 'fig/working_directory_maintainer'
|
28
21
|
|
29
22
|
module Fig; end
|
30
23
|
|
31
24
|
# Main program
|
32
25
|
class Fig::Command
|
33
|
-
include Fig::Command::Listing
|
34
|
-
include Fig::Command::PackageLoad
|
35
|
-
|
36
|
-
def self.get_version()
|
37
|
-
line = nil
|
38
|
-
|
39
|
-
begin
|
40
|
-
File.open(
|
41
|
-
"#{File.expand_path(File.dirname(__FILE__) + '/../../VERSION')}"
|
42
|
-
) do |file|
|
43
|
-
line = file.gets
|
44
|
-
end
|
45
|
-
rescue
|
46
|
-
$stderr.puts 'Could not retrieve version number. Something has mucked with your Fig install.'
|
47
|
-
|
48
|
-
return nil
|
49
|
-
end
|
50
|
-
|
51
|
-
# Note that we accept anything that contains three decimal numbers
|
52
|
-
# seperated by periods. This allows for versions like
|
53
|
-
# "4.3.2-super-special-version-in-3D".
|
54
|
-
if line !~ %r< \b \d+ [.] \d+ [.] \d+ \b >x
|
55
|
-
$stderr.puts %Q<"#{line}" does not look like a version number. Something has mucked with your Fig install.>
|
56
|
-
|
57
|
-
return nil
|
58
|
-
end
|
59
|
-
|
60
|
-
return line
|
61
|
-
end
|
62
|
-
|
63
26
|
def run_fig(argv)
|
64
27
|
begin
|
65
28
|
@options = Fig::Command::Options.new(argv)
|
66
29
|
rescue Fig::UserInputError => error
|
67
30
|
$stderr.puts error.to_s # Logging isn't set up yet.
|
68
|
-
return
|
31
|
+
return Fig::Command::Action::EXIT_FAILURE
|
69
32
|
end
|
70
33
|
|
71
34
|
if not @options.exit_code.nil?
|
72
35
|
return @options.exit_code
|
73
36
|
end
|
74
|
-
@descriptor = @options.descriptor
|
75
37
|
|
76
|
-
|
77
|
-
|
38
|
+
actions = @options.actions()
|
39
|
+
if actions.empty?
|
40
|
+
$stderr.puts "Nothing to do.\n\n"
|
41
|
+
$stderr.puts %q<Run "fig --help" for a full list of commands.>
|
42
|
+
return Fig::Command::Action::EXIT_FAILURE
|
78
43
|
end
|
79
44
|
|
80
|
-
|
81
|
-
|
45
|
+
actions.each do
|
46
|
+
|action|
|
47
|
+
|
48
|
+
if action.execute_immediately_after_command_line_parse?
|
49
|
+
# Note that the action doesn't get an execution context.
|
50
|
+
return action.execute()
|
51
|
+
end
|
82
52
|
end
|
83
53
|
|
84
|
-
|
54
|
+
Fig::Logging.initialize_pre_configuration(@options.log_level())
|
85
55
|
|
86
|
-
|
87
|
-
|
56
|
+
@descriptor = @options.descriptor
|
57
|
+
check_descriptor_requirement()
|
58
|
+
if actions.any? {|action| not action.allow_both_descriptor_and_file? }
|
88
59
|
ensure_descriptor_and_file_were_not_both_specified()
|
89
|
-
@repository.clean(@descriptor)
|
90
|
-
return 0
|
91
|
-
end
|
92
|
-
|
93
|
-
if handle_pre_parse_list_options()
|
94
|
-
return 0
|
95
60
|
end
|
96
61
|
|
97
|
-
|
98
|
-
|
99
|
-
|
62
|
+
configure()
|
63
|
+
set_up_base_package()
|
64
|
+
|
65
|
+
context = ExecutionContext.new(
|
66
|
+
@base_package,
|
67
|
+
base_config(),
|
68
|
+
@environment,
|
69
|
+
@repository,
|
70
|
+
@operating_system
|
71
|
+
)
|
100
72
|
|
101
|
-
|
73
|
+
actions.each do
|
74
|
+
|action|
|
102
75
|
|
103
|
-
|
76
|
+
action.execution_context = context
|
104
77
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
# Ruby v1.8 emits "nil" for nil, whereas ruby v1.9 emits the empty
|
109
|
-
# string, so, for consistency, we need to ensure that we always emit the
|
110
|
-
# empty string.
|
111
|
-
puts @environment[@options.get()] || ''
|
112
|
-
elsif @options.shell_command
|
113
|
-
@environment.execute_shell(@options.shell_command) do
|
114
|
-
|command| @operating_system.shell_exec command
|
78
|
+
exit_code = action.execute
|
79
|
+
if exit_code != Fig::Command::Action::EXIT_SUCCESS
|
80
|
+
return exit_code
|
115
81
|
end
|
116
|
-
elsif @descriptor
|
117
|
-
@environment.include_config(@base_package, @descriptor, nil)
|
118
|
-
@environment.execute_config(
|
119
|
-
@base_package,
|
120
|
-
@descriptor,
|
121
|
-
@options.command_extra_argv || []
|
122
|
-
) { |cmd| @operating_system.shell_exec cmd }
|
123
|
-
elsif not @repository.updating?
|
124
|
-
$stderr.puts "Nothing to do.\n\n"
|
125
|
-
$stderr.puts %q<Run "fig --help" for a full list of commands.>
|
126
|
-
return 1
|
127
82
|
end
|
128
83
|
|
129
|
-
return
|
84
|
+
return Fig::Command::Action::EXIT_SUCCESS
|
130
85
|
end
|
131
86
|
|
132
87
|
def run_with_exception_handling(argv)
|
@@ -136,31 +91,20 @@ class Fig::Command
|
|
136
91
|
rescue Fig::URLAccessError => error
|
137
92
|
urls = error.urls.join(', ')
|
138
93
|
$stderr.puts "Access to #{urls} in #{error.package}/#{error.version} not allowed."
|
139
|
-
return
|
94
|
+
return Fig::Command::Action::EXIT_FAILURE
|
140
95
|
rescue Fig::UserInputError => error
|
141
96
|
log_error_message(error)
|
142
|
-
return
|
143
|
-
rescue OptionParser::InvalidOption => error
|
144
|
-
$stderr.puts error.to_s
|
145
|
-
$stderr.puts Fig::Command::Options::USAGE
|
146
|
-
return 1
|
147
|
-
rescue Fig::RepositoryError => error
|
148
|
-
log_error_message(error)
|
149
|
-
return 1
|
97
|
+
return Fig::Command::Action::EXIT_FAILURE
|
150
98
|
end
|
151
99
|
end
|
152
100
|
|
153
|
-
def emit_version()
|
154
|
-
version = Fig::Command.get_version()
|
155
|
-
return 1 if version.nil?
|
156
|
-
|
157
|
-
puts File.basename($0) + ' v' + version
|
158
|
-
|
159
|
-
return 0
|
160
|
-
end
|
161
|
-
|
162
101
|
private
|
163
102
|
|
103
|
+
ExecutionContext =
|
104
|
+
Struct.new(
|
105
|
+
:base_package, :base_config, :environment, :repository, :operating_system
|
106
|
+
)
|
107
|
+
|
164
108
|
def derive_remote_url()
|
165
109
|
if remote_operation_necessary?()
|
166
110
|
if ENV['FIG_REMOTE_URL'].nil?
|
@@ -182,9 +126,20 @@ class Fig::Command
|
|
182
126
|
end
|
183
127
|
|
184
128
|
def configure()
|
185
|
-
|
129
|
+
set_up_application_configuration()
|
130
|
+
|
131
|
+
Fig::Logging.initialize_post_configuration(
|
132
|
+
@options.log_config() || @configuration['log configuration'],
|
133
|
+
@options.log_level()
|
134
|
+
)
|
186
135
|
|
136
|
+
@operating_system = Fig::OperatingSystem.new(@options.login?)
|
137
|
+
|
138
|
+
prepare_repository()
|
139
|
+
prepare_environment()
|
140
|
+
end
|
187
141
|
|
142
|
+
def set_up_application_configuration()
|
188
143
|
@configuration = Fig::FigRC.find(
|
189
144
|
@options.figrc(),
|
190
145
|
derive_remote_url(),
|
@@ -193,39 +148,44 @@ class Fig::Command
|
|
193
148
|
@options.no_figrc?
|
194
149
|
)
|
195
150
|
|
196
|
-
|
197
|
-
|
198
|
-
@options.log_level()
|
199
|
-
)
|
151
|
+
return
|
152
|
+
end
|
200
153
|
|
201
|
-
|
154
|
+
def prepare_repository()
|
202
155
|
@repository = Fig::Repository.new(
|
203
156
|
@operating_system,
|
204
157
|
@options.home(),
|
205
158
|
@configuration,
|
206
159
|
nil, # remote_user
|
207
|
-
@options.update?,
|
208
|
-
@options.update_if_missing?,
|
209
160
|
check_include_statements_versions?
|
210
161
|
)
|
211
162
|
|
212
|
-
@
|
213
|
-
|
214
|
-
|
215
|
-
|
163
|
+
case @options.update_packages
|
164
|
+
when :unconditionally
|
165
|
+
@repository.update_unconditionally
|
166
|
+
when :if_missing
|
167
|
+
@repository.update_if_missing
|
216
168
|
end
|
217
169
|
|
218
|
-
|
170
|
+
return
|
219
171
|
end
|
220
172
|
|
221
173
|
def prepare_environment()
|
174
|
+
working_directory_maintainer = Fig::WorkingDirectoryMaintainer.new('.')
|
175
|
+
|
176
|
+
Fig::AtExit.add do
|
177
|
+
working_directory_maintainer.prepare_for_shutdown(
|
178
|
+
@base_package && retrieves_should_happen?
|
179
|
+
)
|
180
|
+
end
|
181
|
+
|
222
182
|
environment_variables = nil
|
223
|
-
if
|
183
|
+
if reset_environment?
|
224
184
|
environment_variables = Fig::OperatingSystem.get_environment_variables({})
|
225
185
|
end
|
226
186
|
|
227
|
-
@environment = Fig::
|
228
|
-
@repository, environment_variables,
|
187
|
+
@environment = Fig::RuntimeEnvironment.new(
|
188
|
+
@repository, environment_variables, working_directory_maintainer
|
229
189
|
)
|
230
190
|
|
231
191
|
Fig::AtExit.add { @environment.check_unused_retrieves() }
|
@@ -233,9 +193,36 @@ class Fig::Command
|
|
233
193
|
return
|
234
194
|
end
|
235
195
|
|
236
|
-
def
|
237
|
-
return !
|
238
|
-
|
196
|
+
def set_up_base_package()
|
197
|
+
return if ! load_base_package?
|
198
|
+
|
199
|
+
# We get these before loading the package so that we detect conflicts
|
200
|
+
# between actions.
|
201
|
+
retrieves_should_happen = retrieves_should_happen?
|
202
|
+
register_base_package = register_base_package?
|
203
|
+
apply_config = apply_config?
|
204
|
+
apply_base_config = apply_config ? apply_base_config? : nil
|
205
|
+
|
206
|
+
package_loader = new_package_loader()
|
207
|
+
if @options.actions.all? {|action| action.base_package_can_come_from_descriptor?}
|
208
|
+
@base_package = package_loader.load_package_object()
|
209
|
+
else
|
210
|
+
@base_package = package_loader.load_package_object_from_file()
|
211
|
+
end
|
212
|
+
|
213
|
+
applier = new_package_applier(package_loader.package_source_description())
|
214
|
+
|
215
|
+
if retrieves_should_happen
|
216
|
+
applier.activate_retrieves()
|
217
|
+
end
|
218
|
+
if register_base_package
|
219
|
+
applier.register_package_with_environment()
|
220
|
+
end
|
221
|
+
if apply_config
|
222
|
+
applier.apply_config_to_environment(! apply_base_config)
|
223
|
+
end
|
224
|
+
|
225
|
+
return
|
239
226
|
end
|
240
227
|
|
241
228
|
def base_config()
|
@@ -244,12 +231,30 @@ class Fig::Command
|
|
244
231
|
Fig::Package::DEFAULT_CONFIG
|
245
232
|
end
|
246
233
|
|
234
|
+
def new_package_loader()
|
235
|
+
return Fig::Command::PackageLoader.new(
|
236
|
+
@configuration,
|
237
|
+
@descriptor,
|
238
|
+
@options.package_definition_file,
|
239
|
+
base_config(),
|
240
|
+
@repository
|
241
|
+
)
|
242
|
+
end
|
243
|
+
|
244
|
+
def new_package_applier(package_source_description)
|
245
|
+
return Fig::Command::PackageApplier.new(
|
246
|
+
@base_package,
|
247
|
+
@environment,
|
248
|
+
@options,
|
249
|
+
@descriptor,
|
250
|
+
base_config(),
|
251
|
+
package_source_description
|
252
|
+
)
|
253
|
+
end
|
254
|
+
|
247
255
|
# If the user has specified a descriptor, than any package.fig or --file
|
248
256
|
# option is ignored. Thus, in order to avoid confusing the user, we make
|
249
257
|
# specifying both an error.
|
250
|
-
#
|
251
|
-
# The one exception to this rule is when we are publishing, which should
|
252
|
-
# already have been invoked by the time this is called.
|
253
258
|
def ensure_descriptor_and_file_were_not_both_specified()
|
254
259
|
file = @options.package_definition_file()
|
255
260
|
|
@@ -267,96 +272,81 @@ class Fig::Command
|
|
267
272
|
return
|
268
273
|
end
|
269
274
|
|
270
|
-
def
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
)
|
275
|
+
def check_descriptor_requirement()
|
276
|
+
@options.actions.each do
|
277
|
+
|action|
|
278
|
+
|
279
|
+
case action.descriptor_requirement()
|
280
|
+
when :required
|
281
|
+
if not @descriptor
|
282
|
+
raise Fig::UserInputError.new(
|
283
|
+
"Need to specify a descriptor for #{action.primary_option()}."
|
284
|
+
)
|
285
|
+
end
|
286
|
+
when :warn
|
287
|
+
if @descriptor
|
288
|
+
Fig::Logging.warn(
|
289
|
+
%Q<Ignored descriptor "#{@descriptor.to_string}".>
|
290
|
+
)
|
291
|
+
end
|
292
|
+
end
|
275
293
|
end
|
276
294
|
|
277
295
|
return
|
278
296
|
end
|
279
297
|
|
280
|
-
def
|
281
|
-
|
282
|
-
raise Fig::UserInputError.new(
|
283
|
-
"Cannot specify a package for #{operation_description}."
|
284
|
-
)
|
285
|
-
end
|
298
|
+
def remote_operation_necessary?()
|
299
|
+
return @options.actions.any? {|action| action.remote_operation_necessary?}
|
286
300
|
end
|
287
301
|
|
288
|
-
def
|
289
|
-
return
|
290
|
-
|
291
|
-
|
302
|
+
def load_base_package?()
|
303
|
+
return should_perform?(
|
304
|
+
@options.actions, %Q<the base package should be loaded>
|
305
|
+
) {|action| action.load_base_package?}
|
292
306
|
end
|
293
307
|
|
294
|
-
def
|
295
|
-
|
308
|
+
def retrieves_should_happen?()
|
309
|
+
return @options.actions.any? {|action| action.retrieves_should_happen?}
|
310
|
+
end
|
296
311
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
if @descriptor.name == '_meta'
|
303
|
-
raise Fig::UserInputError.new(
|
304
|
-
%q<Due to implementation issues, cannot create a package named "_meta".>
|
305
|
-
)
|
306
|
-
end
|
312
|
+
def register_base_package?()
|
313
|
+
return should_perform?(
|
314
|
+
@options.actions, %Q<the base package should be in the starting set of packages>
|
315
|
+
) {|action| action.register_base_package?}
|
316
|
+
end
|
307
317
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
[
|
314
|
-
Fig::Statement::Configuration.new(
|
315
|
-
nil,
|
316
|
-
nil,
|
317
|
-
Fig::Package::DEFAULT_CONFIG,
|
318
|
-
@options.environment_statements()
|
319
|
-
)
|
320
|
-
]
|
321
|
-
elsif not @options.resources().empty? or not @options.archives().empty?
|
322
|
-
raise Fig::UserInputError.new(
|
323
|
-
'--resource/--archive options were specified, but no --set/--append option was given. Will not publish.'
|
324
|
-
)
|
325
|
-
else
|
326
|
-
load_package_object_from_file()
|
327
|
-
if not @base_package.statements.empty?
|
328
|
-
publish_statements = @base_package.statements
|
329
|
-
else
|
330
|
-
$stderr.puts 'Nothing to publish.'
|
331
|
-
return 1
|
332
|
-
end
|
333
|
-
end
|
318
|
+
def apply_config?()
|
319
|
+
return should_perform?(
|
320
|
+
@options.actions, %Q<any config should be applied>
|
321
|
+
) {|action| action.apply_config?}
|
322
|
+
end
|
334
323
|
|
335
|
-
|
324
|
+
def apply_base_config?()
|
325
|
+
actions_wanting_application =
|
326
|
+
@options.actions.select {|action| action.apply_config?}
|
336
327
|
|
337
|
-
|
338
|
-
|
328
|
+
return should_perform?(
|
329
|
+
actions_wanting_application, %Q<the base config should be applied>
|
330
|
+
) {|action| action.apply_base_config?}
|
331
|
+
end
|
339
332
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
333
|
+
def should_perform?(actions, failure_description, &predicate)
|
334
|
+
yes_actions, no_actions = actions.partition &predicate
|
335
|
+
# Filter out the "don't care" actions".
|
336
|
+
no_actions = no_actions.select { |action| ! predicate.call(action).nil? }
|
344
337
|
|
345
|
-
|
346
|
-
|
347
|
-
return 1
|
348
|
-
else
|
349
|
-
Fig::Logging.info 'Overwriting...'
|
350
|
-
end
|
351
|
-
end
|
352
|
-
end
|
338
|
+
return false if yes_actions.empty?
|
339
|
+
return true if no_actions.empty?
|
353
340
|
|
354
|
-
|
355
|
-
|
356
|
-
|
341
|
+
action_strings = actions.map {|action| action.options.join}
|
342
|
+
action_string = action_strings.join %q<", ">
|
343
|
+
raise Fig::UserInputError.new(
|
344
|
+
%Q<Cannot use "#{action_string}" together because they disagree on whether #{failure_description}.>
|
357
345
|
)
|
346
|
+
end
|
358
347
|
|
359
|
-
|
348
|
+
def reset_environment?()
|
349
|
+
return @options.actions.any? {|action| action.reset_environment?}
|
360
350
|
end
|
361
351
|
|
362
352
|
def log_error_message(error)
|