Skip to content

Commit

Permalink
refactor(dev): skip publication of metadata images in dev mode
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Igrychev <alexey.igrychev@flant.com>
  • Loading branch information
alexey-igrychev committed Mar 21, 2022
1 parent 69f4319 commit 007f442
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cmd/werf/common/conveyor_options.go
Expand Up @@ -64,7 +64,8 @@ func GetBuildOptions(commonCmdData *CmdData, giterminismManager giterminism_mana
}

buildOptions = build.BuildOptions{
CustomTagFuncList: customTagFuncList,
SkipImageMetadataPublication: *commonCmdData.Dev,
CustomTagFuncList: customTagFuncList,
ImageBuildOptions: container_runtime.LegacyBuildOptions{
IntrospectAfterError: *commonCmdData.IntrospectAfterError,
IntrospectBeforeError: *commonCmdData.IntrospectBeforeError,
Expand Down
2 changes: 1 addition & 1 deletion cmd/werf/compose/main.go
Expand Up @@ -430,7 +430,7 @@ func run(ctx context.Context, containerRuntime container_runtime.ContainerRuntim
return err
}
} else {
if err := c.Build(ctx, build.BuildOptions{}); err != nil {
if err := c.Build(ctx, build.BuildOptions{SkipImageMetadataPublication: *commonCmdData.Dev}); err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/werf/export/export.go
Expand Up @@ -222,7 +222,7 @@ func run(ctx context.Context, imagesToProcess, tagTemplateList []string) error {

return c.Export(ctx, build.ExportOptions{
BuildPhaseOptions: build.BuildPhaseOptions{
BuildOptions: build.BuildOptions{},
BuildOptions: build.BuildOptions{SkipImageMetadataPublication: *commonCmdData.Dev},
ShouldBeBuiltMode: *commonCmdData.SkipBuild,
},
ExportPhaseOptions: build.ExportPhaseOptions{
Expand Down
2 changes: 1 addition & 1 deletion cmd/werf/run/run.go
Expand Up @@ -387,7 +387,7 @@ func run(ctx context.Context, containerRuntime container_runtime.ContainerRuntim
return err
}
} else {
if err := c.Build(ctx, build.BuildOptions{}); err != nil {
if err := c.Build(ctx, build.BuildOptions{SkipImageMetadataPublication: *commonCmdData.Dev}); err != nil {
return err
}
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/build/build_phase.go
Expand Up @@ -42,7 +42,8 @@ type BuildOptions struct {
ReportPath string
ReportFormat ReportFormat

CustomTagFuncList []func(string) string
SkipImageMetadataPublication bool
CustomTagFuncList []func(string) string
}

type IntrospectOptions struct {
Expand Down Expand Up @@ -230,8 +231,10 @@ func (phase *BuildPhase) AfterImageStages(ctx context.Context, img *Image) error
return err
}

if err := phase.publishImageMetadata(ctx, img); err != nil {
return err
if !phase.BuildPhaseOptions.SkipImageMetadataPublication {
if err := phase.publishImageMetadata(ctx, img); err != nil {
return err
}
}

if img.isArtifact {
Expand Down

0 comments on commit 007f442

Please sign in to comment.