Class: DaggerRuby::Directory

Inherits:
DaggerObject show all
Defined in:
lib/dagger_ruby/directory.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

.load_from_host(path, client, opts = {}) ⇒ Object



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

def self.load_from_host(path, client, opts = {})
  args = { "path" => path }
  args["exclude"] = opts[:exclude] if opts[:exclude]
  args["include"] = opts[:include] if opts[:include]

  host_query = QueryBuilder.new("host")
  host_dir_query = host_query.chain_operation("directory", args)
  Directory.new(host_dir_query, client)
end

.root_field_nameObject



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

def self.root_field_name
  "directory"
end

Instance Method Details

#diff(other) ⇒ Object



51
52
53
# File 'lib/dagger_ruby/directory.rb', line 51

def diff(other)
  chain_operation("diff", { "other" => other.is_a?(DaggerObject) ? other.id : other })
end

#directory(path) ⇒ Object



72
73
74
# File 'lib/dagger_ruby/directory.rb', line 72

def directory(path)
  get_object("directory", Directory, { "path" => path })
end

#docker_build(opts = {}) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/dagger_ruby/directory.rb', line 90

def docker_build(opts = {})
  args = {
    "dockerfile" => opts[:dockerfile],
    "platform" => opts[:platform],
    "buildArgs" => opts[:build_args],
    "target" => opts[:target],
  }.compact
  args["secrets"] = opts[:secrets].map { |s| s.is_a?(DaggerObject) ? s.id : s } if opts[:secrets]
  args["noInit"] = opts[:no_init] if opts.key?(:no_init)
  args["ssh"] = opts[:ssh].is_a?(DaggerObject) ? opts[:ssh].id : opts[:ssh] if opts[:ssh]

  require_relative "container" unless defined?(Container)
  get_object("dockerBuild", Container, args)
end

#entries(path = ".") ⇒ Object



82
83
84
# File 'lib/dagger_ruby/directory.rb', line 82

def entries(path = ".")
  get_scalar("entries", { "path" => path })
end

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



76
77
78
79
80
# File 'lib/dagger_ruby/directory.rb', line 76

def export(path, opts = {})
  args = { "path" => path }
  args["wipe"] = opts[:wipe] if opts.key?(:wipe)
  get_scalar("export", args)
end

#file(path) ⇒ Object



68
69
70
# File 'lib/dagger_ruby/directory.rb', line 68

def file(path)
  get_object("file", File, { "path" => path })
end

#filter(opts = {}) ⇒ Object



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

def filter(opts = {})
  args = {}
  args["exclude"] = opts[:exclude] if opts[:exclude]
  args["include"] = opts[:include] if opts[:include]
  args["gitignore"] = opts[:gitignore] if opts[:gitignore]
  chain_operation("filter", args)
end

#glob(pattern) ⇒ Object



86
87
88
# File 'lib/dagger_ruby/directory.rb', line 86

def glob(pattern)
  get_scalar("glob", { "pattern" => pattern })
end

#syncObject



63
64
65
66
# File 'lib/dagger_ruby/directory.rb', line 63

def sync
  get_scalar("id")
  self
end

#terminal(opts = {}) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/dagger_ruby/directory.rb', line 105

def terminal(opts = {})
  args = {}
  if opts[:container]
    args["container"] =
      opts[:container].is_a?(DaggerObject) ? opts[:container].id : opts[:container]
  end
  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

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



25
26
27
28
29
30
31
32
33
34
# File 'lib/dagger_ruby/directory.rb', line 25

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["permissions"] = opts[:permissions] if opts[:permissions]

  chain_operation("withDirectory", args)
end

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



11
12
13
14
15
16
# File 'lib/dagger_ruby/directory.rb', line 11

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

  chain_operation("withFile", args)
end

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



36
37
38
39
40
41
# File 'lib/dagger_ruby/directory.rb', line 36

def with_new_directory(path, opts = {})
  args = { "path" => path }
  args["permissions"] = opts[:permissions] if opts[:permissions]

  chain_operation("withNewDirectory", args)
end

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



18
19
20
21
22
23
# File 'lib/dagger_ruby/directory.rb', line 18

def with_new_file(path, contents, opts = {})
  args = { "path" => path, "contents" => contents }
  args["permissions"] = opts[:permissions] if opts[:permissions]

  chain_operation("withNewFile", args)
end

#without_directory(path) ⇒ Object



47
48
49
# File 'lib/dagger_ruby/directory.rb', line 47

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

#without_file(path) ⇒ Object



43
44
45
# File 'lib/dagger_ruby/directory.rb', line 43

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