Skip to content

Commit

Permalink
repplace deprecated ioutil methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shamil committed Dec 12, 2023
1 parent e07fef0 commit a8f9c6d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"

"github.com/pulumi/crd2pulumi/pkg/codegen"
Expand All @@ -29,7 +28,7 @@ import (
// Version specifies the crd2pulumi version. It should be set by the linker via LDFLAGS. This defaults to dev
var Version = "dev"

const long = `crd2pulumi is a CLI tool that generates typed Kubernetes
const long = `crd2pulumi is a CLI tool that generates typed Kubernetes
CustomResources to use in Pulumi programs, based on a
CustomResourceDefinition YAML schema.`

Expand Down Expand Up @@ -92,7 +91,7 @@ func Execute() error {
}
var err error
if shouldUseStdin {
err = codegen.Generate(cs, []io.ReadCloser{ioutil.NopCloser(bytes.NewBuffer(stdinData))})
err = codegen.Generate(cs, []io.ReadCloser{io.NopCloser(bytes.NewBuffer(stdinData))})
} else {
err = codegen.GenerateFromFiles(cs, args)
}
Expand Down
7 changes: 3 additions & 4 deletions tests/crds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package tests
import (
"fmt"
"io/fs"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand All @@ -32,7 +31,7 @@ const gkeManagedCertsUrl = "https://raw.githubusercontent.com/GoogleCloudPlatfor

// execCrd2Pulumi runs the crd2pulumi binary in a temporary directory
func execCrd2Pulumi(t *testing.T, lang, path string, additionalValidation func(t *testing.T, path string)) {
tmpdir, err := ioutil.TempDir("", "crd2pulumi_test")
tmpdir, err := os.MkdirTemp("", "crd2pulumi_test")
assert.Nil(t, err, "expected to create a temp dir for the CRD output")
t.Cleanup(func() {
t.Logf("removing temp dir %q for %s test", tmpdir, lang)
Expand Down Expand Up @@ -98,7 +97,7 @@ func TestCRDsWithUnderscore(t *testing.T) {
// Ensure inputs are camelCased.
filename := filepath.Join(path, "pulumi_crds", "juice", "v1alpha1", "_inputs.py")
t.Logf("validating underscored field names in %s", filename)
pythonInputs, err := ioutil.ReadFile(filename)
pythonInputs, err := os.ReadFile(filename)
if err != nil {
t.Fatalf("expected to read generated Python code: %s", err)
}
Expand All @@ -108,7 +107,7 @@ func TestCRDsWithUnderscore(t *testing.T) {
// Ensure outputs are camelCased.
filename = filepath.Join(path, "pulumi_crds", "juice", "v1alpha1", "outputs.py")
t.Logf("validating underscored field names in %s", filename)
pythonInputs, err = ioutil.ReadFile(filename)
pythonInputs, err = os.ReadFile(filename)
if err != nil {
t.Fatalf("expected to read generated Python code: %s", err)
}
Expand Down
3 changes: 1 addition & 2 deletions tests/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -51,7 +50,7 @@ func UnmarshalSchemas(yamlPath string) (map[string]any, error) {
}

func UnmarshalTypeSpecJSON(jsonPath string) (map[string]pschema.TypeSpec, error) {
jsonFile, err := ioutil.ReadFile(jsonPath)
jsonFile, err := os.ReadFile(jsonPath)
if err != nil {
return nil, fmt.Errorf("could not read file %s: %w", jsonPath, err)
}
Expand Down

0 comments on commit a8f9c6d

Please sign in to comment.