freeconf / yang

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

Panic when 'config:true' is added in yang #74

Closed davidmat50 closed 1 year ago

davidmat50 commented 1 year ago

Panic happens when the field 'config : true' is added.

panic: interface conversion: *meta.Module is not meta.HasConfig: missing method Config

goroutine 1 [running]:
github.com/freeconf/yang/meta.(*compiler).compile(0xc0004a0000?, {0xddcd80?, 0xc000524120?})
        C:/Users/dama0416/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20230804003402-7593854e7f4d/meta/compile.go:91 +0x24b  
github.com/freeconf/yang/meta.(*compiler).compile(0xc000202780?, {0xddd0a0?, 0xc0004a0000?})
        C:/Users/dama0416/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20230804003402-7593854e7f4d/meta/compile.go:135 +0x687 
github.com/freeconf/yang/meta.(*compiler).module(0x10?, 0xc0004a0000)
        C:/Users/dama0416/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20230804003402-7593854e7f4d/meta/compile.go:52 +0x206  
github.com/freeconf/yang/meta.Compile(0xc0004a0000)
        C:/Users/dama0416/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20230804003402-7593854e7f4d/meta/compile.go:21 +0x4a   
github.com/freeconf/yang/parser.LoadModuleWithOptions(0xc00052f360, {0xc00001e0e0, 0xd}, {{0x0?, 0x0?}, {0x0?, 0xc00049bc60?}})
        C:/Users/dama0416/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20230804003402-7593854e7f4d/parser/loader.go:72 +0x1fd 
github.com/freeconf/yang/parser.LoadModule(...)
        C:/Users/dama0416/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20230804003402-7593854e7f4d/parser/loader.go:16        
e2eso-json-schema-generator/generator/yangparser.(*YangParser).ParseAndGenerateJsonSchema(0xc00049bcc0)
.
.
.

File used: basic_config1.yang

module basic_config1 {

    namespace "urn:params:basic_config";
    prefix basic_config;

    yang-version 1.1;

    container root-container {
        config true;
        leaf leaf-init {
            description "This is a leaf with config false";
            type boolean;
            default true;
            units USD;
        }
    }
}

file2 : basic_config2.yang

module basic_config2 {

    namespace "urn:params:basic_config";
    prefix basic_config;

    yang-version 1.1;

    container root-container {
        leaf leaf-init {
            description "This is a leaf with config false";
            type boolean;
            default true;
            units USD;
        }

        choice choice-init {
            description "This is a choice with config false";
            default case-A;
            case case-A {
                leaf leaf-init1 {
                    type string;
                    config true;
                }
            }
            case case-B {
                leaf leaf-init2 {
                    type string;
                }
            }
        }
    }
}
dhubler commented 1 year ago

fixed

davidmat50 commented 1 year ago

I observe that the issue is only fixed partially. In the description, there were files basic_config1.yang and basic_config2.yang the panic issue for basic_config1.yang is solved. But panic still happens for basic_config2.yang

one more concern (not related to isuue mentioned in ticket) : usually when i execute 'go get -u github.com/freeconf/yang' , the latest version image is expected to get downlaoded. But it is not happening now. It used to happen before. Now , i always end up in pull using the commit number if i need to fetch the image with fix. eg: go get -u github.com/freeconf/yang@0ba64e6 Can you make it in such a way that 'go get -u github.com/freeconf/yang' fethces the latest image from master.

davidmat50 commented 1 year ago

i have created https://github.com/freeconf/yang/issues/83 for the 2nd part