Skip to content

Commit

Permalink
quote targets (#14)
Browse files Browse the repository at this point in the history
* quote targets

* remove deprecated methods
  • Loading branch information
ewhauser authored Aug 31, 2022
1 parent e249c57 commit ac56db2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
5 changes: 2 additions & 3 deletions internal/bazel_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"crypto/sha256"
"io/fs"
"io/ioutil"
"log"
"os"
"strings"
Expand Down Expand Up @@ -72,7 +71,7 @@ func (b bazelClient) QueryTarget(queryTemplate string, targets map[string]bool)

var targetKeys []string
for k := range targets {
targetKeys = append(targetKeys, k)
targetKeys = append(targetKeys, "'"+k+"'")
}

var tpl bytes.Buffer
Expand Down Expand Up @@ -118,7 +117,7 @@ func (b bazelClient) processBazelSourcefileTargets(targets []*Target,
}

func (b bazelClient) performBazelQuery(query string) ([]*Target, error) {
file, err := ioutil.TempFile("", ".txt")
file, err := os.CreateTemp("", ".txt")
if err != nil {
log.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/bazel_sourcefile_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"crypto/sha256"
"errors"
"io/ioutil"
"os"
"path"
"strings"
Expand All @@ -28,7 +27,7 @@ func NewBazelSourceFileTarget(name string, digest []byte, workingDirectory strin
sourceFile := path.Join(workingDirectory, filenamePath)
if _, err := os.Stat(sourceFile); !errors.Is(err, os.ErrNotExist) {
// path/to/whatever does not exist
contents, err := ioutil.ReadFile(sourceFile)
contents, err := os.ReadFile(sourceFile)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions internal/io_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand All @@ -30,7 +29,7 @@ func WriteTargetsFile(targets map[string]bool, output string) {

func ReadHashFile(filename string) (map[string]string, error) {
x := map[string]string{}
startingContent, err := ioutil.ReadFile(filename)
startingContent, err := os.ReadFile(filename)
if err != nil {
return nil, nil
}
Expand All @@ -54,7 +53,7 @@ func WriteHashFile(filename string, data interface{}) (string, error) {
return "", err
}

err = ioutil.WriteFile(filename, out.Bytes(), 0644)
err = os.WriteFile(filename, out.Bytes(), 0644)
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/proto_delimited_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package internal

import (
"bytes"
"io/ioutil"
"os"
"testing"
)

func TestDelimitedReader(t *testing.T) {
protoBytes, err := ioutil.ReadFile("query.protodelim")
protoBytes, err := os.ReadFile("query.protodelim")
if err != nil {
t.Errorf("Error reading file")
}
Expand Down

0 comments on commit ac56db2

Please sign in to comment.