1
0
mirror of https://github.com/rancher/steve.git synced 2025-08-01 23:03:28 +00:00
steve/pkg/resources/formatter.go

22 lines
518 B
Go
Raw Normal View History

package resources
import (
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/convert"
"github.com/rancher/norman/pkg/types/values"
)
func Formatter(request *types.APIRequest, resource *types.RawResource) {
selfLink := convert.ToString(values.GetValueN(resource.Values, "metadata", "selfLink"))
if selfLink == "" {
return
}
u := request.URLBuilder.RelativeToRoot(selfLink)
resource.Links["view"] = u
if _, ok := resource.Links["update"]; ok {
resource.Links["update"] = u
}
}