Class: CivoCLI::KubernetesApplications
- Inherits:
-
Thor
- Object
- Thor
- CivoCLI::KubernetesApplications
- Defined in:
- lib/kubernetes_applications.rb
Instance Method Summary collapse
Instance Method Details
#add(name) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/kubernetes_applications.rb', line 66 def add(name) CivoCLI::Config.set_api_auth name, plan = name.split(":") app = Finder.detect_app(name) if app.default puts "You cannot choose to install #{app.name}".colorize(:red) + " because it is a pre-installed application" exit 1 end cluster = Finder.detect_cluster([:cluster]) plans = app.plans&.items if app && plans.present? && plan.blank? if AskService.available? plan = AskService.choose("You requested to add #{app.name} but didn't select a plan. Please choose one...", plans.map(&:label)) if plan.present? puts "Thank you, next time you could use \"#{app.name}:#{plan}\" to choose automatically" end else puts "You need to specify a plan".colorize(:red) + " from those available (#{plans.join(", ")} using the syntax \"#{app.name}:plan\"" exit 1 end end if plan.present? Civo::Kubernetes.update(id: cluster.id, applications: "#{app.name}:#{plan}") else Civo::Kubernetes.update(id: cluster.id, applications: app.name) end puts "Added #{app.name.colorize(:green)} #{app.version} to Kubernetes cluster #{cluster.name.colorize(:green)}" rescue Flexirest::HTTPException => e puts e.result.reason.colorize(:red) exit 1 end |
#list ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kubernetes_applications.rb', line 7 def list CivoCLI::Config.set_api_auth if [:quiet] Civo::Kubernetes.applications.items.each do |app| puts "#{app.name} (#{app.version}, #{app.category})" end else rows = [] Civo::Kubernetes.applications.items.each do |app| plans = app.plans&.items if plans.present? plans = plans.map {|p| p.label}.join(", ") else plans = "Not applicable" end dependencies = app.dependencies&.items if dependencies.present? dependencies = dependencies.map {|d| d}.join(", ") else dependencies = " " end rows << [app.name, app.version, app.category, plans, dependencies] end puts Terminal::Table.new headings: ['Name', 'Version', 'Category', 'Plans', 'Dependencies'], rows: rows end rescue Flexirest::HTTPForbiddenClientException reject_user_access end |
#show(name) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kubernetes_applications.rb', line 40 def show(name) CivoCLI::Config.set_api_auth rows = [] app = Finder.detect_app(name) puts " Name : #{app.name}" puts " Version : #{app.version}" puts " Category : #{app.category}" puts " Maintainer : #{app.maintainer}" puts " URL : #{app.url}" puts " Description : #{app.description}" if app.dependencies puts " Dependencies : #{app.dependencies.join(", ")}" end rescue Flexirest::HTTPException => e puts e.result.reason.colorize(:red) exit 1 end |