Method: Cnvrg::Images#initialize
- Defined in:
- lib/cnvrg/Images.rb
#initialize(working_dir, image_name = "") ⇒ Images
Returns a new instance of Images.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/cnvrg/Images.rb', line 13 def initialize(working_dir, image_name="") begin config = YAML.load_file(working_dir+"/.cnvrg/config.yml") idx = YAML.load_file(working_dir + "/.cnvrg/idx.yml") @working_dir = working_dir @commit_id =idx[:commit] @project_title = config[:project_name] @project_slug = config[:project_slug] @owner = config[:owner] @is_docker = config[:docker] if image_name.empty? @image_name = config[:image_base] @image_tag = config[:image_tag] @image_slug = find_image() else @image_name = image_name if !@image_name.nil? and !@image_name.empty? if image_name.include? ":" @image_name = image_name[0, image_name.index(":")] @image_tag = image_name[image_name.index(":")+1, image_name.size] else @image_name = image_name @image_tag = "lastest" end end @image_slug = find_image(false) update_image_activity(@commit_id, nil) config = {project_name: config[:project_name], project_slug: config[:project_slug], owner: config[:owner], docker: true, image_base: @image_name, image_tag: @image_tag, image_slug: image_slug} File.open(working_dir+"/.cnvrg/config.yml", "w+") { |f| f.write config.to_yaml } end rescue => e end end |