public void parse()

in services/provisioning-service/src/main/java/com/epam/datalab/backendapi/core/commands/CommandParserMock.java [284:353]


    public void parse(String cmd, String uuid) {
        command = null;
        action = null;
        resourceType = null;
        imageType = null;
        requestId = uuid;
        responsePath = null;
        name = null;
        json = null;

        envMap.clear();
        varMap.clear();
        otherArgs.clear();
        variables.clear();

        List<String> args = extractArgs(cmd);
        dockerCommand = args.contains("docker");
        int i = 0;
        String s;
        Pair<String, String> p;

        while (i < args.size()) {
            if ((s = getArgValue(args, i, "-v")) != null) {
                p = getPair("-v", s, ":");
                varMap.put(p.getValue(), p.getKey());
            } else if ((s = getArgValue(args, i, "-e")) != null) {
                p = getPair("-e", s, "=");
                envMap.put(p.getKey(), p.getValue());
            } else if ((s = getArgValue(args, i, "docker")) != null || (s = getArgValue(args, i, "python")) != null) {
                command = s;
            } else if ((s = getArgValue(args, i, "--action")) != null) {
                action = s;
            } else if ((s = getArgValue(args, i, "--name")) != null) {
                name = s;
            } else if ((s = getArgValue(args, i, "echo")) != null) {
                if (s.equals("-e")) {
                    if (i >= args.size()) {
                        throw new DatalabException("Argument \"echo -e\" detected but not have value");
                    }
                    s = args.get(i);
                    args.remove(i);
                }
                json = s;
            } else if ((s = getArgValue(args, i, "--result_path")) != null) {
                responsePath = s;
                varMap.put("/response", responsePath);
                args.remove(i);
            } else {
                i++;
            }
        }

        if (args.size() > 0) {
            otherArgs.addAll(args);
        }

        resourceType = envMap.get("conf_resource");
        if (isDockerCommand()) {
            imageType = getImageName(args);
            imageType = imageType.replace("docker.datalab-", "").replace(":latest", "");
        }
        responsePath = varMap.get("/response");

        variables.putAll(envMap);
        variables.putAll(getJsonVariables(json));
        variables.put("request_id", requestId);
        variables.put("instance_id", "i-" + requestId.replace("-", "").substring(0, 17));
        variables.put("cluster_id", "j-" + requestId.replace("-", "").substring(0, 13).toUpperCase());
        variables.put("notebook_id", requestId.replace("-", "").substring(17, 22));
    }