feat: allow a subdir within a context

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2020-04-03 15:34:59 -03:00
parent 0fe0a64113
commit 3aaec5015b
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
1 changed files with 9 additions and 4 deletions

View File

@ -39,10 +39,11 @@ import (
)
var (
opts = &config.KanikoOptions{}
force bool
logLevel string
logFormat string
opts = &config.KanikoOptions{}
ctxSubPath string
force bool
logLevel string
logFormat string
)
func init() {
@ -131,6 +132,7 @@ var RootCmd = &cobra.Command{
func addKanikoOptionsFlags() {
RootCmd.PersistentFlags().StringVarP(&opts.DockerfilePath, "dockerfile", "f", "Dockerfile", "Path to the dockerfile to be built.")
RootCmd.PersistentFlags().StringVarP(&opts.SrcContext, "context", "c", "/workspace/", "Path to the dockerfile build context.")
RootCmd.PersistentFlags().StringVarP(&ctxSubPath, "context-sub-path", "", "", "Sub path within the given context.")
RootCmd.PersistentFlags().StringVarP(&opts.Bucket, "bucket", "b", "", "Name of the GCS bucket from which to access build context as tarball.")
RootCmd.PersistentFlags().VarP(&opts.Destinations, "destination", "d", "Registry the final image should be pushed to. Set it repeatedly for multiple destinations.")
RootCmd.PersistentFlags().StringVarP(&opts.SnapshotMode, "snapshotMode", "", "full", "Change the file attributes inspected during snapshotting")
@ -259,6 +261,9 @@ func resolveSourceContext() error {
if err != nil {
return err
}
if ctxSubPath != "" {
opts.SrcContext = filepath.Join(opts.SrcContext, ctxSubPath)
}
logrus.Debugf("Build context located at %s", opts.SrcContext)
return nil
}