Class: EtnaApp::Janus::Token::Generate

Inherits:
Etna::Command show all
Includes:
WithLogger
Defined in:
lib/commands.rb

Instance Attribute Summary

Attributes inherited from Etna::Command

#parent

Instance Method Summary collapse

Methods included from WithLogger

#logger

Methods inherited from Etna::Command

#completions, #fill_in_missing_params, #find_command, #initialize, parent_scope, #setup

Methods included from Etna::CommandOrExecutor

#command_name, #completions_for, #desc, #flag_argspec, #flag_as_parameter, included, #parse_flags, #program_name, #usage

Constructor Details

This class inherits a constructor from Etna::Command

Instance Method Details

#execute(email:, task: false, project_name: nil) ⇒ Object



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/commands.rb', line 222

def execute(email:, task: false, project_name: nil)
  # the token is not required, but can be used if available
  # to generate a task token, so we pass it in here
  janus_client = Etna::Clients::Janus.new(
    token: ENV['TOKEN'],
    ignore_ssl: EtnaApp.instance.config(:ignore_ssl),
    **EtnaApp.instance.config(:janus, EtnaApp.instance.environment))

  generate_token_workflow = Etna::Clients::Janus::GenerateTokenWorkflow.new(
    janus_client: janus_client,
    token_type: task ? 'task' : 'login',
    email: email,
    project_name: project_name,
    private_key_file: EtnaApp.instance.config(:private_key, EtnaApp.instance.environment)
  )
  generate_token_workflow.generate!
end