forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
clients_nodocker.go
45 lines (36 loc) · 1.59 KB
/
clients_nodocker.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
40
41
42
43
44
45
// 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 2020-present Datadog, Inc.
//go:build !docker
// +build !docker
package metadata
import (
"fmt"
"github.com/StackVista/stackstate-agent/pkg/config"
"github.com/StackVista/stackstate-agent/pkg/util/docker"
"github.com/StackVista/stackstate-agent/pkg/util/ecs/common"
v1 "github.com/StackVista/stackstate-agent/pkg/util/ecs/metadata/v1"
v2 "github.com/StackVista/stackstate-agent/pkg/util/ecs/metadata/v2"
v3 "github.com/StackVista/stackstate-agent/pkg/util/ecs/metadata/v3"
)
// V1 returns a client for the ECS metadata API v1, also called introspection
// endpoint, by detecting the endpoint address. Returns an error if it was not
// possible to detect the endpoint address.
func V1() (*v1.Client, error) {
return nil, docker.ErrDockerNotCompiled
}
// V2 returns a client for the ECS metadata API v2 that uses the default
// endpoint address.
func V2() (*v2.Client, error) {
if !config.IsCloudProviderEnabled(common.CloudProviderName) {
return nil, fmt.Errorf("Cloud Provider %s is disabled by configuration", common.CloudProviderName)
}
return v2.NewDefaultClient(), nil
}
// V3FromCurrentTask returns a client for the ECS metadata API v3 by detedting
// the endpoint address from the task the executable is running in. Returns an
// error if it was not possible to detect the endpoint address.
func V3FromCurrentTask() (*v3.Client, error) {
return nil, docker.ErrDockerNotCompiled
}