Class: Ufo::Init
Class Method Summary collapse
-
.cli_options ⇒ Object
Ugly, this is how I can get the options from to match with this Thor::Group.
Instance Method Summary collapse
- #init_files ⇒ Object
-
#set_destination_root ⇒ Object
for specs.
- #set_source_path ⇒ Object
- #setup_template_repo ⇒ Object
- #upsert_gitignore ⇒ Object
- #user_message ⇒ Object
Methods inherited from Sequence
Class Method Details
.cli_options ⇒ Object
Ugly, this is how I can get the options from to match with this Thor::Group
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ufo/init.rb', line 7 def self. [ [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."], [:image, required: true, desc: "Docker image name without the tag. Example: tongueroo/hi. Configures ufo/settings.yml"], [:app, required: true, desc: "App name. Preferably one word. Used in the generated ufo/task_definitions.rb."], [:launch_type, default: "ec2", desc: "ec2 or fargate."], [:execution_role_arn, desc: "execution role arn used by tasks, required for fargate."], [:template, desc: "Custom template to use."], [:template_mode, desc: "Template mode: replace or additive."], ] end |
Instance Method Details
#init_files ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ufo/init.rb', line 51 def init_files # map variables @app = [:app] @image = [:image] @execution_role_arn_input = get_execution_role_arn_input # copy the files puts "Setting up ufo project..." directory ".", exclude_pattern: /(\.git|templates)/ if @options[:launch_type] == "fargate" copy_file ".ufo/templates/fargate.json.erb", ".ufo/templates/main.json.erb" else copy_file ".ufo/templates/main.json.erb" end end |
#set_destination_root ⇒ Object
for specs
42 43 44 45 46 47 48 49 |
# File 'lib/ufo/init.rb', line 42 def set_destination_root return unless ENV['UFO_ROOT'] dest = ENV['UFO_ROOT'] FileUtils.rm_rf(dest) && FileUtils.mkdir_p(dest) self.destination_root = dest FileUtils.cd(dest) end |
#set_source_path ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ufo/init.rb', line 28 def set_source_path return unless @options[:template] custom_template = "#{ENV['HOME']}/.ufo/templates/#{@options[:template]}" if @options[:template_mode] == "replace" # replace the template entirely override_source_paths(custom_template) else # additive: modify on top of default template default_template = File.("../../template", __FILE__) override_source_paths([custom_template, default_template]) end end |
#setup_template_repo ⇒ Object
22 23 24 25 26 |
# File 'lib/ufo/init.rb', line 22 def setup_template_repo return unless @options[:template]&.include?('/') sync_template_repo end |
#upsert_gitignore ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/ufo/init.rb', line 67 def upsert_gitignore return unless File.exist?(".gitignore") append_to_file ".gitignore", <<-EOL .ufo/output .ufo/data EOL end |
#user_message ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ufo/init.rb', line 75 def puts "Starter ufo files created." puts <<-EOL #{"="*64} Congrats 🎉 You have successfully set up ufo for your project. To deploy to ECS: ufo ship #{@app}-web If you need to customize the ECS task definition to configure things like memory and cpu allocation. You can do this by adjusting the files the .ufo/variables folder. These variables get applied to the .ufo/templates/main.json.erb task definition json that is passed to the ECS register task definition api. Some additional starter example roles for your apps were set up in in .ufo/task_definitions.rb. Be sure to check it out and adjust it for your needs. This allows you to fully customize and control your environment to fit your application's needs. More info: http://ufoships.com EOL end |