Skip to content

Commit

Permalink
Merge pull request #59 from wunderio/feature/stderrprefix
Browse files Browse the repository at this point in the history
Remove "ERROR:" prefix from docker image builds
  • Loading branch information
Rade333 authored Mar 26, 2024
2 parents 923e922 + 57dc2e1 commit d770fbf
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions cmd/ciImageBuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ var ciImageBuildCmd = &cobra.Command{
extraImageTagString = fmt.Sprintf("--tag '%s:%s'", imageUrl, extraImageTag)
}
command := fmt.Sprintf("docker build --tag '%s:%s' %s -f '%s' %s", imageUrl, imageTag, extraImageTagString, dockerfile, buildPath)
pipedExec(command, debug)
pipedExec(command, "", "", debug)

// Create AWS/ECR repository (ECR requires a dedicated repository per project)
if strings.HasSuffix(imageRepoHost, ".amazonaws.com") {
Expand All @@ -223,12 +223,12 @@ var ciImageBuildCmd = &cobra.Command{

// Image push
command = fmt.Sprintf("docker push '%s:%s'", imageUrl, imageTag)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)

// Push extra tags
if len(branchName) > 0 {
command = fmt.Sprintf("docker push '%s:%s'", imageUrl, extraImageTag)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ciReleaseCleanfailed.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var ciReleaseCleanfailedCmd = &cobra.Command{
kubectl delete secret -n "${NAMESPACE}" "${secret_to_delete}"
fi
`, namespace, releaseName)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)
},
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/ciReleaseDeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var ciReleaseDeployCmd = &cobra.Command{
fi
`, namespace)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)

if !debug {
// Add helm repositories
Expand Down Expand Up @@ -257,7 +257,7 @@ var ciReleaseDeployCmd = &cobra.Command{
siltaEnvironmentName, branchname, nginxImageUrl,
clusterDomain, extraNoAuthIPs, vpcNativeOverride, extraClusterType,
namespace, siltaConfig, helmFlags, deploymentTimeout)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)

} else if chartName == "frontend" || strings.HasSuffix(chartName, "/frontend") {

Expand Down Expand Up @@ -398,7 +398,7 @@ var ciReleaseDeployCmd = &cobra.Command{
dbRootPassOverride, dbUserPassOverride,
siltaConfig, helmFlags,
deploymentTimeout, deploymentTimeoutSeconds)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)

} else if chartName == "drupal" || strings.HasSuffix(chartName, "/drupal") {

Expand Down Expand Up @@ -441,7 +441,7 @@ var ciReleaseDeployCmd = &cobra.Command{
fi
fi
`, namespace, releaseName)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)

// Clean up failed Helm releases
// TODO: Rewrite
Expand Down Expand Up @@ -477,7 +477,7 @@ var ciReleaseDeployCmd = &cobra.Command{
kubectl delete secret -n "$NAMESPACE" "$secret_to_delete"
fi
`, namespace, releaseName)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)

// Chart value overrides

Expand Down Expand Up @@ -630,7 +630,7 @@ var ciReleaseDeployCmd = &cobra.Command{
clusterDomain, extraNoAuthIPs, vpcNativeOverride, extraClusterType,
dbRootPassOverride, dbUserPassOverride, referenceDataOverride, namespace,
siltaConfig, helmFlags, deploymentTimeout, deploymentTimeoutSeconds)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)

} else {
fmt.Printf("Chart name %s does not match preselected names (drupal, frontend, simple), helm release step was skipped\n", chartName)
Expand Down
2 changes: 1 addition & 1 deletion cmd/ciReleaseInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ but namespace is normalized lowercase version of it.
curl -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/json" -X POST -d '{"body": "<details><summary>Release notes for '${RELEASE_NAME}'</summary>'"${FORMATTED_NOTES//$'\n'/'\n'}"'</details>"}' ${GITHUB_API_URL}
fi
`, namespace, releaseName, githubToken, circlePrNumber, circlePullRequest, circleProjectUsername, circleProjectReponame)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)

command = fmt.Sprintf(`
NAMESPACE='%s'
Expand Down
2 changes: 1 addition & 1 deletion cmd/ciReleaseValidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var ciReleaseValidateCmd = &cobra.Command{
fi
`, namespace, releaseName)

pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)

if chartName == "drupal" || strings.HasSuffix(chartName, "/drupal") {

Expand Down
2 changes: 1 addition & 1 deletion cmd/ciToolsCheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var ciToolsCheckCmd = &cobra.Command{
log.Println(bin + " is installed")
if cmd != "" {
command := fmt.Sprintf("%s %s", bin, cmd)
pipedExec(command, debug)
pipedExec(command, "", "ERROR: ", debug)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func bufferedExec(command string, debug bool) {
}
}

func pipedExec(command string, debug bool) {
func pipedExec(command string, stdOutPrefix string, stdErrPrefix string, debug bool) {
if debug == true {
fmt.Printf("Command (not executed): %s\n", command)
} else {
Expand All @@ -71,12 +71,12 @@ func pipedExec(command string, debug bool) {
errScanner := bufio.NewScanner(cmdErrReader)
go func() {
for errScanner.Scan() {
fmt.Printf("ERROR: %s\n", errScanner.Text())
fmt.Printf("%s%s\n", stdErrPrefix, errScanner.Text())
}
}()
go func() {
for outScanner.Scan() {
fmt.Printf("%s\n", outScanner.Text())
fmt.Printf("%s%s\n", stdOutPrefix, outScanner.Text())
}
}()
err = cmd.Start()
Expand Down

0 comments on commit d770fbf

Please sign in to comment.