Class: DaggerRuby::Container

Inherits:
DaggerObject show all
Defined in:
lib/dagger_ruby/container.rb

Instance Attribute Summary

Attributes inherited from DaggerObject

#client, #query_builder

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DaggerObject

#chain_operation, from_id, #id, #initialize

Constructor Details

This class inherits a constructor from DaggerRuby::DaggerObject

Class Method Details

.root_field_nameObject



7
8
9
# File 'lib/dagger_ruby/container.rb', line 7

def self.root_field_name
  "container"
end

Instance Method Details

#as_service(opts = {}) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/dagger_ruby/container.rb', line 146

def as_service(opts = {})
  args = {}
  args["args"] = opts[:args] if opts[:args]
  args["useEntrypoint"] = opts[:use_entrypoint] if opts.key?(:use_entrypoint)
  if opts.key?(:experimental_privileged_nesting)
    args["experimentalPrivilegedNesting"] =
      opts[:experimental_privileged_nesting]
  end
  args["insecureRootCapabilities"] = opts[:insecure_root_capabilities] if opts.key?(:insecure_root_capabilities)
  args["expand"] = opts[:expand] if opts.key?(:expand)
  args["noInit"] = opts[:no_init] if opts.key?(:no_init)

  require_relative "service" unless defined?(Service)
  get_object("asService", Service, args)
end

#as_tarball(opts = {}) ⇒ Object



365
366
367
368
369
370
371
372
# File 'lib/dagger_ruby/container.rb', line 365

def as_tarball(opts = {})
  args = {}
  args["platformVariants"] = graphql_ids(opts[:platform_variants]) if opts[:platform_variants]
  args["forcedCompression"] = QueryBuilder.enum_value(opts[:forced_compression]) if opts[:forced_compression]
  args["mediaTypes"] = QueryBuilder.enum_value(opts[:media_types]) if opts[:media_types]

  get_object("asTarball", File, args)
end

#default_argsObject



282
283
284
# File 'lib/dagger_ruby/container.rb', line 282

def default_args
  get_scalar("defaultArgs")
end

#directory(path, opts = {}) ⇒ Object



246
247
248
249
250
# File 'lib/dagger_ruby/container.rb', line 246

def directory(path, opts = {})
  args = { "path" => path }
  args["expand"] = opts[:expand] if opts.key?(:expand)
  get_object("directory", Directory, args)
end

#docker_healthcheckObject



286
287
288
289
290
291
# File 'lib/dagger_ruby/container.rb', line 286

def docker_healthcheck
  get_selection(
    "dockerHealthcheck",
    "args shell interval timeout startPeriod startInterval retries",
  )
end

#entrypointObject



278
279
280
# File 'lib/dagger_ruby/container.rb', line 278

def entrypoint
  get_scalar("entrypoint")
end

#env_variable(name) ⇒ Object



297
298
299
# File 'lib/dagger_ruby/container.rb', line 297

def env_variable(name)
  get_scalar("envVariable", { "name" => name })
end

#env_variablesObject



293
294
295
# File 'lib/dagger_ruby/container.rb', line 293

def env_variables
  get_selection("envVariables", "name value")
end

#exit_codeObject



266
267
268
# File 'lib/dagger_ruby/container.rb', line 266

def exit_code
  get_scalar("exitCode")
end

#export(path, opts = {}) ⇒ Object



325
326
327
328
329
330
331
332
333
# File 'lib/dagger_ruby/container.rb', line 325

def export(path, opts = {})
  args = { "path" => path }
  args["platformVariants"] = graphql_ids(opts[:platform_variants]) if opts[:platform_variants]
  args["forcedCompression"] = QueryBuilder.enum_value(opts[:forced_compression]) if opts[:forced_compression]
  args["mediaTypes"] = QueryBuilder.enum_value(opts[:media_types]) if opts[:media_types]
  args["expand"] = opts[:expand] if opts.key?(:expand)

  get_scalar("export", args)
end

#export_image(name, opts = {}) ⇒ Object



339
340
341
342
343
344
345
346
347
# File 'lib/dagger_ruby/container.rb', line 339

def export_image(name, opts = {})
  args = { "name" => name }
  args["platformVariants"] = graphql_ids(opts[:platform_variants]) if opts[:platform_variants]
  args["forcedCompression"] = QueryBuilder.enum_value(opts[:forced_compression]) if opts[:forced_compression]
  args["mediaTypes"] = QueryBuilder.enum_value(opts[:media_types]) if opts[:media_types]

  get_scalar("exportImage", args)
  name
end

#export_to_file(path, opts = {}) ⇒ Object



335
336
337
# File 'lib/dagger_ruby/container.rb', line 335

def export_to_file(path, opts = {})
  export(path, opts)
end

#exposed_portsObject



