utils

package
v0.0.0-...-f06bd48 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddEnvResAttributes = func(res *resource.Resource, attributeMap map[string]string) (*resource.Resource, error) {
	attributes := make([]attribute.KeyValue, 0, 1)

	servieName, ok := attributeMap[serviceNameKey]
	if ok {
		serviceNameAttr := attribute.Key(serviceNameKey).String(servieName)
		attributes = append(attributes, serviceNameAttr)
	}

	servieNameSpace, ok := attributeMap[serviceNamespaceKey]
	if ok {
		serviceNameAttr := attribute.Key(serviceNamespaceKey).String(servieNameSpace)
		attributes = append(attributes, serviceNameAttr)
	}

	envRes := resource.NewSchemaless(attributes...)
	return resource.Merge(res, envRes)

}

AddEnvResAttributes adds service attributes from attributeMap to a resource

View Source
var GetServiceDetails = func() map[string]string {
	resourceAttributes := os.Getenv(resourceAttributesKey)
	if resourceAttributes == "" {
		return nil
	}
	attributeKVPairs := strings.Split(resourceAttributes, commaSeperator)

	attribute := make(map[string]string)

	for _, kv := range attributeKVPairs {
		keyValueList := strings.Split(kv, equalSeperator)
		attribute[keyValueList[0]] = keyValueList[1]
	}

	return attribute
}

GetServiceDetails gets service details from environment variables

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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