freeconf / yang

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

Failing to augment if taget node is choice and data to be augmented also is choice #77

Closed davidmat50 closed 11 months ago

davidmat50 commented 1 year ago

If we try to augment a choice to a choice, it throws the below error. *meta.Choice not a recognizable parent for

As per https://www.rfc-editor.org/rfc/rfc7950.html#section-7.17, there is as below If the target node is a choice node, the "case" statement or a shorthand "case" statement (see Section 7.9.2) can be used within the "augment" statement.

Here short-hand case statement means that we can ignore 'case' keyword and use anotherr node identifier directly assuming that only that node identifier will be present in implicit case branch.

But the loading fails for such a file.

File used: aug-test-5.yang

module aug-test-5 {

    namespace "urn:netcracker:params:basic_augment";
    prefix basic_augment;

    yang-version 1.1;

    augment "/root-container/choice-init" {
        choice choice-D {
            case case-D1 {
                leaf leaf-D1 {
                    type string;
                }
            }
        }
    }

    augment "/root-container/choice-init" {
        case case-C {
            leaf leaf-aug-1 {
                type string;
            }
        }
        case case-D {
            leaf-list leaf-list-aug-1{
                type string;
            }
        }
    }
    container root-container {
        container container-init{
            leaf leaf-init1 {
                type string;
            }
        }
        list list-init {
            leaf leaf-init2 {
                type string;
            }
        }
        choice choice-init {
            case case-A {
                leaf leaf-init3 {
                    type string;
                }
            }
            case case-B {
                leaf leaf-init4 {
                    type string;
                }
            }

            container case-container {
                leaf leaf-init5 {
                    type string;
                }
            }
            list case-list {
                leaf leaf-init6 {
                    type string;
                }
            }
        }
    }
}
dhubler commented 1 year ago

little behind, but i'll take a look in next few days

davidmat50 commented 11 months ago

Fixed https://github.com/freeconf/yang/commit/ac858968990009f40789d4209e94a849d84bdf14

davidmat50 commented 11 months ago

Fixed https://github.com/freeconf/yang/commit/ac858968990009f40789d4209e94a849d84bdf14