Skip to content

CNF-23049: Migrate away from deprecated ioutil - #454

Open
sebrandon1 wants to merge 1 commit into
openshift:mainfrom
sebrandon1:ioutil_deprecation
Open

CNF-23049: Migrate away from deprecated ioutil#454
sebrandon1 wants to merge 1 commit into
openshift:mainfrom
sebrandon1:ioutil_deprecation

Conversation

@sebrandon1

@sebrandon1 sebrandon1 commented Nov 24, 2025

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

Core refactoring: Replace ioutil usage with io and os equivalents

  • Replaced all instances of ioutil.ReadFile with os.ReadFile for reading files, and ioutil.WriteFile with os.WriteFile for writing files in multiple files, such as dockerregistry.go, config.go, and their respective test files. [1] [2] [3] [4] [5] [6]
  • Replaced all instances of ioutil.ReadAll with io.ReadAll for reading from readers and response bodies, affecting HTTP handlers, test helpers, and utility functions. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
  • Replaced ioutil.TempDir with os.MkdirTemp for creating temporary directories in tests. [1] [2]
  • Replaced ioutil.Discard with io.Discard for discarding output in logger setup.
  • Removed deprecated ioutil import statements and updated import blocks accordingly across all affected files. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

These changes ensure the codebase is compatible with newer Go versions and follows up-to-date language standards.

Summary by CodeRabbit

  • Refactor
    • Modernized file, stream, and response-body handling across registry, credential, client, testing, and tooling components.
    • Replaced deprecated Go I/O helpers with supported standard library APIs.
    • Preserved existing functionality, configuration behavior, error handling, request processing, and public interfaces.
    • No user-facing behavior changes are expected from this maintenance update.

@flavianmissi

Copy link
Copy Markdown
Member

Thanks for taking the time to do this, @sebrandon1!

/lgtm
/retitle NO-JIRA: Migrate away from deprecated ioutil

@openshift-ci openshift-ci Bot changed the title Migrate away from deprecated ioutil NO-JIRA: Migrate away from deprecated ioutil Nov 27, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 27, 2025
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@sebrandon1: This pull request explicitly references no jira issue.

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

Core refactoring: Replace ioutil usage with io and os equivalents

  • Replaced all instances of ioutil.ReadFile with os.ReadFile for reading files, and ioutil.WriteFile with os.WriteFile for writing files in multiple files, such as dockerregistry.go, config.go, and their respective test files. [1] [2] [3] [4] [5] [6]
  • Replaced all instances of ioutil.ReadAll with io.ReadAll for reading from readers and response bodies, affecting HTTP handlers, test helpers, and utility functions. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
  • Replaced ioutil.TempDir with os.MkdirTemp for creating temporary directories in tests. [1] [2]
  • Replaced ioutil.Discard with io.Discard for discarding output in logger setup.
  • Removed deprecated ioutil import statements and updated import blocks accordingly across all affected files. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

These changes ensure the codebase is compatible with newer Go versions and follows up-to-date language standards.

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.

Comment thread pkg/testframework/registry.go Outdated
@openshift-ci openshift-ci Bot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 27, 2025
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Dec 1, 2025
@flavianmissi

Copy link
Copy Markdown
Member

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Dec 2, 2025
@openshift-ci

openshift-ci Bot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flavianmissi, 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

@flavianmissi

Copy link
Copy Markdown
Member

this is an internal change.
/label px-approved
/label docs-approved

@openshift-ci openshift-ci Bot added px-approved Signifies that Product Support has signed off on this PR docs-approved Signifies that Docs has signed off on this PR labels Dec 5, 2025
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 18, 2026
@openshift-ci

openshift-ci Bot commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1 sebrandon1 changed the title NO-JIRA: Migrate away from deprecated ioutil CNF-23049: Migrate away from deprecated ioutil Apr 20, 2026
@openshift-ci-robot

openshift-ci-robot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

@sebrandon1: This pull request references CNF-23049 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

Core refactoring: Replace ioutil usage with io and os equivalents

  • Replaced all instances of ioutil.ReadFile with os.ReadFile for reading files, and ioutil.WriteFile with os.WriteFile for writing files in multiple files, such as dockerregistry.go, config.go, and their respective test files. [1] [2] [3] [4] [5] [6]
  • Replaced all instances of ioutil.ReadAll with io.ReadAll for reading from readers and response bodies, affecting HTTP handlers, test helpers, and utility functions. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
  • Replaced ioutil.TempDir with os.MkdirTemp for creating temporary directories in tests. [1] [2]
  • Replaced ioutil.Discard with io.Discard for discarding output in logger setup.
  • Removed deprecated ioutil import statements and updated import blocks accordingly across all affected files. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

These changes ensure the codebase is compatible with newer Go versions and follows up-to-date language standards.

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.

@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ac0bad06-cc03-454f-815f-ca416057b985

📥 Commits

Reviewing files that changed from the base of the PR and between a91ce6e and 6649974.

📒 Files selected for processing (15)
  • pkg/cmd/dockerregistry/dockerregistry.go
  • pkg/dockerregistry/server/blobdescriptorservice_test.go
  • pkg/dockerregistry/server/configuration/configuration.go
  • pkg/dockerregistry/server/signaturedispatcher.go
  • pkg/dockerregistry/server/signaturedispatcher_test.go
  • pkg/dockerregistry/server/util_test.go
  • pkg/kubernetes-common/credentialprovider/config.go
  • pkg/kubernetes-common/credentialprovider/config_test.go
  • pkg/origin-common/clientcmd/clientcmd.go
  • pkg/testframework/registry.go
  • pkg/testutil/logrus.go
  • test/integration/imagelayers/imagelayers_test.go
  • test/integration/pullthrough/pullthrough_test.go
  • test/integration/v2/v2_docker_registry_test.go
  • tools/import-verifier/import-verifier.go
🚧 Files skipped from review as they are similar to previous changes (15)
  • pkg/testframework/registry.go
  • pkg/origin-common/clientcmd/clientcmd.go
  • pkg/cmd/dockerregistry/dockerregistry.go
  • test/integration/imagelayers/imagelayers_test.go
  • pkg/dockerregistry/server/blobdescriptorservice_test.go
  • pkg/kubernetes-common/credentialprovider/config.go
  • pkg/dockerregistry/server/signaturedispatcher_test.go
  • test/integration/v2/v2_docker_registry_test.go
  • tools/import-verifier/import-verifier.go
  • pkg/dockerregistry/server/util_test.go
  • pkg/dockerregistry/server/signaturedispatcher.go
  • pkg/testutil/logrus.go
  • pkg/dockerregistry/server/configuration/configuration.go
  • test/integration/pullthrough/pullthrough_test.go
  • pkg/kubernetes-common/credentialprovider/config_test.go

Walkthrough

Replaces deprecated io/ioutil helpers with io and os equivalents across registry runtime code, credential handling, client configuration, tests, integration tests, test utilities, and import-verification tooling.

Changes

io/ioutil API modernization

Layer / File(s) Summary
Runtime file and stream readers
pkg/cmd/dockerregistry/dockerregistry.go, pkg/dockerregistry/server/..., pkg/kubernetes-common/credentialprovider/config.go, pkg/origin-common/clientcmd/clientcmd.go
Runtime reads now use os.ReadFile or io.ReadAll. Existing control flow and error handling remain unchanged.
Test and integration helpers
pkg/dockerregistry/server/*_test.go, pkg/kubernetes-common/credentialprovider/config_test.go, test/integration/...
Tests replace deprecated helpers with io.ReadAll, os.MkdirTemp, and os.WriteFile.
Supporting utilities and tooling
pkg/testframework/registry.go, pkg/testutil/logrus.go, tools/import-verifier/import-verifier.go
Supporting code uses io.ReadAll, io.Discard, and os.ReadFile.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: deads2k

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the migration from deprecated Go ioutil APIs, which is the main change in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The PR changes only io/os APIs and imports; changed test names are unchanged, and no Ginkgo imports or It/Describe/Context/When title calls exist.
Test Structure And Quality ✅ Passed The PR only changes deprecated I/O calls. All changed tests use standard testing.T, not Ginkgo, and add no cluster waits or test-structure changes.
Microshift Test Compatibility ✅ Passed The patch changes only existing files for ioutil-to-io/os substitutions; the parent-to-HEAD diff adds no Ginkgo tests or MicroShift-sensitive API/resource references.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The diff adds no Ginkgo tests. Changed test files retain existing Test(*testing.T) functions, and added lines only replace ioutil APIs; no SNO-sensitive assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed The PR changes only 15 Go files for ioutil API replacements; no manifests, operators, controllers, or scheduling constructs were added or modified.
Ote Binary Stdout Contract ✅ Passed The PR only replaces ioutil APIs and sets logrus output to io.Discard; the OTE main is unchanged, and klog v2 defaults to stderr.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR only modifies existing tests and replaces ioutil calls; it adds no Ginkgo e2e tests, IPv4 assumptions, or external connectivity.
No-Weak-Crypto ✅ Passed The diff only replaces ioutil calls with io/os APIs; no MD5, SHA1, DES, RC4, Blowfish, ECB, custom crypto, or secret comparisons were added.
Container-Privileges ✅ Passed The PR changes only Go source and test files. The diff adds no privilege controls, and the repository Dockerfiles set USER 1001.
No-Sensitive-Data-In-Logs ✅ Passed The PR adds no sensitive-data logging. The diff only replaces deprecated I/O APIs and ioutil.Discard; existing log statements remain unchanged.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@sebrandon1

Copy link
Copy Markdown
Member Author

Progress update: 5 of 19 PRs in this ioutil migration effort have merged! 🎉

Recently merged:

This PR has been rebased against the latest upstream and is ready for review.

Epic: CNF-23315

@openshift-ci

openshift-ci Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

@sebrandon1: all tests passed!

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. px-approved Signifies that Product Support has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants