diff --git a/libbeat/autodiscover/providers/docker/docker_integration_test.go b/libbeat/autodiscover/providers/docker/docker_integration_test.go index f8a76077978..181af199509 100644 --- a/libbeat/autodiscover/providers/docker/docker_integration_test.go +++ b/libbeat/autodiscover/providers/docker/docker_integration_test.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -//go:build integration +//go:build ( linux || darwin || windows ) && integration package docker diff --git a/libbeat/autodiscover/providers/docker/docker_test.go b/libbeat/autodiscover/providers/docker/docker_test.go index 309a06f0b67..e5e64739e77 100644 --- a/libbeat/autodiscover/providers/docker/docker_test.go +++ b/libbeat/autodiscover/providers/docker/docker_test.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build ( linux || darwin || windows ) +// +build linux darwin windows + package docker import ( diff --git a/libbeat/autodiscover/providers/kubernetes/config_test.go b/libbeat/autodiscover/providers/kubernetes/config_test.go index 710f69785bc..b3e94243563 100644 --- a/libbeat/autodiscover/providers/kubernetes/config_test.go +++ b/libbeat/autodiscover/providers/kubernetes/config_test.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build linux || darwin || windows +// +build linux darwin windows + package kubernetes import ( diff --git a/libbeat/autodiscover/providers/kubernetes/kubernetes_stub.go b/libbeat/autodiscover/providers/kubernetes/kubernetes_stub.go new file mode 100644 index 00000000000..5ae5631dff7 --- /dev/null +++ b/libbeat/autodiscover/providers/kubernetes/kubernetes_stub.go @@ -0,0 +1,114 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//go:build ( aix || solaris ) +// +build aix solaris + +package kubernetes + +import ( + "fmt" + + "github.com/gofrs/uuid" + + "github.com/elastic/beats/v7/libbeat/autodiscover" + "github.com/elastic/elastic-agent-autodiscover/bus" + "github.com/elastic/elastic-agent-autodiscover/kubernetes" + "github.com/elastic/elastic-agent-libs/config" + "github.com/elastic/elastic-agent-libs/keystore" + "github.com/elastic/elastic-agent-libs/logp" + "github.com/elastic/elastic-agent-libs/mapstr" +) + +func init() { + err := autodiscover.Registry.AddProvider("kubernetes", AutodiscoverBuilder) + if err != nil { + logp.Error(fmt.Errorf("could not add `hints` builder")) + } +} + +// Eventer allows defining ways in which kubernetes resource events are observed and processed +type Eventer interface { + kubernetes.ResourceEventHandler + GenerateHints(event bus.Event) bus.Event + Start() error + Stop() +} + +// EventManager allows defining ways in which kubernetes resource events are observed and processed +type EventManager interface { + GenerateHints(event bus.Event) bus.Event + Start() + Stop() +} + +// Provider implements autodiscover provider for docker containers +type Provider struct { + logger *logp.Logger +} + + +// AutodiscoverBuilder builds and returns an autodiscover provider +func AutodiscoverBuilder( + beatName string, + bus bus.Bus, + uuid uuid.UUID, + c *config.C, + keystore keystore.Keystore, +) (autodiscover.Provider, error) { + logger := logp.NewLogger("autodiscover") + + p := &Provider{ + logger: logger, + } + + return p, nil +} + +// Start for Runner interface. +func (p *Provider) Start() { +} + +// Stop signals the stop channel to force the watch loop routine to stop. +func (p *Provider) Stop() { +} + +// String returns a description of kubernetes autodiscover provider. +func (p *Provider) String() string { + return "kubernetes" +} + +func (p *Provider) publish(events []bus.Event) { + if len(events) == 0 { + return + } + +} + +func ShouldPut(event mapstr.M, field string, value interface{}, logger *logp.Logger) { + _, err := event.Put(field, value) + if err != nil { + logger.Debugf("Failed to put field '%s' with value '%s': %s", field, value, err) + } +} + +func ShouldDelete(event mapstr.M, field string, logger *logp.Logger) { + err := event.Delete(field) + if err != nil { + logger.Debugf("Failed to delete field '%s': %s", field, err) + } +} \ No newline at end of file diff --git a/libbeat/autodiscover/providers/kubernetes/node.go b/libbeat/autodiscover/providers/kubernetes/node.go index 8a1630dae9c..1caef8969e6 100644 --- a/libbeat/autodiscover/providers/kubernetes/node.go +++ b/libbeat/autodiscover/providers/kubernetes/node.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -//go:build !aix +//go:build ( !aix && !solaris ) package kubernetes diff --git a/libbeat/autodiscover/providers/kubernetes/node_test.go b/libbeat/autodiscover/providers/kubernetes/node_test.go index 5336ddde758..314bd7d9c60 100644 --- a/libbeat/autodiscover/providers/kubernetes/node_test.go +++ b/libbeat/autodiscover/providers/kubernetes/node_test.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build linux || darwin || windows +// +build linux darwin windows + package kubernetes import ( diff --git a/libbeat/autodiscover/providers/kubernetes/pod.go b/libbeat/autodiscover/providers/kubernetes/pod.go index 31c7297a106..f779cc7d230 100644 --- a/libbeat/autodiscover/providers/kubernetes/pod.go +++ b/libbeat/autodiscover/providers/kubernetes/pod.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -//go:build !aix +//go:build ( !aix && !solaris ) package kubernetes diff --git a/libbeat/autodiscover/providers/kubernetes/pod_test.go b/libbeat/autodiscover/providers/kubernetes/pod_test.go index 4704dc6b8c7..9a0a264aab5 100644 --- a/libbeat/autodiscover/providers/kubernetes/pod_test.go +++ b/libbeat/autodiscover/providers/kubernetes/pod_test.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build ( !aix && !solaris ) +// +build !aix,!solaris + package kubernetes import ( diff --git a/libbeat/autodiscover/providers/kubernetes/service.go b/libbeat/autodiscover/providers/kubernetes/service.go index 5a0c6b3cc3f..da7f598af94 100644 --- a/libbeat/autodiscover/providers/kubernetes/service.go +++ b/libbeat/autodiscover/providers/kubernetes/service.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -//go:build !aix +//go:build ( !aix && !solaris ) package kubernetes diff --git a/libbeat/autodiscover/providers/kubernetes/service_test.go b/libbeat/autodiscover/providers/kubernetes/service_test.go index 510ac6ebd0d..23238a691c6 100644 --- a/libbeat/autodiscover/providers/kubernetes/service_test.go +++ b/libbeat/autodiscover/providers/kubernetes/service_test.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build ( linux || darwin || windows ) +// +build linux darwin windows + package kubernetes import ( diff --git a/libbeat/processors/add_host_metadata/add_host_metadata_test.go b/libbeat/processors/add_host_metadata/add_host_metadata_test.go index c90feb77185..b2164509879 100644 --- a/libbeat/processors/add_host_metadata/add_host_metadata_test.go +++ b/libbeat/processors/add_host_metadata/add_host_metadata_test.go @@ -53,7 +53,7 @@ func TestConfigDefault(t *testing.T) { p, err := New(testConfig) switch runtime.GOOS { - case "windows", "darwin", "linux": + case "windows", "darwin", "linux", "solaris": assert.NoError(t, err) default: assert.IsType(t, types.ErrNotImplemented, err) @@ -100,7 +100,7 @@ func TestConfigNetInfoDisabled(t *testing.T) { p, err := New(testConfig) switch runtime.GOOS { - case "windows", "darwin", "linux": + case "windows", "darwin", "linux", "solaris": assert.NoError(t, err) default: assert.IsType(t, types.ErrNotImplemented, err) @@ -226,7 +226,7 @@ func TestEventWithReplaceFieldsFalse(t *testing.T) { p, err := New(testConfig) switch runtime.GOOS { - case "windows", "darwin", "linux": + case "windows", "darwin", "linux", "solaris": assert.NoError(t, err) default: assert.IsType(t, types.ErrNotImplemented, err) @@ -306,7 +306,7 @@ func TestEventWithReplaceFieldsTrue(t *testing.T) { p, err := New(testConfig) switch runtime.GOOS { - case "windows", "darwin", "linux": + case "windows", "darwin", "linux", "solaris": assert.NoError(t, err) default: assert.IsType(t, types.ErrNotImplemented, err) diff --git a/libbeat/processors/add_kubernetes_metadata/kubernetes_test.go b/libbeat/processors/add_kubernetes_metadata/kubernetes_test.go index 7154d307c5f..2bd2e5c94b7 100644 --- a/libbeat/processors/add_kubernetes_metadata/kubernetes_test.go +++ b/libbeat/processors/add_kubernetes_metadata/kubernetes_test.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build linux || darwin || windows +// +build linux darwin windows + package add_kubernetes_metadata import ( diff --git a/libbeat/tests/compose/compose.go b/libbeat/tests/compose/compose.go index 14c2fe5bd3b..a95a275dc1b 100644 --- a/libbeat/tests/compose/compose.go +++ b/libbeat/tests/compose/compose.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build !solaris +// +build !solaris + package compose import ( diff --git a/libbeat/tests/compose/project.go b/libbeat/tests/compose/project.go index 13c3a9bac48..7829a86af48 100644 --- a/libbeat/tests/compose/project.go +++ b/libbeat/tests/compose/project.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build !solaris +// +build !solaris + package compose import ( diff --git a/libbeat/tests/compose/wrapper.go b/libbeat/tests/compose/wrapper.go index 68f0a670c90..e202a5b9fd1 100644 --- a/libbeat/tests/compose/wrapper.go +++ b/libbeat/tests/compose/wrapper.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build !solaris +// +build !solaris + package compose import ( diff --git a/libbeat/tests/docker/docker.go b/libbeat/tests/docker/docker.go index 0c3c8878c9d..dde1330fd43 100644 --- a/libbeat/tests/docker/docker.go +++ b/libbeat/tests/docker/docker.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build !solaris +// +build !solaris + package docker import (