@@ -284,13 +284,17 @@ def certificate
284
284
# When no certificate file is specified, we infer the usage of
285
285
# certificate content and create a tempfile containing this value.
286
286
# we leave it to to the tempfile to clean it up after the pupet run exists.
287
- file = Tempfile . new ( 'certificate' )
288
- # Check if the specified value is a Sensitive data type. If so, unwrap it and use
289
- # the value.
290
- content = @resource [ :certificate_content ] . respond_to? ( :unwrap ) ? @resource [ :certificate_content ] . unwrap : @resource [ :certificate_content ]
291
- file . write ( content )
292
- file . close
293
- file . path
287
+ @temp_certificate_file ||= begin
288
+ file = Tempfile . new ( 'certificate' )
289
+ # Check if the specified value is a Sensitive data type. If so, unwrap it and use
290
+ # the value.
291
+ content = @resource [ :certificate_content ] . respond_to? ( :unwrap ) ? @resource [ :certificate_content ] . unwrap : @resource [ :certificate_content ]
292
+ file . write ( content )
293
+ file . close
294
+ file
295
+ end
296
+
297
+ @temp_certificate_file . path
294
298
end
295
299
296
300
def private_key
@@ -300,13 +304,16 @@ def private_key
300
304
# When no private key file is specified, we infer the usage of
301
305
# private key content and create a tempfile containing this value.
302
306
# we leave it to to the tempfile to clean it up after the pupet run exists.
303
- file = Tempfile . new ( 'private_key' )
304
- # Check if the specified value is a Sensitive data type. If so, unwrap it and use
305
- # the value.
306
- content = @resource [ :private_key_content ] . respond_to? ( :unwrap ) ? @resource [ :private_key_content ] . unwrap : @resource [ :private_key_content ]
307
- file . write ( content )
308
- file . close
309
- file . path
307
+ @temp_private_key_file ||= begin
308
+ file = Tempfile . new ( 'private_key' )
309
+ # Check if the specified value is a Sensitive data type. If so, unwrap it and use
310
+ # the value.
311
+ content = @resource [ :private_key_content ] . respond_to? ( :unwrap ) ? @resource [ :private_key_content ] . unwrap : @resource [ :private_key_content ]
312
+ file . write ( content )
313
+ file . close
314
+ file
315
+ end
316
+ @temp_private_key_file . path
310
317
end
311
318
312
319
def private_key_type
0 commit comments