freeconf / yang

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

'uses' substatement under augment does not replace the grouping as expected. #55

Closed davidmat50 closed 1 year ago

davidmat50 commented 1 year ago

In normal cases, if 'uses" is used , the entire data definitions inside the grouping referred by the referred 'uses' keyword is being replaced in the data tree. 'Augment' also replaces the augmented data plus any additional data nodes kept under augment.

But if 'uses' is used under augment, then the data refreed by the grouping is not seen as additional data under augment. AS per RFC 7950, 'uses' should be supported as a substatment for 'augment'

Example file:

module aug-with-uses-basic {
    yang-version "1.1";
    revision 2020-02-04 {
        description
          "initial draft";
    }

    leaf test {
        type int8;
    }

    container system {
        leaf host-name {
           type string;
           description
             "Hostname for this system.";
        }

        leaf-list domain-search {
           type string;
           description
             "List of domain names to search.";
        }

        container login {
            leaf message {
            type string;
             description
               "Message given at start of login session.";
            }

            list user {
                key "name";
                leaf name {
                    type string;
                }
                leaf full-name {
                    type string;
                }
                leaf class {
                    type string;
                }
            }
        }
    }

    grouping target {
       leaf port {
         type port-number;
          description "Target port number.";
       }
     }

    typedef port-number {
        type uint16 {
        range "0..65535";
        }
    }

    augment /system/login/user {
       uses target;
     }
}
dhubler commented 1 year ago

i was able to duplicate this. may take few days to address this.

dhubler commented 1 year ago

i think i had interpretation of RFC regarding "augment" fairly wrong. I pushed what i believe to be correct implementation to a branch called aug-with-uses. Can you test this branch to see if it addresses your issue?

dhubler commented 1 year ago

fixed

davidmat50 commented 1 year ago

Hi @dhubler , i hope this is merged to master already. But when i checked the behaviour in the latest version, i am seeing that augemted data is not getting attached to data definitions tree ( ie the dataDefinitions in the module).

It was properly augmenting before but now that is not happening,
The issue i raised initially was only for the 'uses' statement under augemt. Now the entire augment data itself is missing,

davidmat50 commented 1 year ago

Raising this the above observation as a new issue