feat: new git flags

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker
2020-06-15 17:24:04 -03:00
parent 7b8879c03f
commit 57c2df4d97
4 changed files with 91 additions and 6 deletions
+8 -1
View File
@@ -175,6 +175,9 @@ func addKanikoOptionsFlags() {
RootCmd.PersistentFlags().VarP(&opts.Labels, "label", "", "Set metadata for an image. Set it repeatedly for multiple labels.")
RootCmd.PersistentFlags().BoolVarP(&opts.SkipUnusedStages, "skip-unused-stages", "", false, "Build only used stages if defined to true. Otherwise it builds by default all stages, even the unnecessaries ones until it reaches the target stage / end of Dockerfile")
RootCmd.PersistentFlags().BoolVarP(&opts.RunV2, "use-new-run", "", false, "Experimental run command to detect file system changes. This new run command does no rely on snapshotting to detect changes.")
RootCmd.PersistentFlags().StringVarP(&opts.Git.Branch, "git-branch", "", "", "Branch to clone if build context is a git repository")
RootCmd.PersistentFlags().BoolVarP(&opts.Git.SingleBranch, "git-single-branch", "", false, "Whether to clone a single branch")
RootCmd.PersistentFlags().BoolVarP(&opts.Git.RecurseSubmodules, "git-recurse-submodules", "", false, "Whether to clone recursing submodules")
}
// addHiddenFlags marks certain flags as hidden from the executor help text
@@ -266,7 +269,11 @@ func resolveSourceContext() error {
opts.SrcContext = opts.Bucket
}
}
contextExecutor, err := buildcontext.GetBuildContext(opts.SrcContext)
contextExecutor, err := buildcontext.GetBuildContext(opts.SrcContext, buildcontext.BuildOptions{
GitBranch: opts.Git.Branch,
GitSingleBranch: opts.Git.SingleBranch,
GitRecurseSubmodules: opts.Git.RecurseSubmodules,
})
if err != nil {
return err
}