// 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 }
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, } }
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", } }
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 }
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") }
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, "") }
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") }