hashipack 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer/Dockerfile +7 -0
- data/.devcontainer/devcontainer.json +7 -3
- data/Gemfile.lock +2 -2
- data/lib/hashipack/client.rb +27 -16
- data/lib/hashipack/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2423fd4fb8a820ae618c61f0b031cacf63143f5626bc6ad9a7e7db3cd9c3f8e4
|
4
|
+
data.tar.gz: e8e9a8c627d33522cf40efda1b03113cfacde5676386944c702d0647e8f9b7dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c76888f12547f25db4f900a3cfbbafe904c8335897bece060d22cb32f9a30b3bec8546315d590b2329096d344db810cc462cd031f0bcd50d965d5b430b73956
|
7
|
+
data.tar.gz: b8aed88a7362c77203826b202565f29f9b4034413fa7420fb2d60ab8855ca34a6f084ab3baf91290663d74f57e30eeea8ca18e4f92c0d5cb048bde12181a8939
|
@@ -0,0 +1,7 @@
|
|
1
|
+
FROM mcr.microsoft.com/devcontainers/ruby:1-3.3-bullseye
|
2
|
+
|
3
|
+
# Install packages needed to build gems
|
4
|
+
RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
|
5
|
+
RUN sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
|
6
|
+
RUN apt-get update -qq && \
|
7
|
+
apt-get install --no-install-recommends -y packer
|
@@ -3,16 +3,20 @@
|
|
3
3
|
{
|
4
4
|
"name": "Ruby",
|
5
5
|
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
6
|
-
"
|
6
|
+
"build": {
|
7
|
+
"dockerfile": "Dockerfile"
|
8
|
+
},
|
7
9
|
|
8
10
|
// Features to add to the dev container. More info: https://containers.dev/features.
|
9
|
-
|
11
|
+
"features": {
|
12
|
+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
|
13
|
+
},
|
10
14
|
|
11
15
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
12
16
|
// "forwardPorts": [],
|
13
17
|
|
14
18
|
// Use 'postCreateCommand' to run commands after the container is created.
|
15
|
-
|
19
|
+
"postCreateCommand": "packer init spec/docker.pkr.hcl",
|
16
20
|
|
17
21
|
// Configure tool-specific properties.
|
18
22
|
"customizations": {
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hashipack (0.1.
|
4
|
+
hashipack (0.1.6)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
rainbow (3.1.1)
|
21
21
|
rake (13.0.6)
|
22
22
|
regexp_parser (2.8.2)
|
23
|
-
rexml (3.3.
|
23
|
+
rexml (3.3.6)
|
24
24
|
strscan
|
25
25
|
rspec (3.12.0)
|
26
26
|
rspec-core (~> 3.12.0)
|
data/lib/hashipack/client.rb
CHANGED
@@ -1,36 +1,47 @@
|
|
1
1
|
require 'tempfile'
|
2
|
+
require 'open3'
|
2
3
|
|
3
4
|
module Hashipack
|
4
5
|
class Client
|
5
|
-
def build(
|
6
|
-
|
6
|
+
def build(path, on_output: lambda {}, on_progress: lambda {}, estimated_duration: 300, debug: false)
|
7
|
+
directory, filename = File.split(path)
|
8
|
+
debug_suffix = debug ? ' -debug' : ''
|
9
|
+
command = "packer -machine-readable build #{filename}#{debug_suffix}"
|
7
10
|
|
8
11
|
initial_timestamp = 99999999999
|
9
12
|
last_timestamp = 0
|
10
13
|
|
11
14
|
artifacts = []
|
12
15
|
|
13
|
-
|
14
|
-
|
16
|
+
Open3.popen3(command, chdir: directory) do |stdin, stdout, stderr, wait_thr|
|
17
|
+
stdout.each do |line|
|
18
|
+
message = Message.parse(line)
|
15
19
|
|
16
|
-
|
17
|
-
|
20
|
+
if message.type == :ui
|
21
|
+
initial_timestamp = message.timestamp if message.timestamp < initial_timestamp
|
18
22
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
if message.timestamp > last_timestamp
|
24
|
+
last_timestamp = message.timestamp
|
25
|
+
running_duration = message.timestamp - initial_timestamp
|
26
|
+
progress = running_duration / estimated_duration.to_f
|
27
|
+
on_progress.call(progress)
|
28
|
+
end
|
25
29
|
|
26
|
-
|
30
|
+
on_output.call(message.text)
|
27
31
|
|
28
|
-
|
32
|
+
elsif message.type == :artifact
|
29
33
|
|
30
|
-
|
31
|
-
|
34
|
+
artifacts[message.number] ||= Artifact.new
|
35
|
+
artifacts[message.number].append_info(message.key, message.value)
|
32
36
|
|
37
|
+
end
|
33
38
|
end
|
39
|
+
|
40
|
+
stderr.each do |line|
|
41
|
+
puts "Error: #{line}"
|
42
|
+
end
|
43
|
+
|
44
|
+
puts "Exit status: #{wait_thr.value}"
|
34
45
|
end
|
35
46
|
|
36
47
|
artifacts
|
data/lib/hashipack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashipack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas_Skywalker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08
|
11
|
+
date: 2024-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: None.
|
14
14
|
email:
|
@@ -17,6 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".devcontainer/Dockerfile"
|
20
21
|
- ".devcontainer/devcontainer.json"
|
21
22
|
- ".rspec"
|
22
23
|
- ".standard.yml"
|