1 Star 0 Fork 0

docker-mirror / libcompose

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
auth.go 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
lilongyu 提交于 2020-09-24 10:38 . Initial commit
package docker
import (
"github.com/docker/docker/registry"
"github.com/docker/engine-api/types"
)
// AuthLookup defines a method for looking up authentication information
type AuthLookup interface {
All() map[string]types.AuthConfig
Lookup(repoInfo *registry.RepositoryInfo) types.AuthConfig
}
// ConfigAuthLookup implements AuthLookup by reading a Docker config file
type ConfigAuthLookup struct {
context *Context
}
// NewConfigAuthLookup creates a new ConfigAuthLookup for a given context
func NewConfigAuthLookup(context *Context) *ConfigAuthLookup {
return &ConfigAuthLookup{
context: context,
}
}
// Lookup uses a Docker config file to lookup authentication information
func (c *ConfigAuthLookup) Lookup(repoInfo *registry.RepositoryInfo) types.AuthConfig {
if c.context.ConfigFile == nil || repoInfo == nil || repoInfo.Index == nil {
return types.AuthConfig{}
}
return registry.ResolveAuthConfig(c.context.ConfigFile.AuthConfigs, repoInfo.Index)
}
// All uses a Docker config file to get all authentication information
func (c *ConfigAuthLookup) All() map[string]types.AuthConfig {
if c.context.ConfigFile == nil {
return map[string]types.AuthConfig{}
}
return c.context.ConfigFile.AuthConfigs
}
1
https://gitee.com/docker-mirror/libcompose.git
git@gitee.com:docker-mirror/libcompose.git
docker-mirror
libcompose
libcompose
7676619a9822

搜索帮助