Skip to content

Commit 9d4138f

Browse files
committed
Namespace Docker
1 parent c1655d0 commit 9d4138f

22 files changed

Lines changed: 66 additions & 66 deletions

lib/ruby_llm/docker/build_image.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module Docker
7171
# tag: "custom-nginx:v1.0"
7272
# )
7373
#
74-
# @see Docker::Image.build_from_dir
74+
# @see ::Docker::Image.build_from_dir
7575
# @since 0.1.0
7676
BUILD_IMAGE_DEFINITION = ToolForge.define(:build_image) do
7777
description 'Build a Docker image'
@@ -87,7 +87,7 @@ module Docker
8787

8888
execute do |dockerfile:, tag: nil|
8989
# Build the image
90-
image = Docker::Image.build(dockerfile)
90+
image = ::Docker::Image.build(dockerfile)
9191

9292
# If a tag was specified, tag the image
9393
if tag

lib/ruby_llm/docker/copy_to_container.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module Docker
6161
# owner: "app:app"
6262
# )
6363
#
64-
# @see Docker::Container#archive_in_stream
64+
# @see ::Docker::Container#archive_in_stream
6565
# @since 0.1.0
6666
COPY_TO_CONTAINER_DEFINITION = ToolForge.define(:copy_to_container) do
6767
description 'Copy a file or directory from the local filesystem into a running Docker container. ' \
@@ -109,7 +109,7 @@ module Docker
109109
end
110110

111111
execute do |id:, source_path:, destination_path:, owner: nil|
112-
container = Docker::Container.get(id)
112+
container = ::Docker::Container.get(id)
113113

114114
# Verify source path exists
115115
next "Source path not found: #{source_path}" unless File.exist?(source_path)
@@ -139,7 +139,7 @@ module Docker
139139
response_text = "Successfully copied #{file_type} from #{source_path} to #{id}:#{destination_path}"
140140
response_text += "\nOwnership changed to #{owner}" if owner
141141
response_text
142-
rescue Docker::Error::NotFoundError
142+
rescue ::Docker::Error::NotFoundError
143143
"Container #{id} not found"
144144
rescue StandardError => e
145145
"Error copying to container: #{e.message}"

lib/ruby_llm/docker/create_container.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module Docker
5959
# }
6060
# )
6161
#
62-
# @see Docker::Container.create
62+
# @see ::Docker::Container.create
6363
# @since 0.1.0
6464
CREATE_CONTAINER_DEFINITION = ToolForge.define(:create_container) do
6565
description 'Create a Docker container'
@@ -106,13 +106,13 @@ module Docker
106106
config['ExposedPorts'] = exposed_ports if exposed_ports
107107
config['HostConfig'] = host_config if host_config
108108

109-
container = Docker::Container.create(config)
109+
container = ::Docker::Container.create(config)
110110
container_name = container.info['Names']&.first&.delete_prefix('/')
111111

112112
"Container created successfully. ID: #{container.id}, Name: #{container_name}"
113-
rescue Docker::Error::NotFoundError
113+
rescue ::Docker::Error::NotFoundError
114114
"Image #{image} not found"
115-
rescue Docker::Error::ConflictError
115+
rescue ::Docker::Error::ConflictError
116116
"Container with name #{name} already exists"
117117
rescue StandardError => e
118118
"Error creating container: #{e.message}"

lib/ruby_llm/docker/create_network.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module Docker
7272
# check_duplicate: false
7373
# )
7474
#
75-
# @see Docker::Network.create
75+
# @see ::Docker::Network.create
7676
# @since 0.1.0
7777
CREATE_NETWORK_DEFINITION = ToolForge.define(:create_network) do
7878
description 'Create a Docker network'
@@ -100,10 +100,10 @@ module Docker
100100
'CheckDuplicate' => check_duplicate
101101
}
102102

103-
network = Docker::Network.create(name, options)
103+
network = ::Docker::Network.create(name, options)
104104

105105
"Network #{name} created successfully. ID: #{network.id}"
106-
rescue Docker::Error::ConflictError
106+
rescue ::Docker::Error::ConflictError
107107
"Network #{name} already exists"
108108
rescue StandardError => e
109109
"Error creating network: #{e.message}"

lib/ruby_llm/docker/create_volume.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module Docker
7171
# driver: "local"
7272
# )
7373
#
74-
# @see Docker::Volume.create
74+
# @see ::Docker::Volume.create
7575
# @since 0.1.0
7676
CREATE_VOLUME_DEFINITION = ToolForge.define(:create_volume) do
7777
description 'Create a Docker volume'
@@ -92,10 +92,10 @@ module Docker
9292
'Driver' => driver
9393
}
9494

