Created
March 27, 2019 17:51
-
-
Save dreverri/75e848099cbbccc7cdc22ac350c81fdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local safeGet = function(name) function(o, default={}) if std.objectHas(o, name) then o[name] else default; | |
local metadata = safeGet("metadata"); | |
local name = safeGet("name"); | |
local namespace = safeGet("namespace"); | |
local kind = safeGet("kind"); | |
local kindPriority = std.foldl(function(o, k) o { [k]: std.length(o) }, [ | |
"Namespace", | |
"ResourceQuota", | |
"LimitRange", | |
"PodSecurityPolicy", | |
"PodDisruptionBudget", | |
"Secret", | |
"ConfigMap", | |
"StorageClass", | |
"PersistentVolume", | |
"PersistentVolumeClaim", | |
"ServiceAccount", | |
"CustomResourceDefinition", | |
"ClusterRole", | |
"ClusterRoleBinding", | |
"Role", | |
"RoleBinding", | |
"Service", | |
"DaemonSet", | |
"Pod", | |
"ReplicationController", | |
"ReplicaSet", | |
"Deployment", | |
"StatefulSet", | |
"Job", | |
"CronJob", | |
"Ingress", | |
"APIService", | |
], {}); | |
local priority = function(kind) if std.objectHas(kindPriority, kind) then kindPriority[kind] else std.length(kindPriority); | |
local keyF = function(o) std.format("%02d/%s/%s/%s", [priority(kind(o, "")), namespace(metadata(o), ""), kind(o, ""), name(metadata(o), "")]); | |
keyF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment