INNER CODE UNIT · Ruby
resource_hash
Shopify/krane · lib/krane/cluster_resource_discovery.rb:77
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)
{
"verbs" => blob["verbs"],
"kind" => blob["kind"],
"apigroup" => match[:group],
"version" => match[:version],
}
end
def fetch_crds
raw_json, err, st = kubectl.run("get", "CustomResourceDefinition", output: "json", attempts: 5,
use_namespace: false)
if st.success?