Skip to content

Commit 7cbf4b8

Browse files
committed
Make lintastic
1 parent db3e49e commit 7cbf4b8

1 file changed

Lines changed: 13 additions & 20 deletions

File tree

cookbooks/boxcutter_onepassword/libraries/onepassword.rb

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def self.op_read(reference, type = 'auto')
3636
:type => type,
3737
:event => 'op_read',
3838
:extra => { :reference => reference },
39-
:log_stdout => false
39+
:log_stdout => false,
4040
).stdout.strip
4141
end
4242

@@ -54,7 +54,7 @@ def self.op_document_get(item, vault, type = 'auto')
5454
:type => type,
5555
:event => 'op_document_get',
5656
:extra => { :item => item, :vault => vault },
57-
log_stdout: false
57+
:log_stdout => false,
5858
).stdout.strip
5959
end
6060

@@ -141,17 +141,16 @@ def self.install_bootstrap_op_cli
141141
uri = URI.parse(url)
142142

143143
Chef::Log.info(
144-
"boxcutter_onepassword[install_bootstrap_op_cli]: downloading op cli " \
144+
'boxcutter_onepassword[install_bootstrap_op_cli]: downloading op cli ' \
145145
"arch=#{architecture} to #{tmp_path} (basename=#{::File.basename(url)})",
146146
)
147147

148-
149148
# Open a connection and download the file
150149
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
151150
request = Net::HTTP::Get.new(uri)
152151
http.request(request) do |response|
153152
if response.code.to_i >= 400
154-
fail "boxcutter_onepassword[install_bootstrap_op_cli]: failed download " \
153+
fail 'boxcutter_onepassword[install_bootstrap_op_cli]: failed download ' \
155154
"http=#{response.code} url_basename=#{::File.basename(url)}"
156155
end
157156

@@ -186,38 +185,32 @@ def self.unzip_file(zip_file, filename, destination)
186185
# Skip extraction if file already exists
187186
if ::File.exist?(target_path)
188187
Chef::Log.debug("boxcutter_onepassword[unzip_file]: #{target_path} exists; skipping extraction")
189-
return
188+
else
189+
::FileUtils.mkdir_p(File.dirname(target_path))
190+
entry.extract(target_path)
191+
Chef::Log.debug("boxcutter_onepassword[unzip_file]: extracted #{filename.inspect} to #{destination}")
190192
end
191-
192-
::FileUtils.mkdir_p(File.dirname(target_path))
193-
entry.extract(target_path)
194-
Chef::Log.debug("boxcutter_onepassword[unzip_file]: extracted #{filename.inspect} to #{destination}")
195193
end
196194
end
197195

198196
# ---- token discovery helpers ----
199197

200198
def self.op_connect_host_path
201199
op_connect_host_path = '/etc/cinc/op_connect_host'
202-
if ::File.exist?(op_connect_host_path)
203-
Chef::Log.debug("boxcutter_onepassword: using #{op_connect_host_path} for op_connect_host_path")
204-
else
200+
unless ::File.exist?(op_connect_host_path)
205201
op_connect_host_path = '/etc/chef/op_connect_host'
206-
Chef::Log.debug("boxcutter_onepassword: using #{op_connect_host_path} for op_connect_host_path")
207202
end
203+
Chef::Log.debug("boxcutter_onepassword: using #{op_connect_host_path} for op_connect_host_path")
208204
op_connect_host_path
209205
end
210206

211207
def self.op_connect_token_path
212208
op_connect_token_path = '/etc/cinc/op_connect_token'
213-
if ::File.exist?(op_connect_token_path)
214-
Chef::Log.debug("boxcutter_onepassword: using #{op_connect_token_path} for op_connect_token_path")
215-
op_connect_token_path
216-
else
209+
unless ::File.exist?(op_connect_token_path)
217210
op_connect_token_path = '/etc/chef/op_connect_token'
218-
Chef::Log.debug("boxcutter_onepassword: using #{op_connect_token_path} for op_connect_token_path")
219-
op_connect_token_path
220211
end
212+
Chef::Log.debug("boxcutter_onepassword: using #{op_connect_token_path} for op_connect_token_path")
213+
op_connect_token_path
221214
end
222215

223216
def self.op_connect_server_token_found?

0 commit comments

Comments
 (0)