mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-06-12 18:31:09 -04:00
Restore ability to plumb binary data through envvar values
This commit is contained in:
parent
6582c56124
commit
01684ef2c4
5 changed files with 12 additions and 8 deletions
|
|
@ -478,7 +478,7 @@ type Image struct {
|
|||
// EnvVar represents the environment variable.
|
||||
type EnvVar struct {
|
||||
Name string
|
||||
Value string
|
||||
Value string // TODO: switch to []byte
|
||||
}
|
||||
|
||||
// Annotation represents an annotation.
|
||||
|
|
|
|||
|
|
@ -782,7 +782,7 @@ func (kl *Kubelet) makeEnvironmentVariables(ctx context.Context, pod *v1.Pod, co
|
|||
var (
|
||||
configMaps = make(map[string]*v1.ConfigMap)
|
||||
secrets = make(map[string]*v1.Secret)
|
||||
tmpEnv = make(map[string]string)
|
||||
tmpEnv = make(map[string]string) // TODO: switch to map[string][]byte
|
||||
)
|
||||
|
||||
// Env will override EnvFrom variables.
|
||||
|
|
@ -814,6 +814,7 @@ func (kl *Kubelet) makeEnvironmentVariables(ctx context.Context, pod *v1.Pod, co
|
|||
k = envFrom.Prefix + k
|
||||
}
|
||||
|
||||
// TODO: validate no NUL bytes
|
||||
tmpEnv[k] = v
|
||||
}
|
||||
case envFrom.SecretRef != nil:
|
||||
|
|
@ -841,6 +842,7 @@ func (kl *Kubelet) makeEnvironmentVariables(ctx context.Context, pod *v1.Pod, co
|
|||
k = envFrom.Prefix + k
|
||||
}
|
||||
|
||||
// TODO: validate no NUL bytes
|
||||
tmpEnv[k] = string(v)
|
||||
}
|
||||
}
|
||||
|
|
@ -934,6 +936,7 @@ func (kl *Kubelet) makeEnvironmentVariables(ctx context.Context, pod *v1.Pod, co
|
|||
}
|
||||
return result, fmt.Errorf("couldn't find key %v in Secret %v/%v", key, pod.Namespace, name)
|
||||
}
|
||||
// TODO: validate no NUL bytes
|
||||
runtimeVal = string(runtimeValBytes)
|
||||
case utilfeature.DefaultFeatureGate.Enabled(features.EnvFiles) && envVar.ValueFrom.FileKeyRef != nil:
|
||||
f := envVar.ValueFrom.FileKeyRef
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import (
|
|||
"time"
|
||||
|
||||
codes "google.golang.org/grpc/codes"
|
||||
|
||||
crierror "k8s.io/cri-api/pkg/errors"
|
||||
|
||||
"github.com/opencontainers/selinux/go-selinux"
|
||||
|
|
@ -398,7 +399,7 @@ func (m *kubeGenericRuntimeManager) generateContainerConfig(ctx context.Context,
|
|||
e := opts.Envs[idx]
|
||||
envs[idx] = &runtimeapi.KeyValue{
|
||||
Key: e.Name,
|
||||
Value: e.Value,
|
||||
Value: []byte(e.Value),
|
||||
}
|
||||
}
|
||||
config.Envs = envs
|
||||
|
|
|
|||
|
|
@ -4268,7 +4268,7 @@ func (x *ImageSpec) GetImageRef() string {
|
|||
type KeyValue struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
|
@ -4310,11 +4310,11 @@ func (x *KeyValue) GetKey() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (x *KeyValue) GetValue() string {
|
||||
func (x *KeyValue) GetValue() []byte {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
|
||||
// LinuxContainerResources specifies Linux specific configuration for
|
||||
|
|
@ -11823,7 +11823,7 @@ const file_staging_src_k8s_io_cri_api_pkg_apis_runtime_v1_api_proto_rawDesc = ""
|
|||
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"2\n" +
|
||||
"\bKeyValue\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
|
||||
"\x05value\x18\x02 \x01(\tR\x05value\"\x95\x04\n" +
|
||||
"\x05value\x18\x02 \x01(\fR\x05value\"\x95\x04\n" +
|
||||
"\x17LinuxContainerResources\x12\x1d\n" +
|
||||
"\n" +
|
||||
"cpu_period\x18\x01 \x01(\x03R\tcpuPeriod\x12\x1b\n" +
|
||||
|
|
|
|||
|
|
@ -951,7 +951,7 @@ message ImageSpec {
|
|||
|
||||
message KeyValue {
|
||||
string key = 1;
|
||||
string value = 2;
|
||||
bytes value = 2;
|
||||
}
|
||||
|
||||
// LinuxContainerResources specifies Linux specific configuration for
|
||||
|
|
|
|||
Loading…
Reference in a new issue