Merge pull request #18974 from pmorie/config-env

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2016-01-15 06:42:56 -08:00
commit 21aa683fb5
18 changed files with 30414 additions and 29414 deletions

View File

@ -14762,13 +14762,31 @@
"v1.EnvVarSource": {
"id": "v1.EnvVarSource",
"description": "EnvVarSource represents a source for the value of an EnvVar.",
"required": [
"fieldRef"
],
"properties": {
"fieldRef": {
"$ref": "v1.ObjectFieldSelector",
"description": "Selects a field of the pod. Only name and namespace are supported."
"description": "Selects a field of the pod; only name and namespace are supported."
},
"configMapKeyRef": {
"$ref": "v1.ConfigMapKeySelector",
"description": "Selects a key of a ConfigMap."
}
}
},
"v1.ConfigMapKeySelector": {
"id": "v1.ConfigMapKeySelector",
"description": "Selects a key from a ConfigMap.",
"required": [
"key"
],
"properties": {
"name": {
"type": "string",
"description": "Name of the referent. More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#names"
},
"key": {
"type": "string",
"description": "The key to select."
}
}
},

View File

@ -4852,13 +4852,31 @@
"v1.EnvVarSource": {
"id": "v1.EnvVarSource",
"description": "EnvVarSource represents a source for the value of an EnvVar.",
"required": [
"fieldRef"
],
"properties": {
"fieldRef": {
"$ref": "v1.ObjectFieldSelector",
"description": "Selects a field of the pod. Only name and namespace are supported."
"description": "Selects a field of the pod; only name and namespace are supported."
},
"configMapKeyRef": {
"$ref": "v1.ConfigMapKeySelector",
"description": "Selects a key of a ConfigMap."
}
}
},
"v1.ConfigMapKeySelector": {
"id": "v1.ConfigMapKeySelector",
"description": "Selects a key from a ConfigMap.",
"required": [
"key"
],
"properties": {
"name": {
"type": "string",
"description": "Name of the referent. More info: http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#names"
},
"key": {
"type": "string",
"description": "The key to select."
}
}
},

View File

@ -3077,11 +3077,18 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">fieldRef</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Selects a field of the pod. Only name and namespace are supported.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Selects a field of the pod; only name and namespace are supported.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_objectfieldselector">v1.ObjectFieldSelector</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">configMapKeyRef</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Selects a key of a ConfigMap.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_configmapkeyselector">v1.ConfigMapKeySelector</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
@ -4066,6 +4073,47 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1_configmapkeyselector">v1.ConfigMapKeySelector</h3>
<div class="paragraph">
<p>Selects a key from a ConfigMap.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Schema</th>
<th class="tableblock halign-left valign-top">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">name</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Name of the referent. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#names">http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#names</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">key</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The key to select.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1_handler">v1.Handler</h3>
@ -4477,7 +4525,7 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
</div>
<div id="footer">
<div id="footer-text">
Last updated 2016-01-06 14:06:54 UTC
Last updated 2016-01-14 15:18:11 UTC
</div>
</div>
</body>

View File

@ -2613,11 +2613,18 @@ The resulting set of endpoints can be viewed as:<br>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">fieldRef</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Selects a field of the pod. Only name and namespace are supported.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Selects a field of the pod; only name and namespace are supported.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_objectfieldselector">v1.ObjectFieldSelector</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">configMapKeyRef</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Selects a key of a ConfigMap.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_configmapkeyselector">v1.ConfigMapKeySelector</a></p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
@ -6555,6 +6562,47 @@ The resulting set of endpoints can be viewed as:<br>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_v1_containerstatewaiting">v1.ContainerStateWaiting</h3>
<div class="paragraph">
<p>ContainerStateWaiting is a waiting state of a container.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
<col style="width:20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Required</th>
<th class="tableblock halign-left valign-top">Schema</th>
<th class="tableblock halign-left valign-top">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">reason</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">(brief) reason the container is not yet running.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">message</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Message regarding why the container is not yet running.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_unversioned_status">unversioned.Status</h3>
@ -6640,9 +6688,9 @@ The resulting set of endpoints can be viewed as:<br>
</div>
<div class="sect2">
<h3 id="_v1_containerstatewaiting">v1.ContainerStateWaiting</h3>
<h3 id="_v1_configmapkeyselector">v1.ConfigMapKeySelector</h3>
<div class="paragraph">
<p>ContainerStateWaiting is a waiting state of a container.</p>
<p>Selects a key from a ConfigMap.</p>
</div>
<table class="tableblock frame-all grid-all" style="width:100%; ">
<colgroup>
@ -6663,16 +6711,16 @@ The resulting set of endpoints can be viewed as:<br>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">reason</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">(brief) reason the container is not yet running.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">name</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Name of the referent. More info: <a href="http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#names">http://releases.k8s.io/HEAD/docs/user-guide/identifiers.md#names</a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">message</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Message regarding why the container is not yet running.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">key</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The key to select.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
@ -7049,7 +7097,7 @@ The resulting set of endpoints can be viewed as:<br>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2016-01-08 09:05:37 UTC
Last updated 2016-01-14 15:17:59 UTC
</div>
</div>
</body>

