Skip to content

Commit

Permalink
Merge 1beb9a8 into 262d11e
Browse files Browse the repository at this point in the history
  • Loading branch information
rm3l authored Feb 15, 2023
2 parents 262d11e + 1beb9a8 commit 3e2903d
Show file tree
Hide file tree
Showing 30 changed files with 104 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-push-ibm-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: redhat-actions/buildah-build@v2
with:
image: ibmcloudtest-image
tags: v1.18-1
tags: v1.19-1
context: ./.ibm/images
containerfiles: |
./.ibm/images/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .ibm/images/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18
FROM golang:1.19

RUN curl -fsSL https://clis.cloud.ibm.com/install/linux | sh && \
curl -sLO https://github.com/cli/cli/releases/download/v2.1.0/gh_2.1.0_linux_amd64.deb && \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This Dockerfile builds an image containing the Linux, Mac and Windows version of odo
# layered on top of the ubi7/ubi image.

FROM registry.svc.ci.openshift.org/openshift/release:golang-1.18 AS builder
FROM registry.svc.ci.openshift.org/openshift/release:golang-1.19 AS builder

COPY . /go/src/github.com/redhat-developer/odo
WORKDIR /go/src/github.com/redhat-developer/odo
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redhat-developer/odo

go 1.18
go 1.19

