Sha256: 4a97e2c835f647a7a7e0a93a063086910ce88a5f10de216cfc267d5eb85f5499

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

module KubernetesDeploy
  class ClusterResourceDiscovery
    def initialize(namespace:, context:, logger:, namespace_tags:)
      @namespace = namespace
      @context = context
      @logger = logger
      @namespace_tags = namespace_tags
    end

    def crds
      @crds ||= fetch_crds.map do |cr_def|
        CustomResourceDefinition.new(namespace: @namespace, context: @context, logger: @logger,
          definition: cr_def, statsd_tags: @namespace_tags)
      end
    end

    private

    def fetch_crds
      raw_json, _, st = kubectl.run("get", "CustomResourceDefinition", "-a", "--output=json", attempts: 5)
      if st.success?
        JSON.parse(raw_json)["items"]
      else
        []
      end
    end

    def kubectl
      @kubectl ||= Kubectl.new(namespace: @namespace, context: @context, logger: @logger, log_failure_by_default: true)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kubernetes-deploy-0.25.0 lib/kubernetes-deploy/cluster_resource_discovery.rb
kubernetes-deploy-0.24.0 lib/kubernetes-deploy/cluster_resource_discovery.rb
kubernetes-deploy-0.23.0 lib/kubernetes-deploy/cluster_resource_discovery.rb