Merge pull request #120561 from chendave/dependency
kubeadm: remove reference of k8s.io/kubernetes/pkg/apis/core/v1
This commit is contained in:
		@@ -87,10 +87,10 @@ func fuzzClusterConfiguration(obj *kubeadm.ClusterConfiguration, c fuzz.Continue
 | 
				
			|||||||
	obj.APIServer.TimeoutForControlPlane = &metav1.Duration{
 | 
						obj.APIServer.TimeoutForControlPlane = &metav1.Duration{
 | 
				
			||||||
		Duration: constants.DefaultControlPlaneTimeout,
 | 
							Duration: constants.DefaultControlPlaneTimeout,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	obj.ControllerManager.ExtraEnvs = []corev1.EnvVar{}
 | 
						obj.ControllerManager.ExtraEnvs = []kubeadm.EnvVar{}
 | 
				
			||||||
	obj.APIServer.ExtraEnvs = []corev1.EnvVar{}
 | 
						obj.APIServer.ExtraEnvs = []kubeadm.EnvVar{}
 | 
				
			||||||
	obj.Scheduler.ExtraEnvs = []corev1.EnvVar{}
 | 
						obj.Scheduler.ExtraEnvs = []kubeadm.EnvVar{}
 | 
				
			||||||
	obj.Etcd.Local.ExtraEnvs = []corev1.EnvVar{}
 | 
						obj.Etcd.Local.ExtraEnvs = []kubeadm.EnvVar{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func fuzzDNS(obj *kubeadm.DNS, c fuzz.Continue) {
 | 
					func fuzzDNS(obj *kubeadm.DNS, c fuzz.Continue) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -157,7 +157,7 @@ type ControlPlaneComponent struct {
 | 
				
			|||||||
	// ExtraEnvs is an extra set of environment variables to pass to the control plane component.
 | 
						// ExtraEnvs is an extra set of environment variables to pass to the control plane component.
 | 
				
			||||||
	// Environment variables passed using ExtraEnvs will override any existing environment variables, or *_proxy environment variables that kubeadm adds by default.
 | 
						// Environment variables passed using ExtraEnvs will override any existing environment variables, or *_proxy environment variables that kubeadm adds by default.
 | 
				
			||||||
	// +optional
 | 
						// +optional
 | 
				
			||||||
	ExtraEnvs []v1.EnvVar
 | 
						ExtraEnvs []EnvVar
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// APIServer holds settings necessary for API server deployments in the cluster
 | 
					// APIServer holds settings necessary for API server deployments in the cluster
 | 
				
			||||||
@@ -275,7 +275,7 @@ type LocalEtcd struct {
 | 
				
			|||||||
	// ExtraEnvs is an extra set of environment variables to pass to the control plane component.
 | 
						// ExtraEnvs is an extra set of environment variables to pass to the control plane component.
 | 
				
			||||||
	// Environment variables passed using ExtraEnvs will override any existing environment variables, or *_proxy environment variables that kubeadm adds by default.
 | 
						// Environment variables passed using ExtraEnvs will override any existing environment variables, or *_proxy environment variables that kubeadm adds by default.
 | 
				
			||||||
	// +optional
 | 
						// +optional
 | 
				
			||||||
	ExtraEnvs []v1.EnvVar
 | 
						ExtraEnvs []EnvVar
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ServerCertSANs sets extra Subject Alternative Names for the etcd server signing cert.
 | 
						// ServerCertSANs sets extra Subject Alternative Names for the etcd server signing cert.
 | 
				
			||||||
	ServerCertSANs []string
 | 
						ServerCertSANs []string
 | 
				
			||||||
@@ -513,3 +513,8 @@ type Arg struct {
 | 
				
			|||||||
	Name  string
 | 
						Name  string
 | 
				
			||||||
	Value string
 | 
						Value string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// EnvVar represents an environment variable present in a Container.
 | 
				
			||||||
 | 
					type EnvVar struct {
 | 
				
			||||||
 | 
						v1.EnvVar
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,6 @@ package v1beta3
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	v1 "k8s.io/api/core/v1"
 | 
					 | 
				
			||||||
	"k8s.io/apimachinery/pkg/conversion"
 | 
						"k8s.io/apimachinery/pkg/conversion"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
 | 
						"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
 | 
				
			||||||
@@ -44,7 +43,7 @@ func Convert_v1beta3_InitConfiguration_To_kubeadm_InitConfiguration(in *InitConf
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Convert_v1beta3_ControlPlaneComponent_To_kubeadm_ControlPlaneComponent is required due to the missing ControlPlaneComponent.ExtraEnvs in v1beta3.
 | 
					// Convert_v1beta3_ControlPlaneComponent_To_kubeadm_ControlPlaneComponent is required due to the missing ControlPlaneComponent.ExtraEnvs in v1beta3.
 | 
				
			||||||
func Convert_v1beta3_ControlPlaneComponent_To_kubeadm_ControlPlaneComponent(in *ControlPlaneComponent, out *kubeadm.ControlPlaneComponent, s conversion.Scope) error {
 | 
					func Convert_v1beta3_ControlPlaneComponent_To_kubeadm_ControlPlaneComponent(in *ControlPlaneComponent, out *kubeadm.ControlPlaneComponent, s conversion.Scope) error {
 | 
				
			||||||
	out.ExtraEnvs = []v1.EnvVar{}
 | 
						out.ExtraEnvs = []kubeadm.EnvVar{}
 | 
				
			||||||
	out.ExtraArgs = convertToArgs(in.ExtraArgs)
 | 
						out.ExtraArgs = convertToArgs(in.ExtraArgs)
 | 
				
			||||||
	return autoConvert_v1beta3_ControlPlaneComponent_To_kubeadm_ControlPlaneComponent(in, out, s)
 | 
						return autoConvert_v1beta3_ControlPlaneComponent_To_kubeadm_ControlPlaneComponent(in, out, s)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -56,7 +55,7 @@ func Convert_kubeadm_ControlPlaneComponent_To_v1beta3_ControlPlaneComponent(in *
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Convert_v1beta3_LocalEtcd_To_kubeadm_LocalEtcd is required due to the missing LocalEtcd.ExtraEnvs in v1beta3.
 | 
					// Convert_v1beta3_LocalEtcd_To_kubeadm_LocalEtcd is required due to the missing LocalEtcd.ExtraEnvs in v1beta3.
 | 
				
			||||||
func Convert_v1beta3_LocalEtcd_To_kubeadm_LocalEtcd(in *LocalEtcd, out *kubeadm.LocalEtcd, s conversion.Scope) error {
 | 
					func Convert_v1beta3_LocalEtcd_To_kubeadm_LocalEtcd(in *LocalEtcd, out *kubeadm.LocalEtcd, s conversion.Scope) error {
 | 
				
			||||||
	out.ExtraEnvs = []v1.EnvVar{}
 | 
						out.ExtraEnvs = []kubeadm.EnvVar{}
 | 
				
			||||||
	out.ExtraArgs = convertToArgs(in.ExtraArgs)
 | 
						out.ExtraArgs = convertToArgs(in.ExtraArgs)
 | 
				
			||||||
	return autoConvert_v1beta3_LocalEtcd_To_kubeadm_LocalEtcd(in, out, s)
 | 
						return autoConvert_v1beta3_LocalEtcd_To_kubeadm_LocalEtcd(in, out, s)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -205,3 +205,15 @@ func SetDefaults_ResetConfiguration(obj *ResetConfiguration) {
 | 
				
			|||||||
		obj.CertificatesDir = DefaultCertificatesDir
 | 
							obj.CertificatesDir = DefaultCertificatesDir
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// SetDefaults_EnvVar assigns default values for EnvVar.
 | 
				
			||||||
 | 
					// +k8s:defaulter-gen=covers
 | 
				
			||||||
 | 
					func SetDefaults_EnvVar(obj *EnvVar) {
 | 
				
			||||||
 | 
						if obj.ValueFrom != nil {
 | 
				
			||||||
 | 
							if obj.ValueFrom.FieldRef != nil {
 | 
				
			||||||
 | 
								if obj.ValueFrom.FieldRef.APIVersion == "" {
 | 
				
			||||||
 | 
									obj.ValueFrom.FieldRef.APIVersion = "v1"
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -158,7 +158,7 @@ type ControlPlaneComponent struct {
 | 
				
			|||||||
	// ExtraEnvs is an extra set of environment variables to pass to the control plane component.
 | 
						// ExtraEnvs is an extra set of environment variables to pass to the control plane component.
 | 
				
			||||||
	// Environment variables passed using ExtraEnvs will override any existing environment variables, or *_proxy environment variables that kubeadm adds by default.
 | 
						// Environment variables passed using ExtraEnvs will override any existing environment variables, or *_proxy environment variables that kubeadm adds by default.
 | 
				
			||||||
	// +optional
 | 
						// +optional
 | 
				
			||||||
	ExtraEnvs []corev1.EnvVar `json:"extraEnvs,omitempty"`
 | 
						ExtraEnvs []EnvVar `json:"extraEnvs,omitempty"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// APIServer holds settings necessary for API server deployments in the cluster
 | 
					// APIServer holds settings necessary for API server deployments in the cluster
 | 
				
			||||||
@@ -296,7 +296,7 @@ type LocalEtcd struct {
 | 
				
			|||||||
	// ExtraEnvs is an extra set of environment variables to pass to the control plane component.
 | 
						// ExtraEnvs is an extra set of environment variables to pass to the control plane component.
 | 
				
			||||||
	// Environment variables passed using ExtraEnvs will override any existing environment variables, or *_proxy environment variables that kubeadm adds by default.
 | 
						// Environment variables passed using ExtraEnvs will override any existing environment variables, or *_proxy environment variables that kubeadm adds by default.
 | 
				
			||||||
	// +optional
 | 
						// +optional
 | 
				
			||||||
	ExtraEnvs []corev1.EnvVar `json:"extraEnvs,omitempty"`
 | 
						ExtraEnvs []EnvVar `json:"extraEnvs,omitempty"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ServerCertSANs sets extra Subject Alternative Names for the etcd server signing cert.
 | 
						// ServerCertSANs sets extra Subject Alternative Names for the etcd server signing cert.
 | 
				
			||||||
	// +optional
 | 
						// +optional
 | 
				
			||||||
@@ -508,3 +508,8 @@ type Arg struct {
 | 
				
			|||||||
	Name  string `json:"name"`
 | 
						Name  string `json:"name"`
 | 
				
			||||||
	Value string `json:"value"`
 | 
						Value string `json:"value"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// EnvVar represents an environment variable present in a Container.
 | 
				
			||||||
 | 
					type EnvVar struct {
 | 
				
			||||||
 | 
						corev1.EnvVar `json:",inline"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -119,6 +119,16 @@ func RegisterConversions(s *runtime.Scheme) error {
 | 
				
			|||||||
	}); err != nil {
 | 
						}); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if err := s.AddGeneratedConversionFunc((*EnvVar)(nil), (*kubeadm.EnvVar)(nil), func(a, b interface{}, scope conversion.Scope) error {
 | 
				
			||||||
 | 
							return Convert_v1beta4_EnvVar_To_kubeadm_EnvVar(a.(*EnvVar), b.(*kubeadm.EnvVar), scope)
 | 
				
			||||||
 | 
						}); err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if err := s.AddGeneratedConversionFunc((*kubeadm.EnvVar)(nil), (*EnvVar)(nil), func(a, b interface{}, scope conversion.Scope) error {
 | 
				
			||||||
 | 
							return Convert_kubeadm_EnvVar_To_v1beta4_EnvVar(a.(*kubeadm.EnvVar), b.(*EnvVar), scope)
 | 
				
			||||||
 | 
						}); err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if err := s.AddGeneratedConversionFunc((*Etcd)(nil), (*kubeadm.Etcd)(nil), func(a, b interface{}, scope conversion.Scope) error {
 | 
						if err := s.AddGeneratedConversionFunc((*Etcd)(nil), (*kubeadm.Etcd)(nil), func(a, b interface{}, scope conversion.Scope) error {
 | 
				
			||||||
		return Convert_v1beta4_Etcd_To_kubeadm_Etcd(a.(*Etcd), b.(*kubeadm.Etcd), scope)
 | 
							return Convert_v1beta4_Etcd_To_kubeadm_Etcd(a.(*Etcd), b.(*kubeadm.Etcd), scope)
 | 
				
			||||||
	}); err != nil {
 | 
						}); err != nil {
 | 
				
			||||||
@@ -422,7 +432,7 @@ func Convert_kubeadm_ClusterConfiguration_To_v1beta4_ClusterConfiguration(in *ku
 | 
				
			|||||||
func autoConvert_v1beta4_ControlPlaneComponent_To_kubeadm_ControlPlaneComponent(in *ControlPlaneComponent, out *kubeadm.ControlPlaneComponent, s conversion.Scope) error {
 | 
					func autoConvert_v1beta4_ControlPlaneComponent_To_kubeadm_ControlPlaneComponent(in *ControlPlaneComponent, out *kubeadm.ControlPlaneComponent, s conversion.Scope) error {
 | 
				
			||||||
	out.ExtraArgs = *(*[]kubeadm.Arg)(unsafe.Pointer(&in.ExtraArgs))
 | 
						out.ExtraArgs = *(*[]kubeadm.Arg)(unsafe.Pointer(&in.ExtraArgs))
 | 
				
			||||||
	out.ExtraVolumes = *(*[]kubeadm.HostPathMount)(unsafe.Pointer(&in.ExtraVolumes))
 | 
						out.ExtraVolumes = *(*[]kubeadm.HostPathMount)(unsafe.Pointer(&in.ExtraVolumes))
 | 
				
			||||||
	out.ExtraEnvs = *(*[]corev1.EnvVar)(unsafe.Pointer(&in.ExtraEnvs))
 | 
						out.ExtraEnvs = *(*[]kubeadm.EnvVar)(unsafe.Pointer(&in.ExtraEnvs))
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -434,7 +444,7 @@ func Convert_v1beta4_ControlPlaneComponent_To_kubeadm_ControlPlaneComponent(in *
 | 
				
			|||||||
func autoConvert_kubeadm_ControlPlaneComponent_To_v1beta4_ControlPlaneComponent(in *kubeadm.ControlPlaneComponent, out *ControlPlaneComponent, s conversion.Scope) error {
 | 
					func autoConvert_kubeadm_ControlPlaneComponent_To_v1beta4_ControlPlaneComponent(in *kubeadm.ControlPlaneComponent, out *ControlPlaneComponent, s conversion.Scope) error {
 | 
				
			||||||
	out.ExtraArgs = *(*[]Arg)(unsafe.Pointer(&in.ExtraArgs))
 | 
						out.ExtraArgs = *(*[]Arg)(unsafe.Pointer(&in.ExtraArgs))
 | 
				
			||||||
	out.ExtraVolumes = *(*[]HostPathMount)(unsafe.Pointer(&in.ExtraVolumes))
 | 
						out.ExtraVolumes = *(*[]HostPathMount)(unsafe.Pointer(&in.ExtraVolumes))
 | 
				
			||||||
	out.ExtraEnvs = *(*[]corev1.EnvVar)(unsafe.Pointer(&in.ExtraEnvs))
 | 
						out.ExtraEnvs = *(*[]EnvVar)(unsafe.Pointer(&in.ExtraEnvs))
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -493,6 +503,26 @@ func Convert_kubeadm_Discovery_To_v1beta4_Discovery(in *kubeadm.Discovery, out *
 | 
				
			|||||||
	return autoConvert_kubeadm_Discovery_To_v1beta4_Discovery(in, out, s)
 | 
						return autoConvert_kubeadm_Discovery_To_v1beta4_Discovery(in, out, s)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func autoConvert_v1beta4_EnvVar_To_kubeadm_EnvVar(in *EnvVar, out *kubeadm.EnvVar, s conversion.Scope) error {
 | 
				
			||||||
 | 
						out.EnvVar = in.EnvVar
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Convert_v1beta4_EnvVar_To_kubeadm_EnvVar is an autogenerated conversion function.
 | 
				
			||||||
 | 
					func Convert_v1beta4_EnvVar_To_kubeadm_EnvVar(in *EnvVar, out *kubeadm.EnvVar, s conversion.Scope) error {
 | 
				
			||||||
 | 
						return autoConvert_v1beta4_EnvVar_To_kubeadm_EnvVar(in, out, s)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func autoConvert_kubeadm_EnvVar_To_v1beta4_EnvVar(in *kubeadm.EnvVar, out *EnvVar, s conversion.Scope) error {
 | 
				
			||||||
 | 
						out.EnvVar = in.EnvVar
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Convert_kubeadm_EnvVar_To_v1beta4_EnvVar is an autogenerated conversion function.
 | 
				
			||||||
 | 
					func Convert_kubeadm_EnvVar_To_v1beta4_EnvVar(in *kubeadm.EnvVar, out *EnvVar, s conversion.Scope) error {
 | 
				
			||||||
 | 
						return autoConvert_kubeadm_EnvVar_To_v1beta4_EnvVar(in, out, s)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func autoConvert_v1beta4_Etcd_To_kubeadm_Etcd(in *Etcd, out *kubeadm.Etcd, s conversion.Scope) error {
 | 
					func autoConvert_v1beta4_Etcd_To_kubeadm_Etcd(in *Etcd, out *kubeadm.Etcd, s conversion.Scope) error {
 | 
				
			||||||
	out.Local = (*kubeadm.LocalEtcd)(unsafe.Pointer(in.Local))
 | 
						out.Local = (*kubeadm.LocalEtcd)(unsafe.Pointer(in.Local))
 | 
				
			||||||
	out.External = (*kubeadm.ExternalEtcd)(unsafe.Pointer(in.External))
 | 
						out.External = (*kubeadm.ExternalEtcd)(unsafe.Pointer(in.External))
 | 
				
			||||||
@@ -714,7 +744,7 @@ func autoConvert_v1beta4_LocalEtcd_To_kubeadm_LocalEtcd(in *LocalEtcd, out *kube
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	out.DataDir = in.DataDir
 | 
						out.DataDir = in.DataDir
 | 
				
			||||||
	out.ExtraArgs = *(*[]kubeadm.Arg)(unsafe.Pointer(&in.ExtraArgs))
 | 
						out.ExtraArgs = *(*[]kubeadm.Arg)(unsafe.Pointer(&in.ExtraArgs))
 | 
				
			||||||
	out.ExtraEnvs = *(*[]corev1.EnvVar)(unsafe.Pointer(&in.ExtraEnvs))
 | 
						out.ExtraEnvs = *(*[]kubeadm.EnvVar)(unsafe.Pointer(&in.ExtraEnvs))
 | 
				
			||||||
	out.ServerCertSANs = *(*[]string)(unsafe.Pointer(&in.ServerCertSANs))
 | 
						out.ServerCertSANs = *(*[]string)(unsafe.Pointer(&in.ServerCertSANs))
 | 
				
			||||||
	out.PeerCertSANs = *(*[]string)(unsafe.Pointer(&in.PeerCertSANs))
 | 
						out.PeerCertSANs = *(*[]string)(unsafe.Pointer(&in.PeerCertSANs))
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
@@ -731,7 +761,7 @@ func autoConvert_kubeadm_LocalEtcd_To_v1beta4_LocalEtcd(in *kubeadm.LocalEtcd, o
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	out.DataDir = in.DataDir
 | 
						out.DataDir = in.DataDir
 | 
				
			||||||
	out.ExtraArgs = *(*[]Arg)(unsafe.Pointer(&in.ExtraArgs))
 | 
						out.ExtraArgs = *(*[]Arg)(unsafe.Pointer(&in.ExtraArgs))
 | 
				
			||||||
	out.ExtraEnvs = *(*[]corev1.EnvVar)(unsafe.Pointer(&in.ExtraEnvs))
 | 
						out.ExtraEnvs = *(*[]EnvVar)(unsafe.Pointer(&in.ExtraEnvs))
 | 
				
			||||||
	out.ServerCertSANs = *(*[]string)(unsafe.Pointer(&in.ServerCertSANs))
 | 
						out.ServerCertSANs = *(*[]string)(unsafe.Pointer(&in.ServerCertSANs))
 | 
				
			||||||
	out.PeerCertSANs = *(*[]string)(unsafe.Pointer(&in.PeerCertSANs))
 | 
						out.PeerCertSANs = *(*[]string)(unsafe.Pointer(&in.PeerCertSANs))
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -161,7 +161,7 @@ func (in *ControlPlaneComponent) DeepCopyInto(out *ControlPlaneComponent) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	if in.ExtraEnvs != nil {
 | 
						if in.ExtraEnvs != nil {
 | 
				
			||||||
		in, out := &in.ExtraEnvs, &out.ExtraEnvs
 | 
							in, out := &in.ExtraEnvs, &out.ExtraEnvs
 | 
				
			||||||
		*out = make([]corev1.EnvVar, len(*in))
 | 
							*out = make([]EnvVar, len(*in))
 | 
				
			||||||
		for i := range *in {
 | 
							for i := range *in {
 | 
				
			||||||
			(*in)[i].DeepCopyInto(&(*out)[i])
 | 
								(*in)[i].DeepCopyInto(&(*out)[i])
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -227,6 +227,23 @@ func (in *Discovery) DeepCopy() *Discovery {
 | 
				
			|||||||
	return out
 | 
						return out
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 | 
				
			||||||
 | 
					func (in *EnvVar) DeepCopyInto(out *EnvVar) {
 | 
				
			||||||
 | 
						*out = *in
 | 
				
			||||||
 | 
						in.EnvVar.DeepCopyInto(&out.EnvVar)
 | 
				
			||||||
 | 
						return
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvVar.
 | 
				
			||||||
 | 
					func (in *EnvVar) DeepCopy() *EnvVar {
 | 
				
			||||||
 | 
						if in == nil {
 | 
				
			||||||
 | 
							return nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						out := new(EnvVar)
 | 
				
			||||||
 | 
						in.DeepCopyInto(out)
 | 
				
			||||||
 | 
						return out
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 | 
					// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 | 
				
			||||||
func (in *Etcd) DeepCopyInto(out *Etcd) {
 | 
					func (in *Etcd) DeepCopyInto(out *Etcd) {
 | 
				
			||||||
	*out = *in
 | 
						*out = *in
 | 
				
			||||||
@@ -436,7 +453,7 @@ func (in *LocalEtcd) DeepCopyInto(out *LocalEtcd) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	if in.ExtraEnvs != nil {
 | 
						if in.ExtraEnvs != nil {
 | 
				
			||||||
		in, out := &in.ExtraEnvs, &out.ExtraEnvs
 | 
							in, out := &in.ExtraEnvs, &out.ExtraEnvs
 | 
				
			||||||
		*out = make([]corev1.EnvVar, len(*in))
 | 
							*out = make([]EnvVar, len(*in))
 | 
				
			||||||
		for i := range *in {
 | 
							for i := range *in {
 | 
				
			||||||
			(*in)[i].DeepCopyInto(&(*out)[i])
 | 
								(*in)[i].DeepCopyInto(&(*out)[i])
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,6 @@ package v1beta4
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	runtime "k8s.io/apimachinery/pkg/runtime"
 | 
						runtime "k8s.io/apimachinery/pkg/runtime"
 | 
				
			||||||
	v1 "k8s.io/kubernetes/pkg/apis/core/v1"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RegisterDefaults adds defaulters functions to the given scheme.
 | 
					// RegisterDefaults adds defaulters functions to the given scheme.
 | 
				
			||||||
@@ -42,37 +41,21 @@ func SetObjectDefaults_ClusterConfiguration(in *ClusterConfiguration) {
 | 
				
			|||||||
	if in.Etcd.Local != nil {
 | 
						if in.Etcd.Local != nil {
 | 
				
			||||||
		for i := range in.Etcd.Local.ExtraEnvs {
 | 
							for i := range in.Etcd.Local.ExtraEnvs {
 | 
				
			||||||
			a := &in.Etcd.Local.ExtraEnvs[i]
 | 
								a := &in.Etcd.Local.ExtraEnvs[i]
 | 
				
			||||||
			if a.ValueFrom != nil {
 | 
								SetDefaults_EnvVar(a)
 | 
				
			||||||
				if a.ValueFrom.FieldRef != nil {
 | 
					 | 
				
			||||||
					v1.SetDefaults_ObjectFieldSelector(a.ValueFrom.FieldRef)
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	SetDefaults_APIServer(&in.APIServer)
 | 
						SetDefaults_APIServer(&in.APIServer)
 | 
				
			||||||
	for i := range in.APIServer.ControlPlaneComponent.ExtraEnvs {
 | 
						for i := range in.APIServer.ControlPlaneComponent.ExtraEnvs {
 | 
				
			||||||
		a := &in.APIServer.ControlPlaneComponent.ExtraEnvs[i]
 | 
							a := &in.APIServer.ControlPlaneComponent.ExtraEnvs[i]
 | 
				
			||||||
		if a.ValueFrom != nil {
 | 
							SetDefaults_EnvVar(a)
 | 
				
			||||||
			if a.ValueFrom.FieldRef != nil {
 | 
					 | 
				
			||||||
				v1.SetDefaults_ObjectFieldSelector(a.ValueFrom.FieldRef)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i := range in.ControllerManager.ExtraEnvs {
 | 
						for i := range in.ControllerManager.ExtraEnvs {
 | 
				
			||||||
		a := &in.ControllerManager.ExtraEnvs[i]
 | 
							a := &in.ControllerManager.ExtraEnvs[i]
 | 
				
			||||||
		if a.ValueFrom != nil {
 | 
							SetDefaults_EnvVar(a)
 | 
				
			||||||
			if a.ValueFrom.FieldRef != nil {
 | 
					 | 
				
			||||||
				v1.SetDefaults_ObjectFieldSelector(a.ValueFrom.FieldRef)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i := range in.Scheduler.ExtraEnvs {
 | 
						for i := range in.Scheduler.ExtraEnvs {
 | 
				
			||||||
		a := &in.Scheduler.ExtraEnvs[i]
 | 
							a := &in.Scheduler.ExtraEnvs[i]
 | 
				
			||||||
		if a.ValueFrom != nil {
 | 
							SetDefaults_EnvVar(a)
 | 
				
			||||||
			if a.ValueFrom.FieldRef != nil {
 | 
					 | 
				
			||||||
				v1.SetDefaults_ObjectFieldSelector(a.ValueFrom.FieldRef)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -190,7 +190,7 @@ func (in *ControlPlaneComponent) DeepCopyInto(out *ControlPlaneComponent) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	if in.ExtraEnvs != nil {
 | 
						if in.ExtraEnvs != nil {
 | 
				
			||||||
		in, out := &in.ExtraEnvs, &out.ExtraEnvs
 | 
							in, out := &in.ExtraEnvs, &out.ExtraEnvs
 | 
				
			||||||
		*out = make([]corev1.EnvVar, len(*in))
 | 
							*out = make([]EnvVar, len(*in))
 | 
				
			||||||
		for i := range *in {
 | 
							for i := range *in {
 | 
				
			||||||
			(*in)[i].DeepCopyInto(&(*out)[i])
 | 
								(*in)[i].DeepCopyInto(&(*out)[i])
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -256,6 +256,23 @@ func (in *Discovery) DeepCopy() *Discovery {
 | 
				
			|||||||
	return out
 | 
						return out
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 | 
				
			||||||
 | 
					func (in *EnvVar) DeepCopyInto(out *EnvVar) {
 | 
				
			||||||
 | 
						*out = *in
 | 
				
			||||||
 | 
						in.EnvVar.DeepCopyInto(&out.EnvVar)
 | 
				
			||||||
 | 
						return
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvVar.
 | 
				
			||||||
 | 
					func (in *EnvVar) DeepCopy() *EnvVar {
 | 
				
			||||||
 | 
						if in == nil {
 | 
				
			||||||
 | 
							return nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						out := new(EnvVar)
 | 
				
			||||||
 | 
						in.DeepCopyInto(out)
 | 
				
			||||||
 | 
						return out
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 | 
					// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 | 
				
			||||||
func (in *Etcd) DeepCopyInto(out *Etcd) {
 | 
					func (in *Etcd) DeepCopyInto(out *Etcd) {
 | 
				
			||||||
	*out = *in
 | 
						*out = *in
 | 
				
			||||||
@@ -466,7 +483,7 @@ func (in *LocalEtcd) DeepCopyInto(out *LocalEtcd) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	if in.ExtraEnvs != nil {
 | 
						if in.ExtraEnvs != nil {
 | 
				
			||||||
		in, out := &in.ExtraEnvs, &out.ExtraEnvs
 | 
							in, out := &in.ExtraEnvs, &out.ExtraEnvs
 | 
				
			||||||
		*out = make([]corev1.EnvVar, len(*in))
 | 
							*out = make([]EnvVar, len(*in))
 | 
				
			||||||
		for i := range *in {
 | 
							for i := range *in {
 | 
				
			||||||
			(*in)[i].DeepCopyInto(&(*out)[i])
 | 
								(*in)[i].DeepCopyInto(&(*out)[i])
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -259,7 +259,7 @@ func createKubeProxyAddon(cfg *kubeadmapi.ClusterConfiguration, client clientset
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	// Propagate the http/https proxy host environment variables to the container
 | 
						// Propagate the http/https proxy host environment variables to the container
 | 
				
			||||||
	env := &kubeproxyDaemonSet.Spec.Template.Spec.Containers[0].Env
 | 
						env := &kubeproxyDaemonSet.Spec.Template.Spec.Containers[0].Env
 | 
				
			||||||
	*env = append(*env, kubeadmutil.GetProxyEnvVars()...)
 | 
						*env = append(*env, kubeadmutil.MergeKubeadmEnvVars(kubeadmutil.GetProxyEnvVars())...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Create the DaemonSet for kube-proxy or update it in case it already exists
 | 
						// Create the DaemonSet for kube-proxy or update it in case it already exists
 | 
				
			||||||
	return []byte(""), apiclient.CreateOrUpdateDaemonSet(client, kubeproxyDaemonSet)
 | 
						return []byte(""), apiclient.CreateOrUpdateDaemonSet(client, kubeproxyDaemonSet)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,7 +48,7 @@ func CreateInitStaticPodManifestFiles(manifestDir, patchesDir string, cfg *kubea
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// GetStaticPodSpecs returns all staticPodSpecs actualized to the context of the current configuration
 | 
					// GetStaticPodSpecs returns all staticPodSpecs actualized to the context of the current configuration
 | 
				
			||||||
// NB. this method holds the information about how kubeadm creates static pod manifests.
 | 
					// NB. this method holds the information about how kubeadm creates static pod manifests.
 | 
				
			||||||
func GetStaticPodSpecs(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmapi.APIEndpoint, proxyEnvs []v1.EnvVar) map[string]v1.Pod {
 | 
					func GetStaticPodSpecs(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmapi.APIEndpoint, proxyEnvs []kubeadmapi.EnvVar) map[string]v1.Pod {
 | 
				
			||||||
	// Get the required hostpath mounts
 | 
						// Get the required hostpath mounts
 | 
				
			||||||
	mounts := getHostPathVolumesForTheControlPlane(cfg)
 | 
						mounts := getHostPathVolumesForTheControlPlane(cfg)
 | 
				
			||||||
	if proxyEnvs == nil {
 | 
						if proxyEnvs == nil {
 | 
				
			||||||
@@ -67,7 +67,7 @@ func GetStaticPodSpecs(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmap
 | 
				
			|||||||
			ReadinessProbe:  staticpodutil.ReadinessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/readyz", endpoint.BindPort, v1.URISchemeHTTPS),
 | 
								ReadinessProbe:  staticpodutil.ReadinessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/readyz", endpoint.BindPort, v1.URISchemeHTTPS),
 | 
				
			||||||
			StartupProbe:    staticpodutil.StartupProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", endpoint.BindPort, v1.URISchemeHTTPS, cfg.APIServer.TimeoutForControlPlane),
 | 
								StartupProbe:    staticpodutil.StartupProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", endpoint.BindPort, v1.URISchemeHTTPS, cfg.APIServer.TimeoutForControlPlane),
 | 
				
			||||||
			Resources:       staticpodutil.ComponentResources("250m"),
 | 
								Resources:       staticpodutil.ComponentResources("250m"),
 | 
				
			||||||
			Env:             kubeadmutil.MergeEnv(proxyEnvs, cfg.APIServer.ExtraEnvs),
 | 
								Env:             kubeadmutil.MergeKubeadmEnvVars(proxyEnvs, cfg.APIServer.ExtraEnvs),
 | 
				
			||||||
		}, mounts.GetVolumes(kubeadmconstants.KubeAPIServer),
 | 
							}, mounts.GetVolumes(kubeadmconstants.KubeAPIServer),
 | 
				
			||||||
			map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: endpoint.String()}),
 | 
								map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: endpoint.String()}),
 | 
				
			||||||
		kubeadmconstants.KubeControllerManager: staticpodutil.ComponentPod(v1.Container{
 | 
							kubeadmconstants.KubeControllerManager: staticpodutil.ComponentPod(v1.Container{
 | 
				
			||||||
@@ -79,7 +79,7 @@ func GetStaticPodSpecs(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmap
 | 
				
			|||||||
			LivenessProbe:   staticpodutil.LivenessProbe(staticpodutil.GetControllerManagerProbeAddress(cfg), "/healthz", kubeadmconstants.KubeControllerManagerPort, v1.URISchemeHTTPS),
 | 
								LivenessProbe:   staticpodutil.LivenessProbe(staticpodutil.GetControllerManagerProbeAddress(cfg), "/healthz", kubeadmconstants.KubeControllerManagerPort, v1.URISchemeHTTPS),
 | 
				
			||||||
			StartupProbe:    staticpodutil.StartupProbe(staticpodutil.GetControllerManagerProbeAddress(cfg), "/healthz", kubeadmconstants.KubeControllerManagerPort, v1.URISchemeHTTPS, cfg.APIServer.TimeoutForControlPlane),
 | 
								StartupProbe:    staticpodutil.StartupProbe(staticpodutil.GetControllerManagerProbeAddress(cfg), "/healthz", kubeadmconstants.KubeControllerManagerPort, v1.URISchemeHTTPS, cfg.APIServer.TimeoutForControlPlane),
 | 
				
			||||||
			Resources:       staticpodutil.ComponentResources("200m"),
 | 
								Resources:       staticpodutil.ComponentResources("200m"),
 | 
				
			||||||
			Env:             kubeadmutil.MergeEnv(proxyEnvs, cfg.ControllerManager.ExtraEnvs),
 | 
								Env:             kubeadmutil.MergeKubeadmEnvVars(proxyEnvs, cfg.ControllerManager.ExtraEnvs),
 | 
				
			||||||
		}, mounts.GetVolumes(kubeadmconstants.KubeControllerManager), nil),
 | 
							}, mounts.GetVolumes(kubeadmconstants.KubeControllerManager), nil),
 | 
				
			||||||
		kubeadmconstants.KubeScheduler: staticpodutil.ComponentPod(v1.Container{
 | 
							kubeadmconstants.KubeScheduler: staticpodutil.ComponentPod(v1.Container{
 | 
				
			||||||
			Name:            kubeadmconstants.KubeScheduler,
 | 
								Name:            kubeadmconstants.KubeScheduler,
 | 
				
			||||||
@@ -90,7 +90,7 @@ func GetStaticPodSpecs(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmap
 | 
				
			|||||||
			LivenessProbe:   staticpodutil.LivenessProbe(staticpodutil.GetSchedulerProbeAddress(cfg), "/healthz", kubeadmconstants.KubeSchedulerPort, v1.URISchemeHTTPS),
 | 
								LivenessProbe:   staticpodutil.LivenessProbe(staticpodutil.GetSchedulerProbeAddress(cfg), "/healthz", kubeadmconstants.KubeSchedulerPort, v1.URISchemeHTTPS),
 | 
				
			||||||
			StartupProbe:    staticpodutil.StartupProbe(staticpodutil.GetSchedulerProbeAddress(cfg), "/healthz", kubeadmconstants.KubeSchedulerPort, v1.URISchemeHTTPS, cfg.APIServer.TimeoutForControlPlane),
 | 
								StartupProbe:    staticpodutil.StartupProbe(staticpodutil.GetSchedulerProbeAddress(cfg), "/healthz", kubeadmconstants.KubeSchedulerPort, v1.URISchemeHTTPS, cfg.APIServer.TimeoutForControlPlane),
 | 
				
			||||||
			Resources:       staticpodutil.ComponentResources("100m"),
 | 
								Resources:       staticpodutil.ComponentResources("100m"),
 | 
				
			||||||
			Env:             kubeadmutil.MergeEnv(proxyEnvs, cfg.Scheduler.ExtraEnvs),
 | 
								Env:             kubeadmutil.MergeKubeadmEnvVars(proxyEnvs, cfg.Scheduler.ExtraEnvs),
 | 
				
			||||||
		}, mounts.GetVolumes(kubeadmconstants.KubeScheduler), nil),
 | 
							}, mounts.GetVolumes(kubeadmconstants.KubeScheduler), nil),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return staticPodSpecs
 | 
						return staticPodSpecs
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,13 +52,15 @@ func TestGetStaticPodSpecs(t *testing.T) {
 | 
				
			|||||||
	// Creates a Cluster Configuration
 | 
						// Creates a Cluster Configuration
 | 
				
			||||||
	cfg := &kubeadmapi.ClusterConfiguration{
 | 
						cfg := &kubeadmapi.ClusterConfiguration{
 | 
				
			||||||
		KubernetesVersion: "v1.9.0",
 | 
							KubernetesVersion: "v1.9.0",
 | 
				
			||||||
		Scheduler: kubeadmapi.ControlPlaneComponent{ExtraEnvs: []v1.EnvVar{
 | 
							Scheduler: kubeadmapi.ControlPlaneComponent{ExtraEnvs: []kubeadmapi.EnvVar{
 | 
				
			||||||
			{Name: "Foo", Value: "Bar"},
 | 
								{
 | 
				
			||||||
 | 
									EnvVar: v1.EnvVar{Name: "Foo", Value: "Bar"},
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
		}},
 | 
							}},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Executes GetStaticPodSpecs
 | 
						// Executes GetStaticPodSpecs
 | 
				
			||||||
	specs := GetStaticPodSpecs(cfg, &kubeadmapi.APIEndpoint{}, []v1.EnvVar{})
 | 
						specs := GetStaticPodSpecs(cfg, &kubeadmapi.APIEndpoint{}, []kubeadmapi.EnvVar{})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var tests = []struct {
 | 
						var tests = []struct {
 | 
				
			||||||
		name          string
 | 
							name          string
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -224,7 +224,7 @@ func GetEtcdPodSpec(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmapi.A
 | 
				
			|||||||
			},
 | 
								},
 | 
				
			||||||
			LivenessProbe: staticpodutil.LivenessProbe(probeHostname, "/health?exclude=NOSPACE&serializable=true", probePort, probeScheme),
 | 
								LivenessProbe: staticpodutil.LivenessProbe(probeHostname, "/health?exclude=NOSPACE&serializable=true", probePort, probeScheme),
 | 
				
			||||||
			StartupProbe:  staticpodutil.StartupProbe(probeHostname, "/health?serializable=false", probePort, probeScheme, cfg.APIServer.TimeoutForControlPlane),
 | 
								StartupProbe:  staticpodutil.StartupProbe(probeHostname, "/health?serializable=false", probePort, probeScheme, cfg.APIServer.TimeoutForControlPlane),
 | 
				
			||||||
			Env:           cfg.Etcd.Local.ExtraEnvs,
 | 
								Env:           kubeadmutil.MergeKubeadmEnvVars(cfg.Etcd.Local.ExtraEnvs),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		etcdMounts,
 | 
							etcdMounts,
 | 
				
			||||||
		// etcd will listen on the advertise address of the API server, in a different port (2379)
 | 
							// etcd will listen on the advertise address of the API server, in a different port (2379)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,8 +46,10 @@ func TestGetEtcdPodSpec(t *testing.T) {
 | 
				
			|||||||
		Etcd: kubeadmapi.Etcd{
 | 
							Etcd: kubeadmapi.Etcd{
 | 
				
			||||||
			Local: &kubeadmapi.LocalEtcd{
 | 
								Local: &kubeadmapi.LocalEtcd{
 | 
				
			||||||
				DataDir: "/var/lib/etcd",
 | 
									DataDir: "/var/lib/etcd",
 | 
				
			||||||
				ExtraEnvs: []v1.EnvVar{
 | 
									ExtraEnvs: []kubeadmapi.EnvVar{
 | 
				
			||||||
					{Name: "Foo", Value: "Bar"},
 | 
										{
 | 
				
			||||||
 | 
											EnvVar: v1.EnvVar{Name: "Foo", Value: "Bar"},
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,11 +21,13 @@ import (
 | 
				
			|||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	v1 "k8s.io/api/core/v1"
 | 
						v1 "k8s.io/api/core/v1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetProxyEnvVars builds a list of environment variables in order to use the right proxy
 | 
					// GetProxyEnvVars builds a list of environment variables in order to use the right proxy
 | 
				
			||||||
func GetProxyEnvVars() []v1.EnvVar {
 | 
					func GetProxyEnvVars() []kubeadmapi.EnvVar {
 | 
				
			||||||
	envs := []v1.EnvVar{}
 | 
						envs := []kubeadmapi.EnvVar{}
 | 
				
			||||||
	for _, env := range os.Environ() {
 | 
						for _, env := range os.Environ() {
 | 
				
			||||||
		pos := strings.Index(env, "=")
 | 
							pos := strings.Index(env, "=")
 | 
				
			||||||
		if pos == -1 {
 | 
							if pos == -1 {
 | 
				
			||||||
@@ -35,20 +37,23 @@ func GetProxyEnvVars() []v1.EnvVar {
 | 
				
			|||||||
		name := env[:pos]
 | 
							name := env[:pos]
 | 
				
			||||||
		value := env[pos+1:]
 | 
							value := env[pos+1:]
 | 
				
			||||||
		if strings.HasSuffix(strings.ToLower(name), "_proxy") && value != "" {
 | 
							if strings.HasSuffix(strings.ToLower(name), "_proxy") && value != "" {
 | 
				
			||||||
			envVar := v1.EnvVar{Name: name, Value: value}
 | 
								envVar := kubeadmapi.EnvVar{
 | 
				
			||||||
 | 
									EnvVar: v1.EnvVar{Name: name, Value: value},
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			envs = append(envs, envVar)
 | 
								envs = append(envs, envVar)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return envs
 | 
						return envs
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// MergeEnv merges values of environment variable slices. The values defined in later slices overwrite values in previous ones.
 | 
					// MergeKubeadmEnvVars merges values of environment variable slices.
 | 
				
			||||||
func MergeEnv(envList ...[]v1.EnvVar) []v1.EnvVar {
 | 
					// The values defined in later slices overwrite values in previous ones.
 | 
				
			||||||
 | 
					func MergeKubeadmEnvVars(envList ...[]kubeadmapi.EnvVar) []v1.EnvVar {
 | 
				
			||||||
	m := make(map[string]v1.EnvVar)
 | 
						m := make(map[string]v1.EnvVar)
 | 
				
			||||||
	merged := []v1.EnvVar{}
 | 
						merged := []v1.EnvVar{}
 | 
				
			||||||
	for _, envs := range envList {
 | 
						for _, envs := range envList {
 | 
				
			||||||
		for _, env := range envs {
 | 
							for _, env := range envs {
 | 
				
			||||||
			m[env.Name] = env
 | 
								m[env.Name] = env.EnvVar
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for _, v := range m {
 | 
						for _, v := range m {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,26 +22,34 @@ import (
 | 
				
			|||||||
	"github.com/stretchr/testify/assert"
 | 
						"github.com/stretchr/testify/assert"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	v1 "k8s.io/api/core/v1"
 | 
						v1 "k8s.io/api/core/v1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestMergeEnv(t *testing.T) {
 | 
					func TestMergeKubeadmEnvVars(t *testing.T) {
 | 
				
			||||||
	baseEnv := []v1.EnvVar{}
 | 
						baseEnv := []kubeadmapi.EnvVar{}
 | 
				
			||||||
	extraEnv := []v1.EnvVar{}
 | 
						extraEnv := []kubeadmapi.EnvVar{}
 | 
				
			||||||
	MergeEnv(append(baseEnv, extraEnv...))
 | 
						MergeKubeadmEnvVars(append(baseEnv, extraEnv...))
 | 
				
			||||||
	var tests = []struct {
 | 
						var tests = []struct {
 | 
				
			||||||
		name      string
 | 
							name      string
 | 
				
			||||||
		proxyEnv  []v1.EnvVar
 | 
							proxyEnv  []kubeadmapi.EnvVar
 | 
				
			||||||
		extraEnv  []v1.EnvVar
 | 
							extraEnv  []kubeadmapi.EnvVar
 | 
				
			||||||
		mergedEnv []v1.EnvVar
 | 
							mergedEnv []v1.EnvVar
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "normal case without duplicated env",
 | 
								name: "normal case without duplicated env",
 | 
				
			||||||
			proxyEnv: []v1.EnvVar{
 | 
								proxyEnv: []kubeadmapi.EnvVar{
 | 
				
			||||||
				{Name: "Foo1", Value: "Bar1"},
 | 
									{
 | 
				
			||||||
				{Name: "Foo2", Value: "Bar2"},
 | 
										EnvVar: v1.EnvVar{Name: "Foo1", Value: "Bar1"},
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										EnvVar: v1.EnvVar{Name: "Foo2", Value: "Bar2"},
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								extraEnv: []kubeadmapi.EnvVar{
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										EnvVar: v1.EnvVar{Name: "Foo3", Value: "Bar3"},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			extraEnv: []v1.EnvVar{
 | 
					 | 
				
			||||||
				{Name: "Foo3", Value: "Bar3"},
 | 
					 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			mergedEnv: []v1.EnvVar{
 | 
								mergedEnv: []v1.EnvVar{
 | 
				
			||||||
				{Name: "Foo1", Value: "Bar1"},
 | 
									{Name: "Foo1", Value: "Bar1"},
 | 
				
			||||||
@@ -51,12 +59,18 @@ func TestMergeEnv(t *testing.T) {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "extraEnv env take precedence over the proxyEnv",
 | 
								name: "extraEnv env take precedence over the proxyEnv",
 | 
				
			||||||
			proxyEnv: []v1.EnvVar{
 | 
								proxyEnv: []kubeadmapi.EnvVar{
 | 
				
			||||||
				{Name: "Foo1", Value: "Bar1"},
 | 
									{
 | 
				
			||||||
				{Name: "Foo2", Value: "Bar2"},
 | 
										EnvVar: v1.EnvVar{Name: "Foo1", Value: "Bar1"},
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										EnvVar: v1.EnvVar{Name: "Foo2", Value: "Bar2"},
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								extraEnv: []kubeadmapi.EnvVar{
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										EnvVar: v1.EnvVar{Name: "Foo2", Value: "Bar3"},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			extraEnv: []v1.EnvVar{
 | 
					 | 
				
			||||||
				{Name: "Foo2", Value: "Bar3"},
 | 
					 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			mergedEnv: []v1.EnvVar{
 | 
								mergedEnv: []v1.EnvVar{
 | 
				
			||||||
				{Name: "Foo1", Value: "Bar1"},
 | 
									{Name: "Foo1", Value: "Bar1"},
 | 
				
			||||||
@@ -67,7 +81,7 @@ func TestMergeEnv(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for _, test := range tests {
 | 
						for _, test := range tests {
 | 
				
			||||||
		t.Run(test.name, func(t *testing.T) {
 | 
							t.Run(test.name, func(t *testing.T) {
 | 
				
			||||||
			envs := MergeEnv(test.proxyEnv, test.extraEnv)
 | 
								envs := MergeKubeadmEnvVars(test.proxyEnv, test.extraEnv)
 | 
				
			||||||
			if !assert.ElementsMatch(t, envs, test.mergedEnv) {
 | 
								if !assert.ElementsMatch(t, envs, test.mergedEnv) {
 | 
				
			||||||
				t.Errorf("expected env: %v, got: %v", test.mergedEnv, envs)
 | 
									t.Errorf("expected env: %v, got: %v", test.mergedEnv, envs)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user