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

Deprecations #115

Open
jakubdyszkiewicz opened this issue Jan 25, 2022 · 4 comments
Open

Deprecations #115

jakubdyszkiewicz opened this issue Jan 25, 2022 · 4 comments
Assignees
Labels
feature New feature or request

Comments

@jakubdyszkiewicz
Copy link
Contributor

It's not common to deprecate fields to remove them in the next release or move them to some other place. It would be nice to have support for it in aconfig. Maybe something like

type MyConfig struct {
	Hostname int `default:"xyz.internal" usage:"hostname" deprecated:"this will be gone in the next release, the internet is a dangerous place, localhost will be a default"`
}

and have a function to collect all deprecations if the value is set.

@cristaloleg
Copy link
Member

Nice one, can you clarify this part:

a function to collect all deprecations if the value is set

?

@cristaloleg cristaloleg self-assigned this Jan 25, 2022
@jakubdyszkiewicz
Copy link
Contributor Author

Sure, I'd like to collect all the deprecations in something like

type Deprecation struct {
  Flag string
  Env string
  YamlKey string
  Message string
}

So I can collect []Deprecation and print them for user. I want to bother the user with message only if they set (via env/flag/yaml) the deprecated config.

@cristaloleg
Copy link
Member

Should this be enough? https://github.com/cristalhq/aconfig/blob/main/aconfig.go#L188

Basically you can iterate over all fields and these with .Deprecated == true are what you're looking for.

@jakubdyszkiewicz
Copy link
Contributor Author

Ah, yes. That makes sense 👍

@cristaloleg cristaloleg added the feature New feature or request label Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants