Skip to content

CNF-23053: Migrate away from deprecated ioutil#102

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

CNF-23053: Migrate away from deprecated ioutil#102
sebrandon1 wants to merge 1 commit intoopenshift-kni:mainfrom
sebrandon1:ioutil_deprecation

Conversation

@sebrandon1
Copy link
Copy Markdown

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

Migration from ioutil to os/io and related refactoring:

  • Replaced ioutil.ReadFile, ioutil.WriteFile, and ioutil.ReadAll with os.ReadFile, os.WriteFile, and io.ReadAll respectively across all affected files. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]
  • Updated all instances of ioutil.Discard to io.Discard for logger initialization and null logging. [1] [2] [3] [4]

Directory reading and file info handling:

  • Refactored usages of ioutil.ReadDir to use os.ReadDir, and reconstructed []os.FileInfo slices by calling .Info() on each directory entry, ensuring compatibility with the new API. This impacts methods in pkg/fswrap/fswrap.go and pkg/machineinformer/relocatablesysfs.go. [1] [2] [3]

Test and temporary file management updates:

  • Replaced ioutil.TempDir with os.MkdirTemp in test files for creating temporary directories, and updated test file writing to use os.WriteFile. [1] [2] [3] [4] [5] [6]

General import cleanup:

These changes modernize the codebase and remove reliance on deprecated APIs, improving maintainability and future compatibility.

@openshift-ci openshift-ci Bot requested review from MarSik and swatisehgal November 24, 2025 22:34
@openshift-ci
Copy link
Copy Markdown
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 ffromani 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

@sebrandon1
Copy link
Copy Markdown
Author

/retest

@sebrandon1 sebrandon1 changed the title Migrate away from deprecated ioutil CNF-23053: Migrate away from deprecated ioutil Apr 20, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Collaborator

openshift-ci-robot commented Apr 20, 2026

@sebrandon1: This pull request references CNF-23053 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

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

Migration from ioutil to os/io and related refactoring:

  • Replaced ioutil.ReadFile, ioutil.WriteFile, and ioutil.ReadAll with os.ReadFile, os.WriteFile, and io.ReadAll respectively across all affected files. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]
  • Updated all instances of ioutil.Discard to io.Discard for logger initialization and null logging. [1] [2] [3] [4]

Directory reading and file info handling:

  • Refactored usages of ioutil.ReadDir to use os.ReadDir, and reconstructed []os.FileInfo slices by calling .Info() on each directory entry, ensuring compatibility with the new API. This impacts methods in pkg/fswrap/fswrap.go and pkg/machineinformer/relocatablesysfs.go. [1] [2] [3]

Test and temporary file management updates:

  • Replaced ioutil.TempDir with os.MkdirTemp in test files for creating temporary directories, and updated test file writing to use os.WriteFile. [1] [2] [3] [4] [5] [6]

General import cleanup:

These changes modernize the codebase and remove reliance on deprecated APIs, improving maintainability and future compatibility.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants