cutlass 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +5 -4
- data/.github/workflows/check_changelog.yml +14 -8
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +9 -9
- data/README.md +2 -2
- data/lib/cutlass/app.rb +7 -2
- data/lib/cutlass/container_boot.rb +3 -1
- data/lib/cutlass/container_control.rb +7 -0
- data/lib/cutlass/function_query.rb +13 -1
- data/lib/cutlass/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60df15fbdd7d8e5720584aac45b553e93eeb79fb72f78192ba06d51ec8b63a00
|
4
|
+
data.tar.gz: aea137a128750f7184f0bb5cfbd693957bd679dcda2b14e07b449b2611a801e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c1a8c7b46f327e0859b06a1b1311e65f1e10ebd755ab222201059639743010b7071e84c850452f13d47c38f80b688fbb581b06dbb2356b590badd11b6094a53
|
7
|
+
data.tar.gz: c4a7289cbf891b6d258803957c2ecfb59a8ee4f590cb1ef1a9fecc5c7b91651844c1118e4a8bf397ee31dc9287454bba93c6a73689547e1bc86015405b950ce0
|
data/.github/dependabot.yml
CHANGED
@@ -2,8 +2,9 @@ version: 2
|
|
2
2
|
updates:
|
3
3
|
- package-ecosystem: "bundler"
|
4
4
|
directory: "/"
|
5
|
-
open-pull-requests-limit: 1 # Limit concurrent CI runs from executing
|
6
5
|
schedule:
|
7
|
-
interval: "
|
8
|
-
|
9
|
-
|
6
|
+
interval: "daily"
|
7
|
+
- package-ecosystem: "github-actions"
|
8
|
+
directory: "/"
|
9
|
+
schedule:
|
10
|
+
interval: "daily"
|
@@ -1,16 +1,22 @@
|
|
1
1
|
name: Check Changelog
|
2
2
|
|
3
3
|
on:
|
4
|
-
|
5
|
-
|
4
|
+
pull_request:
|
5
|
+
types: [opened, reopened, edited, labeled, unlabeled, synchronize]
|
6
|
+
|
6
7
|
jobs:
|
7
|
-
|
8
|
+
check-changelog:
|
9
|
+
runs-on: ubuntu-latest
|
8
10
|
if: |
|
11
|
+
!contains(github.event.pull_request.body, '[skip changelog]') &&
|
12
|
+
!contains(github.event.pull_request.body, '[changelog skip]') &&
|
13
|
+
!contains(github.event.pull_request.body, '[skip ci]') &&
|
14
|
+
!contains(github.event.pull_request.labels.*.name, 'skip changelog') &&
|
9
15
|
!contains(github.event.pull_request.labels.*.name, 'dependencies') &&
|
10
16
|
!contains(github.event.pull_request.labels.*.name, 'automation')
|
11
|
-
runs-on: ubuntu-latest
|
12
17
|
steps:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
18
|
+
- uses: actions/checkout@v2.3.4
|
19
|
+
- name: Check that CHANGELOG is touched
|
20
|
+
run: |
|
21
|
+
git fetch origin ${{ github.base_ref }} --depth 1 && \
|
22
|
+
git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## 0.3.0
|
4
|
+
|
5
|
+
- Support :env option for start_container https://github.com/heroku/cutlass/pull/31
|
6
|
+
|
7
|
+
## 0.2.4
|
8
|
+
|
9
|
+
- Expose container logs on actively running instances via ContainerControl https://github.com/heroku/cutlass/pull/29
|
10
|
+
|
11
|
+
## 0.2.3
|
12
|
+
|
13
|
+
- Fix keyword arg warning https://github.com/heroku/cutlass/pull/28
|
14
|
+
|
15
|
+
## 0.2.2
|
16
|
+
|
17
|
+
- Support :memory option for start_container https://github.com/heroku/cutlass/pull/27
|
18
|
+
- Add debug log when a function query fails https://github.com/heroku/cutlass/pull/17
|
19
|
+
|
3
20
|
## 0.2.1
|
4
21
|
|
5
22
|
- Fix incorrect conversion of a ProcessStatus into an exit code https://github.com/heroku/cutlass/pull/16
|
data/Gemfile.lock
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cutlass (0.
|
4
|
+
cutlass (0.3.0)
|
5
5
|
docker-api (>= 2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.
|
10
|
+
addressable (2.8.0)
|
11
11
|
public_suffix (>= 2.0.2, < 5.0)
|
12
12
|
ast (2.4.2)
|
13
13
|
crack (0.4.5)
|
14
14
|
rexml
|
15
15
|
dead_end (1.1.6)
|
16
16
|
diff-lcs (1.4.4)
|
17
|
-
docker-api (2.
|
17
|
+
docker-api (2.2.0)
|
18
18
|
excon (>= 0.47.0)
|
19
19
|
multi_json
|
20
|
-
excon (0.
|
20
|
+
excon (0.87.0)
|
21
21
|
hashdiff (1.0.1)
|
22
22
|
multi_json (1.15.0)
|
23
23
|
parallel (1.20.1)
|
24
|
-
parallel_split_test (0.
|
24
|
+
parallel_split_test (0.10.0)
|
25
25
|
parallel (>= 0.5.13)
|
26
26
|
rspec-core (>= 3.9.0)
|
27
27
|
parser (3.0.1.0)
|
28
28
|
ast (~> 2.4.1)
|
29
29
|
public_suffix (4.0.6)
|
30
30
|
rainbow (3.0.0)
|
31
|
-
rake (13.0.
|
31
|
+
rake (13.0.6)
|
32
32
|
regexp_parser (2.1.1)
|
33
33
|
rexml (3.2.5)
|
34
34
|
rspec (3.10.0)
|
@@ -63,8 +63,8 @@ GEM
|
|
63
63
|
rubocop (= 1.12.1)
|
64
64
|
rubocop-performance (= 1.10.1)
|
65
65
|
unicode-display_width (2.0.0)
|
66
|
-
webmock (3.
|
67
|
-
addressable (>= 2.
|
66
|
+
webmock (3.14.0)
|
67
|
+
addressable (>= 2.8.0)
|
68
68
|
crack (>= 0.3.2)
|
69
69
|
hashdiff (>= 0.4.0, < 2.0.0)
|
70
70
|
yard (0.9.26)
|
@@ -85,4 +85,4 @@ DEPENDENCIES
|
|
85
85
|
yard
|
86
86
|
|
87
87
|
BUNDLED WITH
|
88
|
-
2.2.
|
88
|
+
2.2.22
|
data/README.md
CHANGED
@@ -92,7 +92,7 @@ Cutlass::App.new("ruby-getting-started").transaction do |app|
|
|
92
92
|
#
|
93
93
|
# Basically there's a ton of caveats to using this feature. Tread lightly.
|
94
94
|
app.start_container(expose_ports: [8080]) do |container|
|
95
|
-
response = Excon.get("http://localhost:#{container.
|
95
|
+
response = Excon.get("http://localhost:#{container.get_host_port(8080)}/", :idempotent => true, :retry_limit => 5, :retry_interval => 1)
|
96
96
|
expect(response.body).to eq("Welcome to rails")
|
97
97
|
|
98
98
|
# Warning, this does not use the CNB entrypoint so it's in a different dir
|
@@ -169,7 +169,7 @@ An instance of BashResult is returned whenever Cutlass interacts with the shell
|
|
169
169
|
|
170
170
|
Once built an app can `app.start_container` to yield a ContainerControl object.
|
171
171
|
|
172
|
-
- `container.
|
172
|
+
- `container.get_host_port(<port>)` Returns the port on the host machine (your computer, not docker) that docker is bound to
|
173
173
|
- Warning: These following commands do not use the CNB entry point so CNB env vars are not loaded and it my be a different dir than you're expecting
|
174
174
|
- `container.bash_exec(<command>)` Executes a bash command inside of a running container. Returns a BashResult object. By default this will raise an exception if the command returns non-zero exit code. Use kwarg `container.bash_exec(<command>, exception_on_failure: false)` to disable. Returns a BashResult object.
|
175
175
|
- `container.contains_file?(<file path>)` Checks to see if a given file exists on disk. Returns a BashResult object
|
data/lib/cutlass/app.rb
CHANGED
@@ -90,10 +90,15 @@ module Cutlass
|
|
90
90
|
on_teardown { thread.join }
|
91
91
|
end
|
92
92
|
|
93
|
-
def start_container(expose_ports: [])
|
93
|
+
def start_container(env: {}, expose_ports: [], memory: nil)
|
94
94
|
raise "No block given" unless block_given?
|
95
95
|
|
96
|
-
ContainerBoot.new(
|
96
|
+
ContainerBoot.new(
|
97
|
+
image_id: last_build.image_id,
|
98
|
+
env: env,
|
99
|
+
expose_ports: expose_ports,
|
100
|
+
memory: memory
|
101
|
+
).call do |container|
|
97
102
|
yield container
|
98
103
|
end
|
99
104
|
end
|
@@ -33,7 +33,7 @@ module Cutlass
|
|
33
33
|
# container. It does not execute the container's entrypoint. That means if you're running
|
34
34
|
# inside of a CNB image, that env vars won't be set and the directory might be different.
|
35
35
|
class ContainerBoot
|
36
|
-
def initialize(image_id:, expose_ports: [])
|
36
|
+
def initialize(image_id:, env: {}, expose_ports: [], memory: nil)
|
37
37
|
@expose_ports = Array(expose_ports)
|
38
38
|
config = {
|
39
39
|
"Image" => image_id,
|
@@ -52,6 +52,8 @@ module Cutlass
|
|
52
52
|
port_bindings["#{port}/tcp"] = [{"HostPort" => ""}]
|
53
53
|
end
|
54
54
|
|
55
|
+
config["Memory"] = memory.to_i if memory
|
56
|
+
config["Env"] = env.map { |k, v| "#{k}=#{v}" }
|
55
57
|
@container = Docker::Container.create(config)
|
56
58
|
end
|
57
59
|
|
@@ -14,6 +14,13 @@ module Cutlass
|
|
14
14
|
@ports = ports
|
15
15
|
end
|
16
16
|
|
17
|
+
def logs
|
18
|
+
stdout = @container.logs(stdout: 1)
|
19
|
+
stderr = @container.logs(stderr: 1)
|
20
|
+
|
21
|
+
BashResult.new(stdout: stdout, stderr: stderr, status: 0)
|
22
|
+
end
|
23
|
+
|
17
24
|
def get_host_port(port)
|
18
25
|
raise "Port not bound inside container: #{port}, bound ports: #{@ports.inspect}" unless @ports.include?(port)
|
19
26
|
@container.json["NetworkSettings"]["Ports"]["#{port}/tcp"][0]["HostPort"]
|
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "json"
|
2
4
|
require "base64"
|
5
|
+
require "cgi"
|
3
6
|
|
4
7
|
module Cutlass
|
5
8
|
# The purpose of this class is to trigger "Salesforce Functions"
|
@@ -13,11 +16,14 @@ module Cutlass
|
|
13
16
|
# end
|
14
17
|
#
|
15
18
|
class FunctionQuery
|
16
|
-
|
19
|
+
attr_reader :io
|
20
|
+
|
21
|
+
def initialize(port:, spec_version: nil, body: {}, io: Kernel)
|
17
22
|
@send_body = body
|
18
23
|
@port = port
|
19
24
|
@response = nil
|
20
25
|
@spec_version = spec_version || "1.0"
|
26
|
+
@io = io
|
21
27
|
end
|
22
28
|
|
23
29
|
def call
|
@@ -48,6 +54,12 @@ module Cutlass
|
|
48
54
|
|
49
55
|
def as_json
|
50
56
|
JSON.parse(body || "")
|
57
|
+
rescue JSON::ParserError => e
|
58
|
+
io.warn "Body: #{body}"
|
59
|
+
io.warn "Code: #{response&.status}"
|
60
|
+
io.warn "Headers: #{response&.headers.inspect}"
|
61
|
+
io.warn "x-extra-info: #{CGI.unescape(response&.headers&.[]("x-extra-info") || "")}"
|
62
|
+
raise e
|
51
63
|
end
|
52
64
|
|
53
65
|
def body
|
data/lib/cutlass/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cutlass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- schneems
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.
|
95
|
+
rubygems_version: 3.1.4
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Write CNB integration tests for Pack in Ruby with cutlass
|