mirror of
https://github.com/containers/podman.git
synced 2025-06-30 15:49:03 +08:00
Add OnBuild support for podman build
Only supported for docker formated images. OCI Does not support this flag. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
3
vendor/github.com/projectatomic/buildah/commit.go
generated
vendored
3
vendor/github.com/projectatomic/buildah/commit.go
generated
vendored
@ -52,6 +52,9 @@ type CommitOptions struct {
|
||||
// Squash tells the builder to produce an image with a single layer
|
||||
// instead of with possibly more than one layer.
|
||||
Squash bool
|
||||
|
||||
// OnBuild is a list of commands to be run by images based on this image
|
||||
OnBuild []string
|
||||
}
|
||||
|
||||
// PushOptions can be used to alter how an image is copied somewhere.
|
||||
|
22
vendor/github.com/projectatomic/buildah/config.go
generated
vendored
22
vendor/github.com/projectatomic/buildah/config.go
generated
vendored
@ -331,6 +331,24 @@ func (b *Builder) SetUser(spec string) {
|
||||
b.Docker.Config.User = spec
|
||||
}
|
||||
|
||||
// OnBuild returns the OnBuild value from the container.
|
||||
func (b *Builder) OnBuild() []string {
|
||||
return copyStringSlice(b.Docker.Config.OnBuild)
|
||||
}
|
||||
|
||||
// ClearOnBuild removes all values from the OnBuild structure
|
||||
func (b *Builder) ClearOnBuild() {
|
||||
b.Docker.Config.OnBuild = []string{}
|
||||
}
|
||||
|
||||
// SetOnBuild sets a trigger instruction to be executed when the image is used
|
||||
// as the base of another image.
|
||||
// Note: this setting is not present in the OCIv1 image format, so it is
|
||||
// discarded when writing images using OCIv1 formats.
|
||||
func (b *Builder) SetOnBuild(onBuild string) {
|
||||
b.Docker.Config.OnBuild = append(b.Docker.Config.OnBuild, onBuild)
|
||||
}
|
||||
|
||||
// WorkDir returns the default working directory for running commands in the
|
||||
// container, or in a container built using an image built from this container.
|
||||
func (b *Builder) WorkDir() string {
|
||||
@ -348,7 +366,7 @@ func (b *Builder) SetWorkDir(there string) {
|
||||
// Shell returns the default shell for running commands in the
|
||||
// container, or in a container built using an image built from this container.
|
||||
func (b *Builder) Shell() []string {
|
||||
return b.Docker.Config.Shell
|
||||
return copyStringSlice(b.Docker.Config.Shell)
|
||||
}
|
||||
|
||||
// SetShell sets the default shell for running
|
||||
@ -357,7 +375,7 @@ func (b *Builder) Shell() []string {
|
||||
// Note: this setting is not present in the OCIv1 image format, so it is
|
||||
// discarded when writing images using OCIv1 formats.
|
||||
func (b *Builder) SetShell(shell []string) {
|
||||
b.Docker.Config.Shell = shell
|
||||
b.Docker.Config.Shell = copyStringSlice(shell)
|
||||
}
|
||||
|
||||
// Env returns a list of key-value pairs to be set when running commands in the
|
||||
|
8
vendor/github.com/projectatomic/buildah/imagebuildah/build.go
generated
vendored
8
vendor/github.com/projectatomic/buildah/imagebuildah/build.go
generated
vendored
@ -138,6 +138,8 @@ type BuildOptions struct {
|
||||
Labels []string
|
||||
// Annotation metadata for an image
|
||||
Annotations []string
|
||||
// OnBuild commands to be run by images based on this image
|
||||
OnBuild []string
|
||||
}
|
||||
|
||||
// Executor is a buildah-based implementation of the imagebuilder.Executor
|
||||
@ -183,6 +185,7 @@ type Executor struct {
|
||||
squash bool
|
||||
labels []string
|
||||
annotations []string
|
||||
onbuild []string
|
||||
}
|
||||
|
||||
// withName creates a new child executor that will be used whenever a COPY statement uses --from=NAME.
|
||||
@ -598,6 +601,7 @@ func (b *Executor) Prepare(ctx context.Context, ib *imagebuilder.Builder, node *
|
||||
Labels: builder.Labels(),
|
||||
Shell: builder.Shell(),
|
||||
StopSignal: builder.StopSignal(),
|
||||
OnBuild: builder.OnBuild(),
|
||||
}
|
||||
var rootfs *docker.RootFS
|
||||
if builder.Docker.RootFS != nil {
|
||||
@ -714,6 +718,10 @@ func (b *Executor) Commit(ctx context.Context, ib *imagebuilder.Builder) (err er
|
||||
for v := range config.Volumes {
|
||||
b.builder.AddVolume(v)
|
||||
}
|
||||
b.builder.ClearOnBuild()
|
||||
for _, onBuildSpec := range config.OnBuild {
|
||||
b.builder.SetOnBuild(onBuildSpec)
|
||||
}
|
||||
b.builder.SetWorkDir(config.WorkingDir)
|
||||
b.builder.SetEntrypoint(config.Entrypoint)
|
||||
b.builder.SetShell(config.Shell)
|
||||
|
2
vendor/github.com/projectatomic/buildah/imagebuildah/chroot_symlink.go
generated
vendored
2
vendor/github.com/projectatomic/buildah/imagebuildah/chroot_symlink.go
generated
vendored
@ -37,7 +37,7 @@ func resolveChrootedSymlinks() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Our second paramter is the path name to evaluate for symbolic links
|
||||
// Our second parameter is the path name to evaluate for symbolic links
|
||||
symLink, err := getSymbolicLink(flag.Arg(0), flag.Arg(1))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error getting symbolic links: %v\n", err)
|
||||
|
4
vendor/github.com/projectatomic/buildah/pkg/cli/common.go
generated
vendored
4
vendor/github.com/projectatomic/buildah/pkg/cli/common.go
generated
vendored
@ -152,6 +152,10 @@ var (
|
||||
Name: "squash",
|
||||
Usage: "Squash newly built layers into a single new layer. Buildah does not currently support caching so this is a NOOP.",
|
||||
},
|
||||
cli.BoolTFlag{
|
||||
Name: "stream",
|
||||
Usage: "There is no daemon in use, so this command is a NOOP.",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "tag, t",
|
||||
Usage: "tagged `name` to apply to the built image",
|
||||
|
Reference in New Issue
Block a user