From 3549cbef412ea0f947bb5c51bad171cdac4a266b Mon Sep 17 00:00:00 2001 From: mtojek Date: Mon, 2 Aug 2021 14:29:41 +0200 Subject: [PATCH 1/4] Use Go 1.16 --- go.mod | 2 +- go.sum | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 667734bec1..ada0ded2d4 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/elastic/elastic-package -go 1.15 +go 1.16 require ( github.com/AlecAivazis/survey/v2 v2.2.15 diff --git a/go.sum b/go.sum index f830234d5b..826ff2bf7b 100644 --- a/go.sum +++ b/go.sum @@ -248,13 +248,11 @@ github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwo github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fvbommel/sortorder v1.0.1/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= From 6e852e14c3a4c3d04efc70415a0ab8e290184e69 Mon Sep 17 00:00:00 2001 From: mtojek Date: Mon, 2 Aug 2021 14:49:45 +0200 Subject: [PATCH 2/4] WIP --- dist/CHANGELOG.md | 4 + dist/config.yaml | 78 +++++++++++++++++++ internal/builder/dashboards.go | 6 +- internal/builder/external_fields.go | 6 +- internal/docs/readme.go | 9 +-- internal/docs/sample_event.go | 4 +- internal/export/dashboards.go | 4 +- internal/export/dashboards_test.go | 6 +- internal/fields/dependency_manager.go | 8 +- internal/fields/validate.go | 6 +- internal/fields/validate_test.go | 5 +- internal/files/remove.go | 3 +- internal/formatter/formatter.go | 5 +- internal/github/auth.go | 3 +- internal/install/application_configuration.go | 4 +- internal/install/install.go | 3 +- internal/install/version_file.go | 3 +- internal/kibana/client.go | 4 +- internal/packages/archetype/archetype.go | 5 +- .../packages/archetype/data_stream_test.go | 4 +- internal/packages/archetype/package_test.go | 4 +- internal/packages/assets.go | 7 +- internal/profile/config_profile_test.go | 5 +- internal/profile/files.go | 8 +- internal/profile/install_profile.go | 3 +- internal/profile/profile.go | 7 +- internal/registry/client.go | 4 +- internal/stack/dump.go | 3 +- internal/stack/shellinit.go | 4 +- internal/storage/signature.go | 4 +- internal/storage/storage.go | 4 +- internal/testrunner/coverageoutput.go | 5 +- internal/testrunner/reporters/outputs/file.go | 3 +- .../testrunner/runners/asset/test_config.go | 4 +- .../runners/pipeline/ingest_pipeline.go | 12 +-- .../testrunner/runners/pipeline/runner.go | 5 +- .../runners/pipeline/test_result.go | 6 +- internal/testrunner/runners/static/runner.go | 3 +- .../testrunner/runners/static/test_config.go | 3 +- internal/testrunner/runners/system/runner.go | 4 +- .../runners/system/servicedeployer/factory.go | 5 +- .../system/servicedeployer/kubernetes.go | 3 +- .../system/servicedeployer/variants.go | 4 +- .../testrunner/runners/system/test_config.go | 4 +- internal/testrunner/testrunner.go | 3 +- 45 files changed, 174 insertions(+), 113 deletions(-) create mode 100644 dist/CHANGELOG.md create mode 100644 dist/config.yaml diff --git a/dist/CHANGELOG.md b/dist/CHANGELOG.md new file mode 100644 index 0000000000..816d11abe3 --- /dev/null +++ b/dist/CHANGELOG.md @@ -0,0 +1,4 @@ +## Changelog + +e815623 Get elastic-agent-managed-daemonset.yaml from upstream 7.x instead of using a local static file (#452) +b7d8e15 Modify Docker stack orchestration to be ready for Compose V2 (#454) diff --git a/dist/config.yaml b/dist/config.yaml new file mode 100644 index 0000000000..990ccc5df0 --- /dev/null +++ b/dist/config.yaml @@ -0,0 +1,78 @@ +project_name: elastic-package +release: + github: + owner: mtojek + name: elastic-package + name_template: '{{.Tag}}' +milestones: +- repo: + owner: mtojek + name: elastic-package + name_template: '{{ .Tag }}' +scoop: + name: elastic-package + commit_author: + name: goreleaserbot + email: goreleaser@carlosbecker.com + commit_msg_template: Scoop update for {{ .ProjectName }} version {{ .Tag }} +builds: +- id: elastic-package + goos: + - darwin + goarch: + - amd64 + goarm: + - "6" + gomips: + - hardfloat + targets: + - darwin_amd64 + dir: . + main: . + ldflags: + - -X github.com/elastic/elastic-package/internal/version.Tag={{.Tag}} + - -X github.com/elastic/elastic-package/internal/version.CommitHash={{.ShortCommit}} + - -X github.com/elastic/elastic-package/internal/version.BuildTime={{.Timestamp}} + binary: elastic-package + lang: go + gobinary: go +archives: +- id: default + builds: + - elastic-package + name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm + }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}' + format: tar.gz + files: + - licence* + - LICENCE* + - license* + - LICENSE* + - readme* + - README* + - changelog* + - CHANGELOG* + allow_different_binary_count: false +snapshot: + name_template: '{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}' +checksum: + name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt' + algorithm: sha256 +dist: dist +env_files: + github_token: ~/.config/goreleaser/github_token + gitlab_token: ~/.config/goreleaser/gitlab_token + gitea_token: ~/.config/goreleaser/gitea_token +source: + name_template: '{{ .ProjectName }}-{{ .Version }}' + format: tar.gz +gomod: + gobinary: go +announce: + twitter: + message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .GitURL + }}/releases/tag/{{ .Tag }}' +github_urls: + download: https://github.com +gitlab_urls: + download: https://gitlab.com diff --git a/internal/builder/dashboards.go b/internal/builder/dashboards.go index 350618d485..87223ef250 100644 --- a/internal/builder/dashboards.go +++ b/internal/builder/dashboards.go @@ -6,7 +6,7 @@ package builder import ( "encoding/json" - "io/ioutil" + "os" "path/filepath" "github.com/pkg/errors" @@ -31,7 +31,7 @@ func encodeDashboards(destinationDir string) error { } for _, file := range savedObjects { - data, err := ioutil.ReadFile(file) + data, err := os.ReadFile(file) if err != nil { return err } @@ -41,7 +41,7 @@ func encodeDashboards(destinationDir string) error { } if changed { - err = ioutil.WriteFile(file, output, 0644) + err = os.WriteFile(file, output, 0644) if err != nil { return err } diff --git a/internal/builder/external_fields.go b/internal/builder/external_fields.go index eb03f2d473..9a3b18e708 100644 --- a/internal/builder/external_fields.go +++ b/internal/builder/external_fields.go @@ -5,7 +5,7 @@ package builder import ( - "io/ioutil" + "os" "path/filepath" "github.com/pkg/errors" @@ -42,7 +42,7 @@ func resolveExternalFields(packageRoot, destinationDir string) error { return err } for _, file := range fieldsFile { - data, err := ioutil.ReadFile(file) + data, err := os.ReadFile(file) if err != nil { return err } @@ -54,7 +54,7 @@ func resolveExternalFields(packageRoot, destinationDir string) error { } else if injected { logger.Debugf("%s: source file has been changed", rel) - err = ioutil.WriteFile(file, output, 0644) + err = os.WriteFile(file, output, 0644) if err != nil { return err } diff --git a/internal/docs/readme.go b/internal/docs/readme.go index 6b00c1ead3..2a79fb521d 100644 --- a/internal/docs/readme.go +++ b/internal/docs/readme.go @@ -7,7 +7,6 @@ package docs import ( "bytes" "fmt" - "io/ioutil" "os" "path/filepath" "text/template" @@ -33,7 +32,7 @@ func AreReadmesUpToDate() ([]ReadmeFile, error) { return nil, errors.Wrap(err, "package root not found") } - files, err := ioutil.ReadDir(filepath.Join(packageRoot, "_dev", "build", "docs")) + files, err := os.ReadDir(filepath.Join(packageRoot, "_dev", "build", "docs")) if err != nil && !os.IsNotExist(err) { return nil, errors.Wrap(err, "reading directory entries failed") } @@ -87,7 +86,7 @@ func isReadmeUpToDate(fileName, packageRoot string) (bool, error) { // UpdateReadmes function updates all .md readme files using a defined template // files. The function doesn't perform any action if the template file is not present. func UpdateReadmes(packageRoot string) ([]string, error) { - readmeFiles, err := ioutil.ReadDir(filepath.Join(packageRoot, "_dev", "build", "docs")) + readmeFiles, err := os.ReadDir(filepath.Join(packageRoot, "_dev", "build", "docs")) if err != nil && !os.IsNotExist(err) { return nil, errors.Wrap(err, "reading directory entries failed") } @@ -199,7 +198,7 @@ func readReadme(fileName, packageRoot string) ([]byte, bool, error) { logger.Debugf("Read existing %s file (package: %s)", fileName, packageRoot) readmePath := filepath.Join(packageRoot, "docs", fileName) - b, err := ioutil.ReadFile(readmePath) + b, err := os.ReadFile(readmePath) if err != nil && os.IsNotExist(err) { return nil, false, nil } @@ -222,7 +221,7 @@ func writeReadme(fileName, packageRoot string, content []byte) (string, error) { aReadmePath := readmePath(fileName, packageRoot) logger.Debugf("Write %s file to: %s", fileName, aReadmePath) - err = ioutil.WriteFile(aReadmePath, content, 0644) + err = os.WriteFile(aReadmePath, content, 0644) if err != nil { return "", errors.Wrapf(err, "writing file failed (path: %s)", aReadmePath) } diff --git a/internal/docs/sample_event.go b/internal/docs/sample_event.go index 8a963a4d81..91d5e59696 100644 --- a/internal/docs/sample_event.go +++ b/internal/docs/sample_event.go @@ -6,7 +6,7 @@ package docs import ( "fmt" - "io/ioutil" + "os" "path/filepath" "strings" @@ -20,7 +20,7 @@ const sampleEventFile = "sample_event.json" func renderSampleEvent(packageRoot, dataStreamName string) (string, error) { eventPath := filepath.Join(packageRoot, "data_stream", dataStreamName, sampleEventFile) - body, err := ioutil.ReadFile(eventPath) + body, err := os.ReadFile(eventPath) if err != nil { return "", errors.Wrapf(err, "reading sample event file failed (path: %s)", eventPath) } diff --git a/internal/export/dashboards.go b/internal/export/dashboards.go index d957ebe52b..b02d31c68a 100644 --- a/internal/export/dashboards.go +++ b/internal/export/dashboards.go @@ -6,7 +6,7 @@ package export import ( "encoding/json" - "io/ioutil" + "io" "os" "path/filepath" @@ -86,7 +86,7 @@ func saveObjectsToFiles(packageRoot string, objects []common.MapStr) error { // Save object to file objectPath := filepath.Join(targetDir, id.(string)+".json") - err = ioutil.WriteFile(objectPath, b, 0644) + err = os.WriteFile(objectPath, b, 0644) if err != nil { return errors.Wrap(err, "writing to file failed") } diff --git a/internal/export/dashboards_test.go b/internal/export/dashboards_test.go index c43f06c1d3..7dec551bd4 100644 --- a/internal/export/dashboards_test.go +++ b/internal/export/dashboards_test.go @@ -6,7 +6,7 @@ package export import ( "encoding/json" - "io/ioutil" + "io" "testing" "github.com/stretchr/testify/require" @@ -15,7 +15,7 @@ import ( ) func TestTransform(t *testing.T) { - b, err := ioutil.ReadFile("./test/system-navigation.json") + b, err := os.ReadFile("./test/system-navigation.json") require.NoError(t, err) var given common.MapStr @@ -33,7 +33,7 @@ func TestTransform(t *testing.T) { result, err := json.MarshalIndent(&results[0], "", " ") require.NoError(t, err) - expected, err := ioutil.ReadFile("./test/system-navigation.json-expected.json") + expected, err := os.ReadFile("./test/system-navigation.json-expected.json") require.NoError(t, err) require.Equal(t, string(expected), string(result)) diff --git a/internal/fields/dependency_manager.go b/internal/fields/dependency_manager.go index ea6e6da652..418ce5c067 100644 --- a/internal/fields/dependency_manager.go +++ b/internal/fields/dependency_manager.go @@ -6,7 +6,7 @@ package fields import ( "fmt" - "io/ioutil" + "io" "net/http" "os" "path/filepath" @@ -72,7 +72,7 @@ func loadECSFieldsSchema(dep buildmanifest.ECSDependency) ([]FieldDefinition, er } cachedSchemaPath := filepath.Join(loc.FieldsCacheDir(), ecsSchemaName, gitReference, ecsSchemaFile) - content, err := ioutil.ReadFile(cachedSchemaPath) + content, err := os.ReadFile(cachedSchemaPath) if err != nil && !errors.Is(err, os.ErrNotExist) { return nil, errors.Wrapf(err, "can't read cached schema (path: %s)", cachedSchemaPath) } @@ -92,7 +92,7 @@ func loadECSFieldsSchema(dep buildmanifest.ECSDependency) ([]FieldDefinition, er return nil, fmt.Errorf("unexpected HTTP status code: %d", resp.StatusCode) } - content, err = ioutil.ReadAll(resp.Body) + content, err = io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrapf(err, "can't read schema content (URL: %s)", url) } @@ -105,7 +105,7 @@ func loadECSFieldsSchema(dep buildmanifest.ECSDependency) ([]FieldDefinition, er } logger.Debugf("Cache downloaded schema: %s", cachedSchemaPath) - err = ioutil.WriteFile(cachedSchemaPath, content, 0644) + err = os.WriteFile(cachedSchemaPath, content, 0644) if err != nil { return nil, errors.Wrapf(err, "can't write cached schema (path: %s)", cachedSchemaPath) } diff --git a/internal/fields/validate.go b/internal/fields/validate.go index 0ebed23d3d..6d269ce8e4 100644 --- a/internal/fields/validate.go +++ b/internal/fields/validate.go @@ -7,7 +7,7 @@ package fields import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "regexp" "strings" @@ -101,7 +101,7 @@ func CreateValidatorForDataStream(dataStreamRootPath string, opts ...ValidatorOp func loadFieldsForDataStream(dataStreamRootPath string) ([]FieldDefinition, error) { fieldsDir := filepath.Join(dataStreamRootPath, "fields") - fileInfos, err := ioutil.ReadDir(fieldsDir) + fileInfos, err := os.ReadDir(fieldsDir) if err != nil { return nil, errors.Wrapf(err, "reading directory with fields failed (path: %s)", fieldsDir) } @@ -109,7 +109,7 @@ func loadFieldsForDataStream(dataStreamRootPath string) ([]FieldDefinition, erro var fields []FieldDefinition for _, fileInfo := range fileInfos { f := filepath.Join(fieldsDir, fileInfo.Name()) - body, err := ioutil.ReadFile(f) + body, err := os.ReadFile(f) if err != nil { return nil, errors.Wrap(err, "reading fields file failed") } diff --git a/internal/fields/validate_test.go b/internal/fields/validate_test.go index 9bfa182183..d972d86439 100644 --- a/internal/fields/validate_test.go +++ b/internal/fields/validate_test.go @@ -6,7 +6,6 @@ package fields import ( "encoding/json" - "io/ioutil" "testing" "github.com/stretchr/testify/require" @@ -210,7 +209,7 @@ func Test_parseElementValue(t *testing.T) { } func readTestResults(t *testing.T, path string) (f results) { - c, err := ioutil.ReadFile(path) + c, err := os.ReadFile(path) require.NoError(t, err) err = json.Unmarshal(c, &f) @@ -219,7 +218,7 @@ func readTestResults(t *testing.T, path string) (f results) { } func readSampleEvent(t *testing.T, path string) json.RawMessage { - c, err := ioutil.ReadFile(path) + c, err := os.ReadFile(path) require.NoError(t, err) return c } diff --git a/internal/files/remove.go b/internal/files/remove.go index 8810089292..153050a134 100644 --- a/internal/files/remove.go +++ b/internal/files/remove.go @@ -5,7 +5,6 @@ package files import ( - "io/ioutil" "os" "path/filepath" @@ -14,7 +13,7 @@ import ( // RemoveContent method wipes out the directory content. func RemoveContent(dir string) error { - fis, err := ioutil.ReadDir(dir) + fis, err := os.ReadDir(dir) if err != nil { return errors.Wrapf(err, "readdir failed (path: %s)", dir) } diff --git a/internal/formatter/formatter.go b/internal/formatter/formatter.go index c82c60a0c3..4bef4b77b5 100644 --- a/internal/formatter/formatter.go +++ b/internal/formatter/formatter.go @@ -6,7 +6,6 @@ package formatter import ( "fmt" - "io/ioutil" "os" "path/filepath" @@ -51,7 +50,7 @@ func formatFile(path string, failFast bool) error { file := filepath.Base(path) ext := filepath.Ext(file) - content, err := ioutil.ReadFile(path) + content, err := os.ReadFile(path) if err != nil { return errors.Wrap(err, "reading file content failed") } @@ -74,7 +73,7 @@ func formatFile(path string, failFast bool) error { return fmt.Errorf("file is not formatted (path: %s)", path) } - err = ioutil.WriteFile(path, newContent, 0755) + err = os.WriteFile(path, newContent, 0755) if err != nil { return errors.Wrapf(err, "rewriting file failed (path: %s)", path) } diff --git a/internal/github/auth.go b/internal/github/auth.go index b920053ea9..f50d89bda5 100644 --- a/internal/github/auth.go +++ b/internal/github/auth.go @@ -6,7 +6,6 @@ package github import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -43,7 +42,7 @@ func AuthToken() (string, error) { } githubTokenPath := filepath.Join(homeDir, ".elastic/github.token") - token, err := ioutil.ReadFile(githubTokenPath) + token, err := os.ReadFile(githubTokenPath) if err != nil { return "", errors.Wrapf(err, "reading Github token file failed (path: %s)", githubTokenPath) } diff --git a/internal/install/application_configuration.go b/internal/install/application_configuration.go index 1f68905f85..ffc86b155e 100644 --- a/internal/install/application_configuration.go +++ b/internal/install/application_configuration.go @@ -6,7 +6,7 @@ package install import ( "fmt" - "io/ioutil" + "os" "path/filepath" "github.com/pkg/errors" @@ -73,7 +73,7 @@ func Configuration() (*ApplicationConfiguration, error) { return nil, errors.Wrap(err, "can't read configuration directory") } - cfg, err := ioutil.ReadFile(filepath.Join(configPath.RootDir(), applicationConfigurationYmlFile)) + cfg, err := os.ReadFile(filepath.Join(configPath.RootDir(), applicationConfigurationYmlFile)) if err != nil { return nil, errors.Wrap(err, "can't read configuration file") } diff --git a/internal/install/install.go b/internal/install/install.go index b6f261a90e..4b3e038b0a 100644 --- a/internal/install/install.go +++ b/internal/install/install.go @@ -6,7 +6,6 @@ package install import ( "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -197,7 +196,7 @@ func writeStaticResource(err error, path, content string) error { return err } - err = ioutil.WriteFile(path, []byte(content), 0644) + err = os.WriteFile(path, []byte(content), 0644) if err != nil { return errors.Wrapf(err, "writing file failed (path: %s)", path) } diff --git a/internal/install/version_file.go b/internal/install/version_file.go index 097215abc9..331aa76844 100644 --- a/internal/install/version_file.go +++ b/internal/install/version_file.go @@ -6,7 +6,6 @@ package install import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -20,7 +19,7 @@ import ( func checkIfLatestVersionInstalled(elasticPackagePath *locations.LocationManager) (bool, error) { versionPath := filepath.Join(elasticPackagePath.RootDir(), versionFilename) - versionFile, err := ioutil.ReadFile(versionPath) + versionFile, err := os.ReadFile(versionPath) if os.IsExist(err) { return false, nil // old version, no version file } diff --git a/internal/kibana/client.go b/internal/kibana/client.go index 1ac6a2d28b..bc80084e47 100644 --- a/internal/kibana/client.go +++ b/internal/kibana/client.go @@ -6,7 +6,7 @@ package kibana import ( "bytes" - "io/ioutil" + "io" "net/http" "net/url" "os" @@ -91,7 +91,7 @@ func (c *Client) sendRequest(method, resourcePath string, body []byte) (int, []b } defer resp.Body.Close() - body, err = ioutil.ReadAll(resp.Body) + body, err = io.ReadAll(resp.Body) if err != nil { return resp.StatusCode, nil, errors.Wrap(err, "could not read response body") } diff --git a/internal/packages/archetype/archetype.go b/internal/packages/archetype/archetype.go index 1c7adf3fb4..cefe759252 100644 --- a/internal/packages/archetype/archetype.go +++ b/internal/packages/archetype/archetype.go @@ -7,7 +7,6 @@ package archetype import ( "bytes" "encoding/base64" - "io/ioutil" "os" "path/filepath" "text/template" @@ -29,7 +28,7 @@ func renderResourceFile(templateBody string, data interface{}, targetPath string } packageManifestPath := targetPath - err = ioutil.WriteFile(packageManifestPath, rendered.Bytes(), 0644) + err = os.WriteFile(packageManifestPath, rendered.Bytes(), 0644) if err != nil { return errors.Wrapf(err, "can't write resource file (path: %s)", packageManifestPath) } @@ -51,7 +50,7 @@ func writeRawResourceFile(content []byte, targetPath string) error { } packageManifestPath := targetPath - err = ioutil.WriteFile(packageManifestPath, content, 0644) + err = os.WriteFile(packageManifestPath, content, 0644) if err != nil { return errors.Wrapf(err, "can't write resource file (path: %s)", packageManifestPath) } diff --git a/internal/packages/archetype/data_stream_test.go b/internal/packages/archetype/data_stream_test.go index d6b7513774..742e98ba82 100644 --- a/internal/packages/archetype/data_stream_test.go +++ b/internal/packages/archetype/data_stream_test.go @@ -5,7 +5,7 @@ package archetype import ( - "io/ioutil" + "io" "os" "path/filepath" "testing" @@ -56,7 +56,7 @@ func createAndCheckDataStream(t require.TestingT, pd PackageDescriptor, dd DataS wd, err := os.Getwd() require.NoError(t, err) - tempDir, err := ioutil.TempDir("", "archetype-create-data-stream-") + tempDir, err := io.TempDir("", "archetype-create-data-stream-") require.NoError(t, err) os.Chdir(tempDir) diff --git a/internal/packages/archetype/package_test.go b/internal/packages/archetype/package_test.go index db2e002709..1d481f65a1 100644 --- a/internal/packages/archetype/package_test.go +++ b/internal/packages/archetype/package_test.go @@ -5,7 +5,7 @@ package archetype import ( - "io/ioutil" + "io" "os" "path/filepath" "testing" @@ -44,7 +44,7 @@ func createAndCheckPackage(t require.TestingT, pd PackageDescriptor) error { wd, err := os.Getwd() require.NoError(t, err) - tempDir, err := ioutil.TempDir("", "archetype-create-package-") + tempDir, err := io.TempDir("", "archetype-create-package-") require.NoError(t, err) os.Chdir(tempDir) diff --git a/internal/packages/assets.go b/internal/packages/assets.go index b7793d5b6a..fa3f62d563 100644 --- a/internal/packages/assets.go +++ b/internal/packages/assets.go @@ -7,7 +7,6 @@ package packages import ( "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" @@ -123,7 +122,7 @@ func loadElasticsearchAssets(pkgRootPath string) ([]Asset, error) { if dsManifest.Type == dataStreamTypeLogs || dsManifest.Type == dataStreamTypeTraces { elasticsearchDirPath := filepath.Join(filepath.Dir(dsManifestPath), "elasticsearch", "ingest_pipeline") - pipelineFiles, _ := ioutil.ReadDir(elasticsearchDirPath) + pipelineFiles, _ := os.ReadDir(elasticsearchDirPath) if pipelineFiles == nil || len(pipelineFiles) == 0 { continue // ingest pipeline is not defined } @@ -155,7 +154,7 @@ func loadFileBasedAssets(kibanaAssetsFolderPath string, assetType AssetType) ([] return nil, errors.Wrapf(err, "error finding kibana %s assets folder", assetType) } - files, err := ioutil.ReadDir(assetsFolderPath) + files, err := os.ReadDir(assetsFolderPath) if err != nil { return nil, errors.Wrapf(err, "could not read %s files", assetType) } @@ -183,7 +182,7 @@ func loadFileBasedAssets(kibanaAssetsFolderPath string, assetType AssetType) ([] } func readAssetID(assetPath string) (string, error) { - content, err := ioutil.ReadFile(assetPath) + content, err := os.ReadFile(assetPath) if err != nil { return "", errors.Wrap(err, "can't read file body") } diff --git a/internal/profile/config_profile_test.go b/internal/profile/config_profile_test.go index b7349c5ea0..c1f00d967a 100644 --- a/internal/profile/config_profile_test.go +++ b/internal/profile/config_profile_test.go @@ -4,7 +4,6 @@ package profile import ( - "io/ioutil" "os" "path/filepath" "testing" @@ -17,7 +16,7 @@ const ( ) func TestNewProfile(t *testing.T) { - elasticPackageDir, err := ioutil.TempDir("", "package") + elasticPackageDir, err := os.MkdirTemp("", "package") defer cleanupProfile(t, elasticPackageDir) assert.NoError(t, err, "error creating tempdir") t.Logf("writing to directory %s", elasticPackageDir) @@ -33,7 +32,7 @@ func TestNewProfile(t *testing.T) { } func TestNewProfileFrom(t *testing.T) { - elasticPackageDir, err := ioutil.TempDir("", "package") + elasticPackageDir, err := os.MkdirTemp("", "package") defer cleanupProfile(t, elasticPackageDir) assert.NoError(t, err, "error creating tempdir") t.Logf("writing to directory %s", elasticPackageDir) diff --git a/internal/profile/files.go b/internal/profile/files.go index eac07a6969..0bd5d1c1b9 100644 --- a/internal/profile/files.go +++ b/internal/profile/files.go @@ -5,7 +5,7 @@ package profile import ( - "io/ioutil" + "os" "github.com/pkg/errors" ) @@ -25,7 +25,7 @@ const profileStackPath = "stack" // configfilesDiffer checks to see if a local configItem differs from the one it knows. func (cfg simpleFile) configfilesDiffer() (bool, error) { - changes, err := ioutil.ReadFile(cfg.path) + changes, err := os.ReadFile(cfg.path) if err != nil { return false, errors.Wrapf(err, "error reading %s", KibanaConfigFile) } @@ -37,7 +37,7 @@ func (cfg simpleFile) configfilesDiffer() (bool, error) { // writeConfig writes the config item func (cfg simpleFile) writeConfig() error { - err := ioutil.WriteFile(cfg.path, []byte(cfg.body), 0644) + err := os.WriteFile(cfg.path, []byte(cfg.body), 0644) if err != nil { return errors.Wrapf(err, "writing file failed (path: %s)", cfg.path) } @@ -46,7 +46,7 @@ func (cfg simpleFile) writeConfig() error { // readConfig reads the config item, overwriting whatever exists in the fileBody. func (cfg *simpleFile) readConfig() error { - body, err := ioutil.ReadFile(cfg.path) + body, err := os.ReadFile(cfg.path) if err != nil { return errors.Wrapf(err, "reading filed failed (path: %s)", cfg.path) } diff --git a/internal/profile/install_profile.go b/internal/profile/install_profile.go index 88a8254609..eb13dfc161 100644 --- a/internal/profile/install_profile.go +++ b/internal/profile/install_profile.go @@ -6,7 +6,6 @@ package profile import ( "fmt" - "io/ioutil" "os" "path/filepath" @@ -76,7 +75,7 @@ func DeleteProfile(profileName string) error { // FetchAllProfiles returns a list of profile values func FetchAllProfiles(elasticPackagePath string) ([]Metadata, error) { - dirList, err := ioutil.ReadDir(elasticPackagePath) + dirList, err := os.ReadDir(elasticPackagePath) if err != nil { return []Metadata{}, errors.Wrapf(err, "error reading from directory %s", elasticPackagePath) } diff --git a/internal/profile/profile.go b/internal/profile/profile.go index cb844d0fcd..280d1b1a8a 100644 --- a/internal/profile/profile.go +++ b/internal/profile/profile.go @@ -7,7 +7,6 @@ package profile import ( "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" @@ -82,7 +81,7 @@ func newProfileFromExistingFiles(elasticPackagePath string, profileName string, } } - byteFile, err := ioutil.ReadFile(file) + byteFile, err := os.ReadFile(file) if err != nil { return nil, errors.Wrapf(err, "error reading file %s", file) } @@ -266,7 +265,7 @@ func (profile Profile) readProfileResources() error { // metadata returns the metadata struct for the profile func (profile Profile) metadata() (Metadata, error) { packageMetadata := profile.configFiles[PackageProfileMetaFile] - rawPackageMetadata, err := ioutil.ReadFile(packageMetadata.path) + rawPackageMetadata, err := os.ReadFile(packageMetadata.path) if err != nil { return Metadata{}, errors.Wrap(err, "error reading metadata file") } @@ -287,7 +286,7 @@ func (profile *Profile) updateMetadata(meta Metadata) error { if err != nil { return errors.Wrap(err, "error marshalling metadata json") } - err = ioutil.WriteFile(packageMetadata.path, metaString, 0664) + err = os.WriteFile(packageMetadata.path, metaString, 0664) if err != nil { return errors.Wrap(err, "error writing metadata file") } diff --git a/internal/registry/client.go b/internal/registry/client.go index a7c5e1419f..29d64da309 100644 --- a/internal/registry/client.go +++ b/internal/registry/client.go @@ -5,7 +5,7 @@ package registry import ( - "io/ioutil" + "io" "net/http" "net/url" @@ -64,7 +64,7 @@ func (c *Client) get(resourcePath string) (int, []byte, error) { } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return resp.StatusCode, nil, errors.Wrap(err, "could not read response body") } diff --git a/internal/stack/dump.go b/internal/stack/dump.go index 42b21dac76..bb8e7f823b 100644 --- a/internal/stack/dump.go +++ b/internal/stack/dump.go @@ -6,7 +6,6 @@ package stack import ( "fmt" - "io/ioutil" "os" "path/filepath" @@ -61,7 +60,7 @@ func dumpStackLogs(options DumpOptions) error { continue } - err = ioutil.WriteFile(filepath.Join(logsPath, fmt.Sprintf("%s.log", serviceName)), serviceLogs, 0644) + err = os.WriteFile(filepath.Join(logsPath, fmt.Sprintf("%s.log", serviceName)), serviceLogs, 0644) if err != nil { logger.Errorf("can't write service logs (service: %s): %v", serviceName, err) continue diff --git a/internal/stack/shellinit.go b/internal/stack/shellinit.go index fa2a704102..926e896e22 100644 --- a/internal/stack/shellinit.go +++ b/internal/stack/shellinit.go @@ -6,7 +6,7 @@ package stack import ( "fmt" - "io/ioutil" + "os" "github.com/pkg/errors" "gopkg.in/yaml.v3" @@ -39,7 +39,7 @@ type kibanaConfiguration struct { // ShellInit method exposes environment variables that can be used for testing purposes. func ShellInit(elasticStackProfile *profile.Profile) (string, error) { // Read Elasticsearch username and password from Kibana configuration file. - body, err := ioutil.ReadFile(elasticStackProfile.FetchPath(profile.KibanaConfigFile)) + body, err := os.ReadFile(elasticStackProfile.FetchPath(profile.KibanaConfigFile)) if err != nil { return "", errors.Wrap(err, "error reading Kibana config file") } diff --git a/internal/storage/signature.go b/internal/storage/signature.go index 3e494a2347..8143d244c3 100644 --- a/internal/storage/signature.go +++ b/internal/storage/signature.go @@ -7,7 +7,7 @@ package storage import ( "encoding/hex" "fmt" - "io/ioutil" + "io" "sort" "strings" @@ -107,7 +107,7 @@ func calculateFilesSignature(filesystem billy.Filesystem, files []string) (strin return "", errors.Wrapf(err, "reading file failed (path: %s)", file) } - c, err := ioutil.ReadAll(f) + c, err := io.ReadAll(f) if err != nil { return "", errors.Wrapf(err, "reading file content failed (path: %s)", file) } diff --git a/internal/storage/storage.go b/internal/storage/storage.go index 711b5d0029..5d89297ea9 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -6,7 +6,7 @@ package storage import ( "fmt" - "io/ioutil" + "io" "path/filepath" "sort" "strings" @@ -501,7 +501,7 @@ func loadPackageContents(filesystem billy.Filesystem, resourcePaths []string) (f return nil, errors.Wrapf(err, "reading file failed (path: %s)", path) } - c, err := ioutil.ReadAll(f) + c, err := io.ReadAll(f) if err != nil { return nil, errors.Wrapf(err, "reading file content failed (path: %s)", path) } diff --git a/internal/testrunner/coverageoutput.go b/internal/testrunner/coverageoutput.go index 0f3e72fb52..4ae04ca10b 100644 --- a/internal/testrunner/coverageoutput.go +++ b/internal/testrunner/coverageoutput.go @@ -8,7 +8,6 @@ import ( "bytes" "encoding/xml" "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -147,7 +146,7 @@ func findDataStreamsWithoutTests(packageRootPath string, testType TestType) ([]s var noTests []string dataStreamDir := filepath.Join(packageRootPath, "data_stream") - dataStreams, err := ioutil.ReadDir(dataStreamDir) + dataStreams, err := os.ReadDir(dataStreamDir) if errors.Is(err, os.ErrNotExist) { return noTests, nil // there are packages that don't have any data streams (fleet_server, security_detection_engine) } else if err != nil { @@ -260,7 +259,7 @@ func writeCoverageReportFile(report *coberturaCoverage, packageName string) erro return errors.Wrap(err, "can't marshal test coverage report") } - if err := ioutil.WriteFile(filePath, b, 0644); err != nil { + if err := os.WriteFile(filePath, b, 0644); err != nil { return errors.Wrap(err, "could not write test coverage report file") } return nil diff --git a/internal/testrunner/reporters/outputs/file.go b/internal/testrunner/reporters/outputs/file.go index 64b5d1dfe0..982ed93c0d 100644 --- a/internal/testrunner/reporters/outputs/file.go +++ b/internal/testrunner/reporters/outputs/file.go @@ -6,7 +6,6 @@ package outputs import ( "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -49,7 +48,7 @@ func reportToFile(pkg, report string, format testrunner.TestReportFormat) error fileName := fmt.Sprintf("%s_%d.%s", pkg, time.Now().UnixNano(), ext) filePath := filepath.Join(dest, fileName) - if err := ioutil.WriteFile(filePath, []byte(report+"\n"), 0644); err != nil { + if err := os.WriteFile(filePath, []byte(report+"\n"), 0644); err != nil { return errors.Wrap(err, "could not write report file") } diff --git a/internal/testrunner/runners/asset/test_config.go b/internal/testrunner/runners/asset/test_config.go index e182e14190..abadd911ce 100644 --- a/internal/testrunner/runners/asset/test_config.go +++ b/internal/testrunner/runners/asset/test_config.go @@ -5,7 +5,7 @@ package asset import ( - "io/ioutil" + "io" "os" "path/filepath" @@ -29,7 +29,7 @@ func newConfig(assetTestFolderPath string) (*testConfig, error) { return nil, nil } - data, err := ioutil.ReadFile(configFilePath) + data, err := os.ReadFile(configFilePath) if err != nil { return nil, errors.Wrapf(err, "could not load asset loading test configuration file: %s", configFilePath) } diff --git a/internal/testrunner/runners/pipeline/ingest_pipeline.go b/internal/testrunner/runners/pipeline/ingest_pipeline.go index 5f64e13f6c..b231f978dc 100644 --- a/internal/testrunner/runners/pipeline/ingest_pipeline.go +++ b/internal/testrunner/runners/pipeline/ingest_pipeline.go @@ -8,7 +8,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "log" "path/filepath" "regexp" @@ -76,7 +76,7 @@ func installIngestPipelines(esClient *elasticsearch.Client, dataStreamPath strin func loadIngestPipelineFiles(dataStreamPath string, nonce int64) ([]pipelineResource, error) { elasticsearchPath := filepath.Join(dataStreamPath, "elasticsearch", "ingest_pipeline") - fis, err := ioutil.ReadDir(elasticsearchPath) + fis, err := os.ReadDir(elasticsearchPath) if err != nil { return nil, errors.Wrapf(err, "reading ingest pipelines directory failed (path: %s)", elasticsearchPath) } @@ -84,7 +84,7 @@ func loadIngestPipelineFiles(dataStreamPath string, nonce int64) ([]pipelineReso var pipelines []pipelineResource for _, fi := range fis { path := filepath.Join(elasticsearchPath, fi.Name()) - c, err := ioutil.ReadFile(path) + c, err := os.ReadFile(path) if err != nil { return nil, errors.Wrap(err, "reading ingest pipeline failed") } @@ -158,7 +158,7 @@ func putIngestPipeline(esClient *elasticsearch.Client, pipeline pipelineResource } defer r.Body.Close() - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { return errors.Wrapf(err, "failed to read PutPipeline API response body (pipelineName: %s)", pipeline.name) } @@ -179,7 +179,7 @@ func getIngestPipeline(esClient *elasticsearch.Client, pipelineName string) erro } defer r.Body.Close() - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { return errors.Wrapf(err, "failed to read GetPipeline API response body (pipelineName: %s)", pipelineName) } @@ -226,7 +226,7 @@ func simulatePipelineProcessing(esClient *elasticsearch.Client, pipelineName str } defer r.Body.Close() - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { return nil, errors.Wrap(err, "failed to read Simulate API response body") } diff --git a/internal/testrunner/runners/pipeline/runner.go b/internal/testrunner/runners/pipeline/runner.go index 217d73287d..9653877882 100644 --- a/internal/testrunner/runners/pipeline/runner.go +++ b/internal/testrunner/runners/pipeline/runner.go @@ -7,7 +7,6 @@ package pipeline import ( "encoding/json" "fmt" - "io/ioutil" "path/filepath" "regexp" "strings" @@ -157,7 +156,7 @@ func (r *runner) run() ([]testrunner.TestResult, error) { } func (r *runner) listTestCaseFiles() ([]string, error) { - fis, err := ioutil.ReadDir(r.options.TestFolder.Path) + fis, err := os.ReadDir(r.options.TestFolder.Path) if err != nil { return nil, errors.Wrapf(err, "reading pipeline tests failed (path: %s)", r.options.TestFolder.Path) } @@ -175,7 +174,7 @@ func (r *runner) listTestCaseFiles() ([]string, error) { func (r *runner) loadTestCaseFile(testCaseFile string) (*testCase, error) { testCasePath := filepath.Join(r.options.TestFolder.Path, testCaseFile) - testCaseData, err := ioutil.ReadFile(testCasePath) + testCaseData, err := os.ReadFile(testCasePath) if err != nil { return nil, errors.Wrapf(err, "reading input file failed (testCasePath: %s)", testCasePath) } diff --git a/internal/testrunner/runners/pipeline/test_result.go b/internal/testrunner/runners/pipeline/test_result.go index 3e5f62fe13..bf971566fa 100644 --- a/internal/testrunner/runners/pipeline/test_result.go +++ b/internal/testrunner/runners/pipeline/test_result.go @@ -7,7 +7,7 @@ package pipeline import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "github.com/kylelemons/godebug/diff" @@ -35,7 +35,7 @@ func writeTestResult(testCasePath string, result *testResult) error { if err != nil { return errors.Wrap(err, "marshalling test result failed") } - err = ioutil.WriteFile(filepath.Join(testCaseDir, expectedTestResultFile(testCaseFile)), data, 0644) + err = os.WriteFile(filepath.Join(testCaseDir, expectedTestResultFile(testCaseFile)), data, 0644) if err != nil { return errors.Wrap(err, "writing test result failed") } @@ -78,7 +78,7 @@ func readExpectedTestResult(testCasePath string, config *testConfig) (*testResul testCaseFile := filepath.Base(testCasePath) path := filepath.Join(testCaseDir, expectedTestResultFile(testCaseFile)) - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) if err != nil { return nil, errors.Wrap(err, "reading test result file failed") } diff --git a/internal/testrunner/runners/static/runner.go b/internal/testrunner/runners/static/runner.go index ac87c608c9..f7a5ad7ebc 100644 --- a/internal/testrunner/runners/static/runner.go +++ b/internal/testrunner/runners/static/runner.go @@ -5,7 +5,6 @@ package static import ( - "io/ioutil" "os" "path/filepath" @@ -98,7 +97,7 @@ func (r runner) verifySampleEvent() []testrunner.TestResult { return results } - content, err := ioutil.ReadFile(sampleEventPath) + content, err := os.ReadFile(sampleEventPath) if err != nil { results, _ := resultComposer.WithError(errors.Wrap(err, "can't read file")) return results diff --git a/internal/testrunner/runners/static/test_config.go b/internal/testrunner/runners/static/test_config.go index bb0e2faf56..69f9a4436a 100644 --- a/internal/testrunner/runners/static/test_config.go +++ b/internal/testrunner/runners/static/test_config.go @@ -5,7 +5,6 @@ package static import ( - "io/ioutil" "os" "path/filepath" @@ -29,7 +28,7 @@ func newConfig(staticTestFolderPath string) (*testConfig, error) { return nil, nil } - data, err := ioutil.ReadFile(configFilePath) + data, err := os.ReadFile(configFilePath) if err != nil { return nil, errors.Wrapf(err, "could not load static test configuration file: %s", configFilePath) } diff --git a/internal/testrunner/runners/system/runner.go b/internal/testrunner/runners/system/runner.go index 44a22003ef..dc6d504d10 100644 --- a/internal/testrunner/runners/system/runner.go +++ b/internal/testrunner/runners/system/runner.go @@ -7,7 +7,7 @@ package system import ( "encoding/json" "fmt" - "io/ioutil" + "io" "math/rand" "os" "path/filepath" @@ -626,7 +626,7 @@ func writeSampleEvent(path string, doc common.MapStr) error { return errors.Wrap(err, "marshalling sample event failed") } - err = ioutil.WriteFile(filepath.Join(path, "sample_event.json"), body, 0644) + err = os.WriteFile(filepath.Join(path, "sample_event.json"), body, 0644) if err != nil { return errors.Wrap(err, "writing sample event failed") } diff --git a/internal/testrunner/runners/system/servicedeployer/factory.go b/internal/testrunner/runners/system/servicedeployer/factory.go index e45d38b807..6f01367b69 100644 --- a/internal/testrunner/runners/system/servicedeployer/factory.go +++ b/internal/testrunner/runners/system/servicedeployer/factory.go @@ -6,7 +6,6 @@ package servicedeployer import ( "fmt" - "io/ioutil" "os" "path/filepath" @@ -81,12 +80,12 @@ func FindDevDeployPath(options FactoryOptions) (string, error) { } func findServiceDeployer(devDeployPath string) (string, error) { - fis, err := ioutil.ReadDir(devDeployPath) + fis, err := os.ReadDir(devDeployPath) if err != nil { return "", errors.Wrapf(err, "can't read directory (path: %s)", devDeployDir) } - var folders []os.FileInfo + var folders []os.DirEntry for _, fi := range fis { if fi.IsDir() { folders = append(folders, fi) diff --git a/internal/testrunner/runners/system/servicedeployer/kubernetes.go b/internal/testrunner/runners/system/servicedeployer/kubernetes.go index e1a73e977e..86aaa8e633 100644 --- a/internal/testrunner/runners/system/servicedeployer/kubernetes.go +++ b/internal/testrunner/runners/system/servicedeployer/kubernetes.go @@ -6,7 +6,6 @@ package servicedeployer import ( "io" - "io/ioutil" "net/http" "path/filepath" "regexp" @@ -132,7 +131,7 @@ func (ksd KubernetesServiceDeployer) installCustomDefinitions() error { var _ ServiceDeployer = new(KubernetesServiceDeployer) func findKubernetesDefinitions(definitionsDir string) ([]string, error) { - fileInfos, err := ioutil.ReadDir(definitionsDir) + fileInfos, err := os.ReadDir(definitionsDir) if err != nil { return nil, errors.Wrapf(err, "can't read definitions directory (path: %s)", definitionsDir) } diff --git a/internal/testrunner/runners/system/servicedeployer/variants.go b/internal/testrunner/runners/system/servicedeployer/variants.go index 917c3c8033..852a0a4028 100644 --- a/internal/testrunner/runners/system/servicedeployer/variants.go +++ b/internal/testrunner/runners/system/servicedeployer/variants.go @@ -6,7 +6,7 @@ package servicedeployer import ( "fmt" - "io/ioutil" + "io" "os" "path/filepath" "strings" @@ -50,7 +50,7 @@ func ReadVariantsFile(devDeployPath string) (*VariantsFile, error) { return nil, errors.Wrap(err, "can't stat variants file") } - content, err := ioutil.ReadFile(variantsYmlPath) + content, err := os.ReadFile(variantsYmlPath) if err != nil { return nil, errors.Wrap(err, "can't read variants file") } diff --git a/internal/testrunner/runners/system/test_config.go b/internal/testrunner/runners/system/test_config.go index 966affb7c4..6f6f7371cb 100644 --- a/internal/testrunner/runners/system/test_config.go +++ b/internal/testrunner/runners/system/test_config.go @@ -5,7 +5,7 @@ package system import ( - "io/ioutil" + "io" "os" "path/filepath" "regexp" @@ -62,7 +62,7 @@ func (t testConfig) Name() string { } func newConfig(configFilePath string, ctxt servicedeployer.ServiceContext, serviceVariantName string) (*testConfig, error) { - data, err := ioutil.ReadFile(configFilePath) + data, err := os.ReadFile(configFilePath) if err != nil && os.IsNotExist(err) { return nil, errors.Wrapf(err, "unable to find system test configuration file: %s", configFilePath) } diff --git a/internal/testrunner/testrunner.go b/internal/testrunner/testrunner.go index 4cb4ac8142..ab18abd1e6 100644 --- a/internal/testrunner/testrunner.go +++ b/internal/testrunner/testrunner.go @@ -6,7 +6,6 @@ package testrunner import ( "fmt" - "io/ioutil" "os" "path/filepath" "sort" @@ -150,7 +149,7 @@ func AssumeTestFolders(packageRootPath string, dataStreams []string, testType Te dataStreamsPath := filepath.Join(packageRootPath, "data_stream") if dataStreams == nil || len(dataStreams) == 0 { - fileInfos, err := ioutil.ReadDir(dataStreamsPath) + fileInfos, err := os.ReadDir(dataStreamsPath) if os.IsNotExist(err) { return []TestFolder{}, nil // data streams defined } From 8938e400405ef6477466c27f0bf5a8a64d2ec49e Mon Sep 17 00:00:00 2001 From: mtojek Date: Mon, 2 Aug 2021 15:00:39 +0200 Subject: [PATCH 3/4] Fix code references --- internal/export/dashboards.go | 1 - internal/export/dashboards_test.go | 2 +- internal/fields/validate_test.go | 1 + internal/packages/archetype/data_stream_test.go | 3 +-- internal/packages/archetype/package_test.go | 3 +-- internal/testrunner/runners/asset/test_config.go | 1 - internal/testrunner/runners/pipeline/ingest_pipeline.go | 1 + internal/testrunner/runners/pipeline/runner.go | 1 + internal/testrunner/runners/system/runner.go | 1 - .../testrunner/runners/system/servicedeployer/kubernetes.go | 1 + internal/testrunner/runners/system/servicedeployer/variants.go | 1 - internal/testrunner/runners/system/test_config.go | 1 - 12 files changed, 7 insertions(+), 10 deletions(-) diff --git a/internal/export/dashboards.go b/internal/export/dashboards.go index b02d31c68a..508daa98fe 100644 --- a/internal/export/dashboards.go +++ b/internal/export/dashboards.go @@ -6,7 +6,6 @@ package export import ( "encoding/json" - "io" "os" "path/filepath" diff --git a/internal/export/dashboards_test.go b/internal/export/dashboards_test.go index 7dec551bd4..d1b81a8899 100644 --- a/internal/export/dashboards_test.go +++ b/internal/export/dashboards_test.go @@ -6,7 +6,7 @@ package export import ( "encoding/json" - "io" + "os" "testing" "github.com/stretchr/testify/require" diff --git a/internal/fields/validate_test.go b/internal/fields/validate_test.go index d972d86439..0b7f59fd95 100644 --- a/internal/fields/validate_test.go +++ b/internal/fields/validate_test.go @@ -6,6 +6,7 @@ package fields import ( "encoding/json" + "os" "testing" "github.com/stretchr/testify/require" diff --git a/internal/packages/archetype/data_stream_test.go b/internal/packages/archetype/data_stream_test.go index 742e98ba82..b6dde6618c 100644 --- a/internal/packages/archetype/data_stream_test.go +++ b/internal/packages/archetype/data_stream_test.go @@ -5,7 +5,6 @@ package archetype import ( - "io" "os" "path/filepath" "testing" @@ -56,7 +55,7 @@ func createAndCheckDataStream(t require.TestingT, pd PackageDescriptor, dd DataS wd, err := os.Getwd() require.NoError(t, err) - tempDir, err := io.TempDir("", "archetype-create-data-stream-") + tempDir, err := os.MkdirTemp("", "archetype-create-data-stream-") require.NoError(t, err) os.Chdir(tempDir) diff --git a/internal/packages/archetype/package_test.go b/internal/packages/archetype/package_test.go index 1d481f65a1..9c44613dcc 100644 --- a/internal/packages/archetype/package_test.go +++ b/internal/packages/archetype/package_test.go @@ -5,7 +5,6 @@ package archetype import ( - "io" "os" "path/filepath" "testing" @@ -44,7 +43,7 @@ func createAndCheckPackage(t require.TestingT, pd PackageDescriptor) error { wd, err := os.Getwd() require.NoError(t, err) - tempDir, err := io.TempDir("", "archetype-create-package-") + tempDir, err := os.MkdirTemp("", "archetype-create-package-") require.NoError(t, err) os.Chdir(tempDir) diff --git a/internal/testrunner/runners/asset/test_config.go b/internal/testrunner/runners/asset/test_config.go index abadd911ce..0a99487e3e 100644 --- a/internal/testrunner/runners/asset/test_config.go +++ b/internal/testrunner/runners/asset/test_config.go @@ -5,7 +5,6 @@ package asset import ( - "io" "os" "path/filepath" diff --git a/internal/testrunner/runners/pipeline/ingest_pipeline.go b/internal/testrunner/runners/pipeline/ingest_pipeline.go index b231f978dc..907ad477ef 100644 --- a/internal/testrunner/runners/pipeline/ingest_pipeline.go +++ b/internal/testrunner/runners/pipeline/ingest_pipeline.go @@ -10,6 +10,7 @@ import ( "fmt" "io" "log" + "os" "path/filepath" "regexp" "strings" diff --git a/internal/testrunner/runners/pipeline/runner.go b/internal/testrunner/runners/pipeline/runner.go index 9653877882..3bcf49af9f 100644 --- a/internal/testrunner/runners/pipeline/runner.go +++ b/internal/testrunner/runners/pipeline/runner.go @@ -7,6 +7,7 @@ package pipeline import ( "encoding/json" "fmt" + "os" "path/filepath" "regexp" "strings" diff --git a/internal/testrunner/runners/system/runner.go b/internal/testrunner/runners/system/runner.go index dc6d504d10..0929ecee72 100644 --- a/internal/testrunner/runners/system/runner.go +++ b/internal/testrunner/runners/system/runner.go @@ -7,7 +7,6 @@ package system import ( "encoding/json" "fmt" - "io" "math/rand" "os" "path/filepath" diff --git a/internal/testrunner/runners/system/servicedeployer/kubernetes.go b/internal/testrunner/runners/system/servicedeployer/kubernetes.go index 86aaa8e633..ccc53a4e7c 100644 --- a/internal/testrunner/runners/system/servicedeployer/kubernetes.go +++ b/internal/testrunner/runners/system/servicedeployer/kubernetes.go @@ -7,6 +7,7 @@ package servicedeployer import ( "io" "net/http" + "os" "path/filepath" "regexp" "strings" diff --git a/internal/testrunner/runners/system/servicedeployer/variants.go b/internal/testrunner/runners/system/servicedeployer/variants.go index 852a0a4028..9b66e1b32b 100644 --- a/internal/testrunner/runners/system/servicedeployer/variants.go +++ b/internal/testrunner/runners/system/servicedeployer/variants.go @@ -6,7 +6,6 @@ package servicedeployer import ( "fmt" - "io" "os" "path/filepath" "strings" diff --git a/internal/testrunner/runners/system/test_config.go b/internal/testrunner/runners/system/test_config.go index 6f6f7371cb..256ce2d0f4 100644 --- a/internal/testrunner/runners/system/test_config.go +++ b/internal/testrunner/runners/system/test_config.go @@ -5,7 +5,6 @@ package system import ( - "io" "os" "path/filepath" "regexp" From da55fb5b100f8521e2f3c79df2ab82f5ae65d503 Mon Sep 17 00:00:00 2001 From: mtojek Date: Mon, 2 Aug 2021 15:01:26 +0200 Subject: [PATCH 4/4] Fix --- dist/CHANGELOG.md | 4 --- dist/config.yaml | 78 ----------------------------------------------- 2 files changed, 82 deletions(-) delete mode 100644 dist/CHANGELOG.md delete mode 100644 dist/config.yaml diff --git a/dist/CHANGELOG.md b/dist/CHANGELOG.md deleted file mode 100644 index 816d11abe3..0000000000 --- a/dist/CHANGELOG.md +++ /dev/null @@ -1,4 +0,0 @@ -## Changelog - -e815623 Get elastic-agent-managed-daemonset.yaml from upstream 7.x instead of using a local static file (#452) -b7d8e15 Modify Docker stack orchestration to be ready for Compose V2 (#454) diff --git a/dist/config.yaml b/dist/config.yaml deleted file mode 100644 index 990ccc5df0..0000000000 --- a/dist/config.yaml +++ /dev/null @@ -1,78 +0,0 @@ -project_name: elastic-package -release: - github: - owner: mtojek - name: elastic-package - name_template: '{{.Tag}}' -milestones: -- repo: - owner: mtojek - name: elastic-package - name_template: '{{ .Tag }}' -scoop: - name: elastic-package - commit_author: - name: goreleaserbot - email: goreleaser@carlosbecker.com - commit_msg_template: Scoop update for {{ .ProjectName }} version {{ .Tag }} -builds: -- id: elastic-package - goos: - - darwin - goarch: - - amd64 - goarm: - - "6" - gomips: - - hardfloat - targets: - - darwin_amd64 - dir: . - main: . - ldflags: - - -X github.com/elastic/elastic-package/internal/version.Tag={{.Tag}} - - -X github.com/elastic/elastic-package/internal/version.CommitHash={{.ShortCommit}} - - -X github.com/elastic/elastic-package/internal/version.BuildTime={{.Timestamp}} - binary: elastic-package - lang: go - gobinary: go -archives: -- id: default - builds: - - elastic-package - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm - }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}' - format: tar.gz - files: - - licence* - - LICENCE* - - license* - - LICENSE* - - readme* - - README* - - changelog* - - CHANGELOG* - allow_different_binary_count: false -snapshot: - name_template: '{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}' -checksum: - name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt' - algorithm: sha256 -dist: dist -env_files: - github_token: ~/.config/goreleaser/github_token - gitlab_token: ~/.config/goreleaser/gitlab_token - gitea_token: ~/.config/goreleaser/gitea_token -source: - name_template: '{{ .ProjectName }}-{{ .Version }}' - format: tar.gz -gomod: - gobinary: go -announce: - twitter: - message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .GitURL - }}/releases/tag/{{ .Tag }}' -github_urls: - download: https://github.com -gitlab_urls: - download: https://gitlab.com