Class: Kscript::KkElasticCertFingerUtils

Inherits:
Base
  • Object
show all
Defined in:
lib/kscript/plugins/kk_elastic_cert_finger_utils.rb

Constant Summary collapse

DEFAULT_CERT_PATH =
'elasticsearch.crt'

Instance Attribute Summary collapse

Attributes inherited from Base

#logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#human_output?, inherited, #with_error_handling

Constructor Details

#initialize(*args, **opts) ⇒ KkElasticCertFingerUtils

Initialize with certificate path

Parameters:

  • cert_path (String)

    path to the certificate file



18
19
20
21
# File 'lib/kscript/plugins/kk_elastic_cert_finger_utils.rb', line 18

def initialize(*args, **opts)
  super
  @cert_path = args[0] || opts[:cert_path] || self.class::DEFAULT_CERT_PATH
end

Instance Attribute Details

#cert_pathObject (readonly)

Returns the value of attribute cert_path.



14
15
16
# File 'lib/kscript/plugins/kk_elastic_cert_finger_utils.rb', line 14

def cert_path
  @cert_path
end

Class Method Details

.argumentsObject



31
32
33
# File 'lib/kscript/plugins/kk_elastic_cert_finger_utils.rb', line 31

def self.arguments
  '<cert_file>'
end

.authorObject



43
44
45
# File 'lib/kscript/plugins/kk_elastic_cert_finger_utils.rb', line 43

def self.author
  'kk'
end

.descriptionObject



47
48
49
# File 'lib/kscript/plugins/kk_elastic_cert_finger_utils.rb', line 47

def self.description
  'Generate Elasticsearch certificate SHA256 fingerprint.'
end

.groupObject



39
40
41
# File 'lib/kscript/plugins/kk_elastic_cert_finger_utils.rb', line 39

def self.group
  'elastic'
end

.usageObject



35
36
37
# File 'lib/kscript/plugins/kk_elastic_cert_finger_utils.rb', line 35

def self.usage
  "kscript elastic_cert_finger <cert_file>\nkscript elastic_cert_finger ./ca.crt"
end

Instance Method Details

#run(*args, **_opts) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/kscript/plugins/kk_elastic_cert_finger_utils.rb', line 23

def run(*args, **_opts)
  with_error_handling do
    # 支持运行时传入证书路径覆盖初始化时的路径
    @cert_path = args[0] if args[0]
    generate
  end
end