Skip to content

Commit

Permalink
improve: does not print color in log
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyasdf committed Jul 21, 2023
1 parent 4dcfcf4 commit c5b0d4b
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 1 deletion.
20 changes: 20 additions & 0 deletions examples/auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"quay.io": {
"username": "xxx",
"password": "xxxxxxxxx",
"insecure": true
},
"registry.cn-beijing.aliyuncs.com": {
"username": "xxx",
"password": "xxxxxxxxx"
},
"docker.io": {
"username": "xxx",
"password": "xxxxxxxxxx"
},
"quay.io/coreos": {
"username": "abc",
"password": "xxxxxxxxx",
"insecure": true
}
}
14 changes: 14 additions & 0 deletions examples/auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
quay.io:
username: xxx
password: xxxxxxxxx
insecure: true
registry.cn-beijing.aliyuncs.com:
username: xxx
password: xxxxxxxxx
docker.io:
username: xxx
password: xxxxxxxxxx
quay.io/coreos:
username: abc
password: xxxxxxxxx
insecure: true
29 changes: 29 additions & 0 deletions examples/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"auth": {
"quay.io": {
"username": "xxx",
"password": "xxxxxxxxx",
"insecure": true
},
"registry.cn-beijing.aliyuncs.com": {
"username": "xxx",
"password": "xxxxxxxxx"
},
"docker.io": {
"username": "xxx",
"password": "xxxxxxxxxx"
},
"quay.io/coreos": {
"username": "abc",
"password": "xxxxxxxxx",
"insecure": true
}
},
"images": {
"quay.io/coreos/kube-rbac-proxy": "quay.io/ruohe/kube-rbac-proxy",

"quay.io/coreos/kube-rbac-proxy:v1.0": "quay.io/ruohe/kube-rbac-proxy",

"quay.io/coreos/kube-rbac-proxy:v1.0,v2.0": "quay.io/ruohe/kube-rbac-proxy"
}
}
19 changes: 19 additions & 0 deletions examples/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
auth:
quay.io:
username: xxx
password: xxxxxxxxx
insecure: true
registry.cn-beijing.aliyuncs.com:
username: xxx
password: xxxxxxxxx
docker.io:
username: xxx
password: xxxxxxxxxx
quay.io/coreos:
username: abc
password: xxxxxxxxx
insecure: true
images:
quay.io/coreos/kube-rbac-proxy: quay.io/ruohe/kube-rbac-proxy
quay.io/coreos/kube-rbac-proxy:v1.0: quay.io/ruohe/kube-rbac-proxy
quay.io/coreos/kube-rbac-proxy:v1.0,v2.0: quay.io/ruohe/kube-rbac-proxy
6 changes: 6 additions & 0 deletions examples/images.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"quay.io/coreos/kube-rbac-proxy": "quay.io/ruohe/kube-rbac-proxy",
"quay.io/coreos/kube-rbac-proxy:v1.0": "quay.io/ruohe/kube-rbac-proxy",
"quay.io/coreos/kube-rbac-proxy:v1.0,v2.0": "quay.io/ruohe/kube-rbac-proxy",
"quay.io/coreos/kube-rbac-proxy:v1.1": ["quay.io/ruohe/kube-rbac-proxy1", "quay.io/ruohe/kube-rbac-proxy2"]
}
7 changes: 7 additions & 0 deletions examples/images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
quay.io/coreos/kube-rbac-proxy: quay.io/ruohe/kube-rbac-proxy
quay.io/coreos/kube-rbac-proxy:v1.0: quay.io/ruohe/kube-rbac-proxy
quay.io/coreos/kube-rbac-proxy:v1.0,v2.0: quay.io/ruohe/kube-rbac-proxy
quay.io/coreos/kube-rbac-proxy@sha256:14b267eb38aa85fd12d0e168fffa2d8a6187ac53a14a0212b0d4fce8d729598c: quay.io/ruohe/kube-rbac-proxy
quay.io/coreos/kube-rbac-proxy:v1.1:
- quay.io/ruohe/kube-rbac-proxy1
- quay.io/ruohe/kube-rbac-proxy2
6 changes: 5 additions & 1 deletion pkg/client/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ const (
func NewFileLogger(path string) *logrus.Logger {
logger := logrus.New()

// disable color
if len(path) != 0 {
_ = os.Setenv("NO_COLOR", "true")
}

logger.Formatter = &logrus.TextFormatter{
FullTimestamp: true,
TimestampFormat: logTimestampFormat,
ForceColors: true,
}

if file, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666); err == nil {
Expand Down

0 comments on commit c5b0d4b

Please sign in to comment.