metadata

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ECSMetadataEndpoint = "http://100.100.100.200/latest/"
	ECSIdentityEndpoint = ECSMetadataEndpoint + "dynamic/instance-identity/document"
)
View Source
const DISABLE_ECS_ENV = "ALIBABA_CLOUD_NO_ECS_METADATA"
View Source
const KUBE_NODE_NAME_ENV = "KUBE_NODE_NAME"

Variables

View Source
var (
	RegionIDLabels = []string{
		"topology.kubernetes.io/region",
		"failure-domain.beta.kubernetes.io/region",
		"alibabacloud.com/ecs-region-id",
		"sigma.ali/ecs-region-id",
	}
	ZoneIDLabels = []string{
		"topology.kubernetes.io/zone",
		"failure-domain.beta.kubernetes.io/zone",
		"alibabacloud.com/ecs-zone-id",
		"sigma.ali/ecs-zone-id",
	}
	InstanceTypeLabels = []string{
		"node.kubernetes.io/instance-type",
		"beta.kubernetes.io/instance-type",
		"sigma.ali/machine-model",
	}
	InstanceIdLabels = []string{
		"alibabacloud.com/ecs-instance-id",
		"sigma.ali/ecs-instance-id",
	}
)
View Source
var ErrUnknownMetadataKey = errors.New("unknown metadata key")
View Source
var MetadataEnv = map[MetadataKey]string{
	RegionID:  "REGION_ID",
	AccountID: "ALIBABA_CLOUD_ACCOUNT_ID",
	ClusterID: "CLUSTER_ID",
}
View Source
var MetadataLabels = map[MetadataKey][]string{
	RegionID:     RegionIDLabels,
	ZoneID:       ZoneIDLabels,
	InstanceType: InstanceTypeLabels,
	InstanceID:   InstanceIdLabels,
}
View Source
var MetadataProfileDataKeys = map[MetadataKey]string{
	ClusterID: "clusterid",
}

Functions

func MustGet

func MustGet(m MetadataProvider, key MetadataKey) string

Types

type ECSMetadata

type ECSMetadata struct {
	// contains filtered or unexported fields
}

func NewECSMetadata

func NewECSMetadata(httpRT http.RoundTripper) (*ECSMetadata, error)

func (*ECSMetadata) Get

func (m *ECSMetadata) Get(key MetadataKey) (string, error)

type ENVMetadata

type ENVMetadata struct{}

func (*ENVMetadata) Get

func (m *ENVMetadata) Get(key MetadataKey) (string, error)

type EcsFetcher

type EcsFetcher struct {
	// contains filtered or unexported fields
}

func (*EcsFetcher) FetchFor

func (f *EcsFetcher) FetchFor(key MetadataKey) (MetadataProvider, error)

type FakeProvider added in v1.4.0

type FakeProvider struct {
	Values map[MetadataKey]string
}

FakeProvider is a fake metadata provider for testing

func (FakeProvider) Get added in v1.4.0

func (p FakeProvider) Get(key MetadataKey) (string, error)

type InstanceIdentityDocument

type InstanceIdentityDocument struct {
	ZoneID         string `json:"zone-id"`
	RegionID       string `json:"region-id"`
	InstanceID     string `json:"instance-id"`
	InstanceType   string `json:"instance-type"`
	SerialNumber   string `json:"serial-number"`
	OwnerAccountID string `json:"owner-account-id"`
}

type KubernetesMetadata added in v1.4.0

type KubernetesMetadata struct {
	// contains filtered or unexported fields
}

func NewKubernetesMetadata added in v1.4.0

func NewKubernetesMetadata(nodeName string, client kubernetes.Interface) (*KubernetesMetadata, error)

func (*KubernetesMetadata) Get added in v1.4.0

func (m *KubernetesMetadata) Get(key MetadataKey) (string, error)

type KubernetesMetadataFetcher

type KubernetesMetadataFetcher struct {
	// contains filtered or unexported fields
}

func (*KubernetesMetadataFetcher) FetchFor

type Metadata

type Metadata struct {
	// contains filtered or unexported fields
}

func NewMetadata

func NewMetadata() *Metadata

func (*Metadata) EnableEcs

func (m *Metadata) EnableEcs(httpRT http.RoundTripper)

func (*Metadata) EnableKubernetes

func (m *Metadata) EnableKubernetes(client kubernetes.Interface)

func (*Metadata) EnableOpenAPI

func (m *Metadata) EnableOpenAPI(ecsClient cloud.ECSInterface, stsClient cloud.STSInterface)

func (*Metadata) Get

func (m *Metadata) Get(key MetadataKey) (string, error)

type MetadataFetcher

type MetadataFetcher interface {
	FetchFor(key MetadataKey) (MetadataProvider, error)
}

type MetadataKey

type MetadataKey int
const (
	RegionID     MetadataKey = iota
	ZoneID       MetadataKey = iota
	InstanceID   MetadataKey = iota
	InstanceType MetadataKey = iota
	AccountID    MetadataKey = iota
	ClusterID    MetadataKey = iota
)

func (MetadataKey) String

func (k MetadataKey) String() string

type MetadataProvider

type MetadataProvider interface {
	Get(key MetadataKey) (string, error)
}

type OpenAPIFetcher

type OpenAPIFetcher struct {
	// contains filtered or unexported fields
}

func (*OpenAPIFetcher) FetchFor

func (f *OpenAPIFetcher) FetchFor(key MetadataKey) (MetadataProvider, error)

type OpenAPIMetadata

type OpenAPIMetadata struct {
	// contains filtered or unexported fields
}

func NewOpenAPIMetadata

func NewOpenAPIMetadata(c cloud.ECSInterface, s cloud.STSInterface, regionId, instanceId string) (*OpenAPIMetadata, error)

func (*OpenAPIMetadata) Get

func (m *OpenAPIMetadata) Get(key MetadataKey) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL