Class: SwarmClusterCliOpe::Kubernetes::Configuration

Inherits:
BaseConfiguration show all
Defined in:
lib/swarm_cluster_cli_ope/kubernetes/configuration.rb

Constant Summary

Constants inherited from BaseConfiguration

BaseConfiguration::NoBaseConfigurations

Instance Attribute Summary

Attributes inherited from BaseConfiguration

#environment, #stack_name

Instance Method Summary collapse

Methods inherited from BaseConfiguration

base_cfg_path, #development_mode?, #env, exist_base?, #local_compose_project_name, #logger_level, #merged_configurations, #save_project_cfgs, #sync_configurations

Methods included from LoggerConcern

#logger

Instance Method Details

#contextString

In kubernetes abbiamo il context, il context può essere ricevuto o dalla configurazione oppure dal current_context di kubelet

Returns:

  • (String)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/swarm_cluster_cli_ope/kubernetes/configuration.rb', line 15

def context

  context = merged_configurations.dig(:connections_maps,:context) || nil

  if context.nil?
    cmd = ShellCommandExecution.new(['kubectl config current-context'])
    context = cmd.execute.raw_result[:stdout]
    unless yes? "Attenzione, non era presente il contesto nelle configurazioni, usiamo quello attualmente in uso: #{context}, proseguiamo lo stesso?[y,yes]"
      exit
    end

  end
  context
end

#get_syncro(name) ⇒ Object

Funzione per la restituzione della classe di sincro corretta



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/swarm_cluster_cli_ope/kubernetes/configuration.rb', line 45

def get_syncro(name)
  case name
  when 'sqlite3'
    SyncConfigs::Sqlite3
  when 'rsync'
    SyncConfigs::Rsync
  when 'mysql'
    SyncConfigs::Mysql
  when 'pg'
    SyncConfigs::PostGres
  else
    logger.error { "CONFIGURAIONE NON PREVISTA in K8S: #{name}" }
    nil
  end
end

#save_base_cfgsObject

Salva le configurazioni base in HOME



32
33
34
35
36
# File 'lib/swarm_cluster_cli_ope/kubernetes/configuration.rb', line 32

def save_base_cfgs
  super do |obj|
    obj.merge({connections_maps: {context: context}})
  end
end

#shellObject



5
6
7
# File 'lib/swarm_cluster_cli_ope/kubernetes/configuration.rb', line 5

def shell
  @_shell = Thor::Shell::Basic.new
end