コード例 #1
0
ファイル: metadata.go プロジェクト: cjnygard/origin
// collectData collects requested metadata in data map.
// Map's key is the requested name of file to dump
// Map's value is the (sorted) content of the field to be dumped in the file.
func (m *metadataVolume) collectData(data *map[string]string) error {
	errlist := []error{}
	for fieldReference, fileName := range m.fieldReferenceFileNames {
		if values, err := fieldpath.ExtractFieldPathAsString(m.pod, fieldReference); err != nil {
			glog.Error(err)
			errlist = append(errlist, err)
		} else {
			(*data)[fileName] = sortLines(values)
		}
	}
	return utilErrors.NewAggregate(errlist)
}
コード例 #2
0
ファイル: describe.go プロジェクト: Ima8/kubernetes
func envValueFrom(pod *api.Pod, e api.EnvVar) string {
	internalFieldPath, _, err := api.Scheme.ConvertFieldLabel(e.ValueFrom.FieldRef.APIVersion, "Pod", e.ValueFrom.FieldRef.FieldPath, "")
	if err != nil {
		return "" // pod validation should catch this on create
	}

	valueFrom, err := fieldpath.ExtractFieldPathAsString(pod, internalFieldPath)
	if err != nil {
		return "" // pod validation should catch this on create
	}

	return valueFrom
}