lib/kerby/cli.rb in kerby-0.1.2 vs lib/kerby/cli.rb in kerby-0.1.3

- old
+ new

@@ -40,10 +40,17 @@ end private # k8s include directive + # + # For example, <%= k8s_include('base/namespace') %> in manifest file will + # include 'base/namespace.yml' file. + # + # The path is relative to the current (sometimes partial) manifest file. + # + # @!visibility public def k8s_include(path) ERB.new(File.read(Pathname(@_curr_file).dirname + (path + '.yml'))).result(binding) end def sys(command, dry_run) @@ -63,10 +70,24 @@ end @_k8s_node = {} if @_k8s_node.nil? end # return node_yaml value for the key. + # + # For example, command execution: + # + # $ kerby build --node_yaml staging-node.yml manifest.yml + # + # and stageing-node.yml contains: + # + # app: + # namespace: city-A + # + # Then, <%= k8s_node('app.namespace') %> in manifest.yml will be + # generated to 'city-A'. + # + # @!visibility public def k8s_node(key) k8s_node_sub(@_k8s_node, key, key) end def k8s_node_sub(hash, key, prompt) @@ -81,9 +102,11 @@ k8s_node_sub(hash[keys[0]] || {}, keys[1,keys.size-1].join('.'), prompt) end end # k8s_include with YAML indent + # + # @!visibility public def k8s_config_map(path) "|\n" + ERB.new(File.read(Pathname(@_curr_file).dirname + path)).result(binding).split("\n").map do |line| " " + line + "\n" end.join('')