Esempio n. 1
0
File: helpers.go Progetto: bac/juju
// FullIDs2LookUpArgs converts the provided payload "full" IDs into arguments
// for the LookUp API endpoint.
func FullIDs2LookUpArgs(fullIDs []string) LookUpArgs {
	var args LookUpArgs
	for _, fullID := range fullIDs {
		name, rawID := payload.ParseID(fullID)
		args.Args = append(args.Args, LookUpArg{
			Name: name,
			ID:   rawID,
		})
	}
	return args
}
Esempio n. 2
0
func (s *BaseSuite) NewPayload(pType string, id string) payload.Payload {
	name, pluginID := payload.ParseID(id)
	if pluginID == "" {
		pluginID = fmt.Sprintf("%s-%s", name, utils.MustNewUUID())
	}

	return payload.Payload{
		PayloadClass: charm.PayloadClass{
			Name: name,
			Type: pType,
		},
		ID:     pluginID,
		Status: "running",
		Unit:   s.Unit,
	}
}
Esempio n. 3
0
func (s *basePayloadsSuite) newPayload(pType string, id string) payload.Payload {
	name, rawID := payload.ParseID(id)
	if rawID == "" {
		rawID = fmt.Sprintf("%s-%s", name, utils.MustNewUUID())
	}

	return payload.Payload{
		PayloadClass: charm.PayloadClass{
			Name: name,
			Type: pType,
		},
		Status: payload.StateRunning,
		ID:     rawID,
		Unit:   "a-service/0",
	}
}
Esempio n. 4
0
func (c *stubAPIClient) setNew(fullIDs ...string) []payload.Payload {
	var payloads []payload.Payload
	for _, id := range fullIDs {
		name, pluginID := payload.ParseID(id)
		if name == "" {
			panic("missing name")
		}
		if pluginID == "" {
			panic("missing id")
		}
		wl := payload.Payload{
			PayloadClass: charm.PayloadClass{
				Name: name,
				Type: "myplugin",
			},
			ID:     pluginID,
			Status: payload.StateRunning,
		}
		c.payloads[id] = wl
		payloads = append(payloads, wl)
	}
	return payloads
}
Esempio n. 5
0
func (s *idSuite) TestParseIDExtras(c *gc.C) {
	name, id := payload.ParseID("somecharm/0/a-payload/my-payload")

	c.Check(name, gc.Equals, "somecharm")
	c.Check(id, gc.Equals, "0/a-payload/my-payload")
}
Esempio n. 6
0
func (s *idSuite) TestParseIDNameOnly(c *gc.C) {
	name, id := payload.ParseID("a-payload")

	c.Check(name, gc.Equals, "a-payload")
	c.Check(id, gc.Equals, "")
}
Esempio n. 7
0
func (s *idSuite) TestParseIDFull(c *gc.C) {
	name, id := payload.ParseID("a-payload/my-payload")

	c.Check(name, gc.Equals, "a-payload")
	c.Check(id, gc.Equals, "my-payload")
}