Skip to content

Commit

Permalink
extract credentials to own method
Browse files Browse the repository at this point in the history
code climate complained run had too many lines
  • Loading branch information
kbrock committed Oct 16, 2024
1 parent 0d3496f commit 1059803
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/floe/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ def initialize
def run(args = ARGV)
workflows_inputs, opts = parse_options!(args)

credentials =
if opts[:credentials_given]
opts[:credentials] == "-" ? $stdin.read : opts[:credentials]
elsif opts[:credentials_file_given]
File.read(opts[:credentials_file])
end
credentials = create_credentials(opts)

workflows =
workflows_inputs.each_slice(2).map do |workflow, input|
Expand Down Expand Up @@ -82,6 +77,16 @@ def parse_options!(args)
return workflows_inputs, opts
end

def create_credentials(opts)
if opts[:credentials_given]
opts[:credentials] == "-" ? $stdin.read : opts[:credentials]
elsif opts[:credentials_file_given]
File.read(opts[:credentials_file])
else
{}
end
end

def create_workflow(workflow, context_payload, input, credentials)
context = Floe::Workflow::Context.new(context_payload, :input => input, :credentials => credentials)
Floe::Workflow.load(workflow, context)
Expand Down

0 comments on commit 1059803

Please sign in to comment.