Project

General

Profile

Revision ada932ab

Added by Dmitri Dolguikh over 7 years ago

Fixes #7647: Added support for external registries

View differences:

app/controllers/containers/steps_controller.rb
16 16
      render_wizard
17 17
    end
18 18

  
19
    # rubocop:disable Metrics/MethodLength
19 20
    def update
20 21
      case step
21 22
      when :preliminary
22 23
        @container.update_attribute(:compute_resource_id, params[:container][:compute_resource_id])
23 24
      when :image
25
        image = update_or_create_image(params[:image][:image_id], params[:image][:registry_id])
24 26
        @container.update_attributes!(
25
            :image => (image = DockerImage.find_or_create_by_image_id!(params[:image])),
27
            :image => image,
26 28
            :tag => DockerTag.find_or_create_by_tag_and_docker_image_id!(params[:container][:tag],
27 29
                                                                         image.id))
28 30
      when :configuration
......
41 43

  
42 44
    private
43 45

  
46
    def update_or_create_image(id, registry_id)
47
      image = DockerImage.find_or_create_by_image_id!(id)
48
      begin
49
        image.registries << DockerRegistry.find(registry_id) \
50
          unless params[:image][:registry_id].empty?
51
      # rubocop:disable Lint/HandleExceptions
52
      rescue ActiveRecord::StatementInvalid
53
        # ignore, someone else already added the image to the registry
54
      end
55
      image
56
    end
57

  
44 58
    def finish_wizard_path
45 59
      container_path(:id => params[:container_id])
46 60
    end

Also available in: Unified diff