-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
registry.Registry -> registry.Session
renaming this struct to more clearly be session, as that is what it handles. Splitting out files for easier readability. Signed-off-by: Vincent Batts <vbatts@redhat.com>
- Loading branch information
Showing
8 changed files
with
710 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package registry | ||
|
||
import ( | ||
"runtime" | ||
|
||
"github.com/docker/docker/dockerversion" | ||
"github.com/docker/docker/pkg/parsers/kernel" | ||
"github.com/docker/docker/utils" | ||
) | ||
|
||
func HTTPRequestFactory(metaHeaders map[string][]string) *utils.HTTPRequestFactory { | ||
// FIXME: this replicates the 'info' job. | ||
httpVersion := make([]utils.VersionInfo, 0, 4) | ||
httpVersion = append(httpVersion, &simpleVersionInfo{"docker", dockerversion.VERSION}) | ||
httpVersion = append(httpVersion, &simpleVersionInfo{"go", runtime.Version()}) | ||
httpVersion = append(httpVersion, &simpleVersionInfo{"git-commit", dockerversion.GITCOMMIT}) | ||
if kernelVersion, err := kernel.GetKernelVersion(); err == nil { | ||
httpVersion = append(httpVersion, &simpleVersionInfo{"kernel", kernelVersion.String()}) | ||
} | ||
httpVersion = append(httpVersion, &simpleVersionInfo{"os", runtime.GOOS}) | ||
httpVersion = append(httpVersion, &simpleVersionInfo{"arch", runtime.GOARCH}) | ||
ud := utils.NewHTTPUserAgentDecorator(httpVersion...) | ||
md := &utils.HTTPMetaHeadersDecorator{ | ||
Headers: metaHeaders, | ||
} | ||
factory := utils.NewHTTPRequestFactory(ud, md) | ||
return factory | ||
} | ||
|
||
// simpleVersionInfo is a simple implementation of | ||
// the interface VersionInfo, which is used | ||
// to provide version information for some product, | ||
// component, etc. It stores the product name and the version | ||
// in string and returns them on calls to Name() and Version(). | ||
type simpleVersionInfo struct { | ||
name string | ||
version string | ||
} | ||
|
||
func (v *simpleVersionInfo) Name() string { | ||
return v.name | ||
} | ||
|
||
func (v *simpleVersionInfo) Version() string { | ||
return v.version | ||
} |
Oops, something went wrong.