示例#1
0
func (command *commandListEvents) HandleFlags(resource *handler.Resource) error {
	if err := command.Ctx.CheckFlagsSet([]string{"name"}); err != nil {
		return err
	}

	c := command.Ctx.CLIContext
	name := c.String("stack-name")
	id := c.String("stack-id")
	name, id, err := stackcommands.IDAndName(command.Ctx.ServiceClient, name, id)
	if err != nil {
		return err
	}
	opts := &osStackEvents.ListResourceEventsOpts{
		ResourceActions:  strings.Split(c.String("resource-actions"), ","),
		ResourceStatuses: strings.Split(c.String("resource-statuses"), ","),
		ResourceTypes:    strings.Split(c.String("resource-types"), ","),
		SortKey:          osStackEvents.SortKey(c.String("sort-key")),
		SortDir:          osStackEvents.SortDir(c.String("sort-dir")),
	}

	resource.Params = &paramsListEvents{
		opts:         opts,
		stackName:    name,
		stackID:      id,
		resourceName: c.String("name"),
	}
	return nil
}
示例#2
0
func (command *commandListEvents) HandleFlags(resource *handler.Resource) error {
	c := command.Ctx.CLIContext

	stringResourceActions := strings.Split(c.String("resource-actions"), ",")
	resourceActions := make([]osStackEvents.ResourceAction, len(stringResourceActions))
	for i, resourceAction := range stringResourceActions {
		resourceActions[i] = osStackEvents.ResourceAction(resourceAction)
	}

	stringResourceStatuses := strings.Split(c.String("resource-statuses"), ",")
	resourceStatuses := make([]osStackEvents.ResourceStatus, len(stringResourceStatuses))
	for i, resourceStatus := range stringResourceStatuses {
		resourceStatuses[i] = osStackEvents.ResourceStatus(resourceStatus)
	}

	opts := &osStackEvents.ListOpts{
		ResourceActions:  resourceActions,
		ResourceStatuses: resourceStatuses,
		ResourceNames:    strings.Split(c.String("resource-names"), ","),
		ResourceTypes:    strings.Split(c.String("resource-types"), ","),
		SortKey:          osStackEvents.SortKey(c.String("sort-key")),
		SortDir:          osStackEvents.SortDir(c.String("sort-dir")),
	}
	resource.Params = &paramsListEvents{
		opts: opts,
	}
	return nil
}