func (b *BasicManifestFactory) MakeManifest(machine string, pod api.Pod) (api.ContainerManifest, error) {
	envVars, err := service.GetServiceEnvironmentVariables(b.serviceRegistry, machine)
	if err != nil {
		return api.ContainerManifest{}, err
	}
	for ix, container := range pod.DesiredState.Manifest.Containers {
		pod.DesiredState.Manifest.ID = pod.ID
		pod.DesiredState.Manifest.Containers[ix].Env = append(container.Env, envVars...)
	}
	return pod.DesiredState.Manifest, nil
}
Ejemplo n.º 2
0
func (b *BasicBoundPodFactory) MakeBoundPod(machine string, pod *api.Pod) (*api.BoundPod, error) {
	envVars, err := service.GetServiceEnvironmentVariables(api.NewContext(), b.ServiceRegistry, machine)
	if err != nil {
		return nil, err
	}
	boundPod := &api.BoundPod{}
	if err := api.Scheme.Convert(pod, boundPod); err != nil {
		return nil, err
	}
	for ix, container := range boundPod.Spec.Containers {
		boundPod.Spec.Containers[ix].Env = append(container.Env, envVars...)
	}
	// Make a dummy self link so that references to this bound pod will work.
	// TODO: When kubelets get boundPods from apiserver instead of etcd, then
	// the selflink should be generated there.
	boundPod.SelfLink = "/api/v1beta1/boundPods/" + boundPod.Name
	return boundPod, nil
}