Skip to content

Commit

Permalink
Use top-level Krane constant for all files under lib/krane/cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Soares de Andrade committed Oct 9, 2019
1 parent af08e64 commit 5a31140
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions lib/krane/cli/deploy_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ def self.from_options(namespace, context, options)
require 'krane/bindings_parser'
require 'krane/label_selector'

bindings_parser = Krane::BindingsParser.new
bindings_parser = ::Krane::BindingsParser.new
options[:bindings]&.each { |binding_pair| bindings_parser.add(binding_pair) }

selector = Krane::LabelSelector.parse(options[:selector]) if options[:selector]
selector = ::Krane::LabelSelector.parse(options[:selector]) if options[:selector]

logger = Krane::FormattedLogger.build(namespace, context,
logger = ::Krane::FormattedLogger.build(namespace, context,
verbose_prefix: options['verbose-log-prefix'])

protected_namespaces = options['protected-namespaces']
if options['protected-namespaces'].size == 1 && %w('' "").include?(options['protected-namespaces'][0])
protected_namespaces = []
end

Krane::OptionsHelper.with_processed_template_paths([options[:filenames]],
::Krane::OptionsHelper.with_processed_template_paths([options[:filenames]],
require_explicit_path: true) do |paths|
deploy = ::Krane::DeployTask.new(
namespace: namespace,
Expand All @@ -60,7 +60,7 @@ def self.from_options(namespace, context, options)
template_paths: paths,
bindings: bindings_parser.parse,
logger: logger,
max_watch_seconds: Krane::DurationParser.new(options["global-timeout"]).parse!.to_i,
max_watch_seconds: ::Krane::DurationParser.new(options["global-timeout"]).parse!.to_i,
selector: selector,
protected_namespaces: protected_namespaces,
)
Expand Down
6 changes: 3 additions & 3 deletions lib/krane/cli/krane.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def self.exit_on_failure?

def rescue_and_exit
yield
rescue Krane::DeploymentTimeoutError
rescue ::Krane::DeploymentTimeoutError
exit(TIMEOUT_EXIT_CODE)
rescue Krane::FatalDeploymentError
rescue ::Krane::FatalDeploymentError
exit(FAILURE_EXIT_CODE)
rescue Krane::DurationParser::ParsingError => e
rescue ::Krane::DurationParser::ParsingError => e
STDERR.puts(<<~ERROR_MESSAGE)
Error parsing duration
#{e.message}. Duration must be a full ISO8601 duration or time value (e.g. 300s, 10m, 1h)
Expand Down
6 changes: 3 additions & 3 deletions lib/krane/cli/render_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def self.from_options(options)
require 'krane/bindings_parser'
require 'krane/options_helper'

bindings_parser = Krane::BindingsParser.new
bindings_parser = ::Krane::BindingsParser.new
options[:bindings]&.each { |b| bindings_parser.add(b) }

Krane::OptionsHelper.with_processed_template_paths(options[:filenames]) do |paths|
runner = Krane::RenderTask.new(
::Krane::OptionsHelper.with_processed_template_paths(options[:filenames]) do |paths|
runner = ::Krane::RenderTask.new(
current_sha: ENV["REVISION"],
template_paths: paths,
bindings: bindings_parser.parse,
Expand Down
6 changes: 3 additions & 3 deletions lib/krane/cli/restart_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class RestartCommand

def self.from_options(namespace, context, options)
require 'krane/restart_task'
selector = Krane::LabelSelector.parse(options[:selector]) if options[:selector]
restart = Krane::RestartTask.new(
selector = ::Krane::LabelSelector.parse(options[:selector]) if options[:selector]
restart = ::Krane::RestartTask.new(
namespace: namespace,
context: context,
max_watch_seconds: Krane::DurationParser.new(options["global-timeout"]).parse!.to_i,
max_watch_seconds: ::Krane::DurationParser.new(options["global-timeout"]).parse!.to_i,
)
restart.run!(
options[:deployments],
Expand Down
4 changes: 2 additions & 2 deletions lib/krane/cli/run_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class RunCommand

def self.from_options(namespace, context, options)
require "krane/runner_task"
runner = Krane::RunnerTask.new(
runner = ::Krane::RunnerTask.new(
namespace: namespace,
context: context,
max_watch_seconds: Krane::DurationParser.new(options["global-timeout"]).parse!.to_i,
max_watch_seconds: ::Krane::DurationParser.new(options["global-timeout"]).parse!.to_i,
)

runner.run!(
Expand Down
2 changes: 1 addition & 1 deletion lib/krane/cli/version_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class VersionCommand
OPTIONS = {}

def self.from_options(_)
puts("krane #{Krane::VERSION}")
puts("krane #{::Krane::VERSION}")
end
end
end
Expand Down

0 comments on commit 5a31140

Please sign in to comment.