313
314
315
# File 'lib/dagger_ruby/container.rb', line 313

def exposed_ports
  get_selection("exposedPorts", "port protocol description experimentalSkipHealthcheck")
end

#file(path, opts = {}) ⇒ Object



252
253
254
255
256
# File 'lib/dagger_ruby/container.rb', line 252

def file(path, opts = {})
  args = { "path" => path }
  args["expand"] = opts[:expand] if opts.key?(:expand)
  get_object("file", File, args)
end

#from(address) ⇒ Object



11
12
13
# File 'lib/dagger_ruby/container.rb', line 11

def from(address)
  chain_operation("from", { "address" => address })
end

#image_refObject



321
322
323
# File 'lib/dagger_ruby/container.rb', line 321

def image_ref
  get_scalar("imageRef")
end

#import(source, opts = {}) ⇒ Object



162
163
164
165
166
167
# File 'lib/dagger_ruby/container.rb', line 162

def import(source, opts = {})
  args = { "source" => source.is_a?(DaggerObject) ? source.id : source }
  args["tag"] = opts[:tag] if opts[:tag]

  chain_operation("import", args)
end

#label(name) ⇒ Object



305
306
307
# File 'lib/dagger_ruby/container.rb', line 305

def label(name)
  get_scalar("label", { "name" => name })
end

#labelsObject



301
302
303
# File 'lib/dagger_ruby/container.rb', line 301

def labels
  get_selection("labels", "name value")
end

#mountsObject



309
310
311
# File 'lib/dagger_ruby/container.rb', line 309

def mounts
  get_scalar("mounts")
end

#platformObject



317
318
319
# File 'lib/dagger_ruby/container.rb', line 317

def platform
  get_scalar("platform")
end

#publish(address, opts = {}) ⇒ Object



349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/dagger_ruby/container.rb', line 349

def publish(address, opts = {})
  args = { "address" => address }
  args["platformVariants"] = graphql_ids(opts[:platform_variants]) if opts[:platform_variants]
  args["forcedCompression"] = QueryBuilder.enum_value(opts[:forced_compression]) if opts[:forced_compression]
  args["mediaTypes"] = QueryBuilder.enum_value(opts[:media_types]) if opts[:media_types]

  if opts[:registry_service]
    args["registryService"] = if opts[:registry_service].is_a?(DaggerObject)
                                opts[:registry_service].id
                              else
                                opts[:registry_service]
                              end
  end
  get_scalar("publish", args)
end

#stderrObject



262
263
264
# File 'lib/dagger_ruby/container.rb', line 262

def stderr
  get_scalar("stderr")
end

#stdoutObject



258
259
260
# File 'lib/dagger_ruby/container.rb', line 258

def stdout
  get_scalar("stdout")
end

#syncObject



374
375
376
377
# File 'lib/dagger_ruby/container.rb', line 374

def sync
  get_scalar("id") # Force execution by getting ID
  self
end

#terminal(opts = {}) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/dagger_ruby/container.rb', line 169

def terminal(opts = {})
  args = {}
  args["cmd"] = opts[:cmd] if opts[:cmd]
  if opts.key?(:experimental_privileged_nesting)
    args["experimentalPrivilegedNesting"] =
      opts[:experimental_privileged_nesting]
  end
  args["insecureRootCapabilities"] = opts[:insecure_root_capabilities] if opts.key?(:insecure_root_capabilities)

  if args.empty?
    chain_operation("terminal")
  else
    chain_operation("terminal", args)
  end
end

#userObject



274
275
276
# File 'lib/dagger_ruby/container.rb', line 274

def user
  get_scalar("user")
end

#with_default_args(args) ⇒ Object



101
102
103
# File 'lib/dagger_ruby/container.rb', line 101

def with_default_args(args)
  chain_operation("withDefaultArgs", { "args" => args })
end

#with_directory(path, directory, opts = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dagger_ruby/container.rb', line 15

def with_directory(path, directory, opts = {})
  args = { "path" => path, "source" => directory.is_a?(DaggerObject) ? directory.id : directory }
  args["exclude"] = opts[:exclude] if opts[:exclude]
  args["include"] = opts[:include] if opts[:include]
  args["gitignore"] = opts[:gitignore] if opts[:gitignore]
  args["owner"] = opts[:owner] if opts[:owner]
  args["expand"] = opts[:expand] if opts.key?(:expand)
  args["permissions"] = opts[:permissions] if opts[:permissions]

  chain_operation("withDirectory", args)
end

#with_docker_healthcheck(args, opts = {}) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/dagger_ruby/container.rb', line 105

