Skip to content

chore(go): update to 1.17.3. #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2021
Merged
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
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

### Not released yet

DIST:

* go: Build with Golang 1.17.3.
* tools: Update `golangci-lint` to `v1.43.0`. [#76](https://github.com/elastic/harp/pull/76)

## 0.2.0

### 2021-10-26
Expand All @@ -17,7 +22,7 @@ DIST:

CHANGES:

* core/vault: Replace json encoded metadata in secret data by a JSON object. [#68](https://github.com/elastic/harp/pull/68)
* core/vault: Replace JSON encoded metadata in secret data by a JSON object. [#68](https://github.com/elastic/harp/pull/68)
* crypto/pem: Delegate PEM encoding/decoding to `go.step.sm/crypto` [#73](https://github.com/elastic/harp/pull/73)

FEATURES:
Expand All @@ -27,7 +32,7 @@ FEATURES:
* from/vault: Support legacy bundle metadata format. [#69](https://github.com/elastic/harp/pull/69)
* template/engine: `jsonEscape` / `jsonUnescape` is added to handle string escaping using JSON character escaping strategy [#70](https://github.com/elastic/harp/pull/70)
* template/engine: `unquote` is added to unquote a `quote` escaped string. [#70](https://github.com/elastic/harp/pull/70)
* bundle/prefixer: Globally add a prefix to all secret package. [#74](https://github.com/elastic/harp/pull/74)
* bundle/prefixer: Globally add a prefix to all secret packages. [#74](https://github.com/elastic/harp/pull/74)
* plugin/kv: Promote harp-kv as builtin. [#75](https://github.com/elastic/harp/pull/75)

## 0.1.24
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Download a [release](https://github.com/elastic/harp/releases) or build from sou

```sh
$ go version
go version go1.17.2 linux/amd64
go version go1.17.3 linux/amd64
```

> Simple go version manager - <https://github.com/stefanmaric/g>
Expand Down
2 changes: 1 addition & 1 deletion build/mage/docker/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func Build(cmd *artifact.Command) func() error {
}

// Prepare command
// expected behavior
//nolint:gosec // expected behavior
c := exec.Command("docker", "build",
"-t", fmt.Sprintf("elastic/%s", cmd.Kebab()),
"-f", "-",
Expand Down
2 changes: 1 addition & 1 deletion build/mage/docker/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func Release(cmd *artifact.Command) func() error {
}

// Prepare command
// expected behavior
//nolint:gosec // expected behavior
c := exec.Command("docker", "build",
"-t", fmt.Sprintf("elastic/%s:artifacts-%s", cmd.Kebab(), relVer.String()),
"-f", "-",
Expand Down
2 changes: 1 addition & 1 deletion build/mage/docker/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func Tools() error {
}

// Prepare command
// expected behavior
//nolint:gosec // expected behavior
c := exec.Command("docker", "build",
"-t", "elastic/harp-tools",
"-f", "-",
Expand Down
4 changes: 2 additions & 2 deletions build/mage/golang/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (

// Keep only last 2 versions
var goVersions = []string{
"~1.17.2",
"~1.16.9",
"~1.17.3",
"~1.16.10",
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion build/mage/golang/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
var PathSeparatorString = string(os.PathSeparator)

// AllPackagesPath denotes all Go packages in a project.
var AllPackagesPath = strings.Join([]string{".", "..."}, PathSeparatorString)
var AllPackagesPath = "." + PathSeparatorString + "..."

// AllCommandsPath denotes all Go application packages in this project.
var AllCommandsPath = strings.Join([]string{".", "cmd", "..."}, PathSeparatorString)
Expand Down
3 changes: 1 addition & 2 deletions cmd/harp/internal/cmd/plugin_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -102,7 +101,7 @@ func (o *pluginListOptions) Run(cmd *cobra.Command) error {
}

// Crawl each directory to identify readable ones
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
var pathErr *os.PathError
if errors.As(err, &pathErr) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/harp/internal/cmd/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package cmd
import (
"fmt"
"io"
"io/ioutil"

"github.com/hashicorp/vault/api"
"github.com/spf13/afero"
Expand Down Expand Up @@ -113,7 +112,7 @@ func runTemplate(cmd *cobra.Command, args []string) {
}

// Drain reader
body, err := ioutil.ReadAll(reader)
body, err := io.ReadAll(reader)
if err != nil {
log.For(ctx).Fatal("unable to drain input template reader", zap.Error(err), zap.String("path", templateInputPath))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/harp/internal/cmd/transform_encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package cmd

import (
"io/ioutil"
"io"

"github.com/spf13/cobra"
"go.uber.org/zap"
Expand Down Expand Up @@ -69,7 +69,7 @@ var transformEncryptionCmd = func() *cobra.Command {
}

// Drain reader
content, err := ioutil.ReadAll(reader)
content, err := io.ReadAll(reader)
if err != nil {
log.For(ctx).Fatal("unable to drain input reader", zap.Error(err))
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/bundle/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"sort"
"strings"

Expand Down Expand Up @@ -117,7 +116,7 @@ func Load(r io.Reader) (*bundlev1.Bundle, error) {
return nil, fmt.Errorf("unable to process nil reader")
}

decoded, err := ioutil.ReadAll(r)
decoded, err := io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("unable to decompress bundle content")
}
Expand Down Expand Up @@ -390,7 +389,7 @@ func FromDump(r io.Reader) (*bundlev1.Bundle, error) {
}

// Drain input content
content, err := ioutil.ReadAll(r)
content, err := io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("unable to read input content: %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/bundle/patch/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package patch
import (
"fmt"
"io"
"io/ioutil"

"google.golang.org/protobuf/encoding/protojson"

Expand All @@ -43,7 +42,7 @@ func YAML(r io.Reader) (*bundlev1.Patch, error) {
}

// Drain reader
jsonData, err := ioutil.ReadAll(jsonReader)
jsonData, err := io.ReadAll(jsonReader)
if err != nil {
return nil, fmt.Errorf("unbale to drain all json reader content: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/bundle/ruleset/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func FromBundle(b *bundlev1.Bundle) (*bundlev1.RuleSet, error) {

// Process each secret
for _, s := range p.Secrets.Data {
r.Constraints = append(r.Constraints, fmt.Sprintf(`p.has_secret("%s")`, s.Key))
r.Constraints = append(r.Constraints, fmt.Sprintf(`p.has_secret(%q)`, s.Key))
}

// Add the rules
Expand Down
3 changes: 1 addition & 2 deletions pkg/bundle/ruleset/linter/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package linter
import (
"fmt"
"io"
"io/ioutil"

"google.golang.org/protobuf/encoding/protojson"

Expand All @@ -43,7 +42,7 @@ func YAML(r io.Reader) (*bundlev1.RuleSet, error) {
}

// Drain reader
jsonData, err := ioutil.ReadAll(jsonReader)
jsonData, err := io.ReadAll(jsonReader)
if err != nil {
return nil, fmt.Errorf("unbale to drain all json reader content: %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/bundle/template/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package template
import (
"fmt"
"io"
"io/ioutil"

"google.golang.org/protobuf/encoding/protojson"

Expand All @@ -43,7 +42,7 @@ func YAML(r io.Reader) (*bundlev1.Template, error) {
}

// Drain reader
jsonData, err := ioutil.ReadAll(jsonReader)
jsonData, err := io.ReadAll(jsonReader)
if err != nil {
return nil, fmt.Errorf("unbale to drain all json reader content: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/bundle/vfs/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package vfs

import (
"io/ioutil"
"io"
"testing"

"github.com/davecgh/go-spew/spew"
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestBundle_FS_Initialization(t *testing.T) {
return
}

payload, err := ioutil.ReadAll(f)
payload, err := io.ReadAll(f)
if err != nil {
t.Errorf("unable to read file from filesystem : %v", err)
return
Expand Down
3 changes: 1 addition & 2 deletions pkg/container/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"encoding/binary"
"fmt"
"io"
"io/ioutil"

"github.com/awnumar/memguard"
"golang.org/x/crypto/blake2b"
Expand Down Expand Up @@ -75,7 +74,7 @@ func Load(r io.Reader) (*containerv1.Container, error) {
}

// Drain input reader
decoded, err := ioutil.ReadAll(r)
decoded, err := io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("unable to container content")
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/kv/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ import (
"errors"
)

var (
// ErrKeyNotFound is raised when the given key could not be found in the store.
ErrKeyNotFound = errors.New("key not found")
)
// ErrKeyNotFound is raised when the given key could not be found in the store.
var ErrKeyNotFound = errors.New("key not found")

// Store describes the key/value store contract.
type Store interface {
Expand Down
8 changes: 4 additions & 4 deletions pkg/sdk/cmdutil/bug.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -98,7 +97,7 @@ func printOSDetails(w io.Writer) {
case "illumos", "solaris":
// Be sure to use the OS-supplied uname, in "/usr/bin":
printCmdOut(w, "uname -srv: ", "/usr/bin/uname", "-srv")
out, err := ioutil.ReadFile("/etc/release")
out, err := os.ReadFile("/etc/release")
if err == nil {
fmt.Fprintf(w, "/etc/release: %s\n", out)
}
Expand Down Expand Up @@ -157,7 +156,7 @@ func printGlibcVersion(w io.Writer) {
src := []byte(`int main() {}`)
srcfile := filepath.Join(tempdir, "go-bug.c")
outfile := filepath.Join(tempdir, "go-bug")
err := ioutil.WriteFile(srcfile, src, 0o600)
err := os.WriteFile(srcfile, src, 0o600)
if err != nil {
return
}
Expand All @@ -178,7 +177,8 @@ func printGlibcVersion(w io.Writer) {
if m == nil {
return
}
cmd = exec.Command(m[1]) // controlled input
//nolint:gosec // controlled input
cmd = exec.Command(m[1])
out, err = cmd.Output()
if err != nil {
return
Expand Down
1 change: 1 addition & 0 deletions pkg/sdk/cmdutil/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (h *DefaultPluginHandler) Execute(executablePath string, cmdArgs, environme

// invoke cmd binary relaying the environment and args given
// append executablePath to cmdArgs, as execve will make first argument the "binary name".
//nolint:gosec // controlled input
return syscall.Exec(executablePath, append([]string{executablePath}, cmdArgs...), environment)
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/sdk/convert/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"reflect"

"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -62,7 +61,7 @@ func loadFromYAML(r io.Reader) (io.Reader, error) {
}

// Drain input reader
in, err := ioutil.ReadAll(r)
in, err := io.ReadAll(r)
if err != nil && !errors.Is(err, io.EOF) {
return nil, fmt.Errorf("unable to drain input reader: %w", err)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/sdk/security/crypto/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"fmt"

"go.step.sm/crypto/pemutil"

// Import Blake2b
_ "golang.org/x/crypto/blake2b"
"golang.org/x/crypto/ssh"
Expand Down
7 changes: 3 additions & 4 deletions pkg/sdk/tlsconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"os"

"github.com/pkg/errors"
Expand Down Expand Up @@ -117,7 +116,7 @@ func certPool(caFile string, exclusivePool bool) (*x509.CertPool, error) {
return nil, fmt.Errorf("failed to read system certificates: %w", err)
}
}
content, err := ioutil.ReadFile(caFile)
content, err := os.ReadFile(caFile)
if err != nil {
return nil, fmt.Errorf("could not read CA certificate %q: %w", caFile, err)
}
Expand Down Expand Up @@ -187,12 +186,12 @@ func getCert(options *Options) ([]tls.Certificate, error) {

errMessage := "Could not load X509 key pair"

cert, err := ioutil.ReadFile(options.CertFile)
cert, err := os.ReadFile(options.CertFile)
if err != nil {
return nil, errors.Wrap(err, errMessage)
}

prKeyBytes, err := ioutil.ReadFile(options.KeyFile)
prKeyBytes, err := os.ReadFile(options.KeyFile)
if err != nil {
return nil, errors.Wrap(err, errMessage)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/template/cmdutil/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -85,7 +85,7 @@ func (opts *ValueOptions) MergeValues() (map[string]interface{}, error) {
// User specified a value via --set-file
for _, value := range opts.FileValues {
reader := func(rs []rune) (interface{}, error) {
bytes, err := ioutil.ReadFile(string(rs))
bytes, err := os.ReadFile(string(rs))
return string(bytes), err
}
if err := strvals.ParseIntoFile(value, base, reader); err != nil {
Expand Down Expand Up @@ -160,7 +160,7 @@ func processFilePath(currentDirectory, filePath string, result interface{}) erro

// Drain reader
var contentBytes []byte
contentBytes, err = ioutil.ReadAll(reader)
contentBytes, err = io.ReadAll(reader)
if err != nil {
return fmt.Errorf("unable to drain all reader content from '%s': %w", filePath, err)
}
Expand Down
Loading