lib/magellan/cli/resources/worker.rb in magellan-cli-0.4.4 vs lib/magellan/cli/resources/worker.rb in magellan-cli-0.5.0
- old
+ new
@@ -12,12 +12,13 @@
self.resource_dependency = {"stage" => Stage::VERSION_PARAMETER_NAME}
self.hidden_fields = %w[created_at updated_at].map(&:freeze).freeze
self.multiline_fields = %w[migration_command_1 migration_command_2 run_command environment_vars_yaml].map(&:freeze).freeze
self.field_associations = {"stage_version_id" => {name: "stage", resource: "stage~version"} }
- desc "create NAME IMAGE", I18n.t(:create, scope: [:worker, :cmd], resource_name: resource_name)
- method_option :attributes_yaml, aliases: "-A", desc: "path to YAML file which defines attributes"
+ desc "create NAME IMAGE", I18n.t(:create, scope: [:resources, :worker, :cmd], resource_name: resource_name)
+ method_option :attributes_yaml, aliases: "-A", desc: I18n.t(:attributes_yaml, scope: [:resources, :worker, :cmd_create])
+ "path to YAML file which defines attributes"
def create(name, image_name)
s = load_selection!(Stage::VERSION_PARAMETER_NAME)
attrs =
if path = options[:attributes_yaml]
YAML.load_file(path)
@@ -34,11 +35,11 @@
}
post_json("/admin/#{self.resource_key}/new.json", params)
select(name)
end
- desc "update ATTRIBUTES", I18n.t(:update, scope: [:worker, :cmd], resource_name: resource_name)
+ desc "update ATTRIBUTES", I18n.t(:update, scope: [:resources, :worker, :cmd], resource_name: resource_name)
def update(attrs)
if File.readable?(attrs)
attrs = YAML.load_file(attrs)
else
attrs = JSON.parse(attrs)
@@ -50,10 +51,10 @@
parameter_name => attrs
}
put_json("/admin/#{resource_key}/#{w["id"]}/edit.js", params)
end
- desc "prepare_images", I18n.t(:prepare_images, scope: [:worker, :cmd], images_name: Image.resource_name.pluralize, worker_name: Worker.resource_name)
+ desc "prepare_images", I18n.t(:prepare_images, scope: [:resources, :worker, :cmd], images_name: Image.resource_name.pluralize, worker_name: Worker.resource_name)
def prepare_images
s = load_selection!(Worker)
id = s["id"]
r = post_json("/admin/functions~worker/#{id}/simple_method_call.json", {method_name: "prepare_images"})
targets = r["result"].select{|i| i["instance_amount"] > 0 }