Skip to content

Commit

Permalink
Make hound happy
Browse files Browse the repository at this point in the history
  • Loading branch information
vjsamuel committed Jan 12, 2018
1 parent 8415b40 commit 37cfd21
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libbeat/autodiscover/providers/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func AutodiscoverBuilder(bus bus.Bus, c *common.Config) (autodiscover.Provider,
}, nil
}

// Start the autodiscover provider. Start and stop listeners work the
// conventional way. Update listener triggers a stop and then a start
// to simulate an update.
func (p *Provider) Start() {
go func() {
for {
Expand Down Expand Up @@ -166,10 +169,12 @@ func (p *Provider) publish(event bus.Event) {
p.bus.Publish(event)
}

// Stop signals the stop channel to force the watch loop routine to stop.
func (p *Provider) Stop() {
close(p.stop)
}

// String returns a description of kubernetes autodiscover provider.
func (p *Provider) String() string {
return "kubernetes"
}
1 change: 1 addition & 0 deletions libbeat/common/kubernetes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ type Pod struct {
Status PodStatus `json:"status"`
}

// GetContainerID parses the container ID to get the actual ID string
func (s *PodContainerStatus) GetContainerID() string {
cID := s.ContainerID
if cID != "" {
Expand Down
6 changes: 6 additions & 0 deletions libbeat/common/kubernetes/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
"github.com/elastic/beats/libbeat/logp"
)

// GetKubernetesClient returns a kubernetes client. If inCluster is true, it returns an
// in cluster configuration based on the secrets mounted in the Pod. If kubeConfig is passed,
// it parses the config file to get the config required to build a client.
func GetKubernetesClient(inCluster bool, kubeConfig string) (client *k8s.Client, err error) {
if inCluster == true {
client, err = k8s.NewInClusterClient()
Expand All @@ -38,6 +41,9 @@ func GetKubernetesClient(inCluster bool, kubeConfig string) (client *k8s.Client,
return client, nil
}

// DiscoverKubernetesNode figures out the Kubernetes host to use. If host is provided in the config
// use it directly. Else use hostname of the pod which is the Pod ID to query the Pod and get the Node
// name from the specification. Else, return localhost as a default.
func DiscoverKubernetesNode(host string, client *k8s.Client) string {
ctx := context.Background()
if host == "" {
Expand Down

0 comments on commit 37cfd21

Please sign in to comment.