module Kubes::Docker::Strategy::ImageName
Public Instance Methods
args()
click to toggle source
# File lib/kubes/docker/strategy/image_name.rb, line 62 def args # base at end in case of redirection. IE: command > /path custom.args + default.args end
custom()
click to toggle source
# File lib/kubes/docker/strategy/image_name.rb, line 67 def custom custom = Kubes::Args::Custom.new(@name, "#{Kubes.root}/.kubes/config/args/docker.rb") custom.build custom end
default()
click to toggle source
# File lib/kubes/docker/strategy/image_name.rb, line 74 def default Kubes::Docker::Args::Default.new(@name, image_name, @options) end
generate_name()
click to toggle source
# File lib/kubes/docker/strategy/image_name.rb, line 44 def generate_name # IE: tongueroo/demo:kubes- ["#{repo}:kubes-#{@@timestamp}", git_sha].compact.join('-') end
git_sha()
click to toggle source
# File lib/kubes/docker/strategy/image_name.rb, line 53 def git_sha return @git_sha if @git_sha # always call this and dont use the execute method because of the noop option git_installed = system("type git > /dev/null 2>&1") return unless git_installed && File.exist?("#{Kubes.root}/.git") @git_sha = `cd #{Kubes.root} && git rev-parse --short HEAD` @git_sha.strip! end
image_name()
click to toggle source
full_image - Includes the tag. Examples:
123456789.dkr.ecr.us-west-2.amazonaws.com/myapp:kubes-2018-04-20T09-29-08-b7d51df tongueroo/demo-kubes:kubes-2018-04-20T09-29-08-b7d51df
# File lib/kubes/docker/strategy/image_name.rb, line 30 def image_name return generate_name if @options[:generate] return @@image_name if @@image_name return "tongueroo/demo-kubes:kubes-12345678" if ENV['TEST'] unless File.exist?(image_state_path) logger.error "ERROR: Unable to find #{image_state_path} which contains the last docker image name built with kubes build. Please run `kubes docker build` first." exit 1 end data = JSON.load(IO.read(image_state_path)) data['image'] end
image_state_path()
click to toggle source
output can get entirely wiped so dont use that folder
# File lib/kubes/docker/strategy/image_name.rb, line 23 def image_state_path Kubes.config.state.path end
repo()
click to toggle source
# File lib/kubes/docker/strategy/image_name.rb, line 49 def repo Kubes.config.repo end
reserve_image_name()
click to toggle source
# File lib/kubes/docker/strategy/image_name.rb, line 8 def reserve_image_name @@image_name = generate_name end
store_image_name()
click to toggle source
Store this in a file because this name gets reference in other tasks later and we want the image name to stay the same when the commands are run separate in different processes. So we store the state in a file. Only when a new docker build command gets run will the image name state be updated.
# File lib/kubes/docker/strategy/image_name.rb, line 16 def store_image_name FileUtils.mkdir_p(File.dirname(image_state_path)) text = JSON.pretty_generate(image: @@image_name) IO.write(image_state_path, text) end