Пример #1
0
func registerResource(res unversioned.Resource, resList unversioned.Resource,
	tableHeadings []string, tableHeadingsWide []string, headingsMap map[string]string,
	apply, create, update, delete, list ResourceActionCommand) {

	if helpers == nil {
		helpers = make(map[unversioned.TypeMetadata]resourceHelper)
	}

	tmd := res.GetTypeMetadata()
	rh := resourceHelper{
		typeMetadata:      tmd,
		resourceType:      reflect.ValueOf(res).Elem().Type(),
		tableHeadings:     tableHeadings,
		tableHeadingsWide: tableHeadingsWide,
		headingsMap:       headingsMap,
		isList:            false,
		apply:             apply,
		create:            create,
		update:            update,
		delete:            delete,
		list:              list,
	}
	helpers[tmd] = rh

	tmd = resList.GetTypeMetadata()
	rh = resourceHelper{
		typeMetadata:      tmd,
		resourceType:      reflect.ValueOf(resList).Elem().Type(),
		tableHeadings:     tableHeadings,
		tableHeadingsWide: tableHeadingsWide,
		headingsMap:       headingsMap,
		isList:            true,
	}
	helpers[tmd] = rh
}
Пример #2
0
// Return the Resource Manager for a particular resource type.
func GetResourceManager(resource unversioned.Resource) ResourceManager {
	return helpers[resource.GetTypeMetadata()]
}