Add blocked links for update and remove if method is disallowed

This commit is contained in:
Darren Shepherd 2021-08-16 15:41:36 -07:00
parent d9512c366d
commit bcbcef36b3

View File

@ -73,6 +73,14 @@ func formatter(summarycache *summarycache.SummaryCache) types.Formatter {
resource.Links["update"] = u resource.Links["update"] = u
} }
if _, ok := resource.Links["update"]; !ok && slice.ContainsString(resource.Schema.ResourceMethods, "blocked-PUT") {
resource.Links["update"] = "blocked"
}
if _, ok := resource.Links["remove"]; !ok && slice.ContainsString(resource.Schema.ResourceMethods, "blocked-DELETE") {
resource.Links["remove"] = "blocked"
}
if unstr, ok := resource.APIObject.Object.(*unstructured.Unstructured); ok { if unstr, ok := resource.APIObject.Object.(*unstructured.Unstructured); ok {
s, rel := summarycache.SummaryAndRelationship(unstr) s, rel := summarycache.SummaryAndRelationship(unstr)
data.PutValue(unstr.Object, map[string]interface{}{ data.PutValue(unstr.Object, map[string]interface{}{