func (*Guardian) ConvertContainerPathToHostPath(
ctx context.Context, namespace, podName, containerName, containerPath string,
) (string, error) {
var (
client = g.Client()
url = "http://localhost/api/v1/pod/path"
req = webservice.HostPathInfoReq{
Namespace: namespace,
PodName: podName,
ContainerName: containerName,
ContainerPath: containerPath,
}
res *webservice.HostPathInfoRes
)
client.Transport = &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
return net.Dial("unix", serviceSocketPath)
},
}
err := client.ContentJson().GetVar(ctx, url, req).Scan(&res)
if err != nil {
return "", gerror.Wrapf(
err,
`request guardian failed for url: %s, req: %s`,
url, gjson.MustEncodeString(req),
)
}
if res == nil {
return "", gerror.Newf(
`nil response from guardian request url: %s, req: %s`,
url, gjson.MustEncodeString(req),
)
}
return res.HostPath, nil
}