Skip to content

Commit b731f95

Browse files
author
OpenShift Bot
committed
Merge pull request #414 from soltysh/inc_flag
Merged by openshift-bot
2 parents 4194780 + 2d63dc3 commit b731f95

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

cmd/s2i/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ $ s2i build . centos/ruby-22-centos7 hello-world-app
8181
if len(cfg.BuilderPullPolicy) == 0 {
8282
cfg.BuilderPullPolicy = api.DefaultBuilderPullPolicy
8383
}
84+
if len(cfg.PreviousImagePullPolicy) == 0 {
85+
cfg.PreviousImagePullPolicy = api.DefaultPreviousImagePullPolicy
86+
}
8487

8588
if errs := validation.ValidateConfig(cfg); len(errs) > 0 {
8689
for _, e := range errs {
@@ -215,6 +218,9 @@ func newCmdRebuild(cfg *api.Config) *cobra.Command {
215218
if len(cfg.BuilderPullPolicy) == 0 {
216219
cfg.BuilderPullPolicy = api.DefaultBuilderPullPolicy
217220
}
221+
if len(cfg.PreviousImagePullPolicy) == 0 {
222+
cfg.PreviousImagePullPolicy = api.DefaultPreviousImagePullPolicy
223+
}
218224

219225
if glog.V(2) {
220226
fmt.Printf("\n%s\n", describe.DescribeConfig(cfg))
@@ -282,6 +288,9 @@ func newCmdUsage(cfg *api.Config) *cobra.Command {
282288
if len(cfg.BuilderPullPolicy) == 0 {
283289
cfg.BuilderPullPolicy = api.DefaultBuilderPullPolicy
284290
}
291+
if len(cfg.PreviousImagePullPolicy) == 0 {
292+
cfg.PreviousImagePullPolicy = api.DefaultPreviousImagePullPolicy
293+
}
285294

286295
uh, err := sti.NewUsage(cfg)
287296
checkErr(err)

pkg/api/describe/describer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func DescribeConfig(config *api.Config) string {
4040
}
4141
fmt.Fprintf(out, "Remove Old Build:\t%s\n", printBool(config.RemovePreviousImage))
4242
fmt.Fprintf(out, "Builder Pull Policy:\t%s\n", config.BuilderPullPolicy)
43+
fmt.Fprintf(out, "Previous Image Pull Policy:\t%s\n", config.PreviousImagePullPolicy)
4344
fmt.Fprintf(out, "Quiet:\t%s\n", printBool(config.Quiet))
4445
fmt.Fprintf(out, "Layered Build:\t%s\n", printBool(config.LayeredBuild))
4546
if len(config.Destination) > 0 {

pkg/api/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const (
3535

3636
// DefaultPreviousImagePullPolicy specifies policy for pulling the previously
3737
// build Docker image when doing incremental build
38-
DefaultPreviousImagePullPolicy = PullAlways
38+
DefaultPreviousImagePullPolicy = PullIfNotPresent
3939
)
4040

4141
// Config contains essential fields for performing build.

pkg/cmd/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func AddCommonFlags(c *cobra.Command, cfg *api.Config) {
2424
"DEPRECATED: Always pull the builder image even if it is present locally")
2525
c.Flags().VarP(&(cfg.BuilderPullPolicy), "pull-policy", "p",
2626
"Specify when to pull the builder image (always, never or if-not-present)")
27+
c.Flags().Var(&(cfg.PreviousImagePullPolicy), "incremental-pull-policy",
28+
"Specify when to pull the previous image for incremental builds (always, never or if-not-present)")
2729
c.Flags().BoolVar(&(cfg.PreserveWorkingDir), "save-temp-dir", false,
2830
"Save the temporary directory used by S2I instead of deleting it")
2931
c.Flags().StringVarP(&(cfg.DockerCfgPath), "dockercfg-path", "", filepath.Join(os.Getenv("HOME"), ".docker/config.json"),

pkg/docker/fake_docker.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ func (f *FakeDocker) PullImage(imageName string) (*dockerclient.Image, error) {
147147

148148
// CheckAndPullImage pulls a fake docker image
149149
func (f *FakeDocker) CheckAndPullImage(name string) (*dockerclient.Image, error) {
150-
return nil, nil
150+
if f.PullResult {
151+
return &dockerclient.Image{}, nil
152+
}
153+
return nil, f.PullError
151154
}
152155

153156
// BuildImage builds image

0 commit comments

Comments
 (0)