Add CacheCommand to DockerCommand interface
CacheCommand returns true if the command should be cached. Currently, it's only true for RUN but can be added to ADD/COPY later on (these are different since the contents of files for ADD/COPY need to be included in the cache key generation). I also changed CreatedBy to String so that we can log each command before cache extraction or regular execution takes place.
This commit is contained in:
parent
2e10d2761c
commit
4f3ab61b96
|
|
@ -18,7 +18,6 @@ package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||||
|
|
||||||
|
|
@ -47,9 +46,6 @@ func (a *AddCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.Bui
|
||||||
srcs := a.cmd.SourcesAndDest[:len(a.cmd.SourcesAndDest)-1]
|
srcs := a.cmd.SourcesAndDest[:len(a.cmd.SourcesAndDest)-1]
|
||||||
dest := a.cmd.SourcesAndDest[len(a.cmd.SourcesAndDest)-1]
|
dest := a.cmd.SourcesAndDest[len(a.cmd.SourcesAndDest)-1]
|
||||||
|
|
||||||
logrus.Infof("cmd: Add %s", srcs)
|
|
||||||
logrus.Infof("dest: %s", dest)
|
|
||||||
|
|
||||||
// First, resolve any environment replacement
|
// First, resolve any environment replacement
|
||||||
replacementEnvs := buildArgs.ReplacementEnvs(config.Env)
|
replacementEnvs := buildArgs.ReplacementEnvs(config.Env)
|
||||||
resolvedEnvs, err := util.ResolveEnvironmentReplacementList(a.cmd.SourcesAndDest, replacementEnvs, true)
|
resolvedEnvs, err := util.ResolveEnvironmentReplacementList(a.cmd.SourcesAndDest, replacementEnvs, true)
|
||||||
|
|
@ -112,7 +108,12 @@ func (a *AddCommand) FilesToSnapshot() []string {
|
||||||
return a.snapshotFiles
|
return a.snapshotFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config
|
// String returns some information about the command for the image config
|
||||||
func (a *AddCommand) CreatedBy() string {
|
func (a *AddCommand) String() string {
|
||||||
return strings.Join(a.cmd.SourcesAndDest, " ")
|
return a.cmd.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
|
func (a *AddCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,10 @@ limitations under the License.
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||||
"github.com/google/go-containerregistry/pkg/v1"
|
"github.com/google/go-containerregistry/pkg/v1"
|
||||||
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ArgCommand struct {
|
type ArgCommand struct {
|
||||||
|
|
@ -32,7 +29,6 @@ type ArgCommand struct {
|
||||||
|
|
||||||
// ExecuteCommand only needs to add this ARG key/value as seen
|
// ExecuteCommand only needs to add this ARG key/value as seen
|
||||||
func (r *ArgCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
func (r *ArgCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
||||||
logrus.Info("ARG")
|
|
||||||
replacementEnvs := buildArgs.ReplacementEnvs(config.Env)
|
replacementEnvs := buildArgs.ReplacementEnvs(config.Env)
|
||||||
resolvedKey, err := util.ResolveEnvironmentReplacement(r.cmd.Key, replacementEnvs, false)
|
resolvedKey, err := util.ResolveEnvironmentReplacement(r.cmd.Key, replacementEnvs, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -55,7 +51,12 @@ func (r *ArgCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config history
|
// String returns some information about the command for the image config history
|
||||||
func (r *ArgCommand) CreatedBy() string {
|
func (r *ArgCommand) String() string {
|
||||||
return strings.Join([]string{r.cmd.Name(), r.cmd.Key}, " ")
|
return r.cmd.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
|
func (r *ArgCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ type CmdCommand struct {
|
||||||
// ExecuteCommand executes the CMD command
|
// ExecuteCommand executes the CMD command
|
||||||
// Argument handling is the same as RUN.
|
// Argument handling is the same as RUN.
|
||||||
func (c *CmdCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
func (c *CmdCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
||||||
logrus.Info("cmd: CMD")
|
|
||||||
var newCommand []string
|
var newCommand []string
|
||||||
if c.cmd.PrependShell {
|
if c.cmd.PrependShell {
|
||||||
// This is the default shell on Linux
|
// This is the default shell on Linux
|
||||||
|
|
@ -60,15 +59,12 @@ func (c *CmdCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config history
|
// String returns some information about the command for the image config history
|
||||||
func (c *CmdCommand) CreatedBy() string {
|
func (c *CmdCommand) String() string {
|
||||||
cmd := []string{"CMD"}
|
return c.cmd.String()
|
||||||
cmdLine := strings.Join(c.cmd.CmdLine, " ")
|
}
|
||||||
if c.cmd.PrependShell {
|
|
||||||
// TODO: Support shell command here
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
shell := []string{"/bin/sh", "-c"}
|
func (c *CmdCommand) CacheCommand() bool {
|
||||||
appendedShell := append(cmd, shell...)
|
return false
|
||||||
return strings.Join(append(appendedShell, cmdLine), " ")
|
|
||||||
}
|
|
||||||
return strings.Join(append(cmd, cmdLine), " ")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,13 @@ type DockerCommand interface {
|
||||||
// 2. Updating metadata fields in the config
|
// 2. Updating metadata fields in the config
|
||||||
// It should not change the config history.
|
// It should not change the config history.
|
||||||
ExecuteCommand(*v1.Config, *dockerfile.BuildArgs) error
|
ExecuteCommand(*v1.Config, *dockerfile.BuildArgs) error
|
||||||
// The config history has a "created by" field, should return information about the command
|
// Returns a string representation of the command
|
||||||
CreatedBy() string
|
String() string
|
||||||
// A list of files to snapshot, empty for metadata commands or nil if we don't know
|
// A list of files to snapshot, empty for metadata commands or nil if we don't know
|
||||||
FilesToSnapshot() []string
|
FilesToSnapshot() []string
|
||||||
|
// Return true if this command should be true
|
||||||
|
// Currently only true for RUN
|
||||||
|
CacheCommand() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCommand(cmd instructions.Command, buildcontext string) (DockerCommand, error) {
|
func GetCommand(cmd instructions.Command, buildcontext string) (DockerCommand, error) {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ package commands
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/constants"
|
"github.com/GoogleContainerTools/kaniko/pkg/constants"
|
||||||
|
|
||||||
|
|
@ -27,7 +26,6 @@ import (
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||||
"github.com/google/go-containerregistry/pkg/v1"
|
"github.com/google/go-containerregistry/pkg/v1"
|
||||||
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CopyCommand struct {
|
type CopyCommand struct {
|
||||||
|
|
@ -40,9 +38,6 @@ func (c *CopyCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.Bu
|
||||||
srcs := c.cmd.SourcesAndDest[:len(c.cmd.SourcesAndDest)-1]
|
srcs := c.cmd.SourcesAndDest[:len(c.cmd.SourcesAndDest)-1]
|
||||||
dest := c.cmd.SourcesAndDest[len(c.cmd.SourcesAndDest)-1]
|
dest := c.cmd.SourcesAndDest[len(c.cmd.SourcesAndDest)-1]
|
||||||
|
|
||||||
logrus.Infof("cmd: copy %s", srcs)
|
|
||||||
logrus.Infof("dest: %s", dest)
|
|
||||||
|
|
||||||
// Resolve from
|
// Resolve from
|
||||||
if c.cmd.From != "" {
|
if c.cmd.From != "" {
|
||||||
c.buildcontext = filepath.Join(constants.KanikoDir, c.cmd.From)
|
c.buildcontext = filepath.Join(constants.KanikoDir, c.cmd.From)
|
||||||
|
|
@ -106,7 +101,12 @@ func (c *CopyCommand) FilesToSnapshot() []string {
|
||||||
return c.snapshotFiles
|
return c.snapshotFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config
|
// String returns some information about the command for the image config
|
||||||
func (c *CopyCommand) CreatedBy() string {
|
func (c *CopyCommand) String() string {
|
||||||
return strings.Join(c.cmd.SourcesAndDest, " ")
|
return c.cmd.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// CacheCommand returns true since this command should be cached
|
||||||
|
func (c *CopyCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ type EntrypointCommand struct {
|
||||||
|
|
||||||
// ExecuteCommand handles command processing similar to CMD and RUN,
|
// ExecuteCommand handles command processing similar to CMD and RUN,
|
||||||
func (e *EntrypointCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
func (e *EntrypointCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
||||||
logrus.Info("cmd: ENTRYPOINT")
|
|
||||||
var newCommand []string
|
var newCommand []string
|
||||||
if e.cmd.PrependShell {
|
if e.cmd.PrependShell {
|
||||||
// This is the default shell on Linux
|
// This is the default shell on Linux
|
||||||
|
|
@ -58,15 +57,12 @@ func (e *EntrypointCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config history
|
// String returns some information about the command for the image config history
|
||||||
func (e *EntrypointCommand) CreatedBy() string {
|
func (e *EntrypointCommand) String() string {
|
||||||
entrypoint := []string{"ENTRYPOINT"}
|
return e.cmd.String()
|
||||||
cmdLine := strings.Join(e.cmd.CmdLine, " ")
|
}
|
||||||
if e.cmd.PrependShell {
|
|
||||||
// TODO: Support shell command here
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
shell := []string{"/bin/sh", "-c"}
|
func (e *EntrypointCommand) CacheCommand() bool {
|
||||||
appendedShell := append(entrypoint, shell...)
|
return false
|
||||||
return strings.Join(append(appendedShell, cmdLine), " ")
|
|
||||||
}
|
|
||||||
return strings.Join(append(entrypoint, cmdLine), " ")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,11 @@ limitations under the License.
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||||
"github.com/google/go-containerregistry/pkg/v1"
|
"github.com/google/go-containerregistry/pkg/v1"
|
||||||
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type EnvCommand struct {
|
type EnvCommand struct {
|
||||||
|
|
@ -32,7 +29,6 @@ type EnvCommand struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EnvCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
func (e *EnvCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
||||||
logrus.Info("cmd: ENV")
|
|
||||||
newEnvs := e.cmd.Env
|
newEnvs := e.cmd.Env
|
||||||
replacementEnvs := buildArgs.ReplacementEnvs(config.Env)
|
replacementEnvs := buildArgs.ReplacementEnvs(config.Env)
|
||||||
return util.UpdateConfigEnv(newEnvs, config, replacementEnvs)
|
return util.UpdateConfigEnv(newEnvs, config, replacementEnvs)
|
||||||
|
|
@ -43,11 +39,12 @@ func (e *EnvCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config history
|
// String returns some information about the command for the image config history
|
||||||
func (e *EnvCommand) CreatedBy() string {
|
func (e *EnvCommand) String() string {
|
||||||
envArray := []string{e.cmd.Name()}
|
return e.cmd.String()
|
||||||
for _, pair := range e.cmd.Env {
|
}
|
||||||
envArray = append(envArray, pair.Key+"="+pair.Value)
|
|
||||||
}
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
return strings.Join(envArray, " ")
|
func (e *EnvCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,11 @@ func (r *ExposeCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ExposeCommand) CreatedBy() string {
|
func (r *ExposeCommand) String() string {
|
||||||
s := []string{r.cmd.Name()}
|
return r.cmd.String()
|
||||||
return strings.Join(append(s, r.cmd.Ports...), " ")
|
}
|
||||||
|
|
||||||
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
|
func (r *ExposeCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,9 @@ limitations under the License.
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||||
"github.com/google/go-containerregistry/pkg/v1"
|
"github.com/google/go-containerregistry/pkg/v1"
|
||||||
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type HealthCheckCommand struct {
|
type HealthCheckCommand struct {
|
||||||
|
|
@ -31,8 +28,6 @@ type HealthCheckCommand struct {
|
||||||
|
|
||||||
// ExecuteCommand handles command processing similar to CMD and RUN,
|
// ExecuteCommand handles command processing similar to CMD and RUN,
|
||||||
func (h *HealthCheckCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
func (h *HealthCheckCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
||||||
logrus.Info("cmd: HEALTHCHECK")
|
|
||||||
|
|
||||||
check := v1.HealthConfig(*h.cmd.Health)
|
check := v1.HealthConfig(*h.cmd.Health)
|
||||||
config.Healthcheck = &check
|
config.Healthcheck = &check
|
||||||
|
|
||||||
|
|
@ -44,9 +39,12 @@ func (h *HealthCheckCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config history
|
// String returns some information about the command for the image config history
|
||||||
func (h *HealthCheckCommand) CreatedBy() string {
|
func (h *HealthCheckCommand) String() string {
|
||||||
entrypoint := []string{"HEALTHCHECK"}
|
return h.cmd.String()
|
||||||
|
}
|
||||||
return strings.Join(append(entrypoint, strings.Join(h.cmd.Health.Test, " ")), " ")
|
|
||||||
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
|
func (h *HealthCheckCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ limitations under the License.
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||||
|
|
@ -32,7 +30,6 @@ type LabelCommand struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *LabelCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
func (r *LabelCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
|
||||||
logrus.Info("cmd: LABEL")
|
|
||||||
return updateLabels(r.cmd.Labels, config, buildArgs)
|
return updateLabels(r.cmd.Labels, config, buildArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,11 +69,12 @@ func (r *LabelCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config history
|
// String returns some information about the command for the image config history
|
||||||
func (r *LabelCommand) CreatedBy() string {
|
func (r *LabelCommand) String() string {
|
||||||
l := []string{r.cmd.Name()}
|
return r.cmd.String()
|
||||||
for _, kvp := range r.cmd.Labels {
|
}
|
||||||
l = append(l, kvp.String())
|
|
||||||
}
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
return strings.Join(l, " ")
|
func (r *LabelCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,12 @@ func (o *OnBuildCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config history
|
// String returns some information about the command for the image config history
|
||||||
func (o *OnBuildCommand) CreatedBy() string {
|
func (o *OnBuildCommand) String() string {
|
||||||
return o.cmd.Expression
|
return o.cmd.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
|
func (o *OnBuildCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,13 +137,12 @@ func (r *RunCommand) FilesToSnapshot() []string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config
|
// String returns some information about the command for the image config
|
||||||
func (r *RunCommand) CreatedBy() string {
|
func (r *RunCommand) String() string {
|
||||||
cmdLine := strings.Join(r.cmd.CmdLine, " ")
|
return r.cmd.String()
|
||||||
if r.cmd.PrependShell {
|
}
|
||||||
// TODO: Support shell command here
|
|
||||||
shell := []string{"/bin/sh", "-c"}
|
// CacheCommand returns true since this command should be cached
|
||||||
return strings.Join(append(shell, cmdLine), " ")
|
func (r *RunCommand) CacheCommand() bool {
|
||||||
}
|
return true
|
||||||
return cmdLine
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ limitations under the License.
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||||
"github.com/google/go-containerregistry/pkg/v1"
|
"github.com/google/go-containerregistry/pkg/v1"
|
||||||
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
||||||
|
|
@ -46,10 +44,12 @@ func (s *ShellCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config history
|
// String returns some information about the command for the image config history
|
||||||
func (s *ShellCommand) CreatedBy() string {
|
func (s *ShellCommand) String() string {
|
||||||
entrypoint := []string{"SHELL"}
|
return s.cmd.String()
|
||||||
cmdLine := strings.Join(s.cmd.Shell, " ")
|
}
|
||||||
|
|
||||||
return strings.Join(append(entrypoint, cmdLine), " ")
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
|
func (s *ShellCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ limitations under the License.
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||||
"github.com/docker/docker/pkg/signal"
|
"github.com/docker/docker/pkg/signal"
|
||||||
|
|
@ -59,9 +57,12 @@ func (s *StopSignalCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config history
|
// String returns some information about the command for the image config history
|
||||||
func (s *StopSignalCommand) CreatedBy() string {
|
func (s *StopSignalCommand) String() string {
|
||||||
entrypoint := []string{"STOPSIGNAL"}
|
return s.cmd.String()
|
||||||
|
}
|
||||||
return strings.Join(append(entrypoint, s.cmd.Signal), " ")
|
|
||||||
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
|
func (s *StopSignalCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,11 @@ func (r *UserCommand) FilesToSnapshot() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *UserCommand) CreatedBy() string {
|
func (r *UserCommand) String() string {
|
||||||
s := []string{r.cmd.Name(), r.cmd.User}
|
return r.cmd.String()
|
||||||
return strings.Join(s, " ")
|
}
|
||||||
|
|
||||||
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
|
func (r *UserCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ package commands
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||||
|
|
||||||
|
|
@ -72,6 +71,11 @@ func (v *VolumeCommand) FilesToSnapshot() []string {
|
||||||
return v.snapshotFiles
|
return v.snapshotFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *VolumeCommand) CreatedBy() string {
|
func (v *VolumeCommand) String() string {
|
||||||
return strings.Join(append([]string{v.cmd.Name()}, v.cmd.Volumes...), " ")
|
return v.cmd.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
|
func (v *VolumeCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,12 @@ func (w *WorkdirCommand) FilesToSnapshot() []string {
|
||||||
return w.snapshotFiles
|
return w.snapshotFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedBy returns some information about the command for the image config history
|
// String returns some information about the command for the image config history
|
||||||
func (w *WorkdirCommand) CreatedBy() string {
|
func (w *WorkdirCommand) String() string {
|
||||||
return w.cmd.Name() + " " + w.cmd.Path
|
return w.cmd.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// CacheCommand returns false since this command shouldn't be cached
|
||||||
|
func (w *WorkdirCommand) CacheCommand() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ func DoBuild(opts *options.KanikoOptions) (v1.Image, error) {
|
||||||
if dockerCommand == nil {
|
if dockerCommand == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
logrus.Info(dockerCommand.String())
|
||||||
if err := dockerCommand.ExecuteCommand(&imageConfig.Config, buildArgs); err != nil {
|
if err := dockerCommand.ExecuteCommand(&imageConfig.Config, buildArgs); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +139,7 @@ func DoBuild(opts *options.KanikoOptions) (v1.Image, error) {
|
||||||
Layer: layer,
|
Layer: layer,
|
||||||
History: v1.History{
|
History: v1.History{
|
||||||
Author: constants.Author,
|
Author: constants.Author,
|
||||||
CreatedBy: dockerCommand.CreatedBy(),
|
CreatedBy: dockerCommand.String(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue