Ejemplo n.º 1
0
func getResources(serviceID string, resourceLister ResourceLister) (map[string]resource.Resource, error) {
	svcs, err := resourceLister.ListResources([]string{serviceID})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return resource.AsMap(svcs[0].Resources), nil
}
Ejemplo n.º 2
0
func getResources(serviceID string, newAPIRoot func() (api.Connection, error)) (map[string]resource.Resource, error) {
	resclient, err := resourceadapters.NewAPIClient(newAPIRoot)
	if err != nil {
		return nil, errors.Trace(err)
	}
	svcs, err := resclient.ListResources([]string{serviceID})
	if err != nil {
		return nil, errors.Trace(err)
	}
	// ListResources guarantees a number of values returned == number of
	// services passed in.
	return resource.AsMap(svcs[0].Resources), nil
}
Ejemplo n.º 3
0
func (s *ResourceSuite) TestAsMap(c *gc.C) {
	spam := newStoreResource(c, "spam", "a-service", 2)
	eggs := newStoreResource(c, "eggs", "a-service", 3)
	resources := []resource.Resource{
		spam,
		eggs,
	}

	resMap := resource.AsMap(resources)

	c.Check(resMap, jc.DeepEquals, map[string]resource.Resource{
		"spam": spam,
		"eggs": eggs,
	})
}