Skip to content

Commit 9e7180e

Browse files
authored
Merge pull request #12 from github/tmpdir-fixes
Entitlements `tmpdir` fixes
2 parents 42b7e70 + 2743daf commit 9e7180e

File tree

11 files changed

+15
-7
lines changed

11 files changed

+15
-7
lines changed

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
entitlements-gitrepo-auditor-plugin (0.2.1)
4+
entitlements-gitrepo-auditor-plugin (0.2.2)
55
contracts (= 0.17)
66
entitlements (= 0.2.0)
77

@@ -28,16 +28,16 @@ GEM
2828
net-ldap (~> 0.17)
2929
octokit (~> 4.18)
3030
optimist (= 3.0.0)
31-
faraday (2.5.2)
31+
faraday (2.7.10)
3232
faraday-net_http (>= 2.0, < 3.1)
3333
ruby2_keywords (>= 0.0.4)
34-
faraday-net_http (3.0.0)
34+
faraday-net_http (3.0.2)
3535
hashdiff (1.0.1)
3636
i18n (1.12.0)
3737
concurrent-ruby (~> 1.0)
3838
json (2.6.2)
3939
minitest (5.16.3)
40-
net-ldap (0.17.1)
40+
net-ldap (0.18.0)
4141
octokit (4.25.1)
4242
faraday (>= 1, < 3)
4343
sawyer (~> 0.9)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.1
1+
0.2.2

entitlements-gitrepo-auditor-plugin.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
1212
s.homepage = "https://github.com/github/entitlements-gitrepo-auditor-plugin"
1313
s.executables = %w[]
1414

15-
s.add_dependency "entitlements", "0.2.0"
1615
s.add_dependency "contracts", "0.17"
16+
s.add_dependency "entitlements", "0.2.0"
1717

1818
s.add_development_dependency "rake", "= 13.0.6"
1919
s.add_development_dependency "rspec", "= 3.8.0"

lib/entitlements/util/gitrepo.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def initialize(repo:, sshkey:, logger: Entitlements.logger)
3838
@repo = repo
3939
@sshkey = sshkey
4040
@github = "[email protected]:"
41+
@tmpdir_prefix = ENV.fetch("ENTITLEMENTS_TMPDIR_PREFIX", "/data/entitlements_deploys")
4142
end
4243

4344
# Run "git add" on a file.
@@ -206,7 +207,11 @@ def open3_git_execute(dir, commandline, ssh = false)
206207
# else custom that might be going on in the environment. Turn off prompts for the SSH key for
207208
# github.com being trusted or not, only use the provided key as the identity, and ignore any
208209
# ~/.ssh/config file the user running this might have set up.
209-
tempdir = Dir.mktmpdir
210+
211+
# if the @tmpdir_prefix doesn't exist, create it
212+
FileUtils.mkdir_p(@tmpdir_prefix) unless File.directory?(@tmpdir_prefix)
213+
tempdir = Dir.mktmpdir(nil, @tmpdir_prefix)
214+
210215
File.open(File.join(tempdir, "key"), "w") { |f| f.write(sshkey) }
211216
File.open(File.join(tempdir, "ssh"), "w") do |f|
212217
f.puts "#!/bin/sh"

spec/unit/entitlements/util/gitrepo_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@
168168
allow(exitstatus).to receive(:exitstatus).and_return(0)
169169

170170
begin
171+
expect(FileUtils).to receive(:mkdir_p)
172+
.and_return(true)
173+
171174
tempdir = Dir.mktmpdir
172175
allow(Dir).to receive(:mktmpdir).and_return(tempdir)
173176

vendor/cache/faraday-2.5.2.gem

-67 KB
Binary file not shown.

vendor/cache/faraday-2.7.10.gem

68.5 KB
Binary file not shown.
-8 KB
Binary file not shown.
8 KB
Binary file not shown.

vendor/cache/net-ldap-0.17.1.gem

-65.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)