diff --git a/cmd/flux/logs.go b/cmd/flux/logs.go index c9f78239..6acc65f6 100644 --- a/cmd/flux/logs.go +++ b/cmd/flux/logs.go @@ -252,7 +252,7 @@ func logRequest(ctx context.Context, request rest.ResponseWrapper, w io.Writer) scanner := bufio.NewScanner(stream) - const logTmpl = "{{.Timestamp}} {{.Level}} {{.Kind}}{{if .Name}}/{{.Name}}.{{.Namespace}}{{end}} - {{.Message}} {{.Error}}\n" + const logTmpl = "{{.Timestamp}} {{.Level}} {{or .Kind .ControllerKind}}{{if .Name}}/{{.Name}}.{{.Namespace}}{{end}} - {{.Message}} {{.Error}}\n" t, err := template.New("log").Parse(logTmpl) if err != nil { return fmt.Errorf("unable to create template, err: %s", err) @@ -278,7 +278,7 @@ func logRequest(ctx context.Context, request rest.ResponseWrapper, w io.Writer) func filterPrintLog(t *template.Template, l *ControllerLogEntry, w io.Writer) { if (logsArgs.logLevel == "" || logsArgs.logLevel == l.Level) && - (logsArgs.kind == "" || strings.EqualFold(logsArgs.kind, l.Kind)) && + (logsArgs.kind == "" || strings.EqualFold(logsArgs.kind, l.Kind) || strings.EqualFold(logsArgs.kind, l.ControllerKind)) && (logsArgs.name == "" || strings.EqualFold(logsArgs.name, l.Name)) && (logsArgs.allNamespaces || strings.EqualFold(*kubeconfigArgs.Namespace, l.Namespace)) { err := t.Execute(w, l) @@ -289,12 +289,13 @@ func filterPrintLog(t *template.Template, l *ControllerLogEntry, w io.Writer) { } type ControllerLogEntry struct { - Timestamp string `json:"ts"` - Level flags.LogLevel `json:"level"` - Message string `json:"msg"` - Error string `json:"error,omitempty"` - Logger string `json:"logger"` - Kind string `json:"reconciler kind,omitempty"` - Name string `json:"name,omitempty"` - Namespace string `json:"namespace,omitempty"` + Timestamp string `json:"ts"` + Level flags.LogLevel `json:"level"` + Message string `json:"msg"` + Error string `json:"error,omitempty"` + Logger string `json:"logger"` + Kind string `json:"reconciler kind,omitempty"` + ControllerKind string `json:"controllerKind,omitempty"` + Name string `json:"name,omitempty"` + Namespace string `json:"namespace,omitempty"` } diff --git a/cmd/flux/logs_test.go b/cmd/flux/logs_test.go index ba63f051..cb07234e 100644 --- a/cmd/flux/logs_test.go +++ b/cmd/flux/logs_test.go @@ -170,12 +170,13 @@ func TestLogRequest(t *testing.T) { } } -var testPodLogs = `{"level":"info","ts":"2022-08-02T12:55:34.419Z","logger":"controller.gitrepository","msg":"no changes since last reconcilation: observed revision","reconciler group":"source.toolkit.fluxcd.io","reconciler kind":"GitRepository","name":"podinfo","namespace":"default"} -{"level":"error","ts":"2022-08-02T12:56:04.679Z","logger":"controller.gitrepository","msg":"no changes since last reconcilation: observed revision","reconciler group":"source.toolkit.fluxcd.io","reconciler kind":"GitRepository","name":"flux-system","namespace":"flux-system"} +var testPodLogs = `{"level":"info","ts":"2022-08-02T12:55:34.419Z","msg":"no changes since last reconcilation: observed revision","controller":"gitrepository","controllerGroup":"source.toolkit.fluxcd.io","controllerKind":"GitRepository","gitRepository":{"name":"podinfo","namespace":"default"},"namespace":"default","name":"podinfo","reconcileID":"5ef9b2ef-4ea5-47b7-b887-a247cafc1bce"} +{"level":"error","ts":"2022-08-02T12:56:04.679Z","logger":"controller.gitrepository","msg":"no changes since last reconcilation: observed revision","controllerGroup":"source.toolkit.fluxcd.io","controllerKind":"GitRepository","gitRepository":{"name":"podinfo","namespace":"flux-system"},"name":"flux-system","namespace":"flux-system","reconcileID":"543ef9b2ef-4ea5-47b7-b887-a247cafc1bce"} {"level":"error","ts":"2022-08-02T12:56:34.961Z","logger":"controller.kustomization","msg":"no changes since last reconcilation: observed revision","reconciler group":"kustomize.toolkit.fluxcd.io","reconciler kind":"Kustomization","name":"flux-system","namespace":"flux-system"} {"level":"info","ts":"2022-08-02T12:56:34.961Z","logger":"controller.kustomization","msg":"no changes since last reconcilation: observed revision","reconciler group":"kustomize.toolkit.fluxcd.io","reconciler kind":"Kustomization","name":"podinfo","namespace":"default"} {"level":"info","ts":"2022-08-02T12:56:34.961Z","logger":"controller.gitrepository","msg":"no changes since last reconcilation: observed revision","reconciler group":"source.toolkit.fluxcd.io","reconciler kind":"GitRepository","name":"podinfo","namespace":"default"} -{"level":"error","ts":"2022-08-02T12:56:34.961Z","logger":"controller.kustomization","msg":"no changes since last reconcilation: observed revision","reconciler group":"kustomize.toolkit.fluxcd.io","reconciler kind":"Kustomization","name":"podinfo","namespace":"flux-system"}` +{"level":"error","ts":"2022-08-02T12:56:34.961Z","logger":"controller.kustomization","msg":"no changes since last reconcilation: observed revision","reconciler group":"kustomize.toolkit.fluxcd.io","reconciler kind":"Kustomization","name":"podinfo","namespace":"flux-system"} +` type testResponseMapper struct { } diff --git a/go.mod b/go.mod index af84032c..f9a08322 100644 --- a/go.mod +++ b/go.mod @@ -13,11 +13,11 @@ require ( github.com/fluxcd/kustomize-controller/api v0.27.1 github.com/fluxcd/notification-controller/api v0.25.2 github.com/fluxcd/pkg/apis/meta v0.15.0 - github.com/fluxcd/pkg/kustomize v0.6.0 - github.com/fluxcd/pkg/oci v0.7.0 - github.com/fluxcd/pkg/runtime v0.17.0 + github.com/fluxcd/pkg/kustomize v0.7.0 + github.com/fluxcd/pkg/oci v0.8.0 + github.com/fluxcd/pkg/runtime v0.18.0 github.com/fluxcd/pkg/sourceignore v0.2.0 - github.com/fluxcd/pkg/ssa v0.18.0 + github.com/fluxcd/pkg/ssa v0.19.0 github.com/fluxcd/pkg/ssh v0.6.0 github.com/fluxcd/pkg/untar v0.2.0 github.com/fluxcd/pkg/version v0.2.0 @@ -46,7 +46,7 @@ require ( k8s.io/client-go v0.25.0 k8s.io/kubectl v0.25.0 sigs.k8s.io/cli-utils v0.33.0 - sigs.k8s.io/controller-runtime v0.11.2 + sigs.k8s.io/controller-runtime v0.12.3 sigs.k8s.io/kustomize/api v0.12.1 sigs.k8s.io/kustomize/kyaml v0.13.9 sigs.k8s.io/yaml v1.3.0 diff --git a/go.sum b/go.sum index b44d92d0..9318730c 100644 --- a/go.sum +++ b/go.sum @@ -261,16 +261,16 @@ github.com/fluxcd/pkg/apis/kustomize v0.5.0 h1:4Rvr4zWQV2KyHkSQzq8IFPo10b0UVAGEg github.com/fluxcd/pkg/apis/kustomize v0.5.0/go.mod h1:N3Rtc5wDm/omHH0YHUbILyUpRNmWvZGejb5/8Uyk6II= github.com/fluxcd/pkg/apis/meta v0.15.0 h1:uDVzbDNdFjp0GSB9qMpcW6r4K7SAjBQlCxQENSkWgkQ= github.com/fluxcd/pkg/apis/meta v0.15.0/go.mod h1:7NkgFrlswnx2QxP16+8zVNDBf+VhZ7PsDhkcJY6OSgQ= -github.com/fluxcd/pkg/kustomize v0.6.0 h1:v/HK2jvIBeCErPiO0yWVLffRI4iLNKWh4oTd0QuVuAE= -github.com/fluxcd/pkg/kustomize v0.6.0/go.mod h1:4ex1cYIHxyyHtxbZuVpM/Df+e4exI4sb0phmjAzH+7s= -github.com/fluxcd/pkg/oci v0.7.0 h1:7jh31RCF2boQAH2DbBklxX+Qk+Ur7GnAyzaw0o5h0is= -github.com/fluxcd/pkg/oci v0.7.0/go.mod h1:zyyQQJCPByRBNL0K4XfGecHqQfSqAk7LyxgEWLPngc8= -github.com/fluxcd/pkg/runtime v0.17.0 h1:izKzDDWtS8QTQKV391DxqQBDb5eS0jDwWgzjE3KXjv0= -github.com/fluxcd/pkg/runtime v0.17.0/go.mod h1:jphxwbAf1SJRapl62MJ1jMExJottdgeu++YWq0yoHrU= +github.com/fluxcd/pkg/kustomize v0.7.0 h1:604rlpRZTWaOfzDZ1W93aHaFh9kn8/UMX/wzsjwIUQY= +github.com/fluxcd/pkg/kustomize v0.7.0/go.mod h1:zJY3Z0+SX+zs+/A1F6fCT0JvUce265XnrpTtHnujXPo= +github.com/fluxcd/pkg/oci v0.8.0 h1:ky7YemolK/5yGVmw2B8SLn1h4ecrnP38DwCaBOCSDFg= +github.com/fluxcd/pkg/oci v0.8.0/go.mod h1:L+TiQRy92wdqwb2LuScl7T1M24S7IgnzgjBD3iqoKEE= +github.com/fluxcd/pkg/runtime v0.18.0 h1:3naATapV1y65ZWlsXEfJt66zSQBkJwJ9o/e6gqAF//E= +github.com/fluxcd/pkg/runtime v0.18.0/go.mod h1:JKTvOFOCz5Un9KxGcBL7Xjt0fcRa10ZItGB0XFv44AY= github.com/fluxcd/pkg/sourceignore v0.2.0 h1:ooNbIkfxqNB+KKiY4AU+/DxwzjIKIOWBRK1As5QFlug= github.com/fluxcd/pkg/sourceignore v0.2.0/go.mod h1:m9/q+YLMNSWjXns1n/5q3ucwzSSddti+D6ExbNaCo6s= -github.com/fluxcd/pkg/ssa v0.18.0 h1:0je85+fWjW5gWI5RoVQktgkNUShFRANWyG2eouUQKps= -github.com/fluxcd/pkg/ssa v0.18.0/go.mod h1:DNI+yoJ2R50Ap97TuHtLUudfGlpRd7sTAaLLOrqyyzU= +github.com/fluxcd/pkg/ssa v0.19.0 h1:azciQ/M1L7Nf4zkHJ+A+a58uShcTW3ZMbyY8KiYcqrI= +github.com/fluxcd/pkg/ssa v0.19.0/go.mod h1:OjHX/qA4xqLi237l0yccsT6FnLmHxDKukpMXnhdXdyk= github.com/fluxcd/pkg/ssh v0.6.0 h1:yRJ866obXCo0JseJCqlGKtF8cumioPcwIC6kMwf8Spg= github.com/fluxcd/pkg/ssh v0.6.0/go.mod h1:Puf+hWNzFsqdHtjDpsI3PTTvitZu41ObuPFblOdzrrI= github.com/fluxcd/pkg/untar v0.2.0 h1:sJXU+FbJcNUb2ffLJNjeR3hwt3X2loVpOMlCUjyFw6E= @@ -1589,8 +1589,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/cli-utils v0.33.0 h1:/ioqfYu0hVeR2T2SDH3WVPgpqiJkrzqjJFrQ3u+baHk= sigs.k8s.io/cli-utils v0.33.0/go.mod h1:g/zB9hJ5eUN7zIEBIxrO0CwhXU4YISJ+BkLJzvWwlEs= -sigs.k8s.io/controller-runtime v0.11.2 h1:H5GTxQl0Mc9UjRJhORusqfJCIjBO8UtUxGggCwL1rLA= -sigs.k8s.io/controller-runtime v0.11.2/go.mod h1:P6QCzrEjLaZGqHsfd+os7JQ+WFZhvB8MRFsn4dWF7O4= +sigs.k8s.io/controller-runtime v0.12.3 h1:FCM8xeY/FI8hoAfh/V4XbbYMY20gElh9yh+A98usMio= +sigs.k8s.io/controller-runtime v0.12.3/go.mod h1:qKsk4WE6zW2Hfj0G4v10EnNB2jMG1C+NTb8h+DwCoU0= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/kustomize/api v0.12.1 h1:7YM7gW3kYBwtKvoY216ZzY+8hM+lV53LUayghNRJ0vM=