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

feat: support for feature gates #1146

Closed
wants to merge 17 commits into from

Conversation

mandelsoft
Copy link
Contributor

@mandelsoft mandelsoft commented Nov 27, 2024

What this PR does / why we need it

This PR introduces the concept of feature gates for the OCM library/CLI.

A feature has a name and a setting.
The standard setting is a mode value. Setting the mode to off enforces the feature to be disabled.
All other mode values enable the feature and can be used by the implementation to select the way it is supported.
If a feature is not explicitly configured to have a setting it is assumed to be disabled by default.

Optionally, settings may include a arbitrary set of name/value pairs, a value might be structured.

A feature may be enabled or disabled by default, depending of the arguments to the
feature query functions.

The set of feature gates can be set on context-level by a context attribute ocm.software/ocm/feature-gates with the short name
featuregates.

Additionally, a dedicated config object is provided ( featuregates.config.ocm.software).
It supports the following config fields:

  • features: map[string]FeatureGate map of feature settings

A FeatureGate has the fields:

  • mode: string if set to off features is enforced to be disabled. Other values enable the feature
  • attributes: map[string]<any json/yaml> optional named feature settings

Which issue(s) this PR fixes

@mandelsoft mandelsoft requested a review from a team as a code owner November 27, 2024 11:02
@github-actions github-actions bot added kind/feature new feature, enhancement, improvement, extension size/m Medium labels Nov 27, 2024
// Default behavior is to be enabled if entry is given
// for a feature name and mode is not equal *off*.
type FeatureGate struct {
Mode string `json:"mode"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally in favor of this, but why choose to have a Mode setting for the Gate if you already have attributes? Shouldn't the mere presence of the gate determine if its enabled or disabled?

Copy link
Contributor Author

@mandelsoft mandelsoft Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of the mode is to have a fixed/non-optional config field usable to enable/disable a feature and control an implementation mode (if required). The value off is always used to enforce disabling the feature (in case it is enabled by default).

The attributes are completely optional and intended to pass arbitrary information to the feature. (An on/off switch does not use attributes at all (omitempty))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of the mode is to have a fixed/non-optional config field usable to enable/disable a feature and control an implementation mode (if required). The value off is always used to enforce disabling the feature (in case it is enabled by default).

Could you give me an example for an "implementation mode" that is not on/off? Ive never seen it anywhere in production and was assuming that even if there was a non on/off, it would be part of the attributes.

type FeatureGate = featuregatesattr.FeatureGate

// Config describes a memory based repository interface.
type Config struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the reason to have a config and an attribute set, shouldnt attributes alone be enough?

@github-actions github-actions bot added the component/github-actions Changes on GitHub Actions or within `.github/` directory label Nov 27, 2024
@hilmarf hilmarf self-requested a review January 6, 2025 08:56
Comment on lines +16 to +17
// Sort is a processing chain sorting original objects provided by type handler.
var Sort = processing.Sort(Compare)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of the blue...

@github-actions github-actions bot added area/documentation Documentation related component/ocm-cli OCM Command Line Interface labels Jan 6, 2025
docs/reference/ocm_ocm.md Outdated Show resolved Hide resolved
@hilmarf hilmarf added this to the 2025-Q1 milestone Jan 7, 2025
@hilmarf hilmarf enabled auto-merge (squash) January 7, 2025 10:59
@hilmarf hilmarf closed this Jan 7, 2025
auto-merge was automatically disabled January 7, 2025 14:45

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Documentation related component/github-actions Changes on GitHub Actions or within `.github/` directory component/ocm-cli OCM Command Line Interface kind/feature new feature, enhancement, improvement, extension size/l Large
Projects
Status: 🔒Closed
Development

Successfully merging this pull request may close these issues.

3 participants