Skip to content

Commit

Permalink
[DEVHAS-443]update to go 1.19 (#378)
Browse files Browse the repository at this point in the history
* update to go 1.19

Signed-off-by: Stephanie <[email protected]>

* fix go fmt

Signed-off-by: Stephanie <[email protected]>

---------

Signed-off-by: Stephanie <[email protected]>
  • Loading branch information
yangcao77 authored Aug 15, 2023
1 parent 4f7b4a1 commit 2e23404
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Run tests
run: make test
- name: Codecov
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pact_postmerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -69,9 +69,9 @@ jobs:
git --no-pager diff
exit 1
fi
- uses: dominikh/staticcheck-action@v1.2.0
- uses: dominikh/staticcheck-action@v1.3.0
with:
version: "2022.1"
version: "2022.1.3"
install-go: false
- name: Check manifests
run: |
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.18 as builder
FROM golang:1.19 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
2 changes: 1 addition & 1 deletion cdq-analysis/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redhat-appstudio/application-service/cdq-analysis

go 1.18
go 1.19

require (
github.com/devfile/api/v2 v2.2.1-alpha.0.20230413012049-a6c32fca0dbd
Expand Down
3 changes: 1 addition & 2 deletions cdq-analysis/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
//
// Copyright 2023 Red Hat, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
10 changes: 5 additions & 5 deletions cdq-analysis/pkg/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package pkg

import (
"fmt"
"io/ioutil"
"os"
"path"
"reflect"
"strings"
Expand Down Expand Up @@ -52,7 +52,7 @@ func search(log logr.Logger, a Alizer, localpath string, devfileRegistryURL stri
dockerfileContextMapFromRepo := make(map[string]string)
componentPortsMapFromRepo := make(map[string][]int)

files, err := ioutil.ReadDir(localpath)
files, err := os.ReadDir(localpath)
if err != nil {
return nil, nil, nil, nil, err
}
Expand All @@ -63,7 +63,7 @@ func search(log logr.Logger, a Alizer, localpath string, devfileRegistryURL stri
isDockerfilePresent := false
curPath := path.Join(localpath, f.Name())
context := path.Join(srcContext, f.Name())
files, err := ioutil.ReadDir(curPath)
files, err := os.ReadDir(curPath)
if err != nil {
return nil, nil, nil, nil, err
}
Expand Down Expand Up @@ -93,7 +93,7 @@ func search(log logr.Logger, a Alizer, localpath string, devfileRegistryURL stri
// if the dir is .devfile, we dont increment currentLevel
// consider devfile.yaml and .devfile/devfile.yaml as the same level, for example
hiddenDirPath := path.Join(curPath, HiddenDevfileDir)
hiddenfiles, err := ioutil.ReadDir(hiddenDirPath)
hiddenfiles, err := os.ReadDir(hiddenDirPath)
if err != nil {
return nil, nil, nil, nil, err
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func search(log logr.Logger, a Alizer, localpath string, devfileRegistryURL stri
// OR docker/Containerfile, .docker/Containerfile and build/Containerfile
dirName := f.Name()
dirPath := path.Join(curPath, dirName)
files, err := ioutil.ReadDir(dirPath)
files, err := os.ReadDir(dirPath)
if err != nil {
return nil, nil, nil, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cdq-analysis/pkg/detect_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (a MockAlizerClient) DetectComponents(path string) ([]model.Component, erro
"Mux",
},
Tools: []string{
"1.18",
"1.19",
},
Weight: 100,
CanBeComponent: true,
Expand Down
3 changes: 1 addition & 2 deletions cdq-analysis/pkg/devfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package pkg

import (
"io/ioutil"
"net"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -76,7 +75,7 @@ schemaVersion: 2.2.0`
if err != nil {
t.Errorf("TestParseDevfileModel() error: failed to create folder: %v, error: %v", localPath, err)
}
err = ioutil.WriteFile(localDevfilePath, []byte(simpleDevfile), 0644)
err = os.WriteFile(localDevfilePath, []byte(simpleDevfile), 0644)
if err != nil {
t.Errorf("TestParseDevfileModel() error: fail to write to file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cdq-analysis/pkg/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package pkg

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -100,7 +100,7 @@ func CurlEndpoint(endpoint string) ([]byte, error) {
defer resp.Body.Close()

if resp.StatusCode == http.StatusOK {
respBytes, err = ioutil.ReadAll(resp.Body)
respBytes, err = io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
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-appstudio/application-service

go 1.18
go 1.19

require (
github.com/brianvoe/gofakeit/v6 v6.9.0
Expand Down
4 changes: 2 additions & 2 deletions pkg/github/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package github

import (
"io/ioutil"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -44,7 +44,7 @@ func GetMockedClient() *github.Client {
mock.WithRequestMatchHandler(
mock.PostOrgsReposByOrg,
http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
b, _ := ioutil.ReadAll(req.Body)
b, _ := io.ReadAll(req.Body)
reqBody := string(b)
// ToDo: Figure out a better way to dynamically mock errors
if strings.Contains(reqBody, "test-error-response") || strings.Contains(reqBody, "test-server-error-response") || strings.Contains(reqBody, "test-server-error-response-2") {
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/ioutils/ioutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func CreateTempPath(prefix string, appFs afero.Afero) (string, error) {
// Used in cases where we're cleaning up after encountering an error, but want to return the original error instead.
func RemoveFolderAndLogError(log logr.Logger, fs afero.Fs, path string) {
if path != "" {
err := fs.RemoveAll(path)
err := os.RemoveAll(path)
if err != nil {
log.Error(err, fmt.Sprintf("Unable to delete folder %s", path))
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"crypto/sha256"
"encoding/base64"
"fmt"
"io/ioutil"
"io"
"math/rand"
"net/http"
"net/url"
Expand Down Expand Up @@ -155,7 +155,7 @@ func CurlEndpoint(endpoint string) ([]byte, error) {
defer resp.Body.Close()

if resp.StatusCode == http.StatusOK {
respBytes, err = ioutil.ReadAll(resp.Body)
respBytes, err = io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 2e23404

Please sign in to comment.