Skip to content

Commit fcc86c5

Browse files
authored
[Feature] Features startup logging (#1312)
1 parent 105b6bf commit fcc86c5

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- (Feature) PersistentVolume Inspector
77
- (Bugfix) Discover Arango image during ID phase
88
- (Feature) PV Unschedulable condition
9+
- (Feature) Features startup logging
910

1011
## [1.2.27](https://github.com/arangodb/kube-arangodb/tree/1.2.27) (2023-04-27)
1112
- (Feature) Add InSync Cache

cmd/cmd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ func executeMain(cmd *cobra.Command, args []string) {
295295

296296
logger.Info("nice to meet you")
297297

298+
// Print all enabled featured
299+
features.Iterate(func(name string, feature features.Feature) {
300+
logger.Info("Operator Feature %s (%s) is %s.", name, features.GetFeatureArgName(name), util.BoolSwitch(feature.Enabled(), "enabled", "disabled"))
301+
})
302+
298303
// Check operating mode
299304
if !operatorOptions.enableDeployment && !operatorOptions.enableDeploymentReplication && !operatorOptions.enableStorage &&
300305
!operatorOptions.enableBackup && !operatorOptions.enableApps && !operatorOptions.enableK2KClusterSync {

pkg/deployment/features/local.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -59,6 +59,19 @@ var internalCMD = &cobra.Command{
5959
Run: cmdRun,
6060
}
6161

62+
// Iterator defines feature definition iterator
63+
type Iterator func(name string, feature Feature)
64+
65+
// Iterate allows to iterate over all registered functions
66+
func Iterate(iterator Iterator) {
67+
featuresLock.Lock()
68+
defer featuresLock.Unlock()
69+
70+
for name, feature := range features {
71+
iterator(name, feature)
72+
}
73+
}
74+
6275
// Init initializes all registered features.
6376
// If a feature is not provided via process's argument, then it is taken from environment variable
6477
// or from enabled by default setting.

pkg/util/refs.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -146,6 +146,15 @@ func UInt16OrDefault(input *uint16, defaultValue ...uint16) uint16 {
146146
return *input
147147
}
148148

149+
// BoolSwitch define bool switch for defined types - in case of true t T is returned, in case of false f T
150+
func BoolSwitch[T interface{}](s bool, t, f T) T {
151+
if s {
152+
return t
153+
}
154+
155+
return f
156+
}
157+
149158
// NewBool returns a reference to a bool with given value.
150159
func NewBool(input bool) *bool {
151160
return &input

0 commit comments

Comments
 (0)