-
Notifications
You must be signed in to change notification settings - Fork 20
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
Refactor the deprecated APIs #616
Refactor the deprecated APIs #616
Conversation
ae7f2b2
to
3f22b00
Compare
3f22b00
to
d2f2928
Compare
402891c
to
a49ec0a
Compare
a49ec0a
to
6fe9a7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments in-line.
Also, I think you can use configlib.GetAllFeatureFlags()
in the function completionGetEnvAndFeatures()
instead of accessing the content of the config struct directly.
Finally, I still see one more use of these functions in pkg/interfaces/config_client_interface.go
, but considering the time, we can start with this PR.
|
||
config.PopulateContexts(cfg) | ||
|
||
for _, c := range cfg.KnownContexts { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we doing this now? I don't see it being done before this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marc pkg/config/In init.go we were already doing this sync of contexts and servers
// contexts could be lost when older plugins edit the config, so populate them from servers
addedContexts := config.PopulateContexts(c)
I removed the use of StoreClientConfig and used the Config APIs directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, now I understand two things:
StoreClientConfig()
would of course store the config, whichconfig.PopulateContexts(c)
does not do, so in this PR you save each context in the config file by looping and callingconfig.SetContext()
StoreClientConfig()
also made sure any missing servers were created based on the contexts, and now the loop achieves the same thing by the same calls toconfig.SetContext()
This is great, but could you add a comment before the loop to say something like // Now write the context to the configuration file. This will also create any missing server for its corresponding context
Also, I think there still one aspect missing:
config.PopulateContexts(c)
might have change the value of the currentContext; this is not persisted in the config file because the loop never sets the currentContext
I was able to reproduce that last point as follows:
- manually delete a context from
~/.config/tanzu/config-ng.yaml
- set the deleted context as the
current
in~/.config/tanzu/config.yaml
- => So now we have a server that is active that does not exist as a context.
- Now run
tz context list
(or any other command). - => before this PR, the missing context would be added and be set to active, but with this PR the missing context is added but is not set to active.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed review. I have added comments for SetContext and updated the code to use SetActiveContext.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment and then I think we are good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for this cleanup!
* Update deprecated apis like feature flag apis * Remove unused builder publish command * Address review comments * Implement sync of active contexts and server
* Update deprecated apis like feature flag apis * Remove unused builder publish command * Address review comments * Implement sync of active contexts and server
What this PR does / why we need it
Which issue(s) this PR fixes
Fixes #
Describe testing done for PR
Test Setting, Getting feature flags
Set, Get features and env
Release note
Additional information
Special notes for your reviewer