Skip to content

Commit

Permalink
Adding option to define ReportFilename to gather final report in mo…
Browse files Browse the repository at this point in the history
…re computer friendly format - json (#10)
  • Loading branch information
Michal Slusarczyk authored Jun 19, 2020
1 parent 6944023 commit 0860660
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP_NAME=docker-bakery
VERSION=1.2.0
VERSION=1.3.0

.DEFAULT_GOAL: all

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [Config](#config)
- [Properties config section](#properties-config-section)
- [Commands config section](#commands-config-section)
- [Other config attributes](#other-config)
- [Dockerfile.template](#dockerfiletemplate)
- [Usage](#usage)
- [Command help](#command-help)
Expand Down Expand Up @@ -84,6 +85,7 @@ Structure of the `config.json` file is as follows:
"defaultBuildCommand": "docker build --tag {{.IMAGE_NAME}}:{{.IMAGE_VERSION}} --tag {{.DEFAULT_PUSH_REGISTRY}}/{{.IMAGE_NAME}}:{{.IMAGE_VERSION}} --tag {{.DEFAULT_PULL_REGISTRY}}/{{.IMAGE_NAME}}:{{.IMAGE_VERSION}} {{.DOCKERFILE_DIR}}",
"defaultPushCommand": "docker push {{.DEFAULT_PUSH_REGISTRY}}/{{.IMAGE_NAME}}:{{.IMAGE_VERSION}}"
},
"reportFileName": "custom-report-filename.json",
"verbose": false,
"autoBuildExcludes": [
"some-image-name-that-will-be-excluded-from-build-when-parent-changes"
Expand Down Expand Up @@ -122,7 +124,11 @@ Structure of the `config.json` file is as follows:
<a id="commands-config-section"></a>
## Commands config section
This section contains two templates used for building and pushing docker images. It allows for specifying custom parameters.
Commands defined here as templates will be filled with available defined properties from the config section + the dynamic properties set during runtime.
Commands defined here as templates will be filled with available defined properties from the config section + the dynamic properties set during runtime.

<a id="other-config"></a>
## Other config attributes
`reportFileName` - if set it will be used as a file name to store information (in JSON format) about successfully built images.

<a id="dockerfiletemplate"></a>
# Dockerfile.template
Expand Down Expand Up @@ -206,4 +212,4 @@ Applying `docker-bakery` is quite simple. Take a look [here](https://github.com/

<a id="limitations"></a>
# Limitations
At the moment docker multi-stage builds are not fully supported. Only the first line `FROM` is taken into consideration when determining the parent of the image and its place in the hierarchy.
At the moment docker multi-stage builds are not fully supported. Only the first line `FROM` is taken into consideration when determining the parent of the image and its place in the hierarchy.
3 changes: 3 additions & 0 deletions bakery/service/bakery.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ func PrintReport() {
for _, r := range commandResults {
fmt.Printf(color.GreenString("\t%s %s => %s\n", r.Name, r.CurrentVersion, r.NextVersion))
}
if len(config.ReportFileName) > 0 {
commons.WriteToJSONFile(commandResults, config.ReportFileName)
}
errorCount := len(commandErrors)
if errorCount > 0 {
fmt.Printf(color.RedString("Following (%d) errors occurred during image processing:\n", errorCount))
Expand Down
1 change: 1 addition & 0 deletions bakery/service/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config struct {
RootDir string `json:"rootDir"`
Verbose bool `json:"verbose"`
AutoBuildExcludes []string `json:"autoBuildExcludes"`
ReportFileName string `json:"reportFileName"`
}

// Commands is used as part of the config to contain template of build and push commands
Expand Down

0 comments on commit 0860660

Please sign in to comment.