Class: Kubes::CLI::Init
- Defined in:
- lib/kubes/cli/init.rb
Class Method Summary collapse
Instance Method Summary collapse
- #adjust_gitignore ⇒ Object
- #create_base_files ⇒ Object
- #create_dockefile ⇒ Object
- #create_dsl_files ⇒ Object
- #create_yaml_files ⇒ Object
- #message ⇒ Object
Methods included from Logging
Class Method Details
.options ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/kubes/cli/init.rb', line 3 def self. [ [:app, aliases: ["a"], required: true, desc: "Docker repo name. Example: web. Generates .kubes/APP/resources folder"], [:force, aliases: ["y"], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"], [:type, aliases: ["t"], default: "yaml", desc: "Type: dsl or yaml"], [:repo, required: true, desc: "Docker repo name. Example: user/repo. Configures .kubes/config.rb"], [:namespace, aliases: ["n"], desc: "Namespace to use, defaults to APP-ENV. IE: demo-dev"], ] end |
Instance Method Details
#adjust_gitignore ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/kubes/cli/init.rb', line 85 def adjust_gitignore ignores = %w[ .kubes/output .kubes/tmp ].map {|l| "#{l}\n"} # the readlines will have lines with \n so keep consistent for processing if File.exist?(".gitignore") lines = IO.readlines(".gitignore") if lines.detect { |l| l.include?('.kubes/tmp') } return # early else lines += ignores end else lines = ignores end text = lines.join('') IO.write(".gitignore", text) puts "Updated .gitignore" end |
#create_base_files ⇒ Object
64 65 66 67 |
# File 'lib/kubes/cli/init.rb', line 64 def create_base_files set_source("base") directory ".", "." end |
#create_dockefile ⇒ Object
58 59 60 61 62 |
# File 'lib/kubes/cli/init.rb', line 58 def create_dockefile return if File.exist?("Dockerfile") set_source("docker") directory ".", "." end |
#create_dsl_files ⇒ Object
69 70 71 72 73 |
# File 'lib/kubes/cli/init.rb', line 69 def create_dsl_files return unless @options[:type] == "dsl" set_source("dsl") directory ".", ".", end |
#create_yaml_files ⇒ Object
75 76 77 78 79 |
# File 'lib/kubes/cli/init.rb', line 75 def create_yaml_files return if @options[:type] == "dsl" set_source("yaml") directory ".", ".", end |
#message ⇒ Object
81 82 83 |
# File 'lib/kubes/cli/init.rb', line 81 def logger.info "Initialized .kubes folder" end |