makit 0.0.144 → 0.0.145
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +41 -41
- data/exe/makit +5 -5
- data/lib/makit/apache.rb +28 -28
- data/lib/makit/auto.rb +48 -48
- data/lib/makit/cli/base.rb +17 -0
- data/lib/makit/cli/build_commands.rb +500 -500
- data/lib/makit/cli/generators/base_generator.rb +74 -74
- data/lib/makit/cli/generators/dotnet_generator.rb +50 -50
- data/lib/makit/cli/generators/generator_factory.rb +49 -49
- data/lib/makit/cli/generators/node_generator.rb +50 -50
- data/lib/makit/cli/generators/ruby_generator.rb +77 -77
- data/lib/makit/cli/generators/rust_generator.rb +50 -50
- data/lib/makit/cli/generators/templates/dotnet_templates.rb +167 -167
- data/lib/makit/cli/generators/templates/node_templates.rb +161 -161
- data/lib/makit/cli/generators/templates/ruby/gemfile.rb +26 -26
- data/lib/makit/cli/generators/templates/ruby/gemspec.rb +41 -40
- data/lib/makit/cli/generators/templates/ruby/main_lib.rb +33 -33
- data/lib/makit/cli/generators/templates/ruby/rakefile.rb +35 -35
- data/lib/makit/cli/generators/templates/ruby/readme.rb +63 -63
- data/lib/makit/cli/generators/templates/ruby/test.rb +39 -39
- data/lib/makit/cli/generators/templates/ruby/test_helper.rb +29 -29
- data/lib/makit/cli/generators/templates/ruby/version.rb +29 -29
- data/lib/makit/cli/generators/templates/rust_templates.rb +128 -128
- data/lib/makit/cli/main.rb +78 -69
- data/lib/makit/cli/pipeline_commands.rb +311 -0
- data/lib/makit/cli/project_commands.rb +868 -868
- data/lib/makit/cli/repository_commands.rb +661 -661
- data/lib/makit/cli/strategy_commands.rb +207 -212
- data/lib/makit/cli/utility_commands.rb +521 -521
- data/lib/makit/commands/factory.rb +359 -359
- data/lib/makit/commands/middleware/base.rb +73 -73
- data/lib/makit/commands/middleware/cache.rb +248 -248
- data/lib/makit/commands/middleware/command_logger.rb +312 -312
- data/lib/makit/commands/middleware/validator.rb +269 -269
- data/lib/makit/commands/request.rb +316 -316
- data/lib/makit/commands/result.rb +323 -323
- data/lib/makit/commands/runner.rb +386 -386
- data/lib/makit/commands/strategies/base.rb +171 -171
- data/lib/makit/commands/strategies/child_process.rb +162 -162
- data/lib/makit/commands/strategies/factory.rb +136 -136
- data/lib/makit/commands/strategies/synchronous.rb +139 -139
- data/lib/makit/commands.rb +50 -50
- data/lib/makit/configuration/dotnet_project.rb +48 -48
- data/lib/makit/configuration/gitlab_helper.rb +61 -58
- data/lib/makit/configuration/project.rb +446 -168
- data/lib/makit/configuration/rakefile_helper.rb +43 -43
- data/lib/makit/configuration/step.rb +34 -34
- data/lib/makit/configuration/timeout.rb +74 -74
- data/lib/makit/configuration.rb +21 -16
- data/lib/makit/content/default_gitignore.rb +7 -7
- data/lib/makit/content/default_gitignore.txt +225 -225
- data/lib/makit/content/default_rakefile.rb +13 -13
- data/lib/makit/content/gem_rakefile.rb +16 -16
- data/lib/makit/context.rb +1 -1
- data/lib/makit/data.rb +49 -49
- data/lib/makit/directories.rb +140 -140
- data/lib/makit/directory.rb +262 -262
- data/lib/makit/docs/files.rb +89 -89
- data/lib/makit/docs/rake.rb +102 -102
- data/lib/makit/dotnet/cli.rb +69 -69
- data/lib/makit/dotnet/project.rb +217 -217
- data/lib/makit/dotnet/solution.rb +38 -38
- data/lib/makit/dotnet/solution_classlib.rb +239 -239
- data/lib/makit/dotnet/solution_console.rb +264 -264
- data/lib/makit/dotnet/solution_maui.rb +354 -354
- data/lib/makit/dotnet/solution_wasm.rb +275 -275
- data/lib/makit/dotnet/solution_wpf.rb +304 -304
- data/lib/makit/dotnet.rb +102 -102
- data/lib/makit/email.rb +90 -90
- data/lib/makit/environment.rb +142 -142
- data/lib/makit/examples/runner.rb +370 -370
- data/lib/makit/exceptions.rb +45 -45
- data/lib/makit/fileinfo.rb +32 -24
- data/lib/makit/files.rb +43 -43
- data/lib/makit/gems.rb +40 -40
- data/lib/makit/git/cli.rb +54 -54
- data/lib/makit/git/repository.rb +266 -90
- data/lib/makit/git.rb +104 -98
- data/lib/makit/gitlab/pipeline.rb +857 -0
- data/lib/makit/gitlab/pipeline_service_impl.rb +1536 -0
- data/lib/makit/gitlab_runner.rb +59 -59
- data/lib/makit/humanize.rb +218 -137
- data/lib/makit/indexer.rb +47 -47
- data/lib/makit/io/filesystem.rb +111 -0
- data/lib/makit/io/filesystem_service_impl.rb +337 -0
- data/lib/makit/logging/configuration.rb +308 -308
- data/lib/makit/logging/format_registry.rb +84 -84
- data/lib/makit/logging/formatters/base.rb +39 -39
- data/lib/makit/logging/formatters/console_formatter.rb +140 -140
- data/lib/makit/logging/formatters/json_formatter.rb +65 -65
- data/lib/makit/logging/formatters/plain_text_formatter.rb +71 -71
- data/lib/makit/logging/formatters/text_formatter.rb +64 -64
- data/lib/makit/logging/log_request.rb +119 -119
- data/lib/makit/logging/logger.rb +199 -199
- data/lib/makit/logging/sinks/base.rb +91 -91
- data/lib/makit/logging/sinks/console.rb +72 -72
- data/lib/makit/logging/sinks/file_sink.rb +92 -92
- data/lib/makit/logging/sinks/structured.rb +123 -123
- data/lib/makit/logging/sinks/unified_file_sink.rb +296 -296
- data/lib/makit/logging.rb +565 -565
- data/lib/makit/markdown.rb +75 -75
- data/lib/makit/mp/basic_object_mp.rb +17 -17
- data/lib/makit/mp/command_mp.rb +13 -13
- data/lib/makit/mp/command_request.mp.rb +17 -17
- data/lib/makit/mp/project_mp.rb +199 -199
- data/lib/makit/mp/string_mp.rb +205 -199
- data/lib/makit/nuget.rb +74 -74
- data/lib/makit/podman/podman.rb +458 -0
- data/lib/makit/podman/podman_service_impl.rb +1081 -0
- data/lib/makit/port.rb +32 -32
- data/lib/makit/process.rb +377 -377
- data/lib/makit/protoc.rb +112 -107
- data/lib/makit/rake/cli.rb +196 -196
- data/lib/makit/rake/trace_controller.rb +174 -174
- data/lib/makit/rake.rb +81 -81
- data/lib/makit/ruby/cli.rb +185 -185
- data/lib/makit/ruby.rb +25 -25
- data/lib/makit/secrets.rb +51 -51
- data/lib/makit/serializer.rb +130 -130
- data/lib/makit/services/builder.rb +186 -186
- data/lib/makit/services/error_handler.rb +226 -226
- data/lib/makit/services/repository_manager.rb +367 -231
- data/lib/makit/services/validator.rb +112 -112
- data/lib/makit/setup/classlib.rb +101 -101
- data/lib/makit/setup/gem.rb +268 -268
- data/lib/makit/setup/pages.rb +11 -11
- data/lib/makit/setup/razorclasslib.rb +101 -101
- data/lib/makit/setup/runner.rb +54 -54
- data/lib/makit/setup.rb +5 -5
- data/lib/makit/show.rb +110 -110
- data/lib/makit/storage.rb +126 -126
- data/lib/makit/symbols.rb +175 -170
- data/lib/makit/task_info.rb +130 -130
- data/lib/makit/tasks/at_exit.rb +15 -15
- data/lib/makit/tasks/build.rb +22 -22
- data/lib/makit/tasks/clean.rb +13 -13
- data/lib/makit/tasks/configure.rb +10 -10
- data/lib/makit/tasks/format.rb +10 -10
- data/lib/makit/tasks/hook_manager.rb +443 -443
- data/lib/makit/tasks/init.rb +49 -49
- data/lib/makit/tasks/integrate.rb +29 -29
- data/lib/makit/tasks/pull_incoming.rb +13 -13
- data/lib/makit/tasks/setup.rb +16 -16
- data/lib/makit/tasks/sync.rb +17 -17
- data/lib/makit/tasks/tag.rb +16 -16
- data/lib/makit/tasks/task_monkey_patch.rb +81 -81
- data/lib/makit/tasks/test.rb +22 -22
- data/lib/makit/tasks/update.rb +18 -18
- data/lib/makit/tasks.rb +20 -20
- data/lib/makit/test_cache.rb +239 -239
- data/lib/makit/tree.rb +37 -37
- data/lib/makit/v1/configuration/project_service_impl.rb +371 -0
- data/lib/makit/v1/git/git_repository_service_impl.rb +295 -0
- data/lib/makit/v1/makit.v1_pb.rb +35 -35
- data/lib/makit/v1/makit.v1_services_pb.rb +27 -27
- data/lib/makit/v1/services/repository_manager_service_impl.rb +572 -0
- data/lib/makit/version.rb +100 -100
- data/lib/makit/version_util.rb +21 -21
- data/lib/makit/wix.rb +95 -95
- data/lib/makit/yaml.rb +29 -29
- data/lib/makit/zip.rb +17 -17
- data/lib/makit copy.rb +44 -44
- data/lib/makit.rb +111 -43
- metadata +61 -36
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "podman_service_impl"
|
|
4
|
+
|
|
5
|
+
module Makit
|
|
6
|
+
module Podman
|
|
7
|
+
class Podman
|
|
8
|
+
def initialize(podman_executable: "podman")
|
|
9
|
+
@service = PodmanServiceImpl.new(podman_executable: podman_executable)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# High-level convenience methods
|
|
13
|
+
def pull_image(image_name, tag: "latest", force: false)
|
|
14
|
+
request = if grpc_available?
|
|
15
|
+
Podman::Service::PullImageRequest.new(
|
|
16
|
+
image_name: image_name,
|
|
17
|
+
tag: tag,
|
|
18
|
+
force: force
|
|
19
|
+
)
|
|
20
|
+
else
|
|
21
|
+
{
|
|
22
|
+
image_name: image_name,
|
|
23
|
+
tag: tag,
|
|
24
|
+
force: force
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
@service.pull_image(request)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def list_images(all: false, filter: nil)
|
|
32
|
+
request = if grpc_available?
|
|
33
|
+
Podman::Service::ListImagesRequest.new(
|
|
34
|
+
all: all,
|
|
35
|
+
filter: filter
|
|
36
|
+
)
|
|
37
|
+
else
|
|
38
|
+
{
|
|
39
|
+
all: all,
|
|
40
|
+
filter: filter
|
|
41
|
+
}
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
@service.list_images(request)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def remove_image(image_id, force: false)
|
|
48
|
+
request = if grpc_available?
|
|
49
|
+
Podman::Service::RemoveImageRequest.new(
|
|
50
|
+
image_id: image_id,
|
|
51
|
+
force: force
|
|
52
|
+
)
|
|
53
|
+
else
|
|
54
|
+
{
|
|
55
|
+
image_id: image_id,
|
|
56
|
+
force: force
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
@service.remove_image(request)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def inspect_image(image_id)
|
|
64
|
+
request = if grpc_available?
|
|
65
|
+
Podman::Service::InspectImageRequest.new(
|
|
66
|
+
image_id: image_id
|
|
67
|
+
)
|
|
68
|
+
else
|
|
69
|
+
{
|
|
70
|
+
image_id: image_id
|
|
71
|
+
}
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
@service.inspect_image(request)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def create_container(name:, image:, **options)
|
|
78
|
+
request = if grpc_available?
|
|
79
|
+
Podman::Service::CreateContainerRequest.new(
|
|
80
|
+
name: name,
|
|
81
|
+
image: image,
|
|
82
|
+
command: options[:command] || [],
|
|
83
|
+
args: options[:args] || [],
|
|
84
|
+
environment: options[:environment] || {},
|
|
85
|
+
volume_mounts: options[:volume_mounts] || [],
|
|
86
|
+
port_mappings: options[:port_mappings] || [],
|
|
87
|
+
working_directory: options[:working_directory],
|
|
88
|
+
user: options[:user],
|
|
89
|
+
privileged: options[:privileged] || false,
|
|
90
|
+
capabilities: options[:capabilities] || [],
|
|
91
|
+
labels: options[:labels] || {},
|
|
92
|
+
auto_remove: options[:auto_remove] || false,
|
|
93
|
+
memory_limit: options[:memory_limit] || 0,
|
|
94
|
+
cpu_limit: options[:cpu_limit] || 0
|
|
95
|
+
)
|
|
96
|
+
else
|
|
97
|
+
{
|
|
98
|
+
name: name,
|
|
99
|
+
image: image,
|
|
100
|
+
command: options[:command] || [],
|
|
101
|
+
args: options[:args] || [],
|
|
102
|
+
environment: options[:environment] || {},
|
|
103
|
+
volume_mounts: options[:volume_mounts] || [],
|
|
104
|
+
port_mappings: options[:port_mappings] || [],
|
|
105
|
+
working_directory: options[:working_directory],
|
|
106
|
+
user: options[:user],
|
|
107
|
+
privileged: options[:privileged] || false,
|
|
108
|
+
capabilities: options[:capabilities] || [],
|
|
109
|
+
labels: options[:labels] || {},
|
|
110
|
+
auto_remove: options[:auto_remove] || false,
|
|
111
|
+
memory_limit: options[:memory_limit] || 0,
|
|
112
|
+
cpu_limit: options[:cpu_limit] || 0
|
|
113
|
+
}
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
@service.create_container(request)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def start_container(container_id)
|
|
120
|
+
request = if grpc_available?
|
|
121
|
+
Podman::Service::StartContainerRequest.new(
|
|
122
|
+
container_id: container_id
|
|
123
|
+
)
|
|
124
|
+
else
|
|
125
|
+
{
|
|
126
|
+
container_id: container_id
|
|
127
|
+
}
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
@service.start_container(request)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def stop_container(container_id, timeout_seconds: 10)
|
|
134
|
+
request = if grpc_available?
|
|
135
|
+
Podman::Service::StopContainerRequest.new(
|
|
136
|
+
container_id: container_id,
|
|
137
|
+
timeout_seconds: timeout_seconds
|
|
138
|
+
)
|
|
139
|
+
else
|
|
140
|
+
{
|
|
141
|
+
container_id: container_id,
|
|
142
|
+
timeout_seconds: timeout_seconds
|
|
143
|
+
}
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
@service.stop_container(request)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def remove_container(container_id, force: false)
|
|
150
|
+
request = if grpc_available?
|
|
151
|
+
Podman::Service::RemoveContainerRequest.new(
|
|
152
|
+
container_id: container_id,
|
|
153
|
+
force: force
|
|
154
|
+
)
|
|
155
|
+
else
|
|
156
|
+
{
|
|
157
|
+
container_id: container_id,
|
|
158
|
+
force: force
|
|
159
|
+
}
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
@service.remove_container(request)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def list_containers(all: false, filter: nil)
|
|
166
|
+
request = if grpc_available?
|
|
167
|
+
Podman::Service::ListContainersRequest.new(
|
|
168
|
+
all: all,
|
|
169
|
+
filter: filter
|
|
170
|
+
)
|
|
171
|
+
else
|
|
172
|
+
{
|
|
173
|
+
all: all,
|
|
174
|
+
filter: filter
|
|
175
|
+
}
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
@service.list_containers(request)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def inspect_container(container_id)
|
|
182
|
+
request = if grpc_available?
|
|
183
|
+
Podman::Service::InspectContainerRequest.new(
|
|
184
|
+
container_id: container_id
|
|
185
|
+
)
|
|
186
|
+
else
|
|
187
|
+
{
|
|
188
|
+
container_id: container_id
|
|
189
|
+
}
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
@service.inspect_container(request)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def run_script(image, script_content, **options)
|
|
196
|
+
# Create container
|
|
197
|
+
container_request = if grpc_available?
|
|
198
|
+
Podman::Service::CreateContainerRequest.new(
|
|
199
|
+
name: options[:name] || "makit-#{SecureRandom.uuid}",
|
|
200
|
+
image: image,
|
|
201
|
+
command: ["sleep", "infinity"],
|
|
202
|
+
environment: options[:environment] || {},
|
|
203
|
+
volume_mounts: options[:volume_mounts] || [],
|
|
204
|
+
working_directory: options[:working_directory] || "/tmp",
|
|
205
|
+
auto_remove: false
|
|
206
|
+
)
|
|
207
|
+
else
|
|
208
|
+
{
|
|
209
|
+
name: options[:name] || "makit-#{SecureRandom.uuid}",
|
|
210
|
+
image: image,
|
|
211
|
+
command: ["sleep", "infinity"],
|
|
212
|
+
environment: options[:environment] || {},
|
|
213
|
+
volume_mounts: options[:volume_mounts] || [],
|
|
214
|
+
working_directory: options[:working_directory] || "/tmp",
|
|
215
|
+
auto_remove: false
|
|
216
|
+
}
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
container_response = @service.create_container(container_request)
|
|
220
|
+
return container_response unless container_response.respond_to?(:success) ? container_response.success : container_response[:success]
|
|
221
|
+
|
|
222
|
+
# Start container
|
|
223
|
+
container_id = container_response.respond_to?(:container_id) ? container_response.container_id : container_response[:container_id]
|
|
224
|
+
start_response = start_container(container_id)
|
|
225
|
+
return start_response unless start_response.respond_to?(:success) ? start_response.success : start_response[:success]
|
|
226
|
+
|
|
227
|
+
# Execute script
|
|
228
|
+
script_request = if grpc_available?
|
|
229
|
+
Podman::Service::ExecuteScriptRequest.new(
|
|
230
|
+
container_id: container_response.respond_to?(:container_id) ? container_response.container_id : container_response[:container_id],
|
|
231
|
+
script_content: script_content,
|
|
232
|
+
environment: options[:environment] || [],
|
|
233
|
+
working_directory: options[:working_directory] || "/tmp",
|
|
234
|
+
timeout_seconds: options[:timeout] || 300,
|
|
235
|
+
capture_output: options[:capture_output] != false,
|
|
236
|
+
capture_errors: options[:capture_errors] != false
|
|
237
|
+
)
|
|
238
|
+
else
|
|
239
|
+
{
|
|
240
|
+
container_id: container_response.respond_to?(:container_id) ? container_response.container_id : container_response[:container_id],
|
|
241
|
+
script_content: script_content,
|
|
242
|
+
environment: options[:environment] || [],
|
|
243
|
+
working_directory: options[:working_directory] || "/tmp",
|
|
244
|
+
timeout_seconds: options[:timeout] || 300,
|
|
245
|
+
capture_output: options[:capture_output] != false,
|
|
246
|
+
capture_errors: options[:capture_errors] != false
|
|
247
|
+
}
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
result = @service.execute_script(script_request)
|
|
251
|
+
|
|
252
|
+
# Cleanup container
|
|
253
|
+
remove_container(container_response.respond_to?(:container_id) ? container_response.container_id : container_response[:container_id], force: true)
|
|
254
|
+
|
|
255
|
+
result
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def run_command(image, command, **options)
|
|
259
|
+
request = if grpc_available?
|
|
260
|
+
Podman::Service::RunContainerRequest.new(
|
|
261
|
+
image: image,
|
|
262
|
+
command: command,
|
|
263
|
+
args: options[:args] || [],
|
|
264
|
+
environment: options[:environment] || {},
|
|
265
|
+
volume_mounts: options[:volume_mounts] || [],
|
|
266
|
+
port_mappings: options[:port_mappings] || [],
|
|
267
|
+
working_directory: options[:working_directory] || "/tmp",
|
|
268
|
+
user: options[:user],
|
|
269
|
+
auto_remove: options[:auto_remove] != false,
|
|
270
|
+
interactive: options[:interactive] || false,
|
|
271
|
+
tty: options[:tty] || false,
|
|
272
|
+
timeout_seconds: options[:timeout] || 300,
|
|
273
|
+
capture_output: options[:capture_output] != false,
|
|
274
|
+
capture_errors: options[:capture_errors] != false,
|
|
275
|
+
labels: options[:labels] || {}
|
|
276
|
+
)
|
|
277
|
+
else
|
|
278
|
+
{
|
|
279
|
+
image: image,
|
|
280
|
+
command: command,
|
|
281
|
+
args: options[:args] || [],
|
|
282
|
+
environment: options[:environment] || {},
|
|
283
|
+
volume_mounts: options[:volume_mounts] || [],
|
|
284
|
+
port_mappings: options[:port_mappings] || [],
|
|
285
|
+
working_directory: options[:working_directory] || "/tmp",
|
|
286
|
+
user: options[:user],
|
|
287
|
+
auto_remove: options[:auto_remove] != false,
|
|
288
|
+
interactive: options[:interactive] || false,
|
|
289
|
+
tty: options[:tty] || false,
|
|
290
|
+
timeout_seconds: options[:timeout] || 300,
|
|
291
|
+
capture_output: options[:capture_output] != false,
|
|
292
|
+
capture_errors: options[:capture_errors] != false,
|
|
293
|
+
labels: options[:labels] || {}
|
|
294
|
+
}
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
@service.run_container(request)
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
def execute_script_in_container(container_id, script_content, **options)
|
|
301
|
+
request = if grpc_available?
|
|
302
|
+
Podman::Service::ExecuteScriptRequest.new(
|
|
303
|
+
container_id: container_id,
|
|
304
|
+
script_content: script_content,
|
|
305
|
+
environment: options[:environment] || [],
|
|
306
|
+
working_directory: options[:working_directory],
|
|
307
|
+
user: options[:user],
|
|
308
|
+
timeout_seconds: options[:timeout] || 300,
|
|
309
|
+
capture_output: options[:capture_output] != false,
|
|
310
|
+
capture_errors: options[:capture_errors] != false
|
|
311
|
+
)
|
|
312
|
+
else
|
|
313
|
+
{
|
|
314
|
+
container_id: container_id,
|
|
315
|
+
script_content: script_content,
|
|
316
|
+
environment: options[:environment] || [],
|
|
317
|
+
working_directory: options[:working_directory],
|
|
318
|
+
user: options[:user],
|
|
319
|
+
timeout_seconds: options[:timeout] || 300,
|
|
320
|
+
capture_output: options[:capture_output] != false,
|
|
321
|
+
capture_errors: options[:capture_errors] != false
|
|
322
|
+
}
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
@service.execute_script(request)
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def execute_command_in_container(container_id, command, **options)
|
|
329
|
+
request = if grpc_available?
|
|
330
|
+
Podman::Service::ExecuteCommandRequest.new(
|
|
331
|
+
container_id: container_id,
|
|
332
|
+
command: command,
|
|
333
|
+
environment: options[:environment] || [],
|
|
334
|
+
working_directory: options[:working_directory],
|
|
335
|
+
user: options[:user],
|
|
336
|
+
timeout_seconds: options[:timeout] || 300,
|
|
337
|
+
capture_output: options[:capture_output] != false,
|
|
338
|
+
capture_errors: options[:capture_errors] != false
|
|
339
|
+
)
|
|
340
|
+
else
|
|
341
|
+
{
|
|
342
|
+
container_id: container_id,
|
|
343
|
+
command: command,
|
|
344
|
+
environment: options[:environment] || [],
|
|
345
|
+
working_directory: options[:working_directory],
|
|
346
|
+
user: options[:user],
|
|
347
|
+
timeout_seconds: options[:timeout] || 300,
|
|
348
|
+
capture_output: options[:capture_output] != false,
|
|
349
|
+
capture_errors: options[:capture_errors] != false
|
|
350
|
+
}
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
@service.execute_command(request)
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def create_volume(name:, **options)
|
|
357
|
+
request = if grpc_available?
|
|
358
|
+
Podman::Service::CreateVolumeRequest.new(
|
|
359
|
+
name: name,
|
|
360
|
+
driver: options[:driver],
|
|
361
|
+
labels: options[:labels] || {},
|
|
362
|
+
options: options[:options] || {}
|
|
363
|
+
)
|
|
364
|
+
else
|
|
365
|
+
{
|
|
366
|
+
name: name,
|
|
367
|
+
driver: options[:driver],
|
|
368
|
+
labels: options[:labels] || {},
|
|
369
|
+
options: options[:options] || {}
|
|
370
|
+
}
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
@service.create_volume(request)
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
def list_volumes(filter: nil)
|
|
377
|
+
request = if grpc_available?
|
|
378
|
+
Podman::Service::ListVolumesRequest.new(
|
|
379
|
+
filter: filter
|
|
380
|
+
)
|
|
381
|
+
else
|
|
382
|
+
{
|
|
383
|
+
filter: filter
|
|
384
|
+
}
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
@service.list_volumes(request)
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def remove_volume(volume_name, force: false)
|
|
391
|
+
request = if grpc_available?
|
|
392
|
+
Podman::Service::RemoveVolumeRequest.new(
|
|
393
|
+
volume_name: volume_name,
|
|
394
|
+
force: force
|
|
395
|
+
)
|
|
396
|
+
else
|
|
397
|
+
{
|
|
398
|
+
volume_name: volume_name,
|
|
399
|
+
force: force
|
|
400
|
+
}
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
@service.remove_volume(request)
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
def health_check
|
|
407
|
+
@service.health_check(nil)
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
def version
|
|
411
|
+
@service.get_version(nil)
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
def system_info
|
|
415
|
+
@service.get_system_info(nil)
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
# Helper methods for creating common objects
|
|
419
|
+
def create_volume_mount(host_path:, container_path:, mode: "rw")
|
|
420
|
+
if grpc_available?
|
|
421
|
+
Podman::Service::VolumeMount.new(
|
|
422
|
+
host_path: host_path,
|
|
423
|
+
container_path: container_path,
|
|
424
|
+
mode: mode
|
|
425
|
+
)
|
|
426
|
+
else
|
|
427
|
+
{
|
|
428
|
+
host_path: host_path,
|
|
429
|
+
container_path: container_path,
|
|
430
|
+
mode: mode
|
|
431
|
+
}
|
|
432
|
+
end
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
def create_port_mapping(host_port:, container_port:, protocol: "tcp")
|
|
436
|
+
if grpc_available?
|
|
437
|
+
Podman::Service::PortMapping.new(
|
|
438
|
+
host_port: host_port,
|
|
439
|
+
container_port: container_port,
|
|
440
|
+
protocol: protocol
|
|
441
|
+
)
|
|
442
|
+
else
|
|
443
|
+
{
|
|
444
|
+
host_port: host_port,
|
|
445
|
+
container_port: container_port,
|
|
446
|
+
protocol: protocol
|
|
447
|
+
}
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
private
|
|
452
|
+
|
|
453
|
+
def grpc_available?
|
|
454
|
+
PodmanServiceImpl.grpc_available?
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
end
|
|
458
|
+
end
|