Skip to content

Comments

Migrate away from deprecated ioutil#292

Open
sebrandon1 wants to merge 1 commit intoopenshift:mainfrom
sebrandon1:ioutil_deprecation
Open

Migrate away from deprecated ioutil#292
sebrandon1 wants to merge 1 commit intoopenshift:mainfrom
sebrandon1:ioutil_deprecation

Conversation

@sebrandon1
Copy link
Member

ioutil has been deprecated since Go 1.16: https://go.dev/doc/go1.16#ioutil

Tracking issue: redhat-best-practices-for-k8s/telco-bot#52

@coderabbitai
Copy link

coderabbitai bot commented Nov 24, 2025

No actionable comments were generated in the recent review. 🎉


Walkthrough

Replace deprecated ioutil calls with their modern os equivalents across reading and temp-file creation sites; remove now-unused ioutil imports. No functional or error-handling behavior changes.

Changes

Cohort / File(s) Summary
CA bundle and serving cert readers
pkg/controller/cabundleinjector/starter.go, pkg/controller/servingcert/starter/starter.go
Replace ioutil.ReadFile with os.ReadFile; adjust imports (remove ioutil, reorder as needed). Error handling and control flow unchanged.
Test utility temp files
test/util/rotate.go
Replace ioutil.TempFile with os.CreateTemp; remove ioutil import. Surrounding logic preserved.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 24, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sebrandon1
Once this PR has been reviewed and has the lgtm label, please assign p0lyn0mial for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@xingxingxia
Copy link

@sebrandon1 @coderabbitai

err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
has one ioutil.

@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the specific file mentioned by the user
echo "=== Examining pkg/operator/v4_00_assets/bindata.go ==="
cat pkg/operator/v4_00_assets/bindata.go | head -20
echo ""
echo "=== Looking for ioutil usage around line 614 ==="
sed -n '610,620p' pkg/operator/v4_00_assets/bindata.go

echo ""
echo "=== Searching for all remaining ioutil usages in the codebase ==="
rg -n 'ioutil\.' --type=go

echo ""
echo "=== Checking if bindata.go is a generated file ==="
head -5 pkg/operator/v4_00_assets/bindata.go

Length of output: 1466


@xingxingxia @sebrandon1 Good catch! I've verified that pkg/operator/v4_00_assets/bindata.go line 614 does indeed contain a remaining ioutil.WriteFile usage (and an io/ioutil import on line 15). This is actually the only remaining ioutil usage in the entire codebase.

However, this file is a generated file created by go-bindata, as indicated by the header comment:

// Code generated for package v4_00_assets by go-bindata DO NOT EDIT. (@generated)

To address this ioutil usage, you'll need to:

  1. Regenerate the bindata file using the go-bindata tool (or its replacement) with updated code that uses os.WriteFile instead of ioutil.WriteFile
  2. Check if you're using an older version of go-bindata that still generates ioutil calls, and update to a newer version if available
  3. Alternatively, consider migrating to a more modern alternative like go:embed (introduced in Go 1.16) if feasible for your use case

Would you like me to help investigate the bindata generation process or search for the command/script that generates this file?

@sebrandon1
Copy link
Member Author

Yes, this is bindata so I didn't edit that file.

@xingxingxia
Copy link

Maybe it needs regenerated to be updated?

@sebrandon1
Copy link
Member Author

I think that's a good plan. I wonder if that should be a separate PR because regenerating might encompass more changes than just ioutil.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 18, 2026

@sebrandon1: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws 882c6f7 link true /test e2e-aws
ci/prow/e2e-aws-operator 882c6f7 link true /test e2e-aws-operator
ci/prow/e2e-aws-operator-serial-ote 882c6f7 link false /test e2e-aws-operator-serial-ote

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants