Merge pull request #292 from rawkode/feature/allow-build-only

Add Flag to Disable Push to Container Registry
This commit is contained in:
priyawadhwa 2018-08-17 10:50:50 -07:00 committed by GitHub
commit 10efecbb74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -279,6 +279,10 @@ Set this flag as `--tarPath=<path>` to save the image as a tarball at path inste
Set this flag to indicate which build stage is the target build stage.
#### --no-push
Set this flag if you only want to build the image, without pushing to a registry.
### Debug Image
The kaniko executor image is based off of scratch and doesn't contain a shell.

View File

@ -45,6 +45,7 @@ var (
singleSnapshot bool
reproducible bool
target string
noPush bool
)
func init() {
@ -52,7 +53,6 @@ func init() {
RootCmd.PersistentFlags().StringVarP(&srcContext, "context", "c", "/workspace/", "Path to the dockerfile build context.")
RootCmd.PersistentFlags().StringVarP(&bucket, "bucket", "b", "", "Name of the GCS bucket from which to access build context as tarball.")
RootCmd.PersistentFlags().VarP(&destinations, "destination", "d", "Registry the final image should be pushed to. Set it repeatedly for multiple destinations.")
RootCmd.MarkPersistentFlagRequired("destination")
RootCmd.PersistentFlags().StringVarP(&snapshotMode, "snapshotMode", "", "full", "Set this flag to change the file attributes inspected during snapshotting")
RootCmd.PersistentFlags().VarP(&buildArgs, "build-arg", "", "This flag allows you to pass in ARG values at build time. Set it repeatedly for multiple values.")
RootCmd.PersistentFlags().BoolVarP(&dockerInsecureSkipTLSVerify, "insecure-skip-tls-verify", "", false, "Push to insecure registry ignoring TLS verify")
@ -62,6 +62,7 @@ func init() {
RootCmd.PersistentFlags().BoolVarP(&singleSnapshot, "single-snapshot", "", false, "Set this flag to take a single snapshot at the end of the build.")
RootCmd.PersistentFlags().BoolVarP(&reproducible, "reproducible", "", false, "Strip timestamps out of the image to make it reproducible")
RootCmd.PersistentFlags().StringVarP(&target, "target", "", "", " Set the target build stage to build")
RootCmd.PersistentFlags().BoolVarP(&noPush, "no-push", "", false, "Do not push the image to the registry")
}
var RootCmd = &cobra.Command{
@ -73,6 +74,10 @@ var RootCmd = &cobra.Command{
if err := resolveSourceContext(); err != nil {
return err
}
if !noPush && len(destinations) == 0 {
return errors.New("You must provide --destination, or use --no-push")
}
return checkDockerfilePath()
},
Run: func(cmd *cobra.Command, args []string) {
@ -101,6 +106,11 @@ var RootCmd = &cobra.Command{
os.Exit(1)
}
if noPush {
logrus.Info("Skipping push to container registry due to --no-push flag")
os.Exit(0)
}
if err := executor.DoPush(image, destinations, tarPath, dockerInsecureSkipTLSVerify); err != nil {
logrus.Error(err)
os.Exit(1)