Skip to content

Commit 613405f

Browse files
committed
📃 add docs to featureflags
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
1 parent bc67281 commit 613405f

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

featureflags.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
// Copyright (c) Mondoo, Inc.
22
// SPDX-License-Identifier: BUSL-1.1
33

4-
//
5-
// In this file we introduce feature flags. They help us activate optional
6-
// features on requests.
7-
//
8-
// Features can only be activated, never deactivated. Features are efficiently encoded.
9-
// They are introduced at a given version and destined to be removed at a later version.
10-
// Please mark them accordingly. Feature flags are short term contextual information.
4+
// In this file we introduce feature flags.
5+
// - Please configure any new feature-flags in features.yaml
6+
// - To generate, use go generate. See the call to go:generate below
7+
// - To learn more about the generator, look at ./utils/featureflags/main.go header
118
//
129
// Example usage:
1310
//
1411
// features := []Feature{ MassResolver, LiveQueries }
15-
//
1612
// features.IsActive( MassResolver ) // true
17-
//
1813

1914
package cnquery
2015

features.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Mondoo, Inc.
2+
# SPDX-License-Identifier: BUSL-1.1
3+
14
Features:
25
- desc: "Resolve similar queries the same way. If 100 assets have the same dependent
36
queries and overrides, \nthey create the same resolved plan. Cannot be used with
@@ -25,8 +28,8 @@ Features:
2528
id: K8sNodeDiscovery
2629
idx: 4
2730
start: v6.12
28-
status: unknown
29-
- desc: ""
31+
status: sunset, should be done via discovery code instead
32+
- desc: Add context to assets for e.g. Terraform
3033
end: v12.0
3134
id: MQLAssetContext
3235
idx: 5

utils/featureflags/main.go

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
// Copyright (c) Mondoo, Inc.
22
// SPDX-License-Identifier: BUSL-1.1
33

4+
// Generate a go source file with feature-flags and helper vars.
5+
//
6+
// You configure feature-flags in YAML. Here is an example:
7+
//
8+
// - desc: Allows MQL to use variable references across blocks. Fully changes the compiled code.
9+
// end: v7.0
10+
// id: PiperCode
11+
// start: v5.x
12+
// status: default
13+
// idx: 2 # optional, will be generated
14+
//
15+
// Status can be:
16+
// - builtin: features that are completed and have been built into the code, but shouldn't be used (or set) anymore
17+
// - sunset: features that are completed but have not been built into the code, please don't use them anymore
18+
// - new: features that are now available to be used and aren't active by default
19+
// - default: features that are available and turned on by default (you can still turn them off)
20+
// - unknown: try not to have any unknown features, we don't know what's going on with these but don't use them
21+
422
package main
523

624
import (
@@ -18,17 +36,11 @@ type (
1836
Features []*feature
1937
}
2038
feature struct {
21-
Id string `json:"id"`
22-
Idx int `json:"idx"`
23-
Start string `json:"start"`
24-
End string `json:"end,omitempty"`
25-
Desc string `json:"desc"`
26-
// Status can be:
27-
// - builtin: features that are completed and have been built into the code, but shouldn't be used (or set) anymore
28-
// - sunset: features that are completed but have not been built into the code, please don't use them anymore
29-
// - new: features that are now available to be used and aren't active by default
30-
// - default: features that are available and turned on by default (you can still turn them off)
31-
// - unknown: try not to have any unknown features, we don't know what's going on with these but don't use them
39+
Id string `json:"id"`
40+
Idx int `json:"idx"`
41+
Start string `json:"start"`
42+
End string `json:"end,omitempty"`
43+
Desc string `json:"desc"`
3244
Status string `json:"status,omitempty"`
3345
}
3446
)

0 commit comments

Comments
 (0)