mirror of https://github.com/docker/cli.git
plugins: fix encoding for OTEL env var passed to plugin
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
85dcacd78f
commit
5786f20687
|
@ -2,7 +2,9 @@ package manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
|
@ -133,8 +135,14 @@ func getPluginResourceAttributes(cmd *cobra.Command, plugin Plugin) attribute.Se
|
||||||
|
|
||||||
func appendPluginResourceAttributesEnvvar(env []string, cmd *cobra.Command, plugin Plugin) []string {
|
func appendPluginResourceAttributesEnvvar(env []string, cmd *cobra.Command, plugin Plugin) []string {
|
||||||
if attrs := getPluginResourceAttributes(cmd, plugin); attrs.Len() > 0 {
|
if attrs := getPluginResourceAttributes(cmd, plugin); attrs.Len() > 0 {
|
||||||
envVarVal := attrs.Encoded(attribute.DefaultEncoder())
|
// values in environment variables need to be in baggage format
|
||||||
env = append(env, ResourceAttributesEnvvar+"="+envVarVal)
|
// otel/baggage package can be used after update to v1.22, currently it encodes incorrectly
|
||||||
|
attrsSlice := make([]string, attrs.Len())
|
||||||
|
for iter := attrs.Iter(); iter.Next(); {
|
||||||
|
i, v := iter.IndexedAttribute()
|
||||||
|
attrsSlice[i] = string(v.Key) + "=" + url.PathEscape(v.Value.AsString())
|
||||||
|
}
|
||||||
|
env = append(env, ResourceAttributesEnvvar+"="+strings.Join(attrsSlice, ","))
|
||||||
}
|
}
|
||||||
return env
|
return env
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue