Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.

Commit 37683e9

Browse files
author
Anuj Chaudhari
committed
Rename feature-flag from 'context-aware-discovery' to 'context-aware-cli-for-plugins'
1 parent 2fb4c26 commit 37683e9

File tree

10 files changed

+38
-31
lines changed

10 files changed

+38
-31
lines changed

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ install-cli-plugins: ## Install Tanzu CLI plugins
393393
fi
394394

395395
.PHONY: install-cli-plugins-without-discovery
396-
install-cli-plugins-without-discovery: set-unstable-versions set-context-aware-discovery ## Install Tanzu CLI plugins when context-aware discovery is disabled
396+
install-cli-plugins-without-discovery: set-unstable-versions set-context-aware-cli-for-plugins ## Install Tanzu CLI plugins when context-aware discovery is disabled
397397
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS)" ./cmd/cli/tanzu/main.go \
398398
plugin install all --local $(ARTIFACTS_DIR)/$(GOHOSTOS)/$(GOHOSTARCH)/cli
399399
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS)" ./cmd/cli/tanzu/main.go \
@@ -402,20 +402,20 @@ install-cli-plugins-without-discovery: set-unstable-versions set-context-aware-d
402402
test fetch --local $(ARTIFACTS_DIR)/$(GOHOSTOS)/$(GOHOSTARCH)/cli --local $(ARTIFACTS_DIR)-admin/$(GOHOSTOS)/$(GOHOSTARCH)/cli
403403

404404
.PHONY: install-cli-plugins-from-local-discovery
405-
install-cli-plugins-from-local-discovery: clean-catalog-cache clean-cli-plugins set-context-aware-discovery configure-admin-plugins-discovery-source-local ## Install Tanzu CLI plugins from local discovery
405+
install-cli-plugins-from-local-discovery: clean-catalog-cache clean-cli-plugins set-context-aware-cli-for-plugins configure-admin-plugins-discovery-source-local ## Install Tanzu CLI plugins from local discovery
406406
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS) -X 'github.com/vmware-tanzu/tanzu-framework/pkg/v1/config.DefaultStandaloneDiscoveryType=local'" ./cmd/cli/tanzu/main.go plugin sync
407407

408408
.PHONY: install-cli-plugins-from-oci-discovery
409-
install-cli-plugins-from-oci-discovery: clean-catalog-cache clean-cli-plugins set-context-aware-discovery ## Install Tanzu CLI plugins from OCI discovery
409+
install-cli-plugins-from-oci-discovery: clean-catalog-cache clean-cli-plugins set-context-aware-cli-for-plugins ## Install Tanzu CLI plugins from OCI discovery
410410
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS) -X 'github.com/vmware-tanzu/tanzu-framework/pkg/v1/config.DefaultStandaloneDiscoveryType=oci'" ./cmd/cli/tanzu/main.go plugin sync
411411

412412
.PHONY: set-unstable-versions
413413
set-unstable-versions: ## Configures the unstable versions
414414
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS)" ./cmd/cli/tanzu/main.go config set unstable-versions $(TANZU_PLUGIN_UNSTABLE_VERSIONS)
415415

416-
.PHONY: set-context-aware-discovery
417-
set-context-aware-discovery: ## Configures the context-aware-discovery feature flag
418-
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS)" ./cmd/cli/tanzu/main.go config set features.global.context-aware-discovery $(ENABLE_CONTEXT_AWARE_PLUGIN_DISCOVERY)
416+
.PHONY: set-context-aware-cli-for-plugins
417+
set-context-aware-cli-for-plugins: ## Configures the context-aware-cli-for-plugins-beta feature flag
418+
TANZU_CLI_NO_INIT=true $(GO) run -ldflags "$(LD_FLAGS)" ./cmd/cli/tanzu/main.go config set features.global.context-aware-cli-for-plugins $(ENABLE_CONTEXT_AWARE_PLUGIN_DISCOVERY)
419419

420420
.PHONY: configure-admin-plugins-discovery-source-local
421421
configure-admin-plugins-discovery-source-local: ## Configures the admin plugins discovery source

cmd/cli/plugin/login/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ func login(cmd *cobra.Command, args []string) (err error) {
132132
return err
133133
}
134134

135-
// Sync all required plugins if the "features.global.context-aware-discovery" feature is enabled
136-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
135+
// Sync all required plugins if the "features.global.context-aware-cli-for-plugins" feature is enabled
136+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
137137
if err = pluginmanager.SyncPlugins(serverTarget.Name); err != nil {
138138
log.Warning("unable to automatically sync the plugins from target server. Please run 'tanzu plugin sync' command to sync plugins manually")
139139
}

cmd/cli/plugin/managementcluster/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func runInit() error {
188188
}
189189

