makefile build rule modified, ioutil deprecated removed

jobatzil/rename
Enver Bisevac 2022-09-22 16:27:46 +02:00
parent 66f2dadb7a
commit 78d5794221
7 changed files with 10 additions and 13 deletions

View File

@ -40,7 +40,7 @@ generate: $(mocks) cli/server/wire_gen.go mocks/mock_client.go
build: generate ## Build the gitness service binary build: generate ## Build the gitness service binary
@echo "Building Gitness Server" @echo "Building Gitness Server"
CGO_ENABLED=0 go build -ldflags="-X github.com/harness/gitness/version.GitCommit=${GIT_COMMIT} -X github.com/harness/gitness/version.Version=${GITNESS_VERSION}" -o ./gitness . go build -ldflags="-X github.com/harness/gitness/version.GitCommit=${GIT_COMMIT} -X github.com/harness/gitness/version.Version.Major=${GITNESS_VERSION}" -o ./gitness .
test: generate ## Run the go tests test: generate ## Run the go tests
@echo "Running tests" @echo "Running tests"

View File

@ -7,7 +7,7 @@ package cli
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "os"
"time" "time"
"github.com/harness/gitness/cli/util" "github.com/harness/gitness/cli/util"
@ -38,7 +38,7 @@ func (c *loginCommand) run(*kingpin.ParseContext) error {
if err != nil { if err != nil {
return err return err
} }
return ioutil.WriteFile(path, data, OwnerReadWrite) return os.WriteFile(path, data, OwnerReadWrite)
} }
// helper function to register the logout command. // helper function to register the logout command.

View File

@ -7,7 +7,7 @@ package cli
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "os"
"time" "time"
"github.com/harness/gitness/cli/util" "github.com/harness/gitness/cli/util"
@ -37,7 +37,7 @@ func (c *registerCommand) run(*kingpin.ParseContext) error {
if err != nil { if err != nil {
return err return err
} }
return ioutil.WriteFile(path, data, OwnerReadWrite) return os.WriteFile(path, data, OwnerReadWrite)
} }
// helper function to register the register command. // helper function to register the register command.

View File

@ -5,7 +5,6 @@
package cli package cli
import ( import (
"io/ioutil"
"os" "os"
"github.com/harness/gitness/internal/api/openapi" "github.com/harness/gitness/internal/api/openapi"
@ -23,7 +22,7 @@ func (c *swaggerCommand) run(*kingpin.ParseContext) error {
os.Stdout.Write(data) os.Stdout.Write(data)
return nil return nil
} }
return ioutil.WriteFile(c.path, data, OwnerReadWrite) return os.WriteFile(c.path, data, OwnerReadWrite)
} }
// helper function to register the swagger command. // helper function to register the swagger command.

View File

@ -9,7 +9,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -30,7 +29,7 @@ func Client() (*client.HTTPClient, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -10,7 +10,7 @@ import (
"crypto/tls" "crypto/tls"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
@ -93,7 +93,7 @@ func (a *Authorizer) CheckAll(ctx context.Context, principalType enum.PrincipalT
return false, fmt.Errorf("got unexpected status code '%d' - assume unauthorized", response.StatusCode) return false, fmt.Errorf("got unexpected status code '%d' - assume unauthorized", response.StatusCode)
} }
bodyByte, err := ioutil.ReadAll(response.Body) bodyByte, err := io.ReadAll(response.Body)
if err != nil { if err != nil {
return false, err return false, err
} }

View File

@ -6,7 +6,6 @@ package database
import ( import (
"encoding/json" "encoding/json"
"io/ioutil"
"os" "os"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
@ -56,7 +55,7 @@ func seed(db *sqlx.DB) error {
// unmarshal a testdata file. // unmarshal a testdata file.
func unmarshal(path string, v interface{}) error { func unmarshal(path string, v interface{}) error {
out, err := ioutil.ReadFile(path) out, err := os.ReadFile(path)
if err != nil { if err != nil {
return err return err
} }