forked from vmware-tanzu/tanzu-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the deprecated APIs (vmware-tanzu#616)
* Update deprecated apis like feature flag apis * Remove unused builder publish command * Address review comments * Implement sync of active contexts and server
- Loading branch information
1 parent
beb7fde
commit 3e6a2fb
Showing
10 changed files
with
968 additions
and
405 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2024 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package config | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
|
||
"github.com/vmware-tanzu/tanzu-plugin-runtime/config" | ||
) | ||
|
||
// SyncContextsAndServers populate or sync contexts and servers | ||
func SyncContextsAndServers() error { | ||
cfg, err := config.GetClientConfig() | ||
if err != nil { | ||
return errors.Wrap(err, "failed to get client config") | ||
} | ||
|
||
config.PopulateContexts(cfg) | ||
|
||
// Now write the context to the configuration file. This will also create any missing server for its corresponding context | ||
for _, c := range cfg.KnownContexts { | ||
err := config.SetContext(c, false) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to set context") | ||
} | ||
} | ||
|
||
// Now write the active contexts to the configuration file. This will also create any missing active server for its corresponding context | ||
activeContexts, _ := cfg.GetAllActiveContextsList() | ||
for _, c := range activeContexts { | ||
err := config.SetActiveContext(c) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to set active context") | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.