Sha256: fe61d7a989e2a6bda71c52df2d1e6945cf899056ecf132f87545b99b43d54a69
Contents?: true
Size: 1016 Bytes
Versions: 2
Compression:
Stored size: 1016 Bytes
Contents
module Kubec class Kubernetes # :nodoc: class ConfigMap < Hash attr_reader :name, :files def initialize(name, &block) @name = name.to_sym @files = {} prepare instance_eval(&block) end def set(key, value) self[:data][key] = value end # TODO: Refactor def file(path) key = path.split('/').last @files[key] = path path = path_with_stage(path) if stage_config_exist?(path) set key, File.read(path) end private def prepare self[:apiVersion] = 'v1' self[:metadata] = Metadata.new(@name) self[:kind] = 'ConfigMap' self[:data] = {} end def stage_config_exist?(path) File.exist?(path_with_stage(path)) end def path_with_stage(path) path.split('.').tap do |ary| ext = ary.pop ary.push(fetch(:stage, :staging)) ary.push(ext) end.join('.') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kubec-0.3.1 | lib/kubec/kubernetes/config_map.rb |
kubec-0.3.0 | lib/kubec/kubernetes/config_map.rb |