modes

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestModes = map[string]string{
	"ent":    "Nomad Autoscaler Enterprise",
	"pro":    "Nomad Autoscaler Pro",
	"expert": "Nomad Autoscaler Expert",
}

Functions

This section is empty.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker verifies if a set of CLI flags or the fields of an HCL struct object follow the required mode rules.

func NewChecker

func NewChecker(modes map[string]string, enabled []string) *Checker

NewChecker returns a new Checker with the given modes, some of them enabled.

func (*Checker) Flag

func (c *Checker) Flag(name string, modes []string, fn func(string))

Flag wraps the function call to set a flag to register it wit specific modes requirements.

func (*Checker) ValidateFlags

func (c *Checker) ValidateFlags(flags *flag.FlagSet) error

ValidateFlags validates that all flags that have been set fulfill the mode requirements.

func (*Checker) ValidateStruct

func (c *Checker) ValidateStruct(s interface{}) error

ValidateStruct validates if the non-zero fields of a struct follow the mode requirement set for them.

type TestDeepNested

type TestDeepNested struct {
	DeepNestedPro bool `hcl:"deep_nested_pro" modes:"pro"`
}

type TestNestedStruct

type TestNestedStruct struct {
	NestedField    bool `hcl:"nested_field_none"`
	NestedFieldEnt bool `hcl:"nested_field_ent" modes:"ent"`

	DeepNested *TestDeepNested `hcl:"deep_nested,block"`
}

type TestStruct

type TestStruct struct {
	TopLevelNone        bool `hcl:"top_level_none"`
	TopLevelEnt         bool `hcl:"top_level_ent" modes:"ent"`
	TopLevelExpert      bool `hcl:"top_level_expert" modes:"expert"`
	TopLevelEntOrExpert bool `hcl:"top_level_ent_expert" modes:"ent,expert"`
	TopLevelPro         bool `hcl:"top_level_pro" modes:"pro"`

	NestedNone      *TestNestedStruct `hcl:"nested_none,block"`
	NestedPro       *TestNestedStruct `hcl:"nested_pro,block" modes:"pro"`
	NestedProExpert *TestNestedStruct `hcl:"nested_pro_expert,block" modes:"pro,expert"`

	NonPointerNestedEnt TestNestedStruct `hcl:"non_pointer_nested_ent,block" modes:"ent"`

	NestedMultiple []*TestNestedStruct `hcl:"nested_multiple,block"`
}

func NewTestStruct

func NewTestStruct() *TestStruct

func NewTestStructFull

func NewTestStructFull() *TestStruct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL