func createPreRun()

in cmd/client/command/create.go [90:120]


func createPreRun(_ *cobra.Command, args []string) error {
	if len(args) == 0 {
		return errors.New("missing resource type, please specify one of [namespace, cluster, shard, node]")
	}
	resource := strings.ToLower(args[0])
	if resource == ResourceNamespace {
		return nil
	}
	if createOptions.namespace == "" {
		return errors.New("missing namespace, please specify the namespace via -n or --namespace option")
	}
	if resource != ResourceNode && createOptions.nodes == nil {
		return errors.New("missing nodes, please specify the nodes via --nodes option")
	}
	if resource == ResourceCluster {
		return nil
	}
	if createOptions.cluster == "" {
		return errors.New("missing cluster, please specify the cluster via -c or --cluster option")
	}
	if resource == ResourceShard {
		return nil
	}
	if createOptions.shard == -1 {
		return errors.New("missing shard, please specify the shard via -s or --shard option")
	}
	if createOptions.shard < 0 {
		return errors.New("shard must be a positive number")
	}
	return nil
}