feature.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. Copyright © The ESO Authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. https://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. // Package feature provides functionality related to feature flags and feature management.
  14. package feature
  15. import (
  16. "github.com/spf13/pflag"
  17. )
  18. // Feature contains the CLI flags that a provider exposes to a user.
  19. // A optional Initialize func is called once the flags have been parsed.
  20. // A provider can use this to do late-initialization using the defined cli args.
  21. type Feature struct {
  22. Flags *pflag.FlagSet
  23. Initialize func()
  24. }
  25. var features = make([]Feature, 0)
  26. // Features returns all registered features.
  27. func Features() []Feature {
  28. return features
  29. }
  30. // Register registers a new feature.
  31. func Register(f Feature) {
  32. features = append(features, f)
  33. }