95-
Docker::Volume.create(name, options)
95+
::Docker::Volume.create(name, options)
9696

9797
"Volume #{name} created successfully"
98-
rescue Docker::Error::ConflictError
98+
rescue ::Docker::Error::ConflictError
9999
"Volume #{name} already exists"
100100
rescue StandardError => e
101101
"Error creating volume: #{e.message}"

lib/ruby_llm/docker/exec_container.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module Docker
7171
# timeout: 300
7272
# )
7373
#
74-
# @see Docker::Container#exec
74+
# @see ::Docker::Container#exec
7575
# @since 0.1.0
7676
EXEC_CONTAINER_DEFINITION = ToolForge.define(:exec_container) do
7777
description 'Execute a command inside a running Docker container. ' \
@@ -113,7 +113,7 @@ module Docker
113113
default: 60
114114

115115
execute do |id:, cmd:, working_dir: nil, user: nil, env: nil, stdin: nil, timeout: 60|
116-
container = Docker::Container.get(id)
116+
container = ::Docker::Container.get(id)
117117

118118
# Parse command string into array
119119
cmd_array = Shellwords.split(cmd)
@@ -137,7 +137,7 @@ module Docker
137137
stdout_data = result[0]
138138
stderr_data = result[1]
139139
exit_code = result[2]
140-
rescue Docker::Error::TimeoutError
140+
rescue ::Docker::Error::TimeoutError
141141
return "Command execution timed out after #{timeout} seconds"
142142
end
143143

@@ -156,7 +156,7 @@ module Docker
156156
end
157157

158158
response_text.strip
159-
rescue Docker::Error::NotFoundError
159+
rescue ::Docker::Error::NotFoundError
160160
"Container #{id} not found"
161161
rescue StandardError => e
162162
"Error executing command: #{e.message}"

lib/ruby_llm/docker/fetch_container_logs.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module Docker
5555
# tail: 100
5656
# )
5757
#
58-
# @see Docker::Container#logs
58+
# @see ::Docker::Container#logs
5959
# @since 0.1.0
6060
FETCH_CONTAINER_LOGS_DEFINITION = ToolForge.define(:fetch_container_logs) do
6161
description 'Fetch Docker container logs'
@@ -88,7 +88,7 @@ module Docker
8888
default: false
8989

9090
execute do |id:, stdout: true, stderr: true, tail: nil, timestamps: false|
91-
container = Docker::Container.get(id)
91+
container = ::Docker::Container.get(id)
9292

9393
options = {
9494
stdout: stdout,
@@ -98,7 +98,7 @@ module Docker
9898
options[:tail] = tail if tail
9999

100100
container.logs(options)
101-
rescue Docker::Error::NotFoundError
101+
rescue ::Docker::Error::NotFoundError
102102
"Container #{id} not found"
103103
rescue StandardError => e
104104
"Error fetching logs: #{e.message}"

lib/ruby_llm/docker/list_containers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module Docker
4444
# puts "#{container['Names'].first}: #{container['State']}"
4545
# end
4646
#
47-
# @see Docker::Container.all
47+
# @see ::Docker::Container.all
4848
# @since 0.1.0
4949
LIST_CONTAINERS_DEFINITION = ToolForge.define(:list_containers) do
5050
description 'List Docker containers'
@@ -56,7 +56,7 @@ module Docker
5656
default: true
5757

5858
execute do |all: true|
59-
Docker::Container.all(all: all).map(&:info)
59+
::Docker::Container.all(all: all).map(&:info)
6060
end
6161
end
6262

lib/ruby_llm/docker/list_images.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ module Docker
4343
# puts "#{image['RepoTags']}: #{image['Size']} bytes"
4444
# end
4545
#
46-
# @see Docker::Image.all
46+
# @see ::Docker::Image.all
4747
# @since 0.1.0
4848
LIST_IMAGES_DEFINITION = ToolForge.define(:list_images) do
4949
description 'List Docker images'
5050

5151
execute do
52-
Docker::Image.all.map(&:info)
52+
::Docker::Image.all.map(&:info)
5353
end
5454
end
5555

lib/ruby_llm/docker/list_networks.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ module Docker
4444
# puts "#{network['Name']}: #{network['Driver']}"
4545
# end
4646
#
47-
# @see Docker::Network.all
47+
# @see ::Docker::Network.all
4848
# @since 0.1.0
4949
LIST_NETWORKS_DEFINITION = ToolForge.define(:list_networks) do
5050
description 'List Docker networks'
5151

5252
execute do
53-
Docker::Network.all.map(&:info)
53+
::Docker::Network.all.map(&:info)
5454
end
5555
end
5656

0 commit comments

Comments
 (0)