本文整理汇总了Golang中github.com/openshift/source-to-image/pkg/docker.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: New
// New returns the instance of STI builder strategy for the given config.
// If the layeredBuilder parameter is specified, then the builder provided will
// be used for the case that the base Docker image does not have 'tar' or 'bash'
// installed.
func New(req *api.Config, overrides build.Overrides) (*STI, error) {
docker, err := dockerpkg.New(req.DockerConfig, req.PullAuthentication)
if err != nil {
return nil, err
}
var incrementalDocker dockerpkg.Docker
if req.Incremental {
incrementalDocker, err = dockerpkg.New(req.DockerConfig, req.IncrementalAuthentication)
if err != nil {
return nil, err
}
}
inst := scripts.NewInstaller(req.BuilderImage, req.ScriptsURL, docker, req.PullAuthentication)
b := &STI{
installer: inst,
config: req,
docker: docker,
incrementalDocker: incrementalDocker,
git: git.New(),
fs: util.NewFileSystem(),
tar: tar.New(),
callbackInvoker: util.NewCallbackInvoker(),
requiredScripts: []string{api.Assemble, api.Run},
optionalScripts: []string{api.SaveArtifacts},
externalScripts: map[string]bool{},
installedScripts: map[string]bool{},
scriptsURL: map[string]string{},
}
// The sources are downloaded using the GIT downloader.
// TODO: Add more SCM in future.
// TODO: explicit decision made to customize processing for usage specifically vs.
// leveraging overrides; also, we ultimately want to simplify s2i usage a good bit,
// which would lead to replacing this quick short circuit (so this change is tactical)
b.source = overrides.Downloader
if b.source == nil && !req.Usage {
downloader, sourceURL, err := scm.DownloaderForSource(req.Source, req.ForceCopy)
if err != nil {
return nil, err
}
b.source = downloader
req.Source = sourceURL
}
b.garbage = &build.DefaultCleaner{b.fs, b.docker}
b.layered, err = layered.New(req, b, overrides)
// Set interfaces
b.preparer = b
// later on, if we support say .gitignore func in addition to .dockerignore func, setting
// ignorer will be based on config setting
b.ignorer = &ignore.DockerIgnorer{}
b.artifacts = b
b.scripts = b
b.postExecutor = b
return b, err
}
开发者ID:carriercomm,项目名称:origin,代码行数:63,代码来源:sti.go
示例2: New
// New returns the instance of STI builder strategy for the given config.
// If the layeredBuilder parameter is specified, then the builder provided will
// be used for the case that the base Docker image does not have 'tar' or 'bash'
// installed.
func New(req *api.Config, overrides build.Overrides) (*STI, error) {
docker, err := dockerpkg.New(req.DockerConfig, req.PullAuthentication)
if err != nil {
return nil, err
}
var incrementalDocker dockerpkg.Docker
if req.Incremental {
incrementalDocker, err = dockerpkg.New(req.DockerConfig, req.IncrementalAuthentication)
if err != nil {
return nil, err
}
}
inst := scripts.NewInstaller(req.BuilderImage, req.ScriptsURL, docker, req.PullAuthentication)
b := &STI{
installer: inst,
config: req,
docker: docker,
incrementalDocker: incrementalDocker,
git: git.New(),
fs: util.NewFileSystem(),
tar: tar.New(),
callbackInvoker: util.NewCallbackInvoker(),
requiredScripts: []string{api.Assemble, api.Run},
optionalScripts: []string{api.SaveArtifacts},
externalScripts: map[string]bool{},
installedScripts: map[string]bool{},
scriptsURL: map[string]string{},
}
// The sources are downloaded using the GIT downloader.
// TODO: Add more SCM in future.
b.source = overrides.Downloader
if b.source == nil {
downloader, sourceURL, err := scm.DownloaderForSource(req.Source)
if err != nil {
return nil, err
}
b.source = downloader
req.Source = sourceURL
}
b.garbage = &build.DefaultCleaner{b.fs, b.docker}
b.layered, err = layered.New(req, b, overrides)
// Set interfaces
b.preparer = b
// later on, if we support say .gitignore func in addition to .dockerignore func, setting
// ignorer will be based on config setting
b.ignorer = &ignore.DockerIgnorer{}
b.artifacts = b
b.scripts = b
b.postExecutor = b
return b, err
}
开发者ID:4sp1r3,项目名称:source-to-image,代码行数:60,代码来源:sti.go
示例3: GetBuilderImage
// GetBuilderImage processes the config and performs operations necessary to make
// the Docker image specified as BuilderImage available locally.
// It returns information about the base image, containing metadata necessary
// for choosing the right STI build strategy.
func GetBuilderImage(config *api.Config) (*docker.PullResult, error) {
d, err := docker.New(config.DockerConfig, config.PullAuthentication)
result := docker.PullResult{}
if err != nil {
return nil, err
}
var image *dockerclient.Image
if config.ForcePull {
image, err = d.PullImage(config.BuilderImage)
if err != nil {
glog.Warningf("An error occurred when pulling %s: %v. Attempting to use local image.", config.BuilderImage, err)
image, err = d.CheckImage(config.BuilderImage)
}
} else {
image, err = d.CheckAndPullImage(config.BuilderImage)
}
if err != nil {
return nil, err
}
result.Image = image
result.OnBuild = d.IsImageOnBuild(config.BuilderImage)
if err = checkAllowedUser(d, config, result.OnBuild); err != nil {
return nil, err
}
return &result, nil
}
开发者ID:jhadvig,项目名称:origin,代码行数:34,代码来源:strategies.go
示例4: New
// New returns the instance of STI builder strategy for the given config.
// If the layeredBuilder parameter is specified, then the builder provided will
// be used for the case that the base Docker image does not have 'tar' or 'bash'
// installed.
func New(req *api.Config) (*STI, error) {
docker, err := docker.New(req.DockerConfig, req.PullAuthentication)
if err != nil {
return nil, err
}
inst := scripts.NewInstaller(req.BuilderImage, req.ScriptsURL, docker, req.PullAuthentication)
b := &STI{
installer: inst,
config: req,
docker: docker,
git: git.New(),
fs: util.NewFileSystem(),
tar: tar.New(),
callbackInvoker: util.NewCallbackInvoker(),
requiredScripts: []string{api.Assemble, api.Run},
optionalScripts: []string{api.SaveArtifacts},
externalScripts: map[string]bool{},
installedScripts: map[string]bool{},
scriptsURL: map[string]string{},
}
// The sources are downloaded using the GIT downloader.
// TODO: Add more SCM in future.
b.source = &git.Clone{b.git, b.fs}
b.garbage = &build.DefaultCleaner{b.fs, b.docker}
b.layered, err = layered.New(req, b)
// Set interfaces
b.preparer = b
b.artifacts = b
b.scripts = b
b.postExecutor = b
return b, err
}
开发者ID:pombredanne,项目名称:atomic-enterprise,代码行数:39,代码来源:sti.go
示例5: New
// New returns a new instance of OnBuild builder
func New(config *api.Config, overrides build.Overrides) (*OnBuild, error) {
dockerHandler, err := docker.New(config.DockerConfig, config.PullAuthentication)
if err != nil {
return nil, err
}
b := &OnBuild{
docker: dockerHandler,
git: git.New(),
fs: util.NewFileSystem(),
tar: tar.New(),
}
// Use STI Prepare() and download the 'run' script optionally.
s, err := sti.New(config, overrides)
s.SetScripts([]string{}, []string{api.Assemble, api.Run})
downloader := overrides.Downloader
if downloader == nil {
d, sourceURL, err := scm.DownloaderForSource(config.Source)
if err != nil {
return nil, err
}
downloader = d
config.Source = sourceURL
}
b.source = onBuildSourceHandler{
Downloader: downloader,
Preparer: s,
Ignorer: &ignore.DockerIgnorer{},
}
b.garbage = &build.DefaultCleaner{b.fs, b.docker}
return b, nil
}
开发者ID:johnmccawley,项目名称:origin,代码行数:35,代码来源:onbuild.go
示例6: New
// New creates a DockerRunner for executing the methods associated with running
// the produced image in a docker container for verification purposes.
func New(config *api.Config) (*DockerRunner, error) {
client, err := docker.New(config.DockerConfig, config.PullAuthentication)
if err != nil {
glog.Errorf("Failed to connect to Docker daemon: %v", err)
return nil, err
}
return &DockerRunner{client}, nil
}
开发者ID:liggitt,项目名称:source-to-image,代码行数:10,代码来源:run.go
示例7: New
// Create the DockerRunning struct for executing the methods assoicated with running
// the produced image in a docker container for verification purposes.
func New(config *api.Config) (*DockerRunner, error) {
cc, ccerr := docker.New(config.DockerConfig, config.PullAuthentication)
if ccerr != nil {
glog.Errorf("Create of Docker Container client failed with %v \n", ccerr)
return nil, ccerr
}
dr := &DockerRunner{
ContainerClient: cc,
}
return dr, nil
}
开发者ID:iconoeugen,项目名称:source-to-image,代码行数:13,代码来源:run.go
示例8: New
func New(config *api.Config, scripts build.ScriptsHandler, overrides build.Overrides) (*Layered, error) {
d, err := docker.New(config.DockerConfig, config.PullAuthentication)
if err != nil {
return nil, err
}
return &Layered{
docker: d,
config: config,
fs: util.NewFileSystem(),
tar: tar.New(),
scripts: scripts,
}, nil
}
开发者ID:smacc364,项目名称:origin,代码行数:13,代码来源:layered.go
示例9: New
// New creates a Layered builder.
func New(config *api.Config, fs util.FileSystem, scripts build.ScriptsHandler, overrides build.Overrides) (*Layered, error) {
d, err := docker.New(config.DockerConfig, config.PullAuthentication)
if err != nil {
return nil, err
}
tarHandler := tar.New(fs)
tarHandler.SetExclusionPattern(regexp.MustCompile(config.ExcludeRegExp))
return &Layered{
docker: d,
config: config,
fs: fs,
tar: tarHandler,
scripts: scripts,
}, nil
}
开发者ID:php-coder,项目名称:origin,代码行数:16,代码来源:layered.go
示例10: GenerateConfigFromLabels
// GenerateConfigFromLabels generates the S2I Config struct from the Docker
// image labels.
func GenerateConfigFromLabels(image string, config *api.Config) error {
d, err := docker.New(config.DockerConfig, config.PullAuthentication)
if err != nil {
return err
}
var source *dockerclient.Image
if config.ForcePull {
source, err = d.PullImage(image)
} else {
source, err = d.CheckAndPullImage(image)
}
if err != nil {
return err
}
if builderVersion, ok := source.Config.Labels["io.openshift.builder-version"]; ok {
config.BuilderImageVersion = builderVersion
config.BuilderBaseImageVersion = source.Config.Labels["io.openshift.builder-base-version"]
}
config.ScriptsURL = source.Config.Labels[api.DefaultNamespace+"scripts-url"]
if len(config.ScriptsURL) == 0 {
// FIXME: Backward compatibility
config.ScriptsURL = source.Config.Labels["io.s2i.scripts-url"]
}
config.Description = source.Config.Labels[api.KubernetesNamespace+"description"]
config.DisplayName = source.Config.Labels[api.KubernetesNamespace+"display-name"]
if builder, ok := source.Config.Labels[api.DefaultNamespace+"build.image"]; ok {
config.BuilderImage = builder
} else {
return fmt.Errorf("Required label %q not found in image", api.DefaultNamespace+"build.image")
}
if repo, ok := source.Config.Labels[api.DefaultNamespace+"build.source-location"]; ok {
config.Source = repo
} else {
return fmt.Errorf("Required label %q not found in image", api.DefaultNamespace+"source-location")
}
config.ContextDir = source.Config.Labels[api.DefaultNamespace+"build.source-context-dir"]
config.Ref = source.Config.Labels[api.DefaultNamespace+"build.commit.ref"]
return nil
}
开发者ID:jhadvig,项目名称:origin,代码行数:50,代码来源:config.go
示例11: GetBuilderImage
// GetBuilderImage processes the config and performs operations necessary to make
// the Docker image specified as BuilderImage available locally.
// It returns information about the base image, containing metadata necessary
// for choosing the right STI build strategy.
func GetBuilderImage(config *api.Config) (*docker.PullResult, error) {
d, err := docker.New(config.DockerConfig, config.PullAuthentication)
result := docker.PullResult{}
if err != nil {
return nil, err
}
var image *dockerclient.Image
if config.ForcePull {
image, err = d.PullImage(config.BuilderImage)
} else {
image, err = d.CheckAndPull(config.BuilderImage)
}
if err != nil {
return nil, err
}
result.Image = image
result.OnBuild = d.IsImageOnBuild(config.BuilderImage)
return &result, nil
}
开发者ID:yarko,项目名称:source-to-image,代码行数:25,代码来源:strategies.go
示例12: New
// New returns a new instance of OnBuild builder
func New(config *api.Config) (*OnBuild, error) {
dockerHandler, err := docker.New(config.DockerConfig, config.PullAuthentication)
if err != nil {
return nil, err
}
b := &OnBuild{
docker: dockerHandler,
git: git.New(),
fs: util.NewFileSystem(),
tar: tar.New(),
}
// Use STI Prepare() and download the 'run' script optionally.
s, err := sti.New(config)
s.SetScripts([]string{}, []string{api.Assemble, api.Run})
b.source = onBuildSourceHandler{
&git.Clone{b.git, b.fs},
s,
}
b.garbage = &build.DefaultCleaner{b.fs, b.docker}
return b, nil
}
开发者ID:rimolive,项目名称:source-to-image,代码行数:23,代码来源:onbuild.go
示例13: New
// New returns the instance of STI builder strategy for the given config.
// If the layeredBuilder parameter is specified, then the builder provided will
// be used for the case that the base Docker image does not have 'tar' or 'bash'
// installed.
func New(config *api.Config, overrides build.Overrides) (*STI, error) {
docker, err := dockerpkg.New(config.DockerConfig, config.PullAuthentication)
if err != nil {
return nil, err
}
var incrementalDocker dockerpkg.Docker
if config.Incremental {
incrementalDocker, err = dockerpkg.New(config.DockerConfig, config.IncrementalAuthentication)
if err != nil {
return nil, err
}
}
inst := scripts.NewInstaller(config.BuilderImage, config.ScriptsURL, config.ScriptDownloadProxyConfig, docker, config.PullAuthentication)
tarHandler := tar.New()
tarHandler.SetExclusionPattern(regexp.MustCompile(config.ExcludeRegExp))
builder := &STI{
installer: inst,
config: config,
docker: docker,
incrementalDocker: incrementalDocker,
git: git.New(),
fs: util.NewFileSystem(),
tar: tarHandler,
callbackInvoker: util.NewCallbackInvoker(),
requiredScripts: []string{api.Assemble, api.Run},
optionalScripts: []string{api.SaveArtifacts},
optionalRuntimeScripts: []string{api.AssembleRuntime},
externalScripts: map[string]bool{},
installedScripts: map[string]bool{},
scriptsURL: map[string]string{},
}
if len(config.RuntimeImage) > 0 {
builder.runtimeInstaller = scripts.NewInstaller(config.RuntimeImage, config.ScriptsURL, config.ScriptDownloadProxyConfig, docker, config.PullAuthentication)
builder.runtimeDocker, err = dockerpkg.New(config.DockerConfig, config.RuntimeAuthentication)
if err != nil {
return builder, err
}
}
// The sources are downloaded using the Git downloader.
// TODO: Add more SCM in future.
// TODO: explicit decision made to customize processing for usage specifically vs.
// leveraging overrides; also, we ultimately want to simplify s2i usage a good bit,
// which would lead to replacing this quick short circuit (so this change is tactical)
builder.source = overrides.Downloader
if builder.source == nil && !config.Usage {
downloader, sourceURL, err := scm.DownloaderForSource(config.Source, config.ForceCopy)
if err != nil {
return nil, err
}
builder.source = downloader
config.Source = sourceURL
}
builder.garbage = build.NewDefaultCleaner(builder.fs, builder.docker)
builder.layered, err = layered.New(config, builder, overrides)
// Set interfaces
builder.preparer = builder
// later on, if we support say .gitignore func in addition to .dockerignore func, setting
// ignorer will be based on config setting
builder.ignorer = &ignore.DockerIgnorer{}
builder.artifacts = builder
builder.scripts = builder
builder.postExecutor = builder
builder.initPostExecutorSteps()
return builder, err
}
开发者ID:Xmagicer,项目名称:origin,代码行数:78,代码来源:sti.go
注:本文中的github.com/openshift/source-to-image/pkg/docker.New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论