Module: Dapp::Kube::Dapp::Command::Common

Included in:
Dapp
Defined in:
lib/dapp/kube/dapp/command/common.rb

Instance Method Summary collapse

Instance Method Details

#kube_check_helm!Object

Raises:



6
7
8
# File 'lib/dapp/kube/dapp/command/common.rb', line 6

def kube_check_helm!
  raise Error::Command, code: :helm_not_found if shellout('which helm').exitstatus == 1
end

#kube_namespaceObject



14
15
16
# File 'lib/dapp/kube/dapp/command/common.rb', line 14

def kube_namespace
  kubernetes.namespace
end

#kube_release_nameObject



10
11
12
# File 'lib/dapp/kube/dapp/command/common.rb', line 10

def kube_release_name
  "#{name}-#{kube_namespace}"
end

#kubernetesObject



48
49
50
51
52
53
# File 'lib/dapp/kube/dapp/command/common.rb', line 48

def kubernetes
  @kubernetes ||= begin
    namespace = options[:namespace].nil? ? nil : options[:namespace].tr('_', '-')
    Client.new(namespace: namespace)
  end
end

#secretObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dapp/kube/dapp/command/common.rb', line 25

def secret
  @secret ||= begin
    unless secret_key = ENV['DAPP_SECRET_KEY']
      secret_key_not_found_in << '`DAPP_SECRET_KEY`'

      if dappfile_exists?
        file_path = path('.dapp_secret_key')
        if file_path.file?
          secret_key = path('.dapp_secret_key').read.chomp
        else
          secret_key_not_found_in << "`#{file_path}`"
        end
      end
    end

    Secret.new(secret_key) if secret_key
  end
end

#secret_key_not_found_inObject



44
45
46
# File 'lib/dapp/kube/dapp/command/common.rb', line 44

def secret_key_not_found_in
  @secret_key_not_found_in ||= []
end

#secret_key_should_exist!Object

Raises:



18
19
20
21
22
23
# File 'lib/dapp/kube/dapp/command/common.rb', line 18

def secret_key_should_exist!
  raise(Error::Command,
    code: :secret_key_not_found,
    data: {not_found_in: secret_key_not_found_in.join(', ')}
  ) if secret.nil?
end