Sha256: 323c6808f66892dfd74383a0bbbac7d11d2c2a1bad11181b3ea8f6c045b855f9

Contents?: true

Size: 1.41 KB

Versions: 105

Compression:

Stored size: 1.41 KB

Contents

class KuberKit::Core::ImageFactory
  include KuberKit::Import[
    "configs",
    "tools.file_presence_checker",
    "core.registry_store"
  ]

  def create(definition)
    image_attrs = definition.to_image_attrs

    dockerfile_path = image_attrs.dockerfile_path || File.join(image_attrs.dir, configs.image_dockerfile_name)
    file_presence_checker.check_file!(dockerfile_path)

    if image_attrs.build_context_dir
      file_presence_checker.check_dir!(image_attrs.build_context_dir)
      build_context_dir = image_attrs.build_context_dir
    else
      default_dir = File.join(image_attrs.dir, configs.image_build_context_dir)
      build_context_dir = file_presence_checker.dir_exists?(default_dir) ? default_dir : nil
    end

    if image_attrs.registry_name
      registry = registry_store.get(image_attrs.registry_name)
    else
      registry = registry_store.default_registry
    end

    KuberKit::Core::Image.new(
      name:                   image_attrs.name,
      dependencies:           image_attrs.dependencies,
      registry:               registry,
      dockerfile_path:        dockerfile_path,
      build_vars:             image_attrs.build_vars || {},
      build_context_dir:      build_context_dir,
      tag:                    image_attrs.tag || configs.image_tag,
      before_build_callback:  image_attrs.before_build_callback,
      after_build_callback:   image_attrs.after_build_callback
    )
  end
end

Version data entries

105 entries across 105 versions & 1 rubygems

Version Path
kuber_kit-1.3.9 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.3.8 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.3.7 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.1.8 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.3.6 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.1.7 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.3.5 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.3.4 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.1.6 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.3.3 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.3.2 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.1.5 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.3.1 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.3.0 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.1.4 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.2.7 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.2.6 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.2.5 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.2.4 lib/kuber_kit/core/image_factory.rb
kuber_kit-1.2.2 lib/kuber_kit/core/image_factory.rb