View File

@ -39,6 +39,7 @@ func init() {
deepCopy_api_ComponentCondition,
deepCopy_api_ComponentStatus,
deepCopy_api_ComponentStatusList,
deepCopy_api_ConfigMapKeySelector,
deepCopy_api_Container,
deepCopy_api_ContainerImage,
deepCopy_api_ContainerPort,
@ -295,6 +296,14 @@ func deepCopy_api_ComponentStatusList(in ComponentStatusList, out *ComponentStat
return nil
}
func deepCopy_api_ConfigMapKeySelector(in ConfigMapKeySelector, out *ConfigMapKeySelector, c *conversion.Cloner) error {
if err := deepCopy_api_LocalObjectReference(in.LocalObjectReference, &out.LocalObjectReference, c); err != nil {
return err
}
out.Key = in.Key
return nil
}
func deepCopy_api_Container(in Container, out *Container, c *conversion.Cloner) error {
out.Name = in.Name
out.Image = in.Image
@ -682,6 +691,15 @@ func deepCopy_api_EnvVarSource(in EnvVarSource, out *EnvVarSource, c *conversion
} else {
out.FieldRef = nil
}
if in.ConfigMapKeyRef != nil {
in, out := in.ConfigMapKeyRef, &out.ConfigMapKeyRef
*out = new(ConfigMapKeySelector)
if err := deepCopy_api_ConfigMapKeySelector(*in, *out, c); err != nil {
return err
}
} else {
out.ConfigMapKeyRef = nil
}
return nil
}

File diff suppressed because it is too large Load Diff

View File

@ -715,9 +715,12 @@ type EnvVar struct {
}
// EnvVarSource represents a source for the value of an EnvVar.
// Only one of its fields may be set.
type EnvVarSource struct {
// Required: Selects a field of the pod; only name and namespace are supported.
FieldRef *ObjectFieldSelector `json:"fieldRef"`
// Selects a field of the pod; only name and namespace are supported.
FieldRef *ObjectFieldSelector `json:"fieldRef,omitempty"`
// Selects a key of a ConfigMap.
ConfigMapKeyRef *ConfigMapKeySelector `json:"configMapKeyRef,omitempty"`
}
// ObjectFieldSelector selects an APIVersioned field of an object.
@ -730,6 +733,14 @@ type ObjectFieldSelector struct {
FieldPath string `json:"fieldPath"`
}
// Selects a key from a ConfigMap.
type ConfigMapKeySelector struct {
// The ConfigMap to select from.
LocalObjectReference `json:",inline"`
// The key to select.
Key string `json:"key"`
}
// HTTPGetAction describes an action based on HTTP Get requests.
type HTTPGetAction struct {
// Optional: Path to access on the HTTP server.

View File

@ -203,6 +203,21 @@ func Convert_api_ComponentStatusList_To_v1_ComponentStatusList(in *api.Component
return autoConvert_api_ComponentStatusList_To_v1_ComponentStatusList(in, out, s)
}
func autoConvert_api_ConfigMapKeySelector_To_v1_ConfigMapKeySelector(in *api.ConfigMapKeySelector, out *ConfigMapKeySelector, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.ConfigMapKeySelector))(in)
}
if err := Convert_api_LocalObjectReference_To_v1_LocalObjectReference(&in.LocalObjectReference, &out.LocalObjectReference, s); err != nil {
return err
}
out.Key = in.Key
return nil
}
func Convert_api_ConfigMapKeySelector_To_v1_ConfigMapKeySelector(in *api.ConfigMapKeySelector, out *ConfigMapKeySelector, s conversion.Scope) error {
return autoConvert_api_ConfigMapKeySelector_To_v1_ConfigMapKeySelector(in, out, s)
}
func autoConvert_api_Container_To_v1_Container(in *api.Container, out *Container, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.Container))(in)
@ -698,6 +713,15 @@ func autoConvert_api_EnvVarSource_To_v1_EnvVarSource(in *api.EnvVarSource, out *
} else {
out.FieldRef = nil
}
// unable to generate simple pointer conversion for api.ConfigMapKeySelector -> v1.ConfigMapKeySelector
if in.ConfigMapKeyRef != nil {
out.ConfigMapKeyRef = new(ConfigMapKeySelector)
if err := Convert_api_ConfigMapKeySelector_To_v1_ConfigMapKeySelector(in.ConfigMapKeyRef, out.ConfigMapKeyRef, s); err != nil {
return err
}
} else {
out.ConfigMapKeyRef = nil
}
return nil
}
@ -3392,6 +3416,21 @@ func Convert_v1_ComponentStatusList_To_api_ComponentStatusList(in *ComponentStat
return autoConvert_v1_ComponentStatusList_To_api_ComponentStatusList(in, out, s)
}
func autoConvert_v1_ConfigMapKeySelector_To_api_ConfigMapKeySelector(in *ConfigMapKeySelector, out *api.ConfigMapKeySelector, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*ConfigMapKeySelector))(in)
}
if err := Convert_v1_LocalObjectReference_To_api_LocalObjectReference(&in.LocalObjectReference, &out.LocalObjectReference, s); err != nil {
return err
}
out.Key = in.Key
return nil
}
func Convert_v1_ConfigMapKeySelector_To_api_ConfigMapKeySelector(in *ConfigMapKeySelector, out *api.ConfigMapKeySelector, s conversion.Scope) error {
return autoConvert_v1_ConfigMapKeySelector_To_api_ConfigMapKeySelector(in, out, s)
}
func autoConvert_v1_Container_To_api_Container(in *Container, out *api.Container, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*Container))(in)
@ -3887,6 +3926,15 @@ func autoConvert_v1_EnvVarSource_To_api_EnvVarSource(in *EnvVarSource, out *api.
} else {
out.FieldRef = nil
}
// unable to generate simple pointer conversion for v1.ConfigMapKeySelector -> api.ConfigMapKeySelector
if in.ConfigMapKeyRef != nil {
out.ConfigMapKeyRef = new(api.ConfigMapKeySelector)
if err := Convert_v1_ConfigMapKeySelector_To_api_ConfigMapKeySelector(in.ConfigMapKeyRef, out.ConfigMapKeyRef, s); err != nil {
return err
}
} else {
out.ConfigMapKeyRef = nil
}
return nil
}
@ -6292,6 +6340,7 @@ func init() {
autoConvert_api_ComponentCondition_To_v1_ComponentCondition,
autoConvert_api_ComponentStatusList_To_v1_ComponentStatusList,
autoConvert_api_ComponentStatus_To_v1_ComponentStatus,
autoConvert_api_ConfigMapKeySelector_To_v1_ConfigMapKeySelector,
autoConvert_api_ContainerImage_To_v1_ContainerImage,
autoConvert_api_ContainerPort_To_v1_ContainerPort,
autoConvert_api_ContainerStateRunning_To_v1_ContainerStateRunning,
@ -6413,6 +6462,7 @@ func init() {
autoConvert_v1_ComponentCondition_To_api_ComponentCondition,
autoConvert_v1_ComponentStatusList_To_api_ComponentStatusList,
autoConvert_v1_ComponentStatus_To_api_ComponentStatus,
autoConvert_v1_ConfigMapKeySelector_To_api_ConfigMapKeySelector,
autoConvert_v1_ContainerImage_To_api_ContainerImage,
autoConvert_v1_ContainerPort_To_api_ContainerPort,
autoConvert_v1_ContainerStateRunning_To_api_ContainerStateRunning,

View File

@ -184,6 +184,14 @@ func deepCopy_v1_ComponentStatusList(in ComponentStatusList, out *ComponentStatu
return nil
}
func deepCopy_v1_ConfigMapKeySelector(in ConfigMapKeySelector, out *ConfigMapKeySelector, c *conversion.Cloner) error {
if err := deepCopy_v1_LocalObjectReference(in.LocalObjectReference, &out.LocalObjectReference, c); err != nil {
return err
}
out.Key = in.Key
return nil
}
func deepCopy_v1_Container(in Container, out *Container, c *conversion.Cloner) error {
out.Name = in.Name
out.Image = in.Image
@ -533,6 +541,14 @@ func deepCopy_v1_EnvVarSource(in EnvVarSource, out *EnvVarSource, c *conversion.
} else {
out.FieldRef = nil
}
if in.ConfigMapKeyRef != nil {
out.ConfigMapKeyRef = new(ConfigMapKeySelector)
if err := deepCopy_v1_ConfigMapKeySelector(*in.ConfigMapKeyRef, out.ConfigMapKeyRef, c); err != nil {
return err
}
} else {
out.ConfigMapKeyRef = nil
}
return nil
}
@ -2463,6 +2479,7 @@ func init() {
deepCopy_v1_ComponentCondition,
deepCopy_v1_ComponentStatus,
deepCopy_v1_ComponentStatusList,
deepCopy_v1_ConfigMapKeySelector,
deepCopy_v1_Container,
deepCopy_v1_ContainerImage,
deepCopy_v1_ContainerPort,

File diff suppressed because it is too large Load Diff

View File

@ -843,8 +843,10 @@ type EnvVar struct {
// EnvVarSource represents a source for the value of an EnvVar.
type EnvVarSource struct {
// Selects a field of the pod. Only name and namespace are supported.
FieldRef *ObjectFieldSelector `json:"fieldRef"`
// Selects a field of the pod; only name and namespace are supported.
FieldRef *ObjectFieldSelector `json:"fieldRef,omitempty"`
// Selects a key of a ConfigMap.
ConfigMapKeyRef *ConfigMapKeySelector `json:"configMapKeyRef,omitempty"`
}
// ObjectFieldSelector selects an APIVersioned field of an object.
@ -855,6 +857,14 @@ type ObjectFieldSelector struct {
FieldPath string `json:"fieldPath"`
}
// Selects a key from a ConfigMap.
type ConfigMapKeySelector struct {
// The ConfigMap to select from.
LocalObjectReference `json:",inline"`
// The key to select.
Key string `json:"key"`
}
// HTTPGetAction describes an action based on HTTP Get requests.
type HTTPGetAction struct {
// Path to access on the HTTP server.

View File

@ -115,6 +115,15 @@ func (ComponentStatusList) SwaggerDoc() map[string]string {
return map_ComponentStatusList
}
var map_ConfigMapKeySelector = map[string]string{
"": "Selects a key from a ConfigMap.",
"key": "The key to select.",
}
func (ConfigMapKeySelector) SwaggerDoc() map[string]string {
return map_ConfigMapKeySelector
}
var map_Container = map[string]string{
"": "A single application container that you want to run within a pod.",
"name": "Name of the container specified as a DNS_LABEL. Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.",
@ -335,8 +344,9 @@ func (EnvVar) SwaggerDoc() map[string]string {
}
var map_EnvVarSource = map[string]string{
"": "EnvVarSource represents a source for the value of an EnvVar.",
"fieldRef": "Selects a field of the pod. Only name and namespace are supported.",
"": "EnvVarSource represents a source for the value of an EnvVar.",
"fieldRef": "Selects a field of the pod; only name and namespace are supported.",
"configMapKeyRef": "Selects a key of a ConfigMap.",
}
func (EnvVarSource) SwaggerDoc() map[string]string {

View File

@ -968,6 +968,9 @@ func validateEnvVarValueFrom(ev api.EnvVar, fldPath *field.Path) field.ErrorList
case ev.ValueFrom.FieldRef != nil:
numSources++
allErrs = append(allErrs, validateObjectFieldSelector(ev.ValueFrom.FieldRef, &validFieldPathExpressionsEnv, fldPath.Child("fieldRef"))...)
case ev.ValueFrom.ConfigMapKeyRef != nil:
numSources++
allErrs = append(allErrs, validateConfigMapKeySelector(ev.ValueFrom.ConfigMapKeyRef, fldPath.Child("configMapKeyRef"))...)
}
if len(ev.Value) != 0 && numSources != 0 {
@ -996,6 +999,21 @@ func validateObjectFieldSelector(fs *api.ObjectFieldSelector, expressions *sets.
return allErrs
}
func validateConfigMapKeySelector(s *api.ConfigMapKeySelector, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(s.Name) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("name"), ""))
}
if len(s.Key) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("key"), ""))
} else if !IsSecretKey(s.Key) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("key"), s.Key, fmt.Sprintf("must have at most %d characters and match regex %s", validation.DNS1123SubdomainMaxLength, SecretKeyFmt)))
}
return allErrs
}
func validateVolumeMounts(mounts []api.VolumeMount, volumes sets.String, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}

