func()

in cmd/resource/kube.go [232:287]


func (c *Clients) GetKubeResources(r *ReleaseData) (map[string]interface{}, error) {
	log.Printf("Getting resources for %s", r.Name)
	if r.Manifest == "" {
		return nil, errors.New("manifest not provided in the request")
	}
	resources := map[string]interface{}{}
	infos, err := c.getManifestDetails(r)
	if err != nil {
		return nil, err
	}
	namespace := "default"
	for _, info := range infos {
		var spec interface{}
		kind := info.Object.GetObjectKind().GroupVersionKind().GroupKind().Kind
		v := kube.AsVersioned(info)
		if checkSize(resources, ResourcesOutputSize) {
			break
		}

		if stringInSlice(reflect.TypeOf(v).String(), ResourcesOutputIgnoredTypes) {
			continue
		}
		inner := make(map[string]interface{})
		name, ok := ScanFromStruct(v, "ObjectMeta.Name")
		if !ok {
			continue
		}
		ns, ok := ScanFromStruct(v, "ObjectMeta.Namespace")
		if ok {
			namespace = fmt.Sprint(ns)
		}
		if stringInSlice(reflect.TypeOf(v).String(), ResourcesOutputIncludedSpec) {
			spec, ok = ScanFromStruct(v, "Spec")
			if ok {
				spec = structToMap(spec)
			}
		}
		status, ok := ScanFromStruct(v, "Status")
		if ok {
			status = structToMap(status)
		}
		inner = map[string]interface{}{
			fmt.Sprint(name): map[string]interface{}{
				"Namespace": namespace,
				"Spec":      spec,
				"Status":    status,
			},
		}
		if IsZero(resources[kind]) {
			resources[kind] = map[string]interface{}{}
		}
		temp := resources[kind].(map[string]interface{})
		resources[kind] = mergeMaps(temp, inner)
	}
	return resources, nil
}