diff --git a/pkg/odo/cli/feature/doc.go b/pkg/odo/cli/feature/doc.go index 7e9969f2160..ca438e05b74 100644 --- a/pkg/odo/cli/feature/doc.go +++ b/pkg/odo/cli/feature/doc.go @@ -1,2 +1,4 @@ // Package feature allows to determine whether a given feature is enabled or not at the CLI level. +// Active features are accumulated in a global `enabledFeatures` variable, and warning +// can be displayed with the DisplayWarnings function package feature diff --git a/pkg/odo/cli/feature/features.go b/pkg/odo/cli/feature/features.go index 90c985393a5..da90477a719 100644 --- a/pkg/odo/cli/feature/features.go +++ b/pkg/odo/cli/feature/features.go @@ -2,6 +2,7 @@ package feature import ( "context" + "sort" "github.com/redhat-developer/odo/pkg/log" ) @@ -28,6 +29,8 @@ var ( isExperimental: true, description: "flag: --run-on", } + + enabledFeatures = map[OdoFeature]struct{}{} ) // IsEnabled returns whether the specified feature should be enabled or not. @@ -42,8 +45,21 @@ func IsEnabled(ctx context.Context, feat OdoFeature) bool { // Features marked as experimental are enabled only if the experimental mode is set experimentalModeEnabled := isExperimentalModeEnabled(ctx) if experimentalModeEnabled { + enabledFeatures[feat] = struct{}{} + } + return experimentalModeEnabled +} + +func DisplayWarnings() { + features := make([]OdoFeature, 0, len(enabledFeatures)) + for k := range enabledFeatures { + features = append(features, k) + } + sort.Slice(features, func(i, j int) bool { + return features[i].id < features[j].id + }) + for _, feat := range features { log.Experimentalf("Experimental mode enabled for %s. Use at your own risk. More details on https://odo.dev/docs/user-guides/advanced/experimental-mode", feat.description) } - return experimentalModeEnabled } diff --git a/pkg/odo/genericclioptions/runnable.go b/pkg/odo/genericclioptions/runnable.go index b7d95ac9e40..c53cee9c682 100644 --- a/pkg/odo/genericclioptions/runnable.go +++ b/pkg/odo/genericclioptions/runnable.go @@ -26,6 +26,7 @@ import ( "gopkg.in/AlecAivazis/survey.v1" + "github.com/redhat-developer/odo/pkg/odo/cli/feature" "github.com/redhat-developer/odo/pkg/odo/cli/ui" "k8s.io/klog" @@ -202,6 +203,8 @@ func GenericRun(o Runnable, cmd *cobra.Command, args []string) error { } o.SetClientset(deps) + feature.DisplayWarnings() + ctx = fcontext.WithJsonOutput(ctx, commonflags.GetJsonOutputValue(cmdLineObj)) ctx = fcontext.WithRunOn(ctx, platform) ctx = odocontext.WithApplication(ctx, defaultAppName)