View File

@ -87,6 +87,14 @@ func deepCopy_api_CinderVolumeSource(in api.CinderVolumeSource, out *api.CinderV
return nil
}
func deepCopy_api_ConfigMapKeySelector(in api.ConfigMapKeySelector, out *api.ConfigMapKeySelector, c *conversion.Cloner) error {
if err := deepCopy_api_LocalObjectReference(in.LocalObjectReference, &out.LocalObjectReference, c); err != nil {
return err
}
out.Key = in.Key
return nil
}
func deepCopy_api_Container(in api.Container, out *api.Container, c *conversion.Cloner) error {
out.Name = in.Name
out.Image = in.Image
@ -239,6 +247,14 @@ func deepCopy_api_EnvVarSource(in api.EnvVarSource, out *api.EnvVarSource, c *co
} else {
out.FieldRef = nil
}
if in.ConfigMapKeyRef != nil {
out.ConfigMapKeyRef = new(api.ConfigMapKeySelector)
if err := deepCopy_api_ConfigMapKeySelector(*in.ConfigMapKeyRef, out.ConfigMapKeyRef, c); err != nil {
return err
}
} else {
out.ConfigMapKeyRef = nil
}
return nil
}
@ -1661,6 +1677,7 @@ func init() {
deepCopy_api_Capabilities,
deepCopy_api_CephFSVolumeSource,
deepCopy_api_CinderVolumeSource,
deepCopy_api_ConfigMapKeySelector,
deepCopy_api_Container,
deepCopy_api_ContainerPort,
deepCopy_api_DownwardAPIVolumeFile,

View File

@ -116,6 +116,21 @@ func Convert_api_CinderVolumeSource_To_v1_CinderVolumeSource(in *api.CinderVolum
return autoConvert_api_CinderVolumeSource_To_v1_CinderVolumeSource(in, out, s)
}
func autoConvert_api_ConfigMapKeySelector_To_v1_ConfigMapKeySelector(in *api.ConfigMapKeySelector, out *v1.ConfigMapKeySelector, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.ConfigMapKeySelector))(in)
}
if err := Convert_api_LocalObjectReference_To_v1_LocalObjectReference(&in.LocalObjectReference, &out.LocalObjectReference, s); err != nil {
return err
}
out.Key = in.Key
return nil
}
func Convert_api_ConfigMapKeySelector_To_v1_ConfigMapKeySelector(in *api.ConfigMapKeySelector, out *v1.ConfigMapKeySelector, s conversion.Scope) error {
return autoConvert_api_ConfigMapKeySelector_To_v1_ConfigMapKeySelector(in, out, s)
}
func autoConvert_api_Container_To_v1_Container(in *api.Container, out *v1.Container, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.Container))(in)
@ -319,6 +334,15 @@ func autoConvert_api_EnvVarSource_To_v1_EnvVarSource(in *api.EnvVarSource, out *
} else {
out.FieldRef = nil
}
// unable to generate simple pointer conversion for api.ConfigMapKeySelector -> v1.ConfigMapKeySelector
if in.ConfigMapKeyRef != nil {
out.ConfigMapKeyRef = new(v1.ConfigMapKeySelector)
if err := Convert_api_ConfigMapKeySelector_To_v1_ConfigMapKeySelector(in.ConfigMapKeyRef, out.ConfigMapKeyRef, s); err != nil {
return err
}
} else {
out.ConfigMapKeyRef = nil
}
return nil
}
@ -1279,6 +1303,21 @@ func Convert_v1_CinderVolumeSource_To_api_CinderVolumeSource(in *v1.CinderVolume
return autoConvert_v1_CinderVolumeSource_To_api_CinderVolumeSource(in, out, s)
}
func autoConvert_v1_ConfigMapKeySelector_To_api_ConfigMapKeySelector(in *v1.ConfigMapKeySelector, out *api.ConfigMapKeySelector, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*v1.ConfigMapKeySelector))(in)
}
if err := Convert_v1_LocalObjectReference_To_api_LocalObjectReference(&in.LocalObjectReference, &out.LocalObjectReference, s); err != nil {
return err
}
out.Key = in.Key
return nil
}
func Convert_v1_ConfigMapKeySelector_To_api_ConfigMapKeySelector(in *v1.ConfigMapKeySelector, out *api.ConfigMapKeySelector, s conversion.Scope) error {
return autoConvert_v1_ConfigMapKeySelector_To_api_ConfigMapKeySelector(in, out, s)
}
func autoConvert_v1_Container_To_api_Container(in *v1.Container, out *api.Container, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*v1.Container))(in)
@ -1482,6 +1521,15 @@ func autoConvert_v1_EnvVarSource_To_api_EnvVarSource(in *v1.EnvVarSource, out *a
} else {
out.FieldRef = nil
}
// unable to generate simple pointer conversion for v1.ConfigMapKeySelector -> api.ConfigMapKeySelector
if in.ConfigMapKeyRef != nil {
out.ConfigMapKeyRef = new(api.ConfigMapKeySelector)
if err := Convert_v1_ConfigMapKeySelector_To_api_ConfigMapKeySelector(in.ConfigMapKeyRef, out.ConfigMapKeyRef, s); err != nil {
return err
}
} else {
out.ConfigMapKeyRef = nil
}
return nil
}
@ -4456,6 +4504,7 @@ func init() {
autoConvert_api_Capabilities_To_v1_Capabilities,
autoConvert_api_CephFSVolumeSource_To_v1_CephFSVolumeSource,
autoConvert_api_CinderVolumeSource_To_v1_CinderVolumeSource,
autoConvert_api_ConfigMapKeySelector_To_v1_ConfigMapKeySelector,
autoConvert_api_ContainerPort_To_v1_ContainerPort,
autoConvert_api_Container_To_v1_Container,
autoConvert_api_DownwardAPIVolumeFile_To_v1_DownwardAPIVolumeFile,
@ -4546,6 +4595,7 @@ func init() {
autoConvert_v1_Capabilities_To_api_Capabilities,
autoConvert_v1_CephFSVolumeSource_To_api_CephFSVolumeSource,
autoConvert_v1_CinderVolumeSource_To_api_CinderVolumeSource,
autoConvert_v1_ConfigMapKeySelector_To_api_ConfigMapKeySelector,
autoConvert_v1_ContainerPort_To_api_ContainerPort,
autoConvert_v1_Container_To_api_Container,
autoConvert_v1_DownwardAPIVolumeFile_To_api_DownwardAPIVolumeFile,

View File

@ -123,6 +123,14 @@ func deepCopy_v1_CinderVolumeSource(in v1.CinderVolumeSource, out *v1.CinderVolu
return nil
}
func deepCopy_v1_ConfigMapKeySelector(in v1.ConfigMapKeySelector, out *v1.ConfigMapKeySelector, c *conversion.Cloner) error {
if err := deepCopy_v1_LocalObjectReference(in.LocalObjectReference, &out.LocalObjectReference, c); err != nil {
return err
}
out.Key = in.Key
return nil
}
func deepCopy_v1_Container(in v1.Container, out *v1.Container, c *conversion.Cloner) error {
out.Name = in.Name
out.Image = in.Image
@ -275,6 +283,14 @@ func deepCopy_v1_EnvVarSource(in v1.EnvVarSource, out *v1.EnvVarSource, c *conve
} else {
out.FieldRef = nil
}
if in.ConfigMapKeyRef != nil {
out.ConfigMapKeyRef = new(v1.ConfigMapKeySelector)
if err := deepCopy_v1_ConfigMapKeySelector(*in.ConfigMapKeyRef, out.ConfigMapKeyRef, c); err != nil {
return err
}
} else {
out.ConfigMapKeyRef = nil
}
return nil
}
@ -1704,6 +1720,7 @@ func init() {
deepCopy_v1_Capabilities,
deepCopy_v1_CephFSVolumeSource,
deepCopy_v1_CinderVolumeSource,
deepCopy_v1_ConfigMapKeySelector,
deepCopy_v1_Container,
deepCopy_v1_ContainerPort,
deepCopy_v1_DownwardAPIVolumeFile,

View File

@ -39,6 +39,7 @@ import (
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/validation"
apiextensions "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/record"
client "k8s.io/kubernetes/pkg/client/unversioned"
@ -1365,9 +1366,11 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *api.Pod, container *api.Contain
// b. If a source is defined for an environment variable, resolve the source
// 2. Create the container's environment in the order variables are declared
// 3. Add remaining service environment vars
tmpEnv := make(map[string]string)
mappingFunc := expansion.MappingFuncFor(tmpEnv, serviceEnv)
var (
tmpEnv = make(map[string]string)
configMaps = make(map[string]*apiextensions.ConfigMap)
mappingFunc = expansion.MappingFuncFor(tmpEnv, serviceEnv)
)
for _, envVar := range container.Env {
// Accesses apiserver+Pods.
// So, the master may set service env vars, or kubelet may. In case both are doing
@ -1380,11 +1383,28 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *api.Pod, container *api.Contain
if runtimeVal != "" {
// Step 1a: expand variable references
runtimeVal = expansion.Expand(runtimeVal, mappingFunc)
} else if envVar.ValueFrom != nil && envVar.ValueFrom.FieldRef != nil {
} else if envVar.ValueFrom != nil {
// Step 1b: resolve alternate env var sources
runtimeVal, err = kl.podFieldSelectorRuntimeValue(envVar.ValueFrom.FieldRef, pod)
if err != nil {
return result, err
switch {
case envVar.ValueFrom.FieldRef != nil:
runtimeVal, err = kl.podFieldSelectorRuntimeValue(envVar.ValueFrom.FieldRef, pod)
if err != nil {
return result, err
}
case envVar.ValueFrom.ConfigMapKeyRef != nil:
name := envVar.ValueFrom.ConfigMapKeyRef.Name
key := envVar.ValueFrom.ConfigMapKeyRef.Key
configMap, ok := configMaps[name]
if !ok {
configMap, err = kl.kubeClient.Extensions().ConfigMaps(pod.Namespace).Get(name)
if err != nil {
return result, err
}
}
runtimeVal, ok = configMap.Data[key]
if !ok {
return result, fmt.Errorf("Couldn't find key %v in ConfigMap %v/%v", key, pod.Namespace, name)
}
}
}

91
test/e2e/configmap.go Normal file
View File

@ -0,0 +1,91 @@
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package e2e
import (
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/util"
. "github.com/onsi/ginkgo"
)
var _ = Describe("ConfigMap", func() {
f := NewFramework("configmap")
It("should be consumable via environment variable [Conformance]", func() {
name := "configmap-test-" + string(util.NewUUID())
configMap := &extensions.ConfigMap{
ObjectMeta: api.ObjectMeta{
Namespace: f.Namespace.Name,
Name: name,
},
Data: map[string]string{
"data-1": "value-1",
"data-2": "value-2",
"data-3": "value-3",
},
}
By(fmt.Sprintf("Creating configMap %v/%v", f.Namespace.Name, configMap.Name))
defer func() {
By("Cleaning up the configMap")
if err := f.Client.Extensions().ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil {
Failf("unable to delete configMap %v: %v", configMap.Name, err)
}
}()
var err error
if configMap, err = f.Client.Extensions().ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
Failf("unable to create test configMap %s: %v", configMap.Name, err)
}
pod := &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "pod-configmaps-" + string(util.NewUUID()),
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "env-test",
Image: "gcr.io/google_containers/busybox",
Command: []string{"sh", "-c", "env"},
Env: []api.EnvVar{
{
Name: "CONFIG_DATA_1",
ValueFrom: &api.EnvVarSource{
ConfigMapKeyRef: &api.ConfigMapKeySelector{
LocalObjectReference: api.LocalObjectReference{
Name: name,
},
Key: "data-1",
},
},
},
},
},
},
RestartPolicy: api.RestartPolicyNever,
},
}
testContainerOutput("consume configMaps", f.Client, pod, 0, []string{
"CONFIG_DATA_1=value-1",
}, f.Namespace.Name)
})
})