Skip to content

CNF-23053: Migrate away from deprecated ioutil - #102

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift-kni:mainfrom
sebrandon1:ioutil_deprecation
Jul 3, 2026
Merged

openshift-merge-bot[bot] merged 1 commit into
openshift-kni:mainfrom
sebrandon1:ioutil_deprecation

Conversation

@sebrandon1

Copy link
Copy Markdown
Contributor

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.

@sebrandon1

Copy link
Copy Markdown
Contributor 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

openshift-ci-robot commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

@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

@ffromani ffromani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 3, 2026
@openshift-ci

openshift-ci Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ffromani, sebrandon1

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

The pull request process is described 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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 3, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit 71f1209 into openshift-kni:main Jul 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants