Skip to content

Commit

Permalink
--first-only flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Hatcher committed May 19, 2021
1 parent d8b28c3 commit 28dba75
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ var testMode = false

var outputOnly = false

var firstOnly = false

type ErrorLine struct {
Error string `json:"error"`
ErrorDetail ErrorDetail `json:"errorDetail"`
Expand Down Expand Up @@ -81,6 +83,7 @@ func init() {

buildCmd.Flags().BoolP("no-push", "n", false, "Do not push to registry")
buildCmd.Flags().BoolP("output-only", "o", false, "send output to stdout, do not build")
buildCmd.Flags().BoolP("first-only", "f", false, "breaks after processing first image if more than one")

viper.SetDefault("buildImageDirname", "./images")
viper.SetDefault("defaultGitBranch", "main")
Expand All @@ -101,13 +104,19 @@ func runBuild(cmd *cobra.Command, args []string) error {

fnopush, _ := cmd.Flags().GetBool("no-push")

firstOnly, _ := cmd.Flags().GetBool("first-only")

if len(args) < 1 {
matches, _ := filepath.Glob(viper.GetString("buildImageDirname") + "/**/Dockerfile*")
for _, match := range matches {
var mach_tag string = buildImage(match)
if !fnopush || outputonly {
pushImage(mach_tag)
}

if firstOnly {
break
}
}
} else {
for _, arg := range args {
Expand All @@ -127,6 +136,10 @@ func runBuild(cmd *cobra.Command, args []string) error {
if !fnopush || outputonly {
pushImage(mach_tag)
}

if firstOnly {
break
}
}
}
}
Expand Down

0 comments on commit 28dba75

Please sign in to comment.