apache / iceberg-go

Apache Iceberg - Go
https://iceberg.apache.org/
Apache License 2.0
142 stars 34 forks source link

Config File Handling #156

Closed alex-kar closed 1 month ago

alex-kar commented 1 month ago

Handle config file .iceberg-go.yaml in the home directory.

Closes #62

@zeroshade I noticed that --catalog has different functionality compare to pyiceberg cli, where it defines catalog name to be loaded from configuration file.

iceberg-go - --catalog - catalog type. pyiceberg --catalog - catalog name to load from configuration file.

Because of this reason, currently it can load only default catalog.

Another note is that docopt throw's exception when struct has some non default values. https://github.com/docopt/docopt.go/issues/55 Because of this limitation, I can't first parse configuration file and then provide the same struct to docopt to ensure the correct precedence. instead I added this manual mapping:

func mergeConf(fileConf *config.CatalogConfig, resConfig *Config) {
    if len(resConfig.Catalog) == 0 {
        resConfig.Catalog = fileConf.Catalog
    }
    ...
}
nastra commented 1 month ago

@alex-kar can you please rebase and fix the merge conflict?

alex-kar commented 1 month ago

@nastra Rebased onto the latest main.