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
    • Updated file and response-body handling to use modern Go standard library APIs.
    • Removed reliance on deprecated legacy I/O helpers across registry, credential, client, testing, and tooling components.
    • Preserved existing behavior, error handling, and public interfaces.

@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: 2d8c51d7-c4da-4b46-9081-3929cfcdb4d7

📥 Commits

Reviewing files that changed from the base of the PR and between eb1b09d and eaa0661.

📒 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

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 and os 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 without changing surrounding control flow or error handling.
Test and integration read helpers
pkg/dockerregistry/server/*_test.go, pkg/kubernetes-common/credentialprovider/config_test.go, test/integration/...
Tests replace deprecated read and temporary-file helpers with io.ReadAll, os.MkdirTemp, and os.WriteFile.
Test utilities and import verification
pkg/testframework/registry.go, pkg/testutil/logrus.go, tools/import-verifier/import-verifier.go
Supporting utilities use 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 matches the PR’s main change: replacing deprecated ioutil usage across the codebase.
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 No Ginkgo titles were added in the touched tests; the only subtest names are static literals like 'credential present on node'.
Test Structure And Quality ✅ Passed Touched tests use plain testing.T, not Ginkgo; no Describe/It/Eventually or cluster-wait patterns to assess.
Microshift Test Compatibility ✅ Passed PASS: The diff only swaps ioutil for io/os helpers in existing tests; no new Ginkgo specs, MicroShift guards, or unsupported OpenShift APIs were added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the touched test files are plain testing tests and only swap ioutil for io/os APIs.
Topology-Aware Scheduling Compatibility ✅ Passed Only ioutil-to-standard-library refactors in Go files/tests; no manifests, controllers, or scheduling constraints were added.
Ote Binary Stdout Contract ✅ Passed No touched process-level entrypoint writes to stdout; the only main uses log.Printf/log.Fatalf (stderr), and test logger setup discards output.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PASS: The PR only refactors ioutil to io/os; no new Ginkgo e2e tests or IPv4/public-registry assumptions were added in the diff.
No-Weak-Crypto ✅ Passed Patch only replaces ioutil with io/os helpers; no weak crypto, custom crypto, or secret-comparison logic was added.
Container-Privileges ✅ Passed Changed files are only Go source/tests replacing ioutil with io/os; no manifest changes or privileged/hostPID/hostNetwork/hostIPC/SYS_ADMIN settings found.
No-Sensitive-Data-In-Logs ✅ Passed Touched hunks only replace ioutil with io/os equivalents; no new logging of passwords, tokens, PII, or hostnames was introduced.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@sebrandon1
sebrandon1 force-pushed the ioutil_deprecation branch from 51e4a13 to eaa0661 Compare July 20, 2026 18:41
@openshift-ci

openshift-ci Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@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-metal-ipi-ovn-ipv6 eaa0661 link true /test e2e-metal-ipi-ovn-ipv6
ci/prow/e2e-aws-ovn eaa0661 link true /test e2e-aws-ovn
ci/prow/images eaa0661 link true /test images
ci/prow/e2e-agnostic-image-registry eaa0661 link true /test e2e-agnostic-image-registry
ci/prow/e2e-aws-upgrade eaa0661 link true /test e2e-aws-upgrade
ci/prow/e2e-aws-image-registry eaa0661 link true /test e2e-aws-image-registry
ci/prow/e2e-hypershift eaa0661 link true /test e2e-hypershift

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