2014-08-07 10:43:06 -04:00
|
|
|
package registry
|
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
|
2015-02-04 16:22:38 -05:00
|
|
|
"github.com/docker/docker/autogen/dockerversion"
|
2014-08-07 10:43:06 -04:00
|
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
2015-03-29 09:51:08 -04:00
|
|
|
"github.com/docker/docker/pkg/requestdecorator"
|
2014-08-07 10:43:06 -04:00
|
|
|
)
|
|
|
|
|
2015-03-29 09:51:08 -04:00
|
|
|
func HTTPRequestFactory(metaHeaders map[string][]string) *requestdecorator.RequestFactory {
|
2014-08-07 10:43:06 -04:00
|
|
|
// FIXME: this replicates the 'info' job.
|
2015-03-29 09:51:08 -04:00
|
|
|
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))
|
2014-08-07 10:43:06 -04:00
|
|
|
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
|
2015-03-29 09:51:08 -04:00
|
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("kernel", kernelVersion.String()))
|
2014-08-07 10:43:06 -04:00
|
|
|
}
|
2015-03-29 09:51:08 -04:00
|
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("os", runtime.GOOS))
|
|
|
|
httpVersion = append(httpVersion, requestdecorator.NewUAVersionInfo("arch", runtime.GOARCH))
|
|
|
|
uad := &requestdecorator.UserAgentDecorator{
|
|
|
|
Versions: httpVersion,
|
|
|
|
}
|
|
|
|
mhd := &requestdecorator.MetaHeadersDecorator{
|
2014-08-07 10:43:06 -04:00
|
|
|
Headers: metaHeaders,
|
|
|
|
}
|
2015-03-29 09:51:08 -04:00
|
|
|
factory := requestdecorator.NewRequestFactory(uad, mhd)
|
2014-08-07 10:43:06 -04:00
|
|
|
return factory
|
|
|
|
}
|