Class: Funktor::CLI::Init

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/funktor/cli/init.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#work_queue_config=(value) ⇒ Object

Sets the attribute work_queue_config

Parameters:

  • value

    the value to set the attribute work_queue_config to.



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

Parameters:

  • value

    the value to set the attribute work_queue_name to.



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_rootObject



29
30
31
# File 'lib/funktor/cli/init.rb', line 29

def self.destination_root
  name
end

.source_rootObject



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

#dockerfileObject



124
125
126
# File 'lib/funktor/cli/init.rb', line 124

def dockerfile
  template "Dockerfile", File.join("Dockerfile")
end

#function_definitionsObject



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_ymlObject



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

#gemfileObject



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

#gitignoreObject



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_permissionsObject



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/funktor/cli/init.rb', line 88

def iam_permissions
  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_handlersObject



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_jsonObject



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

#resourcesObject



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_ymlObject



120
121
122
# File 'lib/funktor/cli/init.rb', line 120

def serverless_yml
  template "serverless.yml", File.join("serverless.yml")
end

#workersObject



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