Class: Kubes::CLI::New::Resource

Inherits:
Sequence
  • Object
show all
Defined in:
lib/kubes/cli/new/resource.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#logger

Class Method Details

.optionsObject



5
6
7
8
9
10
11
12
# File 'lib/kubes/cli/new/resource.rb', line 5

def self.options
  [
    [:app, aliases: ["a"], default: "demo", desc: "App name"],
    [:force, aliases: ["y"], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
    [:role, aliases: ["r"], desc: "Role. IE: web, clock, worker, migrate, etc. Defaults to convention: web or shared when not set"],
    [:type, aliases: ["t"], default: "yaml", desc: "Type: dsl or yaml"],
  ]
end

Instance Method Details

#create_resourceObject



93
94
95
# File 'lib/kubes/cli/new/resource.rb', line 93

def create_resource
  template file, ".kubes/resources/#{role}/#{file}"
end

#set_template_sourceObject



84
85
86
87
88
89
90
91
# File 'lib/kubes/cli/new/resource.rb', line 84

def set_template_source
  path = File.expand_path("../../../templates/new/resource/#{options[:type]}/#{file}", __dir__)
  unless File.exist?(path)
    logger.info "ERROR: Generator for #{file} not supported".color(:red)
    exit 1
  end
  set_source("new/resource/#{options[:type]}")
end