kubectl-persistent-logger/logs/helpers.go

19 lines
597 B
Go

package logs
import "fmt"
// ParseType returns an API resource type (pluralized) from a singular or
// shortened name. If the resource is unsupported, an error will be returned.
func ParseType(input string) (string, error) {
switch input {
case "deploy", "deployment", "deployments":
return "deployments", nil
case "sts", "statefulset", "statefulsets":
return "statefulsets", nil
case "rs", "replicaset", "replicasets":
return "replicasets", nil
default:
return "", fmt.Errorf(`unsupported resource: "%s". Supported resources are [deployment, statefulset, replicaset]`, input)
}
}