bolt 3.9.1 → 3.9.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bolt might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 677d817ea21f24c36b06d830a6a4f60cc11a1c288b9bc948ad69ee47f59da4f9
4
- data.tar.gz: a5045561603829eda876b5558082ecfa234916393ed4c92e6c5e7851c3cf1f2f
3
+ metadata.gz: b54ca78ebd584ad7e8bd223f086ac1dfc86f6f8bca3e7a7a2aab93a466eebc44
4
+ data.tar.gz: f68a3dfe2dad3a15bd9d970860ad629de9fac40882291d6cd7b677bf0da5814e
5
5
  SHA512:
6
- metadata.gz: 111b4df917e7788816f8ccbac0b1f7ed5ecb35af9ddec145aece1aa8ad8dd10c617383ce0b17b5e9146a528ad15e28751771eba0bef1fb08ddcd91c3db200c62
7
- data.tar.gz: cea97329b768ee991b0757bd0a4ff7ae28b2f0a68b678989adaee488a4c98d2354c618bc4663be18482088e856307238e7e04ac823b3dd65a95465fc08ed8254
6
+ metadata.gz: 879279d0db3506639ed99118623e90435e4f3ee70239aebd43e50d0fb8527eebf1ecfcf4298b6b110fcd34b560f4037cfc44439b2ad9858f67d9dfa1e5ad27e6
7
+ data.tar.gz: 36f05f2209c085c607200a857c380114eac7c631a6dd2b98550d27ece0488f3d0c3883693f83c74c3e87387a81e63d446727931084e40d27e6443a9c05eb1c4a
@@ -27,10 +27,6 @@ module Bolt
27
27
  if @config['interpreters']
28
28
  @config['interpreters'] = normalize_interpreters(@config['interpreters'])
29
29
  end
30
-
31
- if Bolt::Util.windows? && @config['run-as']
32
- raise Bolt::ValidationError, "run-as is not supported when using PowerShell"
33
- end
34
30
  end
35
31
  end
36
32
  end
@@ -26,10 +26,6 @@ module Bolt
26
26
  if @config['interpreters']
27
27
  @config['interpreters'] = normalize_interpreters(@config['interpreters'])
28
28
  end
29
-
30
- if Bolt::Util.windows? && @config['run-as']
31
- raise Bolt::ValidationError, "run-as is not supported when using PowerShell"
32
- end
33
29
  end
34
30
  end
35
31
  end
data/lib/bolt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bolt
4
- VERSION = '3.9.1'
4
+ VERSION = '3.9.2'
5
5
  end
@@ -21,6 +21,10 @@ require 'puppet'
21
21
  # Needed by the `/project_file_metadatas` endpoint
22
22
  require 'puppet/file_serving/fileset'
23
23
 
24
+ # Needed by the 'project_facts_plugin_tarball' endpoint
25
+ require 'minitar'
26
+ require 'zlib'
27
+
24
28
  module BoltServer
25
29
  class TransportApp < Sinatra::Base
26
30
  # This disables Sinatra's error page generation
@@ -71,6 +75,8 @@ module BoltServer
71
75
  # This is needed until the PAL is threadsafe.
72
76
  @pal_mutex = Mutex.new
73
77
 
78
+ @logger = Bolt::Logger.logger(self)
79
+
74
80
  super(nil)
75
81
  end
76
82
 
@@ -675,6 +681,70 @@ module BoltServer
675
681
  end
676
682
  end
677
683
 
684
+ # Returns the base64 encoded tar archive of plugin code that is needed to calculate
685
+ # custom facts
686
+ #
687
+ # @param versioned_project [String] the versioned_project to build the plugin tarball from
688
+ get '/project_facts_plugin_tarball' do
689
+ raise BoltServer::RequestError, "'versioned_project' is a required argument" if params['versioned_project'].nil?
690
+ content_type :json
691
+
692
+ # Inspired by Bolt::Applicator.build_plugin_tarball
693
+ start_time = Time.now
694
+
695
+ # Fetch the plugin files
696
+ plugin_files = in_bolt_project(params['versioned_project']) do |context|
697
+ files = {}
698
+
699
+ # Bolt also sets plugin_modulepath to user modulepath so do it here too for
700
+ # consistency
701
+ plugin_modulepath = context[:pal].user_modulepath
702
+ Puppet.lookup(:current_environment).override_with(modulepath: plugin_modulepath).modules.each do |mod|
703
+ search_dirs = []
704
+ search_dirs << mod.plugins if mod.plugins?
705
+ search_dirs << mod.pluginfacts if mod.pluginfacts?
706
+
707
+ files[mod] ||= []
708
+ Find.find(*search_dirs).each do |file|
709
+ files[mod] << file if File.file?(file)
710
+ end
711
+ end
712
+
713
+ files
714
+ end
715
+
716
+ # Pack the plugin files
717
+ sio = StringIO.new
718
+ begin
719
+ output = Minitar::Output.new(Zlib::GzipWriter.new(sio))
720
+
721
+ plugin_files.each do |mod, files|
722
+ tar_dir = Pathname.new(mod.name)
723
+ mod_dir = Pathname.new(mod.path)
724
+
725
+ files.each do |file|
726
+ tar_path = tar_dir + Pathname.new(file).relative_path_from(mod_dir)
727
+ stat = File.stat(file)
728
+ content = File.binread(file)
729
+ output.tar.add_file_simple(
730
+ tar_path.to_s,
731
+ data: content,
732
+ size: content.size,
733
+ mode: stat.mode & 0o777,
734
+ mtime: stat.mtime
735
+ )
736
+ end
737
+ end
738
+
739
+ duration = Time.now - start_time
740
+ @logger.trace("Packed plugins in #{duration * 1000} ms")
741
+ ensure
742
+ output.close
743
+ end
744
+
745
+ [200, Base64.encode64(sio.string).to_json]
746
+ end
747
+
678
748
  error 404 do
679
749
  err = Bolt::Error.new("Could not find route #{request.path}",
680
750
  'boltserver/not-found')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.1
4
+ version: 3.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-07 00:00:00.000000000 Z
11
+ date: 2021-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable