Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config values from yaml file are ignored when docopt has default values #324

Open
knoguchi opened this issue Mar 6, 2025 · 0 comments
Open

Comments

@knoguchi
Copy link

knoguchi commented Mar 6, 2025

Apache Iceberg version

None

Please describe the bug 🐞

Does this really work?
https://github.com/apache/iceberg-go/blob/ba883bdb1d26cc8ea0505e3910ffee0f9c74f315/cmd/iceberg/main.go#L412C1-L428C2

The intention seems to be to copy values from fileConf to resConfig. However, it only copies values when the resConfig fields are empty. Since doctopt sets default values in resConfig, the values read from the file are ignored when a default value already exists.

For example, I set Output: "json" in my config YAML, but this has no effect because resConfig.Output already has a default value of "text".

Is the below better? But which one has precedence when command line args has non-default value, and file config exists for the same option?

func mergeConf(fileConf *config.CatalogConfig, resConfig *Config) {
	if len(fileConf.CatalogType) > 0 {
		resConfig.Catalog = fileConf.CatalogType
	}
	if len(fileConf.URI) > 0 {
		resConfig.URI = fileConf.URI
	}
	if len(fileConf.Output) > 0 {
		resConfig.Output = fileConf.Output
	}
	if len(fileConf.Credential) > 0 {
		resConfig.Cred = fileConf.Credential
	}
	if len(fileConf.Warehouse) > 0 {
		resConfig.Warehouse = fileConf.Warehouse
	}
}
@knoguchi knoguchi changed the title config files from yaml file is ignored when docopt has default values config values from yaml file are ignored when docopt has default values Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant