fix: helm before rke2 managed manifests
Build / precommit (pull_request) Successful in 5m15s

- add fact to list namespaces
- require namespace before adding additional config
- renamed some files to better match what they are
This commit is contained in:
2025-09-20 22:35:35 +10:00
parent 4c9204858e
commit 4ef99b4573
6 changed files with 55 additions and 11 deletions
+29
View File
@@ -0,0 +1,29 @@
# frozen_string_literal: true
require 'json'
require 'open3'
Facter.add(:k8s_namespaces) do
confine do
File.exist?('/etc/rancher/rke2/rke2.yaml') &&
File.executable?('/usr/bin/kubectl') # Adjust this path if needed
end
setcode do
env = { 'KUBECONFIG' => '/etc/rancher/rke2/rke2.yaml' }
cmd = ['/usr/bin/kubectl', 'get', 'namespaces', '-o', 'json']
stdout, stderr, status = Open3.capture3(env, *cmd)
if status.success?
json = JSON.parse(stdout)
json['items'].map { |item| item['metadata']['name'] }
else
Facter.debug("kubectl error: #{stderr}")
[]
end
rescue StandardError => e
Facter.debug("Exception in k8s_namespaces fact: #{e.message}")
[]
end
end