-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from devops-kung-fu/vaporize
fix: Vaporizes tailog and fixes pre-mature exit
- Loading branch information
Showing
9 changed files
with
100 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"afero" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"bomFormat": "CycloneDX", | ||
"specVersion": "1.2", | ||
"serialNumber": "urn:uuid:c9e967ef-9015-4f27-897b-9011b00a203d", | ||
"serialNumber": "urn:uuid:7206b67d-bb64-4fba-bea1-c4fb3c74145c", | ||
"version": 1, | ||
"metadata": { | ||
"timestamp": "2021-07-14T14:32:52-06:00", | ||
"timestamp": "2021-07-22T20:58:27-06:00", | ||
"tools": [ | ||
{ | ||
"vendor": "CycloneDX", | ||
|
@@ -31,11 +31,11 @@ | |
} | ||
], | ||
"component": { | ||
"bom-ref": "pkg:golang/github.com/devops-kung-fu/[email protected]20210714142452-6a754f3bc11f", | ||
"bom-ref": "pkg:golang/github.com/devops-kung-fu/[email protected]20210714162810-e7d7d897d5dd", | ||
"type": "application", | ||
"name": "github.com/devops-kung-fu/hinge", | ||
"version": "v0.0.0-20210714142452-6a754f3bc11f", | ||
"purl": "pkg:golang/github.com/devops-kung-fu/[email protected]20210714142452-6a754f3bc11f", | ||
"version": "v0.0.0-20210714162810-e7d7d897d5dd", | ||
"purl": "pkg:golang/github.com/devops-kung-fu/[email protected]20210714162810-e7d7d897d5dd", | ||
"externalReferences": [ | ||
{ | ||
"url": "https://github.com/devops-kung-fu/hinge", | ||
|
@@ -45,26 +45,6 @@ | |
} | ||
}, | ||
"components": [ | ||
{ | ||
"bom-ref": "pkg:golang/github.com/devops-kung-fu/[email protected]", | ||
"type": "library", | ||
"name": "github.com/devops-kung-fu/tailog", | ||
"version": "v0.1.7", | ||
"scope": "required", | ||
"hashes": [ | ||
{ | ||
"alg": "SHA-256", | ||
"content": "37578cf1cf65c016cea5e78594f7b074a8c09fcc401d0593f329a409289885d1" | ||
} | ||
], | ||
"purl": "pkg:golang/github.com/devops-kung-fu/[email protected]", | ||
"externalReferences": [ | ||
{ | ||
"url": "https://github.com/devops-kung-fu/tailog", | ||
"type": "vcs" | ||
} | ||
] | ||
}, | ||
{ | ||
"bom-ref": "pkg:golang/github.com/gookit/[email protected]", | ||
"type": "library", | ||
|
@@ -258,13 +238,6 @@ | |
} | ||
], | ||
"dependencies": [ | ||
{ | ||
"ref": "pkg:golang/github.com/devops-kung-fu/[email protected]", | ||
"dependsOn": [ | ||
"pkg:golang/github.com/gookit/[email protected]", | ||
"pkg:golang/golang.org/x/[email protected]" | ||
] | ||
}, | ||
{ | ||
"ref": "pkg:golang/github.com/gookit/[email protected]", | ||
"dependsOn": [ | ||
|
@@ -305,12 +278,12 @@ | |
"ref": "pkg:golang/gopkg.in/[email protected]" | ||
}, | ||
{ | ||
"ref": "pkg:golang/github.com/devops-kung-fu/[email protected]20210714142452-6a754f3bc11f", | ||
"ref": "pkg:golang/github.com/devops-kung-fu/[email protected]20210714162810-e7d7d897d5dd", | ||
"dependsOn": [ | ||
"pkg:golang/github.com/devops-kung-fu/[email protected]", | ||
"pkg:golang/github.com/gookit/[email protected]", | ||
"pkg:golang/github.com/spf13/[email protected]", | ||
"pkg:golang/github.com/spf13/[email protected]", | ||
"pkg:golang/golang.org/x/[email protected]", | ||
"pkg:golang/golang.org/x/[email protected]", | ||
"pkg:golang/gopkg.in/[email protected]", | ||
"pkg:golang/[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package lib | ||
|
||
import "log" | ||
|
||
//IsError Checks to see if an error exists, and if so | ||
//writes it to the log with the provided prefix | ||
func IsError(err error, prefix string) error { | ||
if err != nil { | ||
log.Printf("%v: %v", prefix, err) | ||
} | ||
return err | ||
} | ||
|
||
//IsErrorBool Checks to see if an error exists, and if so | ||
//returns true after writing the error to the log with the provided prefix | ||
func IsErrorBool(err error, prefix string) (b bool) { | ||
if err != nil { | ||
log.Printf("%v: %v", prefix, err) | ||
b = true | ||
} | ||
return | ||
} | ||
|
||
//IfErrorLog Checks to see if an error exists, and if so | ||
//simply writes it to the log. | ||
func IfErrorLog(err error, prefix string) { | ||
if err != nil { | ||
log.Printf("%v: %v", prefix, err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package lib | ||
|
||
import ( | ||
"bytes" | ||
"errors" | ||
"log" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIsError(t *testing.T) { | ||
output := captureOutput(func() { | ||
IsError(errors.New("Test Error"), "[TEST]") | ||
}) | ||
|
||
if output.Len() == 0 { | ||
assert.GreaterOrEqual(t, output.Len(), 0, "No information logged to STDOUT") | ||
assert.GreaterOrEqual(t, strings.Count(output.String(), "\n"), 1, "Expected only a single line of log output") | ||
} | ||
} | ||
|
||
func TestIsErrorBool(t *testing.T) { | ||
output := captureOutput(func() { | ||
IsErrorBool(errors.New("Test Error"), "[TEST]") | ||
}) | ||
|
||
assert.GreaterOrEqual(t, output.Len(), 0, "No information logged to STDOUT") | ||
assert.GreaterOrEqual(t, strings.Count(output.String(), "\n"), 1, "Expected only a single line of log output") | ||
} | ||
|
||
func TestIfErrorLog(t *testing.T) { | ||
output := captureOutput(func() { | ||
IfErrorLog(errors.New("Test Error"), "[TEST]") | ||
}) | ||
|
||
assert.GreaterOrEqual(t, output.Len(), 0, "No information logged to STDOUT") | ||
assert.GreaterOrEqual(t, strings.Count(output.String(), "\n"), 1, "Expected only a single line of log output") | ||
} | ||
|
||
func captureOutput(f func()) bytes.Buffer { | ||
var buf bytes.Buffer | ||
log.SetOutput(&buf) | ||
f() | ||
log.SetOutput(os.Stderr) | ||
return buf | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters