summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-06-13 15:04:45 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-06-13 15:04:45 -0700
commit794b147afe7300d855a32cc4040903cb67e789bb (patch)
treed8181b4c76da285db39629c47fe351bcf416c54e
parentdeea4f3b00a6bd18beba85c05ddec93a143cdb8b (diff)
downloadchef-lcg/systemd-service-target-mode.tar.gz
also changes the file_exist? signature since in ruby that only ever takes one arg.
-rw-r--r--lib/chef/mixin/train_helpers.rb24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/chef/mixin/train_helpers.rb b/lib/chef/mixin/train_helpers.rb
index b37511bdea..1b031ab338 100644
--- a/lib/chef/mixin/train_helpers.rb
+++ b/lib/chef/mixin/train_helpers.rb
@@ -1,6 +1,6 @@
#--
# Author:: Lamont Granquist <lamont@chef.io>
-# Copyright:: Copyright 2010-2018, Chef Software Inc.
+# Copyright:: Copyright 2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,15 +20,31 @@ require "stringio" unless defined?(StringIO)
class Chef
module Mixin
module TrainHelpers
- def file_exist?(*args)
+
+ #
+ # FIXME: generally these helpers all use the pattern of checking for target_mode?
+ # and then if it is we use train. That approach should likely be flipped so that
+ # even when we're running without target mode we still use inspec in its local
+ # mode.
+ #
+
+ # Train wrapper around File.exist? to make it local mode aware.
+ #
+ # @param filename filename to check
+ # @return [Boolean] if it exists
+ #
+ def file_exist?(filename)
if Chef::Config.target_mode?
- Chef.run_context.transport_connection.file(args[0]).exist?
+ Chef.run_context.transport_connection.file(filename).exist?
else
- File.exist?(*args)
+ File.exist?(filename)
end
end
# XXX: modifications to the StringIO won't get written back
+ # FIXME: this is very experimental and may be a bad idea and may break at any time
+ # @api private
+ #
def file_open(*args, &block)
if Chef::Config.target_mode?
content = Chef.run_context.transport_connection.file(args[0]).content