lib/magellan/cli/resources/worker.rb in magellan-cli-0.2.17 vs lib/magellan/cli/resources/worker.rb in magellan-cli-0.2.18
- old
+ new
@@ -4,17 +4,17 @@
module Magellan
module Cli
module Resources
class Worker < Base
- self.resource_name = "functions~worker"
+ self.resource_key = "functions~worker"
self.resource_dependency = {"stage" => "stage-version"}
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", "create Worker with NAME, IMAGE"
+ desc "create NAME, IMAGE", "Create a new #{resource_name} with NAME and IMAGE"
method_option :attributes_yaml, aliases: "-A", desc: "path to YAML file which defines attributes"
def create(name, image_name)
s = load_selection("stage-version")
attrs =
if path = options[:attributes_yaml]
@@ -28,15 +28,15 @@
"name" => name,
"image_name" => image_name,
# "instance_base_name" => name,
}.update(attrs)
}
- post_json("/admin/#{self.resource_name}/new.json", params)
+ post_json("/admin/#{self.resource_key}/new.json", params)
select(name)
end
- desc "update ATTRIBUTE", "update selected worker with ATTRIBUTE(filename or JSON)"
+ desc "update ATTRIBUTES", "Update the ATTRIBUTES(filename or JSON) of the selected #{resource_name}"
def update(attrs)
if File.readable?(attrs)
attrs = YAML.load_file(attrs)
else
attrs = JSON.parse(attrs)
@@ -45,13 +45,13 @@
self.class.hidden_fields.each do |f| attrs.delete(f) end
self.class.field_associations.keys.each do |f| attrs.delete(f) end
params = {
parameter_name => attrs
}
- put_json("/admin/#{resource_name}/#{w["id"]}/edit.js", params)
+ put_json("/admin/#{resource_key}/#{w["id"]}/edit.js", params)
end
- desc "prepare_images", "prepare worker images"
+ desc "prepare_images", "prepare the #{Image.resource_name.pluralize} for the selected #{Worker.resource_name}"
def prepare_images
s = load_selection("functions_worker")
id = s["id"]
r = post_json("/admin/functions~worker/#{id}/simple_method_call.json", {method_name: "prepare_images"})
Image.new.show_list(r["result"])