Skip to content
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
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.6
1.19.1
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ licenser:
go run github.com/elastic/go-licenser -license Elastic

gomod:
go mod tidy -go=1.16 && go mod tidy -go=1.17
go mod tidy
Comment on lines 30 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice !

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, let's see if problems don't come back 😅


update-readme:
cd tools/readme; go run main.go
Expand Down
10 changes: 5 additions & 5 deletions cmd/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package cmd

import (
"io/ioutil"
"os"
"path/filepath"

"github.com/Masterminds/semver"
Expand Down Expand Up @@ -145,7 +145,7 @@ func changelogCmdVersion(nextMode, packageRoot string) (*semver.Version, error)
// trying to conserve original format and comments.
func patchChangelogFile(packageRoot string, patch changelog.Revision) error {
changelogPath := filepath.Join(packageRoot, changelog.PackageChangelogFile)
d, err := ioutil.ReadFile(changelogPath)
d, err := os.ReadFile(changelogPath)
if err != nil {
return err
}
Expand All @@ -155,12 +155,12 @@ func patchChangelogFile(packageRoot string, patch changelog.Revision) error {
return err
}

return ioutil.WriteFile(changelogPath, d, 0644)
return os.WriteFile(changelogPath, d, 0644)
}

func setManifestVersion(packageRoot string, version string) error {
manifestPath := filepath.Join(packageRoot, packages.PackageManifestFile)
d, err := ioutil.ReadFile(manifestPath)
d, err := os.ReadFile(manifestPath)
if err != nil {
return err
}
Expand All @@ -170,5 +170,5 @@ func setManifestVersion(packageRoot string, version string) error {
return err
}

return ioutil.WriteFile(manifestPath, d, 0644)
return os.WriteFile(manifestPath, d, 0644)
}
6 changes: 3 additions & 3 deletions cmd/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package cmd
import (
"bytes"
"flag"
"io/ioutil"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -121,11 +121,11 @@ func TestStatusFormatAndPrint(t *testing.T) {

func assertOutputWithFile(t *testing.T, path string, out string) {
if *generateFlag {
err := ioutil.WriteFile(path, []byte(out), 0644)
err := os.WriteFile(path, []byte(out), 0644)
require.NoError(t, err)
}

d, err := ioutil.ReadFile(path)
d, err := os.ReadFile(path)
require.NoError(t, err)

assert.Equal(t, string(d), out)
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/elastic/elastic-package

go 1.17
go 1.19

require (
github.com/AlecAivazis/survey/v2 v2.3.5
Expand Down
690 changes: 0 additions & 690 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions internal/certs/certs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"os/exec"
Expand Down Expand Up @@ -114,7 +114,7 @@ func testTLSClient(t *testing.T, root *Certificate, commonName, address string)
resp, err := client.Get("https://" + commonName)
require.NoError(t, err)
defer resp.Body.Close()
d, _ := ioutil.ReadAll(resp.Body)
d, _ := io.ReadAll(resp.Body)
assert.Equal(t, http.StatusOK, resp.StatusCode)
assert.Equal(t, "ok", string(d))

Expand Down
4 changes: 2 additions & 2 deletions internal/certs/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"os"
)

// PoolWithCACertificate returns a new pool that includes the CA certificate
Expand Down Expand Up @@ -37,7 +37,7 @@ func SystemPoolWithCACertificate(path string) (*x509.CertPool, error) {
}

func addCACertificateToPool(pool *x509.CertPool, path string) error {
d, err := ioutil.ReadFile(path)
d, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("failed to read certificate in %q: %w", path, err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/dump/componenttemplates.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"

"github.com/elastic/elastic-package/internal/elasticsearch"
)
Expand Down Expand Up @@ -71,7 +71,7 @@ func getComponentTemplatesByName(ctx context.Context, api *elasticsearch.API, na
}
defer resp.Body.Close()

d, err := ioutil.ReadAll(resp.Body)
d, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/dump/ilmpolicies.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"

"github.com/elastic/elastic-package/internal/elasticsearch"
)
Expand Down Expand Up @@ -57,7 +57,7 @@ func getILMPolicyByName(ctx context.Context, api *elasticsearch.API, policy stri
}
defer resp.Body.Close()

d, err := ioutil.ReadAll(resp.Body)
d, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/dump/indextemplates.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"

"github.com/elastic/elastic-package/internal/common"
"github.com/elastic/elastic-package/internal/elasticsearch"
Expand Down Expand Up @@ -77,7 +77,7 @@ func getIndexTemplatesForPackage(ctx context.Context, api *elasticsearch.API, pa
}
defer resp.Body.Close()

d, err := ioutil.ReadAll(resp.Body)
d, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/dump/ingestpipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"

"github.com/elastic/elastic-package/internal/common"
"github.com/elastic/elastic-package/internal/elasticsearch"
Expand Down Expand Up @@ -71,7 +71,7 @@ func getIngestPipelineByID(ctx context.Context, api *elasticsearch.API, id strin
}
defer resp.Body.Close()

d, err := ioutil.ReadAll(resp.Body)
d, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/dump/installedobjects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"encoding/json"
"errors"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -164,7 +163,7 @@ func assertEqualDumps(t *testing.T, expectedDir, resultDir string) {
func assertEquivalentJSON(t *testing.T, expectedPath, foundPath string) {
t.Helper()
readJSON := func(p string) map[string]interface{} {
d, err := ioutil.ReadFile(p)
d, err := os.ReadFile(p)
require.NoError(t, err)
var o map[string]interface{}
err = json.Unmarshal(d, &o)
Expand Down
3 changes: 1 addition & 2 deletions internal/dump/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
Expand All @@ -27,7 +26,7 @@ func dumpJSONResource(dir string, object DumpableJSONResource) error {
return fmt.Errorf("failed to format JSON object: %w", err)
}
path := filepath.Join(dir, object.Name()+".json")
err = ioutil.WriteFile(path, formatted, 0644)
err = os.WriteFile(path, formatted, 0644)
if err != nil {
return fmt.Errorf("failed to dump object to file: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/elasticsearch/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"bytes"
"crypto/x509"
"encoding/pem"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -59,7 +59,7 @@ func writeCACertFile(t *testing.T, cert *x509.Certificate) string {
require.NoError(t, err)

caCertFile := filepath.Join(t.TempDir(), "ca.pem")
err = ioutil.WriteFile(caCertFile, d.Bytes(), 0644)
err = os.WriteFile(caCertFile, d.Bytes(), 0644)
require.NoError(t, err)

return caCertFile
Expand Down
5 changes: 2 additions & 3 deletions internal/files/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package files

import (
"fmt"
"io/ioutil"
"os"

"github.com/ProtonMail/gopenpgp/v2/armor"
Expand Down Expand Up @@ -54,7 +53,7 @@ func VerifySignerConfiguration() error {
func Sign(targetFile string, options SignOptions) error {
signerPrivateKeyfile := os.Getenv(signerPrivateKeyfileEnv)
logger.Debugf("Read signer private keyfile: %s", signerPrivateKeyfile)
signerPrivateKey, err := ioutil.ReadFile(signerPrivateKeyfile)
signerPrivateKey, err := os.ReadFile(signerPrivateKeyfile)
if err != nil {
return errors.Wrapf(err, "can't read the signer private keyfile (path: %s)", signerPrivateKeyfile)
}
Expand Down Expand Up @@ -97,7 +96,7 @@ func Sign(targetFile string, options SignOptions) error {

logger.Debug("Signature generated for the target file, writing the .sig file")
targetSigFile := targetFile + ".sig"
err = ioutil.WriteFile(targetSigFile, []byte(armoredSignature), 0644)
err = os.WriteFile(targetSigFile, []byte(armoredSignature), 0644)
if err != nil {
return errors.Wrap(err, "can't write the signature file")
}
Expand Down
4 changes: 2 additions & 2 deletions internal/kibana/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -60,7 +60,7 @@ func writeCACertFile(t *testing.T, cert *x509.Certificate) string {
require.NoError(t, err)

caCertFile := filepath.Join(t.TempDir(), "ca.pem")
err = ioutil.WriteFile(caCertFile, d.Bytes(), 0644)
err = os.WriteFile(caCertFile, d.Bytes(), 0644)
require.NoError(t, err)

return caCertFile
Expand Down
7 changes: 3 additions & 4 deletions internal/packages/changelog/yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package changelog

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

Expand Down Expand Up @@ -75,15 +74,15 @@ func TestPatchYAML(t *testing.T) {

for _, c := range cases {
t.Run(c.title, func(t *testing.T) {
d, err := ioutil.ReadFile(c.original)
d, err := os.ReadFile(c.original)
require.NoError(t, err)

result, err := PatchYAML(d, c.patch)
require.NoError(t, err)

expected, err := ioutil.ReadFile(c.expected)
expected, err := os.ReadFile(c.expected)
if errors.Is(err, os.ErrNotExist) {
err := ioutil.WriteFile(c.expected, result, 0644)
err := os.WriteFile(c.expected, result, 0644)
require.NoError(t, err)
t.Skip("file generated, run again")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package servicedeployer

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -220,7 +219,7 @@ func writeServiceContainerLogs(serviceName string, content []byte) error {

containerLogsFilepath := filepath.Join(containerLogsDir, fmt.Sprintf("%s-%d.log", serviceName, time.Now().UnixNano()))
logger.Infof("Write container logs to file: %s", containerLogsFilepath)
err = ioutil.WriteFile(containerLogsFilepath, content, 0644)
err = os.WriteFile(containerLogsFilepath, content, 0644)
if err != nil {
return errors.Wrapf(err, "can't write container logs to file (path: %s)", containerLogsFilepath)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"bytes"
_ "embed"
"encoding/base64"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -208,7 +207,7 @@ func readCACertBase64() (string, error) {
return "", errors.Errorf("%s not defined", stack.CACertificateEnv)
}

d, err := ioutil.ReadFile(caCertPath)
d, err := os.ReadFile(caCertPath)
if err != nil {
return "", err
}
Expand Down