def with_docker_healthcheck(args, opts = {})
  healthcheck_args = { "args" => args }
  healthcheck_args["shell"] = opts[:shell] if opts.key?(:shell)
  healthcheck_args["interval"] = opts[:interval] if opts[:interval]
  healthcheck_args["timeout"] = opts[:timeout] if opts[:timeout]
  healthcheck_args["startPeriod"] = opts[:start_period] if opts[:start_period]
  healthcheck_args["startInterval"] = opts[:start_interval] if opts[:start_interval]
  healthcheck_args["retries"] = opts[:retries] if opts[:retries]

  chain_operation("withDockerHealthcheck", healthcheck_args)
end

#with_entrypoint(args, opts = {}) ⇒ Object



95
96
97
98
99
# File 'lib/dagger_ruby/container.rb', line 95

def with_entrypoint(args, opts = {})
  entrypoint_args = { "args" => args }
  entrypoint_args["keepDefaultArgs"] = opts[:keep_default_args] if opts.key?(:keep_default_args)
  chain_operation("withEntrypoint", entrypoint_args)
end

#with_env_variable(name, value, opts = {}) ⇒ Object



63
64
65
66
67
68
# File 'lib/dagger_ruby/container.rb', line 63

def with_env_variable(name, value, opts = {})
  args = { "name" => name, "value" => value }
  args["expand"] = opts[:expand] if opts.key?(:expand)

  chain_operation("withEnvVariable", args)
end

#with_exec(args, opts = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/dagger_ruby/container.rb', line 33

def with_exec(args, opts = {})
  exec_args = { "args" => args }
  exec_args["useEntrypoint"] = opts[:use_entrypoint] if opts.key?(:use_entrypoint)
  exec_args["stdin"] = opts[:stdin] if opts[:stdin]
  exec_args["redirectStdin"] = opts[:redirect_stdin] if opts[:redirect_stdin]
  exec_args["redirectStdout"] = opts[:redirect_stdout] if opts[:redirect_stdout]
  exec_args["redirectStderr"] = opts[:redirect_stderr] if opts[:redirect_stderr]
  exec_args["expect"] = QueryBuilder.enum_value(opts[:expect]) if opts[:expect]
  if opts.key?(:experimental_privileged_nesting)
    exec_args["experimentalPrivilegedNesting"] = opts[:experimental_privileged_nesting]
  end
  if opts.key?(:insecure_root_capabilities)
    exec_args["insecureRootCapabilities"] = opts[:insecure_root_capabilities]
  end
  exec_args["expand"] = opts[:expand] if opts.key?(:expand)
  exec_args["noInit"] = opts[:no_init] if opts.key?(:no_init)

  chain_operation("withExec", exec_args)
end

#with_exposed_port(port, opts = {}) ⇒ Object



185
186
187
188
189
190
191
192
193
194
# File 'lib/dagger_ruby/container.rb', line 185

def with_exposed_port(port, opts = {})
  args = { "port" => port }
  args["protocol"] = QueryBuilder.enum_value(opts[:protocol]) if opts[:protocol]
  args["description"] = opts[:description] if opts[:description]
  if opts.key?(:experimental_skip_healthcheck)
    args["experimentalSkipHealthcheck"] = opts[:experimental_skip_healthcheck]
  end

  chain_operation("withExposedPort", args)
end

#with_file(path, source, opts = {}) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/dagger_ruby/container.rb', line 70

def with_file(path, source, opts = {})
  args = { "path" => path, "source" => source.is_a?(DaggerObject) ? source.id : source }
  args["permissions"] = opts[:permissions] if opts[:permissions]
  args["owner"] = opts[:owner] if opts[:owner]
  args["expand"] = opts[:expand] if opts.key?(:expand)

  chain_operation("withFile", args)
end

#with_label(name, value) ⇒ Object



196
197
198
199
# File 'lib/dagger_ruby/container.rb', line 196

def with_label(name, value)
  args = { "name" => name, "value" => value }
  chain_operation("withLabel", args)
end

#with_mounted_cache(path, cache, opts = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/dagger_ruby/container.rb', line 53

def with_mounted_cache(path, cache, opts = {})
  args = { "path" => path, "cache" => cache.is_a?(DaggerObject) ? cache.id : cache }
  args["source"] = opts[:source] if opts[:source]
  args["sharing"] = QueryBuilder.enum_value(opts[:sharing]) if opts[:sharing]
  args["owner"] = opts[:owner] if opts[:owner]
  args["expand"] = opts[:expand] if opts.key?(:expand)

  chain_operation("withMountedCache", args)
end

#with_mounted_directory(path, source, opts = {}) ⇒ Object



201
202
203
204
205
206
207
208
# File 'lib/dagger_ruby/container.rb', line 201

def with_mounted_directory(path, source, opts = {})
  args = { "path" => path, "source" => source.is_a?(DaggerObject) ? source.id : source }
  args["owner"] = opts[:owner] if opts[:owner]
  args["readOnly"] = opts[:read_only] if opts.key?(:read_only)
  args["expand"] = opts[:expand] if opts.key?(:expand)

  chain_operation("withMountedDirectory", args)
