mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
0995ab5946
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
30 lines
1.2 KiB
Go
30 lines
1.2 KiB
Go
package registry
|
|
|
|
import (
|
|
"runtime"
|
|
|
|
"github.com/docker/docker/autogen/dockerversion"
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
|
"github.com/docker/docker/pkg/requestdecorator"
|
|
)
|
|
|
|
func HTTPRequestFactory(metaHeaders map[string][]string) *requestdecorator.RequestFactory {
|
|
// FIXME: this replicates the 'info' job.
|
|
httpVersion := make([]requestdecorator.UAVersionInfo, 0, 4)
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("docker", dockerversion.VERSION))
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("go", runtime.Version()))
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("git-commit", dockerversion.GITCOMMIT))
|
|
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("kernel", kernelVersion.String()))
|
|
}
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("os", runtime.GOOS))
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("arch", runtime.GOARCH))
|
|
uad := &requestdecorator.UserAgentDecorator{
|
|
Versions: httpVersion,
|
|
}
|
|
mhd := &requestdecorator.MetaHeadersDecorator{
|
|
Headers: metaHeaders,
|
|
}
|
|
factory := requestdecorator.NewRequestFactory(uad, mhd)
|
|
return factory
|
|
}
|