Class: HelmWrapper::Shared::Auths::Azure

Inherits:
Common
  • Object
show all
Includes:
Logging
Defined in:
lib/helm-wrapper/shared/auths/azure.rb

Constant Summary collapse

@@az =
"az"
@@type =
"azure"

Instance Method Summary collapse

Methods included from Logging

configure_logger_for, logger_for

Methods inherited from Common

#type

Constructor Details

#initialize(options:, variables:) ⇒ Azure

Returns a new instance of Azure.



43
44
45
# File 'lib/helm-wrapper/shared/auths/azure.rb', line 43

def initialize(options:, variables:)
  construct(options: options, variables: variables)
end

Instance Method Details

#authObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/helm-wrapper/shared/auths/azure.rb', line 49

def auth()
  ca       = secret(vault: @keyvault, name: @secret_ca)
  endpoint = secret(vault: @keyvault, name: @secret_endpoint)
  token    = secret(vault: @keyvault, name: @secret_token)

  @ca_tempfile = Tempfile.new('helm-wrapper-auths-azure-ca')

  begin
    @ca_tempfile.write(ca)
  ensure
    @ca_tempfile.close
  end

  logger.success("Azure authenticator successfully written Kubernetes CA to file!")

  ENV["HELM_KUBECAFILE"]    = @ca_tempfile.path
  ENV["HELM_KUBEAPISERVER"] = endpoint
  ENV["HELM_KUBETOKEN"]     = token

  logger.success("Azure authenticator environment variables set!")
end

#clearObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/helm-wrapper/shared/auths/azure.rb', line 73

def clear()
  unless @ca_tempfile.nil?
    @ca_tempfile.unlink
    @ca_tempfile = nil

    logger.info("Azure authenticator Kubernetes CA file cleared!")
  end

  ENV.delete("HELM_KUBECAFILE")
  ENV.delete("HELM_KUBEAPISERVER")
  ENV.delete("HELM_KUBETOKEN")

  logger.info("Azure authenticator environment variables cleared!")
end