Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into dependabot/go_modules/otel…
Browse files Browse the repository at this point in the history
…-dependencies-422ad7f5bc
  • Loading branch information
andrzej-stencel committed Oct 1, 2024
2 parents 2e73474 + a9d54fb commit 602f69b
Show file tree
Hide file tree
Showing 26 changed files with 143 additions and 126 deletions.
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ linters-settings:
# Select the Go version to target. The default is '1.13'.
go: "1.22.7"

nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 0

nolintlint:
# Enable to ensure that nolint directives are all used. Default is true.
allow-unused: false
Expand Down
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2320,11 +2320,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-licenser@v0.

--------------------------------------------------------------------------------
Dependency : github.com/elastic/go-sysinfo
Version: v1.14.1
Version: v1.14.2
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/go-sysinfo@v1.14.1/LICENSE.txt:
Contents of probable licence file $GOMODCACHE/github.com/elastic/go-sysinfo@v1.14.2/LICENSE.txt:


Apache License
Expand Down
5 changes: 3 additions & 2 deletions _meta/config/elastic-agent.docker.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ outputs:
default:
type: elasticsearch
hosts: '${ELASTICSEARCH_HOSTS:http://elasticsearch:9200}'
username: '${ELASTICSEARCH_USERNAME:elastic}'
password: '${ELASTICSEARCH_PASSWORD:changeme}'
username: '${ELASTICSEARCH_USERNAME:}'
password: '${ELASTICSEARCH_PASSWORD:}'
api_key: '${ELASTICSEARCH_API_KEY:}'
preset: balanced

inputs:
Expand Down
32 changes: 32 additions & 0 deletions changelog/fragments/1726144746-container-default-credentials.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Kind can be one of:
# - breaking-change: a change to previously-documented behavior
# - deprecation: functionality that is being removed in a later release
# - bug-fix: fixes a problem in a previous version
# - enhancement: extends functionality but does not break or fix existing behavior
# - feature: new functionality
# - known-issue: problems that we are aware of in a given version
# - security: impacts on the security of a product or a user’s deployment.
# - upgrade: important information for someone upgrading from a prior version
# - other: does not fit into any of the other categories
kind: breaking-change

# Change summary; a 80ish characters long description of the change.
summary: Remove default credentials when running Elastic Agent in container mode

# Long description; in case the summary is not enough to describe the change
# this field accommodate a description without length limits.
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
description: ELASTICSEARCH_USERNAME and ELASTICSEARCH_PASSWORD now need to be explicitly set when running the agent in container mode

# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
component: elastic-agent

# PR URL; optional; the PR number that added the changeset.
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
# Please provide it if you are adding a fragment for a different PR.
#pr: https://github.com/owner/repo/1234

# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
# If not present is automatically filled by the tooling with the issue linked to the PR number.
#issue: https://github.com/owner/repo/1234
32 changes: 32 additions & 0 deletions changelog/fragments/1726145045-container-api-key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Kind can be one of:
# - breaking-change: a change to previously-documented behavior
# - deprecation: functionality that is being removed in a later release
# - bug-fix: fixes a problem in a previous version
# - enhancement: extends functionality but does not break or fix existing behavior
# - feature: new functionality
# - known-issue: problems that we are aware of in a given version
# - security: impacts on the security of a product or a user’s deployment.
# - upgrade: important information for someone upgrading from a prior version
# - other: does not fit into any of the other categories
kind: enhancement

# Change summary; a 80ish characters long description of the change.
summary: Support ELASTICSEARCH_API_KEY environment variable when running in container mode

# Long description; in case the summary is not enough to describe the change
# this field accommodate a description without length limits.
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
#description:

# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
component: elastic-agent

# PR URL; optional; the PR number that added the changeset.
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
# Please provide it if you are adding a fragment for a different PR.
#pr: https://github.com/owner/repo/1234

# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
# If not present is automatically filled by the tooling with the issue linked to the PR number.
#issue: https://github.com/owner/repo/1234
13 changes: 10 additions & 3 deletions dev-tools/cmd/buildfleetcfg/buildfleetcfg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions dev-tools/licenses/license_generate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dev-tools/mage/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
// It checks the file permissions of python test cases and YAML files.
// It checks .go source files using 'go vet'.
func Check() error {
fmt.Println(">> check: Checking source code for common problems") //nolint:forbidigo // it's ok to use fmt.println in mage
fmt.Println(">> check: Checking source code for common problems")

mg.Deps(GoVet, CheckYAMLNotExecutable, devtools.CheckNoChanges)

Expand Down Expand Up @@ -69,7 +69,7 @@ func GoVet() error {

// CheckLicenseHeaders checks license headers in .go files.
func CheckLicenseHeaders() error {
fmt.Println(">> fmt - go-licenser: Checking for missing headers") //nolint:forbidigo // it's ok to use fmt.println in mage
fmt.Println(">> fmt - go-licenser: Checking for missing headers")
mg.Deps(InstallGoLicenser)

licenser := gotool.Licenser
Expand Down
4 changes: 0 additions & 4 deletions dev-tools/mage/gotool/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ func runVGo(cmd string, args *Args) error {
}, cmd, args)
}

func runGo(cmd string, args *Args) error {
return execGoWith(sh.RunWith, cmd, args)
}

func execGoWith(
fn func(map[string]string, string, ...string) error,
cmd string, args *Args,
Expand Down
20 changes: 0 additions & 20 deletions dev-tools/mage/kubernetes/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,3 @@ func kubectlIn(env map[string]string, stdout, stderr io.Writer, input string, ar

return c.Run()
}

func kubectlStart(env map[string]string, stdout, stderr io.Writer, args ...string) (*exec.Cmd, error) {
c := exec.Command("kubectl", args...)
c.Env = os.Environ()
for k, v := range env {
c.Env = append(c.Env, k+"="+v)
}
c.Stdout = stdout
c.Stderr = stderr
c.Stdin = nil

if mg.Verbose() {
fmt.Println("exec:", "kubectl", strings.Join(args, " "))
}

if err := c.Start(); err != nil {
return nil, err
}
return c, nil
}
6 changes: 5 additions & 1 deletion dev-tools/mage/target/common/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ func PackageSystemTests() error {
parent := filepath.Dir(targetFile)
if !fileExists(parent) {
fmt.Printf(">> creating parent dir: %s", parent)
os.Mkdir(parent, 0750)
err = os.Mkdir(parent, 0750)
if err != nil {
fmt.Printf(">> %s", err)
return err
}
}

err = devtools.Tar(systemTestsDir, targetFile)
Expand Down
5 changes: 3 additions & 2 deletions elastic-agent.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ outputs:
default:
type: elasticsearch
hosts: '${ELASTICSEARCH_HOSTS:http://elasticsearch:9200}'
username: '${ELASTICSEARCH_USERNAME:elastic}'
password: '${ELASTICSEARCH_PASSWORD:changeme}'
username: '${ELASTICSEARCH_USERNAME:}'
password: '${ELASTICSEARCH_PASSWORD:}'
api_key: '${ELASTICSEARCH_API_KEY:}'
preset: balanced

inputs:
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/elastic/elastic-transport-go/v8 v8.6.0
github.com/elastic/go-elasticsearch/v8 v8.15.0
github.com/elastic/go-licenser v0.4.2
github.com/elastic/go-sysinfo v1.14.1
github.com/elastic/go-sysinfo v1.14.2
github.com/elastic/go-ucfg v0.8.8
github.com/elastic/mock-es v0.0.0-20240712014503-e5b47ece0015
github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.11.0
Expand Down Expand Up @@ -455,8 +455,6 @@ require (

replace (
github.com/Shopify/sarama => github.com/elastic/sarama v1.19.1-0.20220310193331-ebc2b0d8eef3
github.com/dop251/goja => github.com/andrewkroh/goja v0.0.0-20190128172624-dd2ac4456e20
github.com/dop251/goja_nodejs => github.com/dop251/goja_nodejs v0.0.0-20171011081505-adff31b136e6
// openshift removed all tags from their repo, use the pseudoversion from the release-3.9 branch HEAD
// See https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/12d41f40b0d408b0167633d8095160d3343d46ac/go.mod#L38
github.com/openshift/api v3.9.0+incompatible => github.com/openshift/api v0.0.0-20180801171038-322a19404e37
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ github.com/elastic/go-licenser v0.4.2 h1:bPbGm8bUd8rxzSswFOqvQh1dAkKGkgAmrPxbUi+
github.com/elastic/go-licenser v0.4.2/go.mod h1:W8eH6FaZDR8fQGm+7FnVa7MxI1b/6dAqxz+zPB8nm5c=
github.com/elastic/go-structform v0.0.12 h1:HXpzlAKyej8T7LobqKDThUw7BMhwV6Db24VwxNtgxCs=
github.com/elastic/go-structform v0.0.12/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4=
github.com/elastic/go-sysinfo v1.14.1 h1:BpY/Utfz75oKSpsQnbAJmmlnT3gBV9WFsopBEYgjhZY=
github.com/elastic/go-sysinfo v1.14.1/go.mod h1:FKUXnZWhnYI0ueO7jhsGV3uQJ5hiz8OqM5b3oGyaRr8=
github.com/elastic/go-sysinfo v1.14.2 h1:DeIy+pVfdRsd08Nx2Xjh+dUS+jrEEI7LGc29U/BKVWo=
github.com/elastic/go-sysinfo v1.14.2/go.mod h1:jPSuTgXG+dhhh0GKIyI2Cso+w5lPJ5PvVqKlL8LV/Hk=
github.com/elastic/go-ucfg v0.8.8 h1:54KIF/2zFKfl0MzsSOCGOsZ3O2bnjFQJ0nDJcLhviyk=
github.com/elastic/go-ucfg v0.8.8/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA=
github.com/elastic/go-windows v1.0.2 h1:yoLLsAsV5cfg9FLhZ9EXZ2n2sQFKeDYrHenkcivY4vI=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func TestExpectedCloudProcessID(t *testing.T) {
}

for _, tc := range testcases {
tc := tc // make a copy to avoid implicit memory aliasing
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.id, expectedCloudProcessID(&tc.component))
})
Expand Down Expand Up @@ -142,6 +143,7 @@ func TestMatchesCloudProcessID(t *testing.T) {
}

for _, tc := range testcases {
tc := tc // make a copy to avoid implicit memory aliasing
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.matches, matchesCloudProcessID(&tc.component, tc.processID))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAddingHeaders(t *testing.T) {
rtt := WithHeaders(c.Transport, Headers)

c.Transport = rtt
resp, err := c.Get(server.URL)
resp, err := c.Get(server.URL) //nolint:noctx // this is fine in tests
require.NoError(t, err)
b, err := io.ReadAll(resp.Body)
defer resp.Body.Close()
Expand Down
12 changes: 8 additions & 4 deletions internal/pkg/agent/errors/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func TestErrorsWrap(t *testing.T) {
ew := fmt.Errorf("wrapper: %w", ce)
outer := New(ew)

outerCustom, ok := outer.(Error)
var outerCustom Error
ok := errors.As(outer, &outerCustom)
if !ok {
t.Error("expected Error")
return
Expand Down Expand Up @@ -109,7 +110,8 @@ func TestErrors(t *testing.T) {

for _, tc := range cases {
actualErr := New(tc.args...)
agentErr, ok := actualErr.(Error)
var agentErr Error
ok := errors.As(actualErr, &agentErr)
if !ok {
t.Errorf("[%s] expected Error", tc.id)
continue
Expand Down Expand Up @@ -151,7 +153,8 @@ func TestMetaFold(t *testing.T) {
err3 := New("level3", err2, M("key1", "level3"), M("key3", "level3"))
err4 := New("level4", err3)

resultingErr, ok := err4.(Error)
var resultingErr Error
ok := errors.As(err4, &resultingErr)
if !ok {
t.Fatal("error is not Error")
}
Expand Down Expand Up @@ -186,7 +189,8 @@ func TestMetaCallDoesNotModifyCollection(t *testing.T) {
err3 := New("level3", err2, M("key1", "level3"), M("key3", "level3"))
err4 := New("level4", err3)

resultingErr, ok := err4.(agentError)
var resultingErr agentError
ok := errors.As(err4, &resultingErr)
if !ok {
t.Fatal("error is not Error")
}
Expand Down
12 changes: 12 additions & 0 deletions internal/pkg/fleetapi/uploader/uploader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ func Test_retrySender_Send(t *testing.T) {
assert.Equal(t, tc.err, err)
assert.Equal(t, tc.status, resp.StatusCode)
}
defer func() {
if resp != nil && resp.Body != nil {
err := resp.Body.Close()
assert.NoError(t, err)
}
}()
sender.AssertExpectations(t)
})
}
Expand Down Expand Up @@ -166,6 +172,12 @@ func Test_retrySender_bodyValidation(t *testing.T) {
wait: backoff,
}
resp, err := c.Send(context.Background(), "POST", "/", nil, nil, bytes.NewReader([]byte("abcd")))
defer func() {
if resp != nil && resp.Body != nil {
err := resp.Body.Close()
assert.NoError(t, err)
}
}()
require.NoError(t, err)
assert.Equal(t, resp.StatusCode, 200)
assert.Equal(t, []byte("abcd"), body1)
Expand Down
26 changes: 0 additions & 26 deletions pkg/component/fake/component/comp/dialer.go

This file was deleted.

Loading

0 comments on commit 602f69b

Please sign in to comment.