本文整理汇总了Golang中github.com/docker/docker/reference.Named.Hostname方法的典型用法代码示例。如果您正苦于以下问题:Golang Named.Hostname方法的具体用法?Golang Named.Hostname怎么用?Golang Named.Hostname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/docker/docker/reference.Named
的用法示例。
在下文中一共展示了Named.Hostname方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getRepositoryMountCandidates
// getRepositoryMountCandidates returns an array of v2 metadata items belonging to the given registry. The
// array is sorted from youngest to oldest. If requireReigstryMatch is true, the resulting array will contain
// only metadata entries having registry part of SourceRepository matching the part of repoInfo.
func getRepositoryMountCandidates(
repoInfo reference.Named,
hmacKey []byte,
max int,
v2Metadata []metadata.V2Metadata,
) []metadata.V2Metadata {
candidates := []metadata.V2Metadata{}
for _, meta := range v2Metadata {
sourceRepo, err := reference.ParseNamed(meta.SourceRepository)
if err != nil || repoInfo.Hostname() != sourceRepo.Hostname() {
continue
}
// target repository is not a viable candidate
if meta.SourceRepository == repoInfo.FullName() {
continue
}
candidates = append(candidates, meta)
}
sortV2MetadataByLikenessAndAge(repoInfo, hmacKey, candidates)
if max >= 0 && len(candidates) > max {
// select the youngest metadata
candidates = candidates[:max]
}
return candidates
}
示例2: newRepositoryInfo
// newRepositoryInfo validates and breaks down a repository name into a RepositoryInfo
func newRepositoryInfo(config *serviceConfig, name reference.Named) (*RepositoryInfo, error) {
index, err := newIndexInfo(config, name.Hostname())
if err != nil {
return nil, err
}
official := !strings.ContainsRune(name.Name(), '/')
return &RepositoryInfo{name, index, official}, nil
}
示例3: PullImage
func (i *Image) PullImage(ctx context.Context, ref reference.Named, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error {
defer trace.End(trace.Begin(ref.String()))
log.Debugf("PullImage: ref = %+v, metaheaders = %+v\n", ref, metaHeaders)
options := imagec.Options{
Destination: os.TempDir(),
Reference: ref.String(),
Timeout: imagec.DefaultHTTPTimeout,
Outstream: outStream,
}
if authConfig != nil {
if len(authConfig.Username) > 0 {
options.Username = authConfig.Username
}
if len(authConfig.Password) > 0 {
options.Password = authConfig.Password
}
}
portLayerServer := PortLayerServer()
if portLayerServer != "" {
options.Host = portLayerServer
}
insecureRegistries := InsecureRegistries()
for _, registry := range insecureRegistries {
if registry == ref.Hostname() {
options.InsecureAllowHTTP = true
break
}
}
log.Infof("PullImage: reference: %s, %s, portlayer: %#v",
options.Reference,
options.Host,
portLayerServer)
ic := imagec.NewImageC(options, streamformatter.NewJSONStreamFormatter())
err := ic.PullImage()
if err != nil {
return err
}
return nil
}