end

#with_mounted_file(path, source, opts = {}) ⇒ Object



210
211
212
213
214
215
216
# File 'lib/dagger_ruby/container.rb', line 210

def with_mounted_file(path, source, opts = {})
  args = { "path" => path, "source" => source.is_a?(DaggerObject) ? source.id : source }
  args["owner"] = opts[:owner] if opts[:owner]
  args["expand"] = opts[:expand] if opts.key?(:expand)

  chain_operation("withMountedFile", args)
end

#with_mounted_secret(path, source, opts = {}) ⇒ Object



218
219
220
221
222
223
224
225
# File 'lib/dagger_ruby/container.rb', line 218

def with_mounted_secret(path, source, opts = {})
  args = { "path" => path, "source" => source.is_a?(DaggerObject) ? source.id : source }
  args["owner"] = opts[:owner] if opts[:owner]
  args["mode"] = opts[:mode] if opts[:mode]
  args["expand"] = opts[:expand] if opts.key?(:expand)

  chain_operation("withMountedSecret", args)
end

#with_new_file(path, contents, opts = {}) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/dagger_ruby/container.rb', line 79

def with_new_file(path, contents, opts = {})
  args = { "path" => path, "contents" => contents }
  args["permissions"] = opts[:permissions] if opts[:permissions]
  args["owner"] = opts[:owner] if opts[:owner]
  args["expand"] = opts[:expand] if opts.key?(:expand)

  chain_operation("withNewFile", args)
end

#with_registry_auth(address, username, secret) ⇒ Object



125
126
127
128
129
130
131
132
# File 'lib/dagger_ruby/container.rb', line 125

def with_registry_auth(address, username, secret)
  args = {
    "address" => address,
    "username" => username,
    "secret" => secret.is_a?(DaggerObject) ? secret.id : secret,
  }
  chain_operation("withRegistryAuth", args)
end

#with_secret_variable(name, secret) ⇒ Object Also known as: with_secret_env



88
89
90
91
# File 'lib/dagger_ruby/container.rb', line 88

def with_secret_variable(name, secret)
  args = { "name" => name, "secret" => secret.is_a?(DaggerObject) ? secret.id : secret }
  chain_operation("withSecretVariable", args)
end

#with_service_binding(alias_name, service) ⇒ Object



138
139
140
141
142
143
144
# File 'lib/dagger_ruby/container.rb', line 138

def with_service_binding(alias_name, service)
  args = {
    "alias" => alias_name,
    "service" => service.is_a?(DaggerObject) ? service.id : service,
  }
  chain_operation("withServiceBinding", args)
end

#with_user(name) ⇒ Object



121
122
123
# File 'lib/dagger_ruby/container.rb', line 121

def with_user(name)
  chain_operation("withUser", { "name" => name })
end

#with_workdir(path, expand: nil) ⇒ Object



27
28
29
30
31
# File 'lib/dagger_ruby/container.rb', line 27

def with_workdir(path, expand: nil)
  args = { "path" => path }
  args["expand"] = expand unless expand.nil?
  chain_operation("withWorkdir", args)
end

#without_directory(path) ⇒ Object



227
228
229
# File 'lib/dagger_ruby/container.rb', line 227

def without_directory(path)
  chain_operation("withoutDirectory", { "path" => path })
end

#without_docker_healthcheckObject



117
118
119
# File 'lib/dagger_ruby/container.rb', line 117

def without_docker_healthcheck
  chain_operation("withoutDockerHealthcheck")
end

#without_env_variable(name) ⇒ Object



235
236
237
# File 'lib/dagger_ruby/container.rb', line 235

def without_env_variable(name)
  chain_operation("withoutEnvVariable", { "name" => name })
end

#without_exposed_port(port, opts = {}) ⇒ Object



239
240
241
242
243
244
# File 'lib/dagger_ruby/container.rb', line 239

def without_exposed_port(port, opts = {})
  args = { "port" => port }
  args["protocol"] = QueryBuilder.enum_value(opts[:protocol]) if opts[:protocol]

  chain_operation("withoutExposedPort", args)
end

#without_file(path) ⇒ Object



231
232
233
# File 'lib/dagger_ruby/container.rb', line 231

def without_file(path)
  chain_operation("withoutFile", { "path" => path })
end

#without_registry_auth(address) ⇒ Object



134
135
136
# File 'lib/dagger_ruby/container.rb', line 134

def without_registry_auth(address)
  chain_operation("withoutRegistryAuth", { "address" => address })
end

#workdirObject



270
271
272
# File 'lib/dagger_ruby/container.rb', line 270

def workdir
  get_scalar("workdir")
end