INNER CODE UNIT · Ruby

fetch_api_path

Shopify/krane · lib/krane/cluster_resource_discovery.rb:65

    def fetch_api_path(path)
      @api_path_cache[path] ||= begin
        raw_json, err, st = kubectl.run("get", "--raw", path, attempts: 2, use_namespace: false)
        if st.success?
          JSON.parse(raw_json)
        else
          logger.warn("Error retrieving api path: #{err}")
          {}
        end
      end
    end

    def resource_hash(path, namespaced, blob)
      return unless blob["namespaced"] == namespaced
      # skip sub-resources
      return if blob["name"].include?("/")
      path_regex = %r{(/apis?/)(?<group>[^/]*)/?(?<version>v.+)}
      match = path.match(path_regex)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…