Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated ioutil usage #2181

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions doc/man_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -168,7 +167,7 @@ func TestManPrintFlagsHidesShortDeprecated(t *testing.T) {
func TestGenManTree(t *testing.T) {
c := &cobra.Command{Use: "do [OPTIONS] arg1 arg2"}
header := &GenManHeader{Section: "2"}
tmpdir, err := ioutil.TempDir("", "test-gen-man-tree")
tmpdir, err := os.MkdirTemp("", "test-gen-man-tree")
if err != nil {
t.Fatalf("Failed to create tmpdir: %s", err.Error())
}
Expand Down Expand Up @@ -219,7 +218,7 @@ func assertNextLineEquals(scanner *bufio.Scanner, expectedLine string) error {
}

func BenchmarkGenManToFile(b *testing.B) {
file, err := ioutil.TempFile("", "")
file, err := os.CreateTemp("", "")
if err != nil {
b.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions doc/md_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package doc

import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -94,7 +93,7 @@ func TestGenMdNoTag(t *testing.T) {

func TestGenMdTree(t *testing.T) {
c := &cobra.Command{Use: "do [OPTIONS] arg1 arg2"}
tmpdir, err := ioutil.TempDir("", "test-gen-md-tree")
tmpdir, err := os.MkdirTemp("", "test-gen-md-tree")
if err != nil {
t.Fatalf("Failed to create tmpdir: %v", err)
}
Expand All @@ -110,7 +109,7 @@ func TestGenMdTree(t *testing.T) {
}

func BenchmarkGenMarkdownToFile(b *testing.B) {
file, err := ioutil.TempFile("", "")
file, err := os.CreateTemp("", "")
if err != nil {
b.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions doc/rest_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package doc

import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -81,7 +80,7 @@ func TestGenRSTNoTag(t *testing.T) {
func TestGenRSTTree(t *testing.T) {
c := &cobra.Command{Use: "do [OPTIONS] arg1 arg2"}

tmpdir, err := ioutil.TempDir("", "test-gen-rst-tree")
tmpdir, err := os.MkdirTemp("", "test-gen-rst-tree")
if err != nil {
t.Fatalf("Failed to create tmpdir: %s", err.Error())
}
Expand All @@ -97,7 +96,7 @@ func TestGenRSTTree(t *testing.T) {
}

func BenchmarkGenReSTToFile(b *testing.B) {
file, err := ioutil.TempFile("", "")
file, err := os.CreateTemp("", "")
if err != nil {
b.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions doc/yaml_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package doc
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -58,7 +57,7 @@ func TestGenYamlNoTag(t *testing.T) {
func TestGenYamlTree(t *testing.T) {
c := &cobra.Command{Use: "do [OPTIONS] arg1 arg2"}

tmpdir, err := ioutil.TempDir("", "test-gen-yaml-tree")
tmpdir, err := os.MkdirTemp("", "test-gen-yaml-tree")
if err != nil {
t.Fatalf("Failed to create tmpdir: %s", err.Error())
}
Expand All @@ -85,7 +84,7 @@ func TestGenYamlDocRunnable(t *testing.T) {
}

func BenchmarkGenYamlToFile(b *testing.B) {
file, err := ioutil.TempFile("", "")
file, err := os.CreateTemp("", "")
if err != nil {
b.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions site/content/docgen/md.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ package main

import (
"log"
"io/ioutil"
"io"
"os"

"k8s.io/kubernetes/pkg/kubectl/cmd"
Expand All @@ -45,7 +45,7 @@ import (
)

func main() {
kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)
kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, io.Discard, io.Discard)
err := doc.GenMarkdownTree(kubectl, "./")
if err != nil {
log.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions site/content/docgen/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ package main

import (
"log"
"io/ioutil"
"io"
"os"

"k8s.io/kubernetes/pkg/kubectl/cmd"
Expand All @@ -45,7 +45,7 @@ import (
)

func main() {
kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)
kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, io.Discard, io.Discard)
err := doc.GenReSTTree(kubectl, "./")
if err != nil {
log.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions site/content/docgen/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This program can actually generate docs for the kubectl command in the kubernete
package main

import (
"io/ioutil"
"io"
"log"
"os"

Expand All @@ -45,7 +45,7 @@ import (
)

func main() {
kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)
kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, io.Discard, io.Discard)
err := doc.GenYamlTree(kubectl, "./")
if err != nil {
log.Fatal(err)
Expand Down