Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ that conveys the intent of your change.

# Development Environment Setup

## Install Golang 1.18
## Install Golang 1.26

Documentation on installing GoLang can be found [here](https://golang.org/doc/install). While
the CF CLI might be compatible with other versions of GoLang, this is the only
Expand Down
7 changes: 3 additions & 4 deletions cf/actors/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package actors

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"

"errors"
"errors"

"code.cloudfoundry.org/cli/v9/cf/api/applicationbits"
"code.cloudfoundry.org/cli/v9/cf/api/applicationbits"
"code.cloudfoundry.org/cli/v9/cf/api/resources"
"code.cloudfoundry.org/cli/v9/cf/appfiles"
. "code.cloudfoundry.org/cli/v9/cf/i18n"
Expand Down Expand Up @@ -84,7 +83,7 @@ func (actor PushActorImpl) ProcessPath(dirOrZipFile string, f func(string) error
return nil
}

tempDir, err := ioutil.TempDir("", "unzipped-app")
tempDir, err := os.MkdirTemp("", "unzipped-app")
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions cf/api/buildpack_bits.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"crypto/x509"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
gonet "net"
"net/http"
Expand Down Expand Up @@ -52,7 +51,7 @@ func zipErrorHelper(err error) error {
}

func (repo CloudControllerBuildpackBitsRepository) CreateBuildpackZipFile(buildpackPath string) (*os.File, string, error) {
zipFileToUpload, err := ioutil.TempFile("", "buildpack-upload")
zipFileToUpload, err := os.CreateTemp("", "buildpack-upload")
if err != nil {
os.RemoveAll(zipFileToUpload.Name())
return nil, "", fmt.Errorf("%s: %s", T("Couldn't create temp file for upload"), err.Error())
Expand Down
4 changes: 2 additions & 2 deletions cf/api/curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"bufio"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httputil"
"net/textproto"
Expand Down Expand Up @@ -64,7 +64,7 @@ func (repo CloudControllerCurlRepository) Request(method, path, headerString, bo
headerBytes, _ := httputil.DumpResponse(res, false)
resHeaders = string(headerBytes)

bytes, err := ioutil.ReadAll(res.Body)
bytes, err := io.ReadAll(res.Body)
if err != nil {
err = fmt.Errorf("%s: %s", T("Error reading response"), err.Error())
}
Expand Down
3 changes: 1 addition & 2 deletions cf/appfiles/app_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/sha1"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -212,7 +211,7 @@ func (appfiles ApplicationFiles) WalkAppFiles(dir string, onEachFile func(string
}

func loadIgnoreFile(dir string) CfIgnore {
fileContents, err := ioutil.ReadFile(filepath.Join(dir, ".cfignore"))
fileContents, err := os.ReadFile(filepath.Join(dir, ".cfignore"))
if err != nil {
return NewCfIgnore("")
}
Expand Down
5 changes: 2 additions & 3 deletions cf/commands/application/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package application

import (
"fmt"
"io/ioutil"
"os"
"regexp"
"strconv"
Expand Down Expand Up @@ -818,7 +817,7 @@ func (cmd Push) ValidateContextAndAppParams(appsFromManifest []models.AppParams,
}

func (cmd *Push) uploadApp(appGUID, appDir, appDirOrZipFile string, localFiles []models.AppFileFields) error {
uploadDir, err := ioutil.TempDir("", "apps")
uploadDir, err := os.MkdirTemp("", "apps")
if err != nil {
return err
}
Expand All @@ -834,7 +833,7 @@ func (cmd *Push) uploadApp(appGUID, appDir, appDirOrZipFile string, localFiles [
return err
}

zipFile, err := ioutil.TempFile("", "uploads")
zipFile, err := os.CreateTemp("", "uploads")
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions cf/commands/curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -152,5 +151,5 @@ func (cmd Curl) writeToFile(responseBody, filePath string) (err error) {
return
}

return ioutil.WriteFile(filePath, []byte(responseBody), 0644)
return os.WriteFile(filePath, []byte(responseBody), 0644)
}
4 changes: 2 additions & 2 deletions cf/commands/pluginrepo/add_plugin_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -99,7 +99,7 @@ func (cmd *AddPluginRepo) Execute(c flags.FlagContext) error {
return errors.New(repoURL + T(" is not responding. Please make sure it is a valid plugin repo."))
}

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return errors.New(T("Error reading response from server: ") + err.Error())
}
Expand Down
5 changes: 2 additions & 3 deletions cf/configuration/config_disk_persistor.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package configuration

import (
"io/ioutil"
"os"
)

Expand Down Expand Up @@ -70,7 +69,7 @@ func (dp DiskPersistor) read(data DataInterface) error {
return err
}

jsonBytes, err := ioutil.ReadFile(dp.filePath)
jsonBytes, err := os.ReadFile(dp.filePath)
if err != nil {
return err
}
Expand All @@ -85,6 +84,6 @@ func (dp DiskPersistor) write(data DataInterface) error {
return err
}

err = ioutil.WriteFile(dp.filePath, bytes, filePermissions)
err = os.WriteFile(dp.filePath, bytes, filePermissions)
return err
}
6 changes: 3 additions & 3 deletions cf/flagcontext/flag_content_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package flagcontext

import (
"fmt"
"io/ioutil"
"os"
"strings"
)

Expand All @@ -18,15 +18,15 @@ func GetContentsFromOptionalFlagValue(input string) ([]byte, error) {
trimmedInput := strings.Trim(input, `"'`)
if strings.HasPrefix(trimmedInput, `@`) {
trimmedInput = strings.Trim(trimmedInput[1:], `"'`)
bs, err := ioutil.ReadFile(trimmedInput)
bs, err := os.ReadFile(trimmedInput)
if err != nil {
return []byte{}, err
}

return bs, nil
}

bs, err := ioutil.ReadFile(trimmedInput)
bs, err := os.ReadFile(trimmedInput)
if err != nil {
return []byte(trimmedInput), nil
}
Expand Down
3 changes: 1 addition & 2 deletions cf/manifest/manifest_disk_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package manifest
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -82,7 +81,7 @@ func (repo DiskRepository) readAllYAMLFiles(path string) (mergedMap generic.Map,
}

func parseManifest(file io.Reader) (yamlMap generic.Map, err error) {
manifest, err := ioutil.ReadAll(file)
manifest, err := io.ReadAll(file)
if err != nil {
return
}
Expand Down
11 changes: 5 additions & 6 deletions cf/net/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -250,7 +249,7 @@ func (gateway Gateway) performRequestForResponseBytes(request *Request) ([]byte,
}
defer rawResponse.Body.Close()

bytes, err := ioutil.ReadAll(rawResponse.Body)
bytes, err := io.ReadAll(rawResponse.Body)
if err != nil {
return bytes, nil, rawResponse, fmt.Errorf("%s: %s", T("Error reading response"), err.Error())
}
Expand All @@ -267,7 +266,7 @@ func (gateway Gateway) PerformRequestForJSONResponse(request *Request, response
bytes, headers, rawResponse, err := gateway.performRequestForResponseBytes(request)
if err != nil {
if rawResponse != nil && rawResponse.Body != nil {
b, _ := ioutil.ReadAll(rawResponse.Body)
b, _ := io.ReadAll(rawResponse.Body)
_ = json.Unmarshal(b, &response)
}
return headers, err
Expand Down Expand Up @@ -361,7 +360,7 @@ func (gateway Gateway) doRequestHandlingAuth(request *Request) (*http.Response,
httpReq := request.HTTPReq

if request.SeekableBody != nil {
httpReq.Body = ioutil.NopCloser(request.SeekableBody)
httpReq.Body = io.NopCloser(request.SeekableBody)
}

if gateway.authenticator != nil {
Expand Down Expand Up @@ -390,8 +389,8 @@ func (gateway Gateway) doRequestAndHandlerError(request *Request) (*http.Respons

if rawResponse.StatusCode > 299 {
defer rawResponse.Body.Close()
jsonBytes, _ := ioutil.ReadAll(rawResponse.Body)
rawResponse.Body = ioutil.NopCloser(bytes.NewBuffer(jsonBytes))
jsonBytes, _ := io.ReadAll(rawResponse.Body)
rawResponse.Body = io.NopCloser(bytes.NewBuffer(jsonBytes))
err = gateway.errHandler(rawResponse.StatusCode, jsonBytes)
}

Expand Down
6 changes: 3 additions & 3 deletions cf/net/request_dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package net

import (
"bytes"
"io/ioutil"
"io"
"net/http"
"net/http/httputil"
"net/url"
Expand Down Expand Up @@ -54,9 +54,9 @@ func (p RequestDumper) DumpRequest(req *http.Request) {
return
}

requestBody, err := ioutil.ReadAll(req.Body)
requestBody, err := io.ReadAll(req.Body)
req.Body.Close()
req.Body = ioutil.NopCloser(bytes.NewBuffer(requestBody))
req.Body = io.NopCloser(bytes.NewBuffer(requestBody))

if len(requestBody) == 0 {
return
Expand Down
5 changes: 2 additions & 3 deletions cf/terminal/tee_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package terminal
import (
"fmt"
"io"
"io/ioutil"
)

type TeePrinter struct {
Expand All @@ -14,14 +13,14 @@ type TeePrinter struct {

func NewTeePrinter(w io.Writer) *TeePrinter {
return &TeePrinter{
outputBucket: ioutil.Discard,
outputBucket: io.Discard,
stdout: w,
}
}

func (t *TeePrinter) SetOutputBucket(bucket io.Writer) {
if bucket == nil {
bucket = ioutil.Discard
bucket = io.Discard
}

t.outputBucket = bucket
Expand Down
4 changes: 2 additions & 2 deletions cf/util/json/json_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package json
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
)

Expand Down Expand Up @@ -64,7 +64,7 @@ func readJSONFile(path string) ([]byte, error) {
return nil, err
}

bytes, err := ioutil.ReadAll(file)
bytes, err := io.ReadAll(file)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions i18n/resources/i18n_resources.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.