190190
// Sync plugins if management-cluster creation is successful
191-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
191+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
192192
server, err := config.GetCurrentServer()
193193
if err == nil && server != nil {
194194
err = pluginmanager.SyncPlugins(server.Name)

cmd/cli/plugin/managementcluster/upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func runUpgradeRegion(server *v1alpha1.Server) error {
9797
}
9898

9999
// Sync plugins if management-cluster upgrade is successful
100-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
100+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
101101
err = pluginmanager.SyncPlugins(server.Name)
102102
if err != nil {
103103
log.Warningf("unable to sync plugins after management cluster upgrade. Please run `tanzu plugin sync` command manually to install/update plugins")

docs/dev/build.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@ For more detailed information on these APIs check out this [doc](../api-machiner
8686

8787
The Tanzu CLI is an amalgamation of all the Tanzu infrastructure elements under one unified core CLI experience. The core CLI supports a plugin model where the developers of different Tanzu services (bundled or SaaS) can distribute plugins that target functionalities of the services they own. When users switch between different services via the CLI context, we want to surface only the relevant plugins for the given context for a crisp user experience.
8888

89-
This feature is gated by `features.global.context-aware-discovery` CLI feature flag and can be turned on/off as described [here](../cli/config-features.md). When this feature is enabled, CLI will not automatically use already installed plugins with context-aware discovery and users will need to install plugins again with `tanzu plugin install` command.
89+
This feature is gated by `features.global.context-aware-cli-for-plugins` CLI feature flag and can be turned on/off as described [here](../cli/config-features.md). When this feature is enabled, CLI will not automatically use already installed plugins with context-aware discovery and users will need to install plugins again with `tanzu plugin install` command.
9090

9191
For more detailed information on these design check out this [doc](../design/context-aware-plugin-discovery.md)

pkg/v1/cli/catalog/catalog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func Test_ContextCatalog_With_Context(t *testing.T) {
173173
// the featuregate is configured to true by default
174174
func Test_CatalogCacheFileName(t *testing.T) {
175175
assert := assert.New(t)
176-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
176+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
177177
assert.Equal(catalogCacheFileName, "catalog.yaml")
178178
}
179179
}

pkg/v1/cli/command/core/plugin_manager.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var listPluginCmd = &cobra.Command{
5858
Use: "list",
5959
Short: "List available plugins",
6060
RunE: func(cmd *cobra.Command, args []string) error {
61-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
61+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
6262
serverName := ""
6363
server, err := config.GetCurrentServer()
6464
if err == nil && server != nil {
@@ -178,7 +178,7 @@ var describePluginCmd = &cobra.Command{
178178
}
179179
pluginName := args[0]
180180

181-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
181+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
182182
serverName := ""
183183
server, err := config.GetCurrentServer()
184184
if err == nil && server != nil {
@@ -228,7 +228,7 @@ var installPluginCmd = &cobra.Command{
228228
}
229229
pluginName := args[0]
230230

231-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
231+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
232232
serverName := ""
233233
server, err := config.GetCurrentServer()
234234
if err == nil && server != nil {
@@ -287,7 +287,7 @@ var upgradePluginCmd = &cobra.Command{
287287
}
288288
pluginName := args[0]
289289

290-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
290+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
291291
serverName := ""
292292
server, err := config.GetCurrentServer()
293293
if err == nil && server != nil {
@@ -333,7 +333,7 @@ var deletePluginCmd = &cobra.Command{
333333
}
334334
pluginName := args[0]
335335

336-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
336+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
337337
serverName := ""
338338
server, err := config.GetCurrentServer()
339339
if err == nil && server != nil {
@@ -359,7 +359,7 @@ var cleanPluginCmd = &cobra.Command{
359359
Use: "clean",
360360
Short: "Clean the plugins",
361361
RunE: func(cmd *cobra.Command, args []string) (err error) {
362-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
362+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
363363
return pluginmanager.Clean()
364364
}
365365
return cli.Clean()
@@ -370,7 +370,7 @@ var syncPluginCmd = &cobra.Command{
370370
Use: "sync",
371371
Short: "Sync the plugins",
372372
RunE: func(cmd *cobra.Command, args []string) (err error) {
373-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
373+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
374374
serverName := ""
375375
server, err := config.GetCurrentServer()
376376
if err == nil && server != nil {
@@ -383,7 +383,7 @@ var syncPluginCmd = &cobra.Command{
383383
log.Success("Done")
384384
return nil
385385
}
386-
return errors.Errorf("command is only applicable if `%s` feature is enabled", config.FeatureContextAwareDiscovery)
386+
return errors.Errorf("command is only applicable if `%s` feature is enabled", config.FeatureContextAwareCLIForPlugins)
387387
},
388388
}
389389

pkg/v1/cli/command/core/root.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ func NewRootCmd() (*cobra.Command, error) {
6969
return nil, fmt.Errorf("failed to copy legacy configuration directory to new location: %w", err)
7070
}
7171

72-
// If context-aware-discovery is not enabled
72+
// If context-aware-cli-for-plugins feature is not enabled
7373
// check that all plugins in the core distro are installed or do so.
74-
if !config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
74+
if !config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
7575
plugins, err = checkAndInstallMissingPlugins(plugins)
7676
if err != nil {
7777
return nil, err
@@ -99,7 +99,7 @@ func getAvailablePlugins() ([]*v1alpha1.PluginDescriptor, error) {
9999
plugins := make([]*v1alpha1.PluginDescriptor, 0)
100100
var err error
101101

102-
if config.IsFeatureActivated(config.FeatureContextAwareDiscovery) {
102+
if config.IsFeatureActivated(config.FeatureContextAwareCLIForPlugins) {
103103
currentServerName := ""
104104

105105
server, err := config.GetCurrentServer()

pkg/v1/cli/pluginmanager/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ func availablePluginsFromStandaloneAndServerPlugins(discoveredServerPlugins, dis
178178
for i := range discoveredStandalonePlugins {
179179
matchIndex := pluginIndexForName(availablePlugins, discoveredStandalonePlugins[i].Name)
180180

181-
// Add the standalone plugin to available plugin if it doesn't exist in the serverPlugins list
181+
// Add the standalone plugin to available plugins if it doesn't exist in the serverPlugins list
182182
// OR
183-
// Current standalone discovery type is local and there is
183+
// Current standalone discovery is of type 'local'
184184
// We are overriding the discovered plugins that we got from server in case of 'local' discovery type
185185
// to allow developers to use the plugins that are built locally and not returned from the server
186186
// This local discovery is only used for development purpose and should not be used for production

pkg/v1/config/clientconfig.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import (
2020

2121
// This block is for global feature constants, to allow them to be used more broadly
2222
const (
23-
// FeatureContextAwareDiscovery determines whether to use legacy way of discovering plugins or
23+
// FeatureContextAwareCLIForPlugins determines whether to use legacy way of discovering plugins or
2424
// to use the new context-aware Plugin API based plugin discovery mechanism
2525
// Users can set this featureflag so that we can have context-aware plugin discovery be opt-in for now.
26-
FeatureContextAwareDiscovery = "features.global.context-aware-discovery"
26+
FeatureContextAwareCLIForPlugins = "features.global.context-aware-cli-for-plugins"
2727
// DualStack feature flags determine whether it is permitted to create
2828
// clusters with a dualstack TKG_IP_FAMILY. There are separate flags for
2929
// each primary, "ipv4,ipv6" vs "ipv6,ipv4", and flags for management vs
@@ -40,13 +40,20 @@ const (
4040
)
4141

4242
// DefaultCliFeatureFlags is used to populate an initially empty config file with default values for feature flags.
43-
// If a developer expects that their feature will be ready to release, they should create an entry here with a true
44-
// value. If a developer has a beta feature they want to expose, but leave turned off by default, they should create
45-
// an entry here with a false value. The keys MUST be in the format "features.<plugin>.<feature>" or initialization
43+
// The keys MUST be in the format "features.<plugin>.<feature>" or initialization
4644
// will fail. Note that "global" is a special value for <plugin> to be used for CLI-wide features.
45+
//
46+
// If a developer expects that their feature will be ready to release, they should create an entry here with a true
47+
// value.
48+
// If a developer has a beta feature they want to expose, but leave turned off by default, they should create
49+
// an entry here with a false value. WE HIGHLY RECOMMEND the use of a SEPARATE flag for beta use; one that ends in "-beta".
50+
// Thus, if you plan to eventually release a feature with a flag named "features.cluster.foo-bar", you should consider
51+
// releasing the beta version with "features.cluster.foo-bar-beta". This will make it much easier when it comes time for
52+
// mainstreaming the feature (with a default true value) under the flag name "features.cluster.foo-bar", as there will be
53+
// no conflict with previous installs (that have a false value for the entry "features.cluster.foo-bar-beta").
4754
var (
4855
DefaultCliFeatureFlags = map[string]bool{
49-
FeatureContextAwareDiscovery: common.ContextAwareDiscoveryEnabled(),
56+
FeatureContextAwareCLIForPlugins: common.ContextAwareDiscoveryEnabled(),
5057
"features.management-cluster.import": false,
5158
"features.management-cluster.export-from-confirm": true,
5259
"features.management-cluster.standalone-cluster-mode": false,

0 commit comments

Comments
 (0)