func deletePreRun()

in cmd/client/command/delete.go [88:116]


func deletePreRun(_ *cobra.Command, args []string) error {
	if len(args) == 0 {
		return fmt.Errorf("missing resource type")
	}

	resource := strings.ToLower(args[0])
	if resource == ResourceNamespace {
		return nil
	}
	if deleteOptions.namespace == "" {
		return fmt.Errorf("missing namespace, please specify the namespace via -n or --namespace option")
	}
	if resource == ResourceCluster {
		return nil
	}
	if deleteOptions.cluster == "" {
		return fmt.Errorf("missing cluster, please specify the cluster via -c or --cluster option")
	}
	if resource == ResourceShard {
		return nil
	}
	if deleteOptions.shard == -1 {
		return fmt.Errorf("missing shard, please specify the shard via -s or --shard option")
	}
	if deleteOptions.shard < 0 {
		return fmt.Errorf("invalid shard %d", deleteOptions.shard)
	}
	return nil
}