Skip to content

Commit 20bb3ff

Browse files
committed
Fix log initialization
Use proper flags and remove use of logrus and klog Signed-off-by: Todd Short <[email protected]>
1 parent c54b571 commit 20bb3ff

File tree

5 files changed

+6
-19
lines changed

5 files changed

+6
-19
lines changed

.github/workflows/e2e.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
name: e2e-artifacts
4242
path: /tmp/artifacts/
4343

44-
- uses: codecov/codecov-action@v5
44+
- uses: codecov/codecov-action@v5.4.0
4545
with:
4646
disable_search: true
4747
files: coverage/e2e.out

.github/workflows/unit-test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: |
2424
make test-unit
2525
26-
- uses: codecov/codecov-action@v5
26+
- uses: codecov/codecov-action@v5.4.0
2727
with:
2828
disable_search: true
2929
files: coverage/unit.out

cmd/catalogd/main.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"time"
3030

3131
"github.com/containers/image/v5/types"
32-
"github.com/sirupsen/logrus"
3332
"github.com/spf13/cobra"
3433
corev1 "k8s.io/api/core/v1"
3534
"k8s.io/apimachinery/pkg/fields"
@@ -42,7 +41,6 @@ import (
4241
"k8s.io/client-go/metadata"
4342
_ "k8s.io/client-go/plugin/pkg/client/auth"
4443
"k8s.io/klog/v2"
45-
"k8s.io/klog/v2/textlogger"
4644
"k8s.io/utils/ptr"
4745
ctrl "sigs.k8s.io/controller-runtime"
4846
crcache "sigs.k8s.io/controller-runtime/pkg/cache"
@@ -146,7 +144,7 @@ func init() {
146144

147145
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
148146
utilruntime.Must(ocv1.AddToScheme(scheme))
149-
ctrl.SetLogger(textlogger.NewLogger(textlogger.NewConfig()))
147+
ctrl.SetLogger(klog.NewKlogr())
150148
}
151149

152150
func main() {
@@ -190,10 +188,6 @@ func validateConfig(cfg *config) error {
190188
}
191189

192190
func run(ctx context.Context) error {
193-
if klog.V(4).Enabled() {
194-
logrus.SetLevel(logrus.DebugLevel)
195-
}
196-
197191
authFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("%s-%s.json", authFilePrefix, apimachineryrand.String(8)))
198192

199193
protocol := "http://"

cmd/operator-controller/main.go

+2-9
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"time"
3030

3131
"github.com/containers/image/v5/types"
32-
"github.com/sirupsen/logrus"
3332
"github.com/spf13/cobra"
3433
corev1 "k8s.io/api/core/v1"
3534
apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
@@ -40,7 +39,6 @@ import (
4039
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
4140
_ "k8s.io/client-go/plugin/pkg/client/auth"
4241
"k8s.io/klog/v2"
43-
"k8s.io/klog/v2/textlogger"
4442
"k8s.io/utils/ptr"
4543
ctrl "sigs.k8s.io/controller-runtime"
4644
crcache "sigs.k8s.io/controller-runtime/pkg/cache"
@@ -148,15 +146,14 @@ func init() {
148146
//adds version sub command
149147
operatorControllerCmd.AddCommand(versionCommand)
150148

151-
klog.InitFlags(flag.CommandLine)
152-
153149
//add klog flags to flagset
150+
klog.InitFlags(flag.CommandLine)
154151
flags.AddGoFlagSet(flag.CommandLine)
155152

156153
//add feature gate flags to flagset
157154
features.OperatorControllerFeatureGate.AddFlag(flags)
158155

159-
ctrl.SetLogger(textlogger.NewLogger(textlogger.NewConfig()))
156+
ctrl.SetLogger(klog.NewKlogr())
160157
}
161158
func validateMetricsFlags() error {
162159
if (cfg.certFile != "" && cfg.keyFile == "") || (cfg.certFile == "" && cfg.keyFile != "") {
@@ -179,10 +176,6 @@ func validateMetricsFlags() error {
179176
return nil
180177
}
181178
func run() error {
182-
if klog.V(4).Enabled() {
183-
logrus.SetLevel(logrus.DebugLevel)
184-
}
185-
186179
setupLog.Info("starting up the controller", "version info", version.String())
187180

188181
authFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("%s-%s.json", authFilePrefix, apimachineryrand.String(8)))

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ require (
2121
github.com/operator-framework/helm-operator-plugins v0.8.0
2222
github.com/operator-framework/operator-registry v1.51.0
2323
github.com/prometheus/client_golang v1.22.0
24-
github.com/sirupsen/logrus v1.9.3
2524
github.com/spf13/cobra v1.9.1
2625
github.com/stretchr/testify v1.10.0
2726
golang.org/x/exp v0.0.0-20250228200357-dead58393ab7
@@ -187,6 +186,7 @@ require (
187186
github.com/sigstore/fulcio v1.6.4 // indirect
188187
github.com/sigstore/rekor v1.3.8 // indirect
189188
github.com/sigstore/sigstore v1.8.12 // indirect
189+
github.com/sirupsen/logrus v1.9.3 // indirect
190190
github.com/smallstep/pkcs7 v0.1.1 // indirect
191191
github.com/spf13/cast v1.7.0 // indirect
192192
github.com/spf13/pflag v1.0.6 // indirect

0 commit comments

Comments
 (0)