本文整理汇总了Golang中github.com/openshift/source-to-image/pkg/api.Config.PreviousImagePullPolicy方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.PreviousImagePullPolicy方法的具体用法?Golang Config.PreviousImagePullPolicy怎么用?Golang Config.PreviousImagePullPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/openshift/source-to-image/pkg/api.Config
的用法示例。
在下文中一共展示了Config.PreviousImagePullPolicy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newCmdRebuild
func newCmdRebuild(cfg *api.Config) *cobra.Command {
buildCmd := &cobra.Command{
Use: "rebuild <image> [<new-tag>]",
Short: "Rebuild an existing image",
Long: "Rebuild an existing application image that was built by S2I previously.",
Run: func(cmd *cobra.Command, args []string) {
// If user specifies the arguments, then we override the stored ones
if len(args) >= 1 {
cfg.Tag = args[0]
} else {
cmd.Help()
os.Exit(1)
}
if r, err := os.Open(cfg.DockerCfgPath); err == nil {
defer r.Close()
cfg.PullAuthentication = docker.LoadAndGetImageRegistryAuth(r, cfg.Tag)
}
pr, err := docker.GetRebuildImage(cfg)
checkErr(err)
err = build.GenerateConfigFromLabels(cfg, pr)
checkErr(err)
if len(args) >= 2 {
cfg.Tag = args[1]
}
// Attempt to read the .dockercfg and extract the authentication for
// docker pull
if r, err := os.Open(cfg.DockerCfgPath); err == nil {
defer r.Close()
cfg.PullAuthentication = docker.LoadAndGetImageRegistryAuth(r, cfg.BuilderImage)
}
if len(cfg.BuilderPullPolicy) == 0 {
cfg.BuilderPullPolicy = api.DefaultBuilderPullPolicy
}
if len(cfg.PreviousImagePullPolicy) == 0 {
cfg.PreviousImagePullPolicy = api.DefaultPreviousImagePullPolicy
}
glog.V(2).Infof("\n%s\n", describe.Config(cfg))
builder, _, err := strategies.GetStrategy(cfg)
checkErr(err)
result, err := builder.Build(cfg)
checkErr(err)
for _, message := range result.Messages {
glog.V(1).Infof(message)
}
},
}
cmdutil.AddCommonFlags(buildCmd, cfg)
return buildCmd
}
示例2: newCmdUsage
func newCmdUsage(cfg *api.Config) *cobra.Command {
oldScriptsFlag := ""
oldDestination := ""
usageCmd := &cobra.Command{
Use: "usage <image>",
Short: "Print usage of the assemble script associated with the image",
Long: "Create and start a container from the image and invoke its usage script.",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.Help()
os.Exit(1)
}
cfg.Usage = true
cfg.BuilderImage = args[0]
if len(oldScriptsFlag) != 0 {
glog.Warning("DEPRECATED: Flag --scripts is deprecated, use --scripts-url instead")
cfg.ScriptsURL = oldScriptsFlag
}
if len(cfg.BuilderPullPolicy) == 0 {
cfg.BuilderPullPolicy = api.DefaultBuilderPullPolicy
}
if len(cfg.PreviousImagePullPolicy) == 0 {
cfg.PreviousImagePullPolicy = api.DefaultPreviousImagePullPolicy
}
uh, err := sti.NewUsage(cfg)
checkErr(err)
err = uh.Show()
checkErr(err)
},
}
usageCmd.Flags().StringVarP(&(oldDestination), "location", "l", "",
"Specify a destination location for untar operation")
cmdutil.AddCommonFlags(usageCmd, cfg)
return usageCmd
}
示例3: newCmdBuild
func newCmdBuild(cfg *api.Config) *cobra.Command {
useConfig := false
oldScriptsFlag := ""
oldDestination := ""
buildCmd := &cobra.Command{
Use: "build <source> <image> [<tag>]",
Short: "Build a new image",
Long: "Build a new Docker image named <tag> (if provided) from a source repository and base image.",
Example: `
# Build an application Docker image from a Git repository
$ s2i build git://github.com/openshift/ruby-hello-world centos/ruby-22-centos7 hello-world-app
# Build from a local directory
$ s2i build . centos/ruby-22-centos7 hello-world-app
`,
Run: func(cmd *cobra.Command, args []string) {
glog.V(1).Infof("Running S2I version %q\n", version.Get())
// Attempt to restore the build command from the configuration file
if useConfig {
config.Restore(cfg, cmd)
}
// If user specifies the arguments, then we override the stored ones
if len(args) >= 2 {
cfg.Source = args[0]
cfg.BuilderImage = args[1]
if len(args) >= 3 {
cfg.Tag = args[2]
}
}
if cfg.Incremental && len(cfg.RuntimeImage) > 0 {
fmt.Fprintln(os.Stderr, "ERROR: Incremental build with runtime image isn't supported")
os.Exit(1)
}
if cfg.ForcePull {
glog.Warning("DEPRECATED: The '--force-pull' option is deprecated. Use '--pull-policy' instead")
}
if len(cfg.BuilderPullPolicy) == 0 {
cfg.BuilderPullPolicy = api.DefaultBuilderPullPolicy
}
if len(cfg.PreviousImagePullPolicy) == 0 {
cfg.PreviousImagePullPolicy = api.DefaultPreviousImagePullPolicy
}
if errs := validation.ValidateConfig(cfg); len(errs) > 0 {
for _, e := range errs {
fmt.Fprintf(os.Stderr, "ERROR: %s\n", e)
}
fmt.Println()
cmd.Help()
os.Exit(1)
}
// Persists the current command line options and config into .s2ifile
if useConfig {
config.Save(cfg, cmd)
}
// Attempt to read the .dockercfg and extract the authentication for
// docker pull
if r, err := os.Open(cfg.DockerCfgPath); err == nil {
defer r.Close()
auths := docker.LoadImageRegistryAuth(r)
cfg.PullAuthentication = docker.GetImageRegistryAuth(auths, cfg.BuilderImage)
if cfg.Incremental {
cfg.IncrementalAuthentication = docker.GetImageRegistryAuth(auths, cfg.Tag)
}
if len(cfg.RuntimeImage) > 0 {
cfg.RuntimeAuthentication = docker.GetImageRegistryAuth(auths, cfg.RuntimeImage)
}
}
if len(cfg.EnvironmentFile) > 0 {
result, err := util.ReadEnvironmentFile(cfg.EnvironmentFile)
if err != nil {
glog.Warningf("Unable to read environment file %q: %v", cfg.EnvironmentFile, err)
} else {
for name, value := range result {
cfg.Environment = append(cfg.Environment, api.EnvironmentSpec{Name: name, Value: value})
}
}
}
if len(oldScriptsFlag) != 0 {
glog.Warning("DEPRECATED: Flag --scripts is deprecated, use --scripts-url instead")
cfg.ScriptsURL = oldScriptsFlag
}
if len(oldDestination) != 0 {
glog.Warning("DEPRECATED: Flag --location is deprecated, use --destination instead")
cfg.Destination = oldDestination
}
glog.V(2).Infof("\n%s\n", describe.Config(cfg))
err := docker.CheckReachable(cfg)
if err != nil {
//.........这里部分代码省略.........