podman
45 строк · 1.4 Кб
1package config
2
3import (
4"errors"
5"fmt"
6"os"
7
8dockerclient "github.com/fsouza/go-dockerclient"
9"github.com/openshift/imagebuilder"
10)
11
12// configOnlyExecutor implements the Executor interface that an
13// imagebuilder.Builder expects to be able to call to do some heavy lifting,
14// but it just refuses to do the work of ADD, COPY, or RUN. It also doesn't
15// care if the working directory exists in a container, because it's really
16// only concerned with letting the Builder's RunConfig get updated by changes
17// from a Dockerfile. Try anything more than that and it'll return an error.
18type configOnlyExecutor struct{}
19
20func (g *configOnlyExecutor) Preserve(path string) error {
21return errors.New("ADD/COPY/RUN not supported as changes")
22}
23
24func (g *configOnlyExecutor) EnsureContainerPath(path string) error {
25return nil
26}
27
28func (g *configOnlyExecutor) EnsureContainerPathAs(path, user string, mode *os.FileMode) error {
29return nil
30}
31
32func (g *configOnlyExecutor) Copy(excludes []string, copies ...imagebuilder.Copy) error {
33if len(copies) == 0 {
34return nil
35}
36return errors.New("ADD/COPY not supported as changes")
37}
38
39func (g *configOnlyExecutor) Run(run imagebuilder.Run, config dockerclient.Config) error {
40return errors.New("RUN not supported as changes")
41}
42
43func (g *configOnlyExecutor) UnrecognizedInstruction(step *imagebuilder.Step) error {
44return fmt.Errorf("did not understand change instruction %q", step.Original)
45}
46