Sha256: a793f2f62b750fd170268637ab716f00b25ee698275c33780c8ac774ee50fbc9

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

require "base64"

module Kubes::Compiler::Shared
  module Helpers
    extend Kubes::Compiler::Dsl::Core::Fields
    fields "name"

    def docker_image
      return @options[:image] if @options[:image] # override
      return Kubes.config.image if Kubes.config.image
      built_image_helper
    end

    def built_image
      Deprecated.new.built_image
      built_image_helper
    end

    def built_image_helper
      path = Kubes.config.state.docker_image_path
      unless File.exist?(path)
        raise Kubes::MissingDockerImage.new("Missing file with docker image built by kubes: #{path}. Try first running: kubes docker build")
      end
      IO.read(path)
    end

    def with_extra(value)
      [value, extra].compact.join('-')
    end

    def extra
      extra = ENV['KUBES_EXTRA']
      extra&.strip&.empty? ? nil : extra # if blank string then also return nil
    end

    def encode64(v)
      Base64.strict_encode64(v.to_s).strip
    end
    alias_method :base64, :encode64

    def decode64(v)
      Base64.strict_decode64(v)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
kubes-0.7.1 lib/kubes/compiler/shared/helpers.rb
kubes-0.7.0 lib/kubes/compiler/shared/helpers.rb
kubes-0.6.8 lib/kubes/compiler/shared/helpers.rb
kubes-0.6.7 lib/kubes/compiler/shared/helpers.rb
kubes-0.6.6 lib/kubes/compiler/shared/helpers.rb
kubes-0.6.5 lib/kubes/compiler/shared/helpers.rb
kubes-0.6.4 lib/kubes/compiler/shared/helpers.rb
kubes-0.6.3 lib/kubes/compiler/shared/helpers.rb
kubes-0.6.2 lib/kubes/compiler/shared/helpers.rb
kubes-0.6.1 lib/kubes/compiler/shared/helpers.rb
kubes-0.6.0 lib/kubes/compiler/shared/helpers.rb
kubes-0.5.1 lib/kubes/compiler/shared/helpers.rb
kubes-0.5.0 lib/kubes/compiler/shared/helpers.rb