mirror of
https://github.com/safing/portbase
synced 2025-09-01 18:19:57 +00:00
Merge pull request #95 from safing/feature/annotations
Add quick-settings and requires annotation
This commit is contained in:
commit
8a39b73c9c
2 changed files with 72 additions and 1 deletions
24
Gopkg.lock
generated
24
Gopkg.lock
generated
|
@ -25,6 +25,14 @@
|
||||||
revision = "fba169763ea663f7496376e5cdf709e4c7504704"
|
revision = "fba169763ea663f7496376e5cdf709e4c7504704"
|
||||||
version = "v0.1"
|
version = "v0.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
digest = "1:5680f8c40e48f07cb77aece3165a866aaf8276305258b3b70db8ec7ad6ddb78d"
|
||||||
|
name = "github.com/armon/go-radix"
|
||||||
|
packages = ["."]
|
||||||
|
pruneopts = ""
|
||||||
|
revision = "1a2de0c21c94309923825da3df33a4381872c795"
|
||||||
|
version = "v1.0.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:baf770c4efa1883bb5e444614e85b8028bbad33913aca290a43298f65d9df485"
|
digest = "1:baf770c4efa1883bb5e444614e85b8028bbad33913aca290a43298f65d9df485"
|
||||||
|
@ -214,7 +222,10 @@
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:83fd2513b9f6ae0997bf646db6b74e9e00131e31002116fda597175f25add42d"
|
digest = "1:83fd2513b9f6ae0997bf646db6b74e9e00131e31002116fda597175f25add42d"
|
||||||
name = "github.com/stretchr/testify"
|
name = "github.com/stretchr/testify"
|
||||||
packages = ["assert"]
|
packages = [
|
||||||
|
"assert",
|
||||||
|
"require",
|
||||||
|
]
|
||||||
pruneopts = ""
|
pruneopts = ""
|
||||||
revision = "f654a9112bbeac49ca2cd45bfbe11533c4666cf8"
|
revision = "f654a9112bbeac49ca2cd45bfbe11533c4666cf8"
|
||||||
version = "v1.6.1"
|
version = "v1.6.1"
|
||||||
|
@ -278,6 +289,14 @@
|
||||||
pruneopts = ""
|
pruneopts = ""
|
||||||
revision = "0ba52f642ac2f9371a88bfdde41f4b4e195a37c0"
|
revision = "0ba52f642ac2f9371a88bfdde41f4b4e195a37c0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
digest = "1:10d47e7094ce8dd202cca920e4c58a68ba1d113908c30fb0cc8590b7d333a348"
|
||||||
|
name = "golang.org/x/sync"
|
||||||
|
packages = ["errgroup"]
|
||||||
|
pruneopts = ""
|
||||||
|
revision = "67f06af15bc961c363a7260195bcd53487529a21"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:bf837d996e7dfe7b819cbe53c8c9733e93228577f0561e43996b9ef0ea8a68a9"
|
digest = "1:bf837d996e7dfe7b819cbe53c8c9733e93228577f0561e43996b9ef0ea8a68a9"
|
||||||
|
@ -339,6 +358,7 @@
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
input-imports = [
|
input-imports = [
|
||||||
"github.com/aead/serpent",
|
"github.com/aead/serpent",
|
||||||
|
"github.com/armon/go-radix",
|
||||||
"github.com/bluele/gcache",
|
"github.com/bluele/gcache",
|
||||||
"github.com/davecgh/go-spew/spew",
|
"github.com/davecgh/go-spew/spew",
|
||||||
"github.com/dgraph-io/badger",
|
"github.com/dgraph-io/badger",
|
||||||
|
@ -351,10 +371,12 @@
|
||||||
"github.com/shirou/gopsutil/host",
|
"github.com/shirou/gopsutil/host",
|
||||||
"github.com/spf13/cobra",
|
"github.com/spf13/cobra",
|
||||||
"github.com/stretchr/testify/assert",
|
"github.com/stretchr/testify/assert",
|
||||||
|
"github.com/stretchr/testify/require",
|
||||||
"github.com/tevino/abool",
|
"github.com/tevino/abool",
|
||||||
"github.com/tidwall/gjson",
|
"github.com/tidwall/gjson",
|
||||||
"github.com/tidwall/sjson",
|
"github.com/tidwall/sjson",
|
||||||
"go.etcd.io/bbolt",
|
"go.etcd.io/bbolt",
|
||||||
|
"golang.org/x/sync/errgroup",
|
||||||
"golang.org/x/sys/windows",
|
"golang.org/x/sys/windows",
|
||||||
]
|
]
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
|
|
|
@ -84,8 +84,57 @@ const (
|
||||||
// SubsystemAnnotation can be used to mark an option as part
|
// SubsystemAnnotation can be used to mark an option as part
|
||||||
// of a module subsystem.
|
// of a module subsystem.
|
||||||
SubsystemAnnotation = "safing/portbase:module:subsystem"
|
SubsystemAnnotation = "safing/portbase:module:subsystem"
|
||||||
|
// QuickSettingAnnotation can be used to add quick settings to
|
||||||
|
// a configuration option. A quick setting can support the user
|
||||||
|
// by switching between pre-configured values.
|
||||||
|
// The type of a quick-setting annotation is []QuickSetting or QuickSetting.
|
||||||
|
QuickSettingsAnnotation = "safing/portbase:ui:quick-setting"
|
||||||
|
// RequiresAnnotation can be used to mark another option as a
|
||||||
|
// requirement. The type of RequiresAnnotation is []ValueRequirement
|
||||||
|
// or ValueRequirement.
|
||||||
|
RequiresAnnotation = "safing/portbase:config:requires"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// QuickSettingsAction defines the action of a quick setting.
|
||||||
|
type QuickSettingsAction string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// QuickReplace replaces the current setting with the one from
|
||||||
|
// the quick setting.
|
||||||
|
QuickReplace = QuickSettingsAction("replace")
|
||||||
|
// QuickMergeTop merges the value of the quick setting with the
|
||||||
|
// already configured one adding new values on the top. Merging
|
||||||
|
// is only supported for OptTypeStringArray.
|
||||||
|
QuickMergeTop = QuickSettingsAction("merge-top")
|
||||||
|
// QuickMergeBottom merges the value of the quick setting with the
|
||||||
|
// already configured one adding new values at the bottom. Merging
|
||||||
|
// is only supported for OptTypeStringArray.
|
||||||
|
QuickMergeBottom = QuickSettingsAction("merge-bottom")
|
||||||
|
)
|
||||||
|
|
||||||
|
// QuickSetting defines a quick setting for a configuration option and
|
||||||
|
// should be used together with the QuickSettingsAnnotation.
|
||||||
|
type QuickSetting struct {
|
||||||
|
// Name is the name of the quick setting.
|
||||||
|
Name string
|
||||||
|
|
||||||
|
// Value is the value that the quick-setting configures. It must match
|
||||||
|
// the expected value type of the annotated option.
|
||||||
|
Value interface{}
|
||||||
|
|
||||||
|
// Action defines the action of the quick setting.
|
||||||
|
Action QuickSettingsAction
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueRequirement defines a requirement on another configuraiton option.
|
||||||
|
type ValueRequirement struct {
|
||||||
|
// Key is the key of the configuration option that is required.
|
||||||
|
Key string
|
||||||
|
|
||||||
|
// Value that is required.
|
||||||
|
Value interface{}
|
||||||
|
}
|
||||||
|
|
||||||
// Values for the DisplayHintAnnotation
|
// Values for the DisplayHintAnnotation
|
||||||
const (
|
const (
|
||||||
// DisplayHintOneOf is used to mark an option
|
// DisplayHintOneOf is used to mark an option
|
||||||
|
|
Loading…
Add table
Reference in a new issue