-
Notifications
You must be signed in to change notification settings - Fork 15
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 #77 from anchore/improve-logging
feat: improve logging
- Loading branch information
Showing
13 changed files
with
147 additions
and
13 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
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,21 @@ | ||
FROM gcr.io/distroless/static:nonroot | ||
|
||
COPY snapshot/kai /usr/bin | ||
|
||
USER nonroot:nobody | ||
|
||
ARG BUILD_DATE | ||
ARG BUILD_VERSION | ||
ARG VCS_REF | ||
ARG VCS_URL | ||
|
||
LABEL org.opencontainers.image.created=$BUILD_DATE | ||
LABEL org.opencontainers.image.title="kai" | ||
LABEL org.opencontainers.image.description="KAI (Kubernetes Automated Inventory) can poll Kubernetes Cluster API(s) to tell Anchore which Images are currently in-use" | ||
LABEL org.opencontainers.image.source=$VCS_URL | ||
LABEL org.opencontainers.image.revision=$VCS_REF | ||
LABEL org.opencontainers.image.vendor="Anchore, Inc." | ||
LABEL org.opencontainers.image.version=$BUILD_VERSION | ||
LABEL org.opencontainers.image.licenses="Apache-2.0" | ||
|
||
ENTRYPOINT ["kai"] |
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 |
---|---|---|
|
@@ -47,3 +47,4 @@ anchoredetails: | |
http: | ||
insecure: false | ||
timeoutseconds: 10 | ||
verboseinventoryreports: false |
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 |
---|---|---|
|
@@ -47,3 +47,4 @@ anchoredetails: | |
http: | ||
insecure: false | ||
timeoutseconds: 0 | ||
verboseinventoryreports: false |
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 |
---|---|---|
|
@@ -47,3 +47,4 @@ anchoredetails: | |
http: | ||
insecure: false | ||
timeoutseconds: 10 | ||
verboseinventoryreports: false |
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,27 @@ | ||
package tracker | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/anchore/kai/internal/log" | ||
) | ||
|
||
// TrackFunctionTime is a function that tracks the time it takes to execute a function | ||
// and logs the time it took to execute the function | ||
// | ||
// It takes a time.Time object and a string as parameters | ||
// The time.Time object is the time the function started executing | ||
// The string is the name of the function that is being tracked (or any arbitrary message useful for logging) | ||
// | ||
// It is intended to be run at the beginning of a function and defer the function call | ||
// for example: | ||
// | ||
// func someFunction() { | ||
// start := time.Now() | ||
// defer TrackFunctionTime(start, "someFunction") | ||
// // do stuff | ||
// } | ||
func TrackFunctionTime(start time.Time, msg string) { | ||
elapsed := time.Since(start) | ||
log.Log.Debugf("%s took %s", msg, elapsed) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: skaffold/v4beta2 | ||
kind: Config | ||
metadata: | ||
name: kai | ||
build: | ||
artifacts: | ||
- image: local/kai | ||
docker: | ||
dockerfile: Dockerfile.skaffold | ||
deploy: | ||
helm: | ||
releases: | ||
- name: kai | ||
chartPath: anchore-charts/stable/kai | ||
setValueTemplates: | ||
image.repository: "{{.IMAGE_REPO_local_kai}}" | ||
image.tag: "{{.IMAGE_TAG_local_kai}}" | ||
setValues: | ||
kai.log.level: debug | ||
kai.log.structured: false | ||
kai.quiet: false | ||
kai.verboseInventoryReports: false | ||
kai.pollingIntervalSeconds: 60 |