示例#1
0
// containerResourceRuntimeValue returns the value of the provided container resource
func containerResourceRuntimeValue(fs *api.ResourceFieldSelector, pod *api.Pod, container *api.Container) (string, error) {
	containerName := fs.ContainerName
	if len(containerName) == 0 {
		return fieldpath.ExtractContainerResourceValue(fs, container)
	} else {
		return fieldpath.ExtractResourceValueByContainerName(fs, pod, containerName)
	}
}
示例#2
0
文件: env.go 项目: php-coder/origin
func getEnvVarRefValue(f *clientcmd.Factory, store *resourceStore, from *kapi.EnvVarSource, obj runtime.Object, c *kapi.Container) (string, error) {
	if from.SecretKeyRef != nil {
		return getSecretRefValue(f, store, from.SecretKeyRef)
	}

	if from.ConfigMapKeyRef != nil {
		return getConfigMapRefValue(f, store, from.ConfigMapKeyRef)
	}

	if from.FieldRef != nil {
		return fieldpath.ExtractFieldPathAsString(obj, from.FieldRef.FieldPath)
	}

	if from.ResourceFieldRef != nil {
		return fieldpath.ExtractContainerResourceValue(from.ResourceFieldRef, c)
	}

	return "", fmt.Errorf("invalid valueFrom")
}