1
0
mirror of https://github.com/rancher/steve.git synced 2025-04-28 03:10:32 +00:00

Run formatter before links

This commit is contained in:
Darren Shepherd 2019-08-14 13:13:13 -07:00
parent f2c0706220
commit de50acc048
2 changed files with 19 additions and 13 deletions

View File

@ -157,12 +157,12 @@ func (j *EncodingResponseWriter) convert(b builder.Builder, context *types.APIRe
ActionLinks: context.Request.Header.Get("X-API-Action-Links") != "",
}
j.addLinks(b, schema, context, input, rawResource)
if schema.Formatter != nil {
schema.Formatter(context, rawResource)
}
j.addLinks(b, schema, context, input, rawResource)
return rawResource
}
@ -172,12 +172,18 @@ func (j *EncodingResponseWriter) addLinks(b builder.Builder, schema *types.Schem
}
self := context.URLBuilder.ResourceLink(rawResource.Schema, rawResource.ID)
rawResource.Links["self"] = self
if context.AccessControl.CanUpdate(context, types.ToAPI(input), schema) == nil {
rawResource.Links["update"] = self
if _, ok := rawResource.Links["self"]; !ok {
rawResource.Links["self"] = self
}
if context.AccessControl.CanDelete(context, types.ToAPI(input), schema) == nil {
rawResource.Links["remove"] = self
if _, ok := rawResource.Links["update"]; !ok {
if context.AccessControl.CanUpdate(context, types.ToAPI(input), schema) == nil {
rawResource.Links["update"] = self
}
}
if _, ok := rawResource.Links["remove"]; !ok {
if context.AccessControl.CanDelete(context, types.ToAPI(input), schema) == nil {
rawResource.Links["remove"] = self
}
}
}

12
vendor/modules.txt vendored
View File

@ -44,10 +44,10 @@ github.com/rancher/norman/pkg/types
github.com/rancher/norman/pkg/types/convert
github.com/rancher/norman/pkg/store/proxy
github.com/rancher/norman/pkg/subscribe
github.com/rancher/norman/pkg/types/values
github.com/rancher/norman/pkg/store/empty
github.com/rancher/norman/pkg/api/builtin
github.com/rancher/norman/pkg/data
github.com/rancher/norman/pkg/store/empty
github.com/rancher/norman/pkg/types/values
github.com/rancher/norman/pkg/api/builtin
github.com/rancher/norman/pkg/api
github.com/rancher/norman/pkg/urlbuilder
github.com/rancher/norman/pkg/httperror
@ -237,8 +237,6 @@ k8s.io/client-go/util/cert
k8s.io/client-go/util/flowcontrol
k8s.io/client-go/kubernetes/scheme
k8s.io/client-go/tools/clientcmd
k8s.io/client-go/informers
k8s.io/client-go/informers/rbac
k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1
k8s.io/client-go/kubernetes/typed/apps/v1
k8s.io/client-go/kubernetes/typed/apps/v1beta1
@ -274,6 +272,8 @@ k8s.io/client-go/kubernetes/typed/settings/v1alpha1
k8s.io/client-go/kubernetes/typed/storage/v1
k8s.io/client-go/kubernetes/typed/storage/v1alpha1
k8s.io/client-go/kubernetes/typed/storage/v1beta1
k8s.io/client-go/informers
k8s.io/client-go/informers/rbac
k8s.io/client-go/util/workqueue
k8s.io/client-go/informers/internalinterfaces
k8s.io/client-go/tools/pager
@ -286,6 +286,7 @@ k8s.io/client-go/util/keyutil
k8s.io/client-go/tools/auth
k8s.io/client-go/tools/clientcmd/api/latest
k8s.io/client-go/util/homedir
k8s.io/client-go/tools/reference
k8s.io/client-go/informers/admissionregistration
k8s.io/client-go/informers/apps
k8s.io/client-go/informers/auditregistration
@ -304,7 +305,6 @@ k8s.io/client-go/informers/settings
k8s.io/client-go/informers/storage
k8s.io/client-go/informers/rbac/v1alpha1
k8s.io/client-go/informers/rbac/v1beta1
k8s.io/client-go/tools/reference
k8s.io/client-go/tools/clientcmd/api/v1
k8s.io/client-go/informers/admissionregistration/v1beta1
k8s.io/client-go/informers/apps/v1