1
0
mirror of https://github.com/rancher/cli.git synced 2026-02-05 09:48:36 +01:00
Files
cli/cmd/util_actions.go
Daishan Peng 03ebe1a203 cli 2.0
2017-09-15 14:34:17 -07:00

24 lines
546 B
Go

package cmd
import (
"errors"
"fmt"
"strings"
"github.com/rancher/go-rancher/v3"
)
func pickAction(resource *client.Resource, actions ...string) (string, error) {
for _, action := range actions {
if _, ok := resource.Actions[action]; ok {
return action, nil
}
}
msg := fmt.Sprintf("%s not currently available on %s %s", strings.Join(actions, "/"), resource.Type, resource.Id)
return "", errors.New(replaceTypeNames(msg))
}
func replaceTypeNames(msg string) string {
return strings.Replace(msg, "project", "environment", -1)
}