# frozen_string_literal: true require 'facter' require 'json' # a simple helm module module Facter::Util::Helm def self.get_helm_repos(helm_cmd) return [] unless File.executable?(helm_cmd) output = Facter::Core::Execution.execute( "#{helm_cmd} repo list --output json --repository-config /etc/helm/repositories.yaml", on_fail: nil ) return [] if output.to_s.strip.empty? parse_helm_output(output) rescue StandardError => e Facter.debug("helm_repos fact error: #{e}") [] end def self.parse_helm_output(output) JSON.parse(output).map do |repo| { 'name' => repo['name'], 'url' => repo['url'] } end end end