freeconf / yang

Standards-based management for Golang microservices
Apache License 2.0
38 stars 14 forks source link

Single quotes from "when" and "must" expression is missing after yang parsing and loading. #49

Closed davidmat50 closed 1 year ago

davidmat50 commented 1 year ago

If a when expression is ending with single quotes ' , then the .When().Expression() method is not returning the complete when condition including the single qutoes. eg: If the when expression is "class != 'wheel'", then the Expression() method just returns "class != 'wheel" - the single quotes after wheel is missing.

Yang file used to test:

module basic_when {

    namespace "urn:params:basic_when";
    prefix basic_when;

    container root-container {
        leaf leaf-root {
            type enumeration {
                enum "one";
                enum "two";
                enum "three";
            }
        }
        container container-condition {
            leaf leaf-nested {
                type boolean;
            }
        }
        leaf leaf-root-when {
            when "../leaf-root = 'one'";
            type int8;
        }
        leaf-list leaf-list-root-when {
            when "../leaf-root = 'two'";
            type int8;
        }
        container container-leafs {
            leaf leaf-nested-when {
                when "../../container-condition/leaf-nested = 'true'";
                type int8;
            }
            leaf-list leaf-list-nested-when {
                when "../../container-condition/leaf-nested = 'false'";
                type int8;
            }
        }
        container container-when {
            when "../leaf-root = 'two'";
            leaf leaf-A {
                type string;
            }
        }
        list list-when {
            when "../leaf-root = 'three'";
            leaf leaf-B {
                type string;
            }
        }
    }
}

The same issue exists for must expression also.