require (
github.com/ActiveState/termtest v0.7.1
Expand Down
2 changes: 1 addition & 1 deletion openshift-ci/build-root/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dockerfile to bootstrap build and test in openshift-ci

FROM registry.ci.openshift.org/openshift/release:golang-1.18
FROM registry.ci.openshift.org/openshift/release:golang-1.19

RUN yum -y install make wget gcc git httpd-tools
3 changes: 1 addition & 2 deletions pkg/preference/implem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package preference
import (
"context"
"fmt"
"io/ioutil"
"os"
"strconv"
"testing"
Expand All @@ -19,7 +18,7 @@ import (

func TestNew(t *testing.T) {

tempConfigFile, err := ioutil.TempFile("", "odoconfig")
tempConfigFile, err := os.CreateTemp("", "odoconfig")
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package registry

import (
"context"
"io/ioutil"
"os"
"path"
"sort"
Expand Down Expand Up @@ -262,7 +261,7 @@ func createRegistryDevfiles(registry api.Registry, devfileIndex []indexSchema.Sc
func (o RegistryClient) retrieveDevfileDataFromRegistry(ctx context.Context, registryName string, devfileName string) (api.DevfileData, error) {

// Create random temporary file
tmpFile, err := ioutil.TempDir("", "odo")
tmpFile, err := os.MkdirTemp("", "odo")
if err != nil {
return api.DevfileData{}, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/registry/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package registry

import (
"context"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
Expand All @@ -20,7 +19,7 @@ import (
)

func TestGetDevfileRegistries(t *testing.T) {
tempConfigFile, err := ioutil.TempFile("", "odoconfig")
tempConfigFile, err := os.CreateTemp("", "odoconfig")
if err != nil {
t.Fatal("Fail to create temporary config file")
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/registry/starter_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package registry
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -143,7 +142,7 @@ func downloadGitProject(starterProject *devfilev1.StarterProject, starterToken,
originalPath := ""
if starterProject.SubDir != "" {
originalPath = path
path, err = ioutil.TempDir("", "")
path, err = os.MkdirTemp("", "")
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package registry

import (
"context"
"io/ioutil"
"os"
"testing"

"github.com/google/go-cmp/cmp"
Expand All @@ -13,7 +13,7 @@ import (
)

func TestIsSecure(t *testing.T) {
tempConfigFile, err := ioutil.TempFile("", "odoconfig")
tempConfigFile, err := os.CreateTemp("", "odoconfig")
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/segment/integrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package segment

import (
"context"
"io/ioutil"
"os"
"testing"

Expand All @@ -15,7 +14,7 @@ import (
)

func TestGetRegistryOptions(t *testing.T) {
tempConfigFile, err := ioutil.TempFile("", "odoconfig")
tempConfigFile, err := os.CreateTemp("", "odoconfig")
if err != nil {
t.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/segment/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"os/user"
Expand Down Expand Up @@ -205,7 +204,7 @@ func getUserIdentity(telemetryFilePath string) (string, error) {

// Get-or-Create the anonymousID file that contains a UUID
if _, err := os.Stat(telemetryFilePath); !os.IsNotExist(err) {
id, err = ioutil.ReadFile(telemetryFilePath)
id, err = os.ReadFile(telemetryFilePath)
if err != nil {
return "", err
}
Expand All @@ -214,7 +213,7 @@ func getUserIdentity(telemetryFilePath string) (string, error) {
// check if the id is a valid uuid, if not, nil is returned
if uuid.Parse(strings.TrimSpace(string(id))) == nil {
id = []byte(uuid.NewRandom().String())
if err := ioutil.WriteFile(telemetryFilePath, id, 0600); err != nil {
if err := os.WriteFile(telemetryFilePath, id, 0600); err != nil {
return "", err
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/segment/segment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -53,7 +53,7 @@ func mockServer() (chan []byte, *httptest.Server) {

server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
bin, err := ioutil.ReadAll(r.Body)
bin, err := io.ReadAll(r.Body)
if err != nil {
log.Error(err)
return
Expand Down
7 changes: 3 additions & 4 deletions pkg/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package sync

import (
"errors"
io "io"
"io/ioutil"
"io"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -362,7 +361,7 @@ func TestUpdateIndexWithWatchChanges(t *testing.T) {
for _, fileToCreate := range tt.initialFilesToCreate {
filePath := filepath.Join(directory, fileToCreate)

if err := ioutil.WriteFile(filePath, []byte("non-empty-string"), 0644); err != nil {
if err := os.WriteFile(filePath, []byte("non-empty-string"), 0644); err != nil {
t.Fatalf("TestUpdateIndexWithWatchChangesLocal error: unable to write to index file path: %v", err)
}

Expand Down Expand Up @@ -397,7 +396,7 @@ func TestUpdateIndexWithWatchChanges(t *testing.T) {
addedFilePath := filepath.Join(directory, addedFile)
syncParams.WatchFiles = append(syncParams.WatchFiles, addedFilePath)

if err := ioutil.WriteFile(addedFilePath, []byte("non-empty-string"), 0644); err != nil {
if err := os.WriteFile(addedFilePath, []byte("non-empty-string"), 0644); err != nil {
t.Fatalf("TestUpdateIndexWithWatchChangesLocal error: unable to write to index file path: %v", err)
}
}
Expand Down
27 changes: 20 additions & 7 deletions pkg/testingutil/filesystem/default_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ limitations under the License.
package filesystem

import (
"io/ioutil"
"io/fs"
"os"
"path/filepath"
"time"
)

// DefaultFs implements Filesystem using same-named functions from "os" and "io/ioutil"
// DefaultFs implements Filesystem using same-named functions from "os" and "io"
type DefaultFs struct{}

var _ Filesystem = DefaultFs{}
Expand Down Expand Up @@ -99,22 +99,22 @@ func (DefaultFs) Getwd() (dir string, err error) {

// ReadFile via ioutil.ReadFile
func (DefaultFs) ReadFile(filename string) ([]byte, error) {
return ioutil.ReadFile(filename)
return os.ReadFile(filename)
}

// WriteFile via ioutil.WriteFile
func (DefaultFs) WriteFile(filename string, data []byte, perm os.FileMode) error {
return ioutil.WriteFile(filename, data, perm)
return os.WriteFile(filename, data, perm)
}

// TempDir via ioutil.TempDir
func (DefaultFs) TempDir(dir, prefix string) (string, error) {
return ioutil.TempDir(dir, prefix)
return os.MkdirTemp(dir, prefix)
}

// TempFile via ioutil.TempFile
func (DefaultFs) TempFile(dir, prefix string) (File, error) {
file, err := ioutil.TempFile(dir, prefix)
file, err := os.CreateTemp(dir, prefix)
if err != nil {
return nil, err
}
Expand All @@ -123,7 +123,20 @@ func (DefaultFs) TempFile(dir, prefix string) (File, error) {

// ReadDir via ioutil.ReadDir
func (DefaultFs) ReadDir(dirname string) ([]os.FileInfo, error) {
return ioutil.ReadDir(dirname)
entries, err := os.ReadDir(dirname)
if err != nil {
return nil, err
}
infos := make([]fs.FileInfo, 0, len(entries))
var info os.FileInfo
for _, entry := range entries {
info, err = entry.Info()
if err != nil {
return nil, err
}
infos = append(infos, info)
}
return infos, nil
}

// Walk via filepath.Walk
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/config_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package util

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"strings"

"github.com/redhat-developer/odo/pkg/testingutil/filesystem"
"gopkg.in/yaml.v2"

"github.com/redhat-developer/odo/pkg/testingutil/filesystem"
)

// CreateIfNotExists creates the directory and the file if it doesn't exist
Expand Down Expand Up @@ -59,7 +59,7 @@ func WriteToYAMLFile(c interface{}, filename string) error {
if err = CreateIfNotExists(filename); err != nil {
return err
}
err = ioutil.WriteFile(filename, data, 0600)
err = os.WriteFile(filename, data, 0600)
if err != nil {
return fmt.Errorf("unable to write config to file %v: %w", c, err)
}
Expand Down
15 changes: 9 additions & 6 deletions pkg/util/file_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package util
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -55,7 +54,7 @@ func ReadFileIndex(filePath string) (*FileIndex, error) {
return NewFileIndex(), nil
}

byteValue, err := ioutil.ReadFile(filePath)
byteValue, err := os.ReadFile(filePath)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -197,7 +196,7 @@ func write(filePath string, fi *FileIndex) error {
}
// While 0666 is the mask used when a file is created using os.Create,
// gosec objects, so use 0600 instead
return ioutil.WriteFile(filePath, jsonData, 0600)
return os.WriteFile(filePath, jsonData, 0600)
}

// WriteFile writes a file map to a file, the file map is given by
Expand Down Expand Up @@ -483,14 +482,18 @@ func recursiveChecker(pathOptions recursiveCheckerPathOptions, ignoreRules []str
}

// read the current folder and read inner files and folders
files, err := ioutil.ReadDir(matchedPath)
entries, err := os.ReadDir(matchedPath)
if err != nil {
return IndexerRet{}, err
}
if len(files) == 0 {
if len(entries) == 0 {
continue
}
for _, f := range files {
for _, entry := range entries {
f, err := entry.Info()
if err != nil {
return IndexerRet{}, err
}
if _, ok := remoteDirectories[filepath.Join(joinedRelPath, f.Name())]; ok {
continue
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/util/file_indexer_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -216,7 +215,7 @@ func TestGenerateNewFileDataEntry(t *testing.T) {
t.Fatalf("TestUpdateIndexWithWatchChangesLocal error: unable to create directories for %s: %v", tt.absolutePath, err)
}

if err := ioutil.WriteFile(tt.absolutePath, []byte("non-empty-string"), 0644); err != nil {
if err := os.WriteFile(tt.absolutePath, []byte("non-empty-string"), 0644); err != nil {
t.Fatalf("TestUpdateIndexWithWatchChangesLocal error: unable to write to index file path: %v", err)
}

Expand Down
Loading

0 comments on commit 3e2903d

Please sign in to comment.