forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
provider.go
39 lines (32 loc) · 1.14 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package providers
import (
"github.com/StackVista/stackstate-agent/pkg/util/containers"
"github.com/StackVista/stackstate-agent/pkg/util/log"
)
// ContainerImpl without implementation
// Implementations should call Register() in their init()
var containerImpl containers.ContainerImplementation
// ContainerImpl returns the ContainerImplementation
func ContainerImpl() containers.ContainerImplementation {
if containerImpl == nil {
panic("Trying to get nil ContainerInterface")
}
return containerImpl
}
// Register allows to set a ContainerImplementation
func Register(impl containers.ContainerImplementation) {
if containerImpl == nil {
containerImpl = impl
} else {
log.Critical("Trying to set multiple ContainerImplementation")
}
}
// Deregister allows to unset a ContainerImplementation
// this should only be used in tests to clean the global state
func Deregister() {
containerImpl = nil
}