facts

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFact

func GetFact(fact string, file string, log Logger) ([]byte, gjson.Result, error)

GetFact looks up a single fact from the facts file, errors reading the file is reported but an absent fact is handled as empty result and no error

func GetFactJSON

func GetFactJSON(fact string, facts json.RawMessage) (gjson.Result, error)

GetFactJSON looks up a single fact from the JSON data, absent fact is handled as empty result and no error

func HasFact

func HasFact(fact string, operator string, value string, file string, log Logger) (bool, error)

HasFact evaluates the expression against facts in the file

func HasFactJSON

func HasFactJSON(fact string, operator string, value string, facts json.RawMessage, log Logger) (bool, error)

func JSON

func JSON(file string, log Logger) (json.RawMessage, error)

JSON parses the data, including doing any conversions needed, and returns JSON text

func MatchFacts

func MatchFacts(filters [][3]string, facts json.RawMessage, log Logger) bool

MatchFacts match fact filters in a OR manner, only facts matching all filters will be true

func MatchFile

func MatchFile(filters [][3]string, file string, log Logger) bool

MatchFile match fact filters in a OR manner, only nodes that have all the matching facts will be true here

func ParseFactFilterString added in v0.19.0

func ParseFactFilterString(f string) ([3]string, error)

ParseFactFilterString parses a fact filter string as typically typed on the CLI

Types

type Logger

type Logger interface {
	Warnf(format string, args ...any)
	Debugf(format string, args ...any)
	Errorf(format string, args ...any)
}

Logger provides logging facilities

Jump to

Keyboard shortcuts

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