Class: Funktor::CLI::Init
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Funktor::CLI::Init
- Includes:
- Thor::Actions
- Defined in:
- lib/funktor/cli/init.rb
Instance Attribute Summary collapse
-
#work_queue_config ⇒ Object
writeonly
Sets the attribute work_queue_config.
-
#work_queue_name ⇒ Object
writeonly
Sets the attribute work_queue_name.
Class Method Summary collapse
Instance Method Summary collapse
- #dockerfile ⇒ Object
- #function_definitions ⇒ Object
- #funktor_config_yml ⇒ Object
- #gemfile ⇒ Object
- #gitignore ⇒ Object
- #iam_permissions ⇒ Object
- #lambda_handlers ⇒ Object
- #package_json ⇒ Object
- #resources ⇒ Object
- #serverless_yml ⇒ Object
- #workers ⇒ Object
Instance Attribute Details
#work_queue_config=(value) ⇒ Object
Sets the attribute work_queue_config
10 11 12 |
# File 'lib/funktor/cli/init.rb', line 10 def work_queue_config=(value) @work_queue_config = value end |
#work_queue_name=(value) ⇒ Object
Sets the attribute work_queue_name
9 10 11 |
# File 'lib/funktor/cli/init.rb', line 9 def work_queue_name=(value) @work_queue_name = value end |
Class Method Details
.destination_root ⇒ Object
29 30 31 |
# File 'lib/funktor/cli/init.rb', line 29 def self.destination_root name end |
.source_root ⇒ Object
25 26 27 |
# File 'lib/funktor/cli/init.rb', line 25 def self.source_root File.join File.dirname(__FILE__), 'templates' end |
Instance Method Details
#dockerfile ⇒ Object
124 125 126 |
# File 'lib/funktor/cli/init.rb', line 124 def dockerfile template "Dockerfile", File.join("Dockerfile") end |
#function_definitions ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/funktor/cli/init.rb', line 100 def function_definitions template File.join("funktor_config", "function_definitions", "incoming_job_handler.yml"), File.join("funktor_config", "function_definitions", "incoming_job_handler.yml") template File.join("funktor_config", "function_definitions", "job_activator.yml"), File.join("funktor_config", "function_definitions", "job_activator.yml") queues.each do |queue_details| @work_queue_name = queue_details.keys.first @work_queue_config = queue_details.values.first template File.join("funktor_config", "function_definitions", "work_queue_handler.yml"), File.join("funktor_config", "function_definitions", "#{work_queue_name.underscore}_queue_handler.yml") end end |
#funktor_config_yml ⇒ Object
33 34 35 36 37 38 |
# File 'lib/funktor/cli/init.rb', line 33 def funktor_config_yml #template "funktor_config.yml", File.join("funktor_config.yml") template File.join("funktor_config", "funktor.yml"), File.join("funktor_config", "funktor.yml") template File.join("funktor_config", "environment.yml"), File.join("funktor_config", "environment.yml") template File.join("funktor_config", "boot.rb"), File.join("funktor_config", "boot.rb") end |
#gemfile ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/funktor/cli/init.rb', line 48 def gemfile if File.exist?("Gemfile") gem_data = File.open("Gemfile").read if gem_data =~ /funktor/ say "funktor is already installed in Gemfile" else run "bundle add funktor" end else template "Gemfile", File.join("Gemfile") end end |
#gitignore ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/funktor/cli/init.rb', line 61 def gitignore # TODO clean this up so that we have a single source of truth for .gitignor stuff if File.exist?(".gitignore") append_to_file ".gitignore", ".serverless" append_to_file ".gitignore", "node_modules" else template "gitignore", File.join(".gitignore") end end |
#iam_permissions ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/funktor/cli/init.rb', line 88 def template File.join("funktor_config", "iam_permissions", "ssm.yml"), File.join("funktor_config", "iam_permissions", "ssm.yml") template File.join("funktor_config", "iam_permissions", "incoming_job_queue.yml"), File.join("funktor_config", "iam_permissions", "incoming_job_queue.yml") queues.each do |queue_details| @work_queue_name = queue_details.keys.first @work_queue_config = queue_details.values.first template File.join("funktor_config", "iam_permissions", "work_queue.yml"), File.join("funktor_config", "iam_permissions", "#{work_queue_name.underscore}_queue.yml") end template File.join("funktor_config", "iam_permissions", "jobs_table.yml"), File.join("funktor_config", "iam_permissions", "jobs_table.yml") template File.join("funktor_config", "iam_permissions", "jobs_table_secondary_index.yml"), File.join("funktor_config", "iam_permissions", "jobs_table_secondary_index.yml") end |
#lambda_handlers ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/funktor/cli/init.rb', line 110 def lambda_handlers template File.join("lambda_event_handlers", "incoming_job_handler.rb"), File.join("lambda_event_handlers", "incoming_job_handler.rb") template File.join("lambda_event_handlers", "job_activator.rb"), File.join("lambda_event_handlers", "job_activator.rb") queues.each do |queue_details| @work_queue_name = queue_details.keys.first @work_queue_config = queue_details.values.first template File.join("lambda_event_handlers", "work_queue_handler.rb"), File.join("lambda_event_handlers", "#{work_queue_name.underscore}_queue_handler.rb") end end |
#package_json ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/funktor/cli/init.rb', line 40 def package_json if File.exist?("package.json") say "package.json already exists" else template "package.json", File.join("package.json") end end |
#resources ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/funktor/cli/init.rb', line 75 def resources template File.join("funktor_config", "resources", "incoming_job_queue.yml"), File.join("funktor_config", "resources", "incoming_job_queue.yml") template File.join("funktor_config", "resources", "incoming_job_queue_user.yml"), File.join("funktor_config", "resources", "incoming_job_queue_user.yml") # TODO - Figure out how to make the dashboard aware of various queues... template File.join("funktor_config", "resources", "cloudwatch_dashboard.yml"), File.join("funktor_config", "resources", "cloudwatch_dashboard.yml") queues.each do |queue_details| @work_queue_name = queue_details.keys.first @work_queue_config = queue_details.values.first template File.join("funktor_config", "resources", "work_queue.yml"), File.join("funktor_config", "resources", "#{work_queue_name.underscore}_queue.yml") end template File.join("funktor_config", "resources", "jobs_table.yml"), File.join("funktor_config", "resources", "jobs_table.yml") end |
#serverless_yml ⇒ Object
120 121 122 |
# File 'lib/funktor/cli/init.rb', line 120 def serverless_yml template "serverless.yml", File.join("serverless.yml") end |
#workers ⇒ Object
71 72 73 |
# File 'lib/funktor/cli/init.rb', line 71 def workers template File.join("app", "workers", "hello_worker.rb"), File.join("app", "workers", "hello_worker.rb") end |