diff --git a/manifest.rb b/manifest.rb index ba9f149..150ce19 100644 --- a/manifest.rb +++ b/manifest.rb @@ -2,7 +2,6 @@ require 'octokit' require 'fileutils' -require 'byebug' require_relative 'templates/kustomization' require_relative 'templates/flux' @@ -210,12 +209,14 @@ def print_manifests # rubocop:disable Metrics/AbcSize, Metrics/MethodLength File.write "/tmp/#{t.path}", t.manifest.to_yaml end + puts @templates.find(&:flux?)&.manifest&.to_yaml @templates.map(&:directory).uniq.each do |dir| next if dir.empty? puts '---' puts `kustomize build /tmp/#{dir.join('/')}` end + puts "\n" end end diff --git a/templates/base.rb b/templates/base.rb index 354781a..9209bc8 100644 --- a/templates/base.rb +++ b/templates/base.rb @@ -31,7 +31,7 @@ def path def method_missing(method_name, *args, &block) super unless method_name.to_s.end_with?('?') - method_name.to_s.delete('?') == file_name + method_name.to_s.delete('?') == file_name.delete('.') end def respond_to_missing?(method_name, include_private = false) diff --git a/templates/flux.rb b/templates/flux.rb index c374f28..b1a8c7a 100644 --- a/templates/flux.rb +++ b/templates/flux.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +# https://docs.fluxcd.io/en/latest/references/fluxyaml-config-files.html + require_relative 'base' module Templates @@ -10,7 +12,7 @@ def manifest { 'version' => 1, 'commandUpdated' => { - 'generators' => options[:generators] || [] + 'generators' => generators } } end @@ -18,5 +20,9 @@ def manifest def directory [] end + + def generators + options[:generators] || [] + end end end diff --git a/templates/kustomization.rb b/templates/kustomization.rb index aabf0b8..633832f 100644 --- a/templates/kustomization.rb +++ b/templates/kustomization.rb @@ -47,6 +47,7 @@ def images end end + # https://github.com/kubernetes-sigs/kustomize/blob/master/examples/jsonpatch.md def ingress_patch { 'target' => { @@ -59,6 +60,7 @@ def ingress_patch } end + # https://github.com/kubernetes-sigs/kustomize/blob/master/examples/image.md def images_patch img_tuple = options[:image].split(':') {