makit 0.0.143 → 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/lib/makit/cli/base.rb +17 -0
 - data/lib/makit/cli/generators/templates/ruby/gemspec.rb +1 -0
 - data/lib/makit/cli/main.rb +9 -0
 - data/lib/makit/cli/pipeline_commands.rb +311 -0
 - data/lib/makit/cli/strategy_commands.rb +2 -7
 - data/lib/makit/commands/result.rb +1 -1
 - data/lib/makit/configuration/dotnet_project.rb +9 -0
 - data/lib/makit/configuration/gitlab_helper.rb +4 -1
 - data/lib/makit/configuration/project.rb +362 -84
 - data/lib/makit/configuration/timeout.rb +1 -1
 - data/lib/makit/configuration.rb +5 -0
 - data/lib/makit/fileinfo.rb +8 -0
 - data/lib/makit/git/repository.rb +207 -31
 - data/lib/makit/git.rb +6 -0
 - data/lib/makit/gitlab/pipeline.rb +857 -0
 - data/lib/makit/gitlab/pipeline_service_impl.rb +1536 -0
 - data/lib/makit/humanize.rb +81 -0
 - data/lib/makit/io/filesystem.rb +111 -0
 - data/lib/makit/io/filesystem_service_impl.rb +337 -0
 - data/lib/makit/mp/string_mp.rb +15 -9
 - data/lib/makit/podman/podman.rb +458 -0
 - data/lib/makit/podman/podman_service_impl.rb +1081 -0
 - data/lib/makit/process.rb +214 -0
 - data/lib/makit/protoc.rb +6 -1
 - data/lib/makit/services/repository_manager.rb +268 -132
 - data/lib/makit/symbols.rb +5 -0
 - 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 +1 -1
 - data/lib/makit/v1/makit.v1_services_pb.rb +1 -1
 - data/lib/makit/v1/services/repository_manager_service_impl.rb +572 -0
 - data/lib/makit/version.rb +1 -1
 - data/lib/makit.rb +68 -0
 - 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
         
     |