deckformat

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	VersionKey   = "_format_version"
	TransformKey = "_transform"
	HistoryKey   = "_ignore" // the top-level key in deck files for storing history info
)

Variables

View Source
var EntityPointers = map[string][]string{

	"acls": {
		"$.acls[*]",
		"$.consumers[*].acls[*]",
	},
	"basicauth_credentials": {
		"$.basicauth_credentials[*]",
		"$.consumers[*].basicauth_credentials[*]",
	},
	"ca_certificates": {
		"$.ca_certificates[*]",
	},
	"certificates": {
		"$.certificates[*]",
	},
	"consumer_group_consumers": {
		"$.consumer_group_consumers[*]",
	},
	"consumer_group_plugins": {
		"$.consumer_group_plugins[*]",
		"$.consumer_groups[*].consumer_group_plugins[*]",
	},
	"consumer_groups": {
		"$.consumer_groups[*]",
	},
	"consumers": {
		"$.consumers[*]",
	},
	"document_objects": {
		"$.document_objects[*]",
		"$.services[*].document_objects[*]",
	},
	"hmacauth_credentials": {
		"$.hmacauth_credentials[*]",
		"$.consumers[*].hmacauth_credentials[*]",
	},
	"jwt_secrets": {
		"$.jwt_secrets[*]",
		"$.consumers[*].jwt_secrets[*]",
	},
	"keyauth_credentials": {
		"$.keyauth_credentials[*]",
		"$.consumers[*].keyauth_credentials[*]",
	},
	"mtls_auth_credentials": {
		"$.mtls_auth_credentials[*]",
		"$.consumers[*].mtls_auth_credentials[*]",
		"$.ca_certificates[*].mtls_auth_credentials[*]",
	},
	"oauth2_credentials": {
		"$.oauth2_credentials[*]",
		"$.consumers[*].oauth2_credentials[*]",
	},
	"plugins": {
		"$.plugins[*]",
		"$.routes[*].plugins[*]",
		"$.services[*].plugins[*]",
		"$.services[*].routes[*].plugins[*]",
		"$.consumers[*].plugins[*]",
		"$.consumer_group_plugins[*]",
		"$.consumer_groups[*].consumer_group_plugins[*]",
		"$.consumer_groups[*].plugins[*]",
	},
	"rbac_role_endpoints": {
		"$.rbac_role_endpoints[*]",
		"$.rbac_roles[*].rbac_role_endpoints[*]",
	},
	"rbac_role_entities": {
		"$.rbac_role_entities[*]",
		"$.rbac_roles[*].rbac_role_entities[*]",
	},
	"rbac_roles": {
		"$.rbac_roles[*]",
	},
	"routes": {
		"$.routes[*]",
		"$.services[*].routes[*]",
	},
	"services": {
		"$.services[*]",
	},
	"snis": {
		"$.snis[*]",
		"$.certificates[*].snis[*]",
	},
	"targets": {
		"$.targets[*]",
		"$.upstreams[*].targets[*]",
		"$.certificates[*].upstreams[*].targets[*]",
	},
	"upstreams": {
		"$.upstreams[*]",
		"$.certificates[*].upstreams[*]",
	},
	"vaults": {
		"$.vaults[*]",
	},
}

EntityPointers is a map of entity names to an array of JSONpointers that can be used to find all of those entities in a deck file. For example; credentials typically can be under their own top-level key, or nested under a consumer. Additional sets are dynamically added (capitalized) for other common uses. e.g. "PluginOwners" is a list of all entities that can hold plugins.

Functions

func CompatibleFile

func CompatibleFile(data1 map[string]interface{}, data2 map[string]interface{}) error

CompatibleFile returns nil if the files are compatible. An error otherwise. see CompatibleVersion and CompatibleTransform for what compatibility means.

func CompatibleTransform

func CompatibleTransform(data1 map[string]interface{}, data2 map[string]interface{}) error

CompatibleTransform checks if 2 files are compatible, by '_transform' keys. Returns nil if compatible, and error otherwise.

func CompatibleVersion

func CompatibleVersion(data1 map[string]interface{}, data2 map[string]interface{}) error

CompatibleVersion checks if 2 files are compatible, by '_format_version'. Version is compatible if they are the same major. Missing versions are assumed to be compatible. Returns nil if compatible, and error otherwise.

func ConvertDBless added in v0.1.14

func ConvertDBless(data map[string]interface{}) (map[string]interface{}, error)

ConvertDBless converts a DBless format to a decK type format. This updates the consumer-groups related entities into nested objects, since that is an operation that is too complex to do via a CLI.

func GetEntities added in v0.1.27

func GetEntities(deckfile *yaml.Node, entityType string) []*yaml.Node

GetEntities returns all entities of a given type found within the yamlNode. The result will never be nil, but can be an empty array. The deckfile may be nil, the entityType must be a valid entity type, or it will panic.

func HistoryAppend added in v0.1.10

func HistoryAppend(filedata map[string]interface{}, newEntry interface{})

HistoryAppend appends an entry (if non-nil) to the history info array. If there is no array, it will create one.

func HistoryClear added in v0.1.10

func HistoryClear(filedata map[string]interface{})

func HistoryGet added in v0.1.10

func HistoryGet(filedata map[string]interface{}) (historyArray []interface{})

HistoryGet returns a the history info array. If there is none, or if filedata is nil, it will return an empty one.

func HistoryNewEntry added in v0.1.10

func HistoryNewEntry(cmd string) map[string]interface{}

HistoryNewEntry returns a new JSONobject with tool version and command keys set.

func HistorySet added in v0.1.10

func HistorySet(filedata map[string]interface{}, historyArray []interface{})

HistorySet sets the history info array. Setting to nil will delete the history.

func ParseFormatVersion

func ParseFormatVersion(data map[string]interface{}) (int, int, error)

parseFormatVersion parses field `_format_version` and returns major+minor. Field must be present, a string, and have an 'x.y' format. Returns an error otherwise.

func ToolVersionGet added in v0.1.10

func ToolVersionGet() (name string, version string, commit string)

ToolVersionGet returns the individual components of the info

func ToolVersionSet added in v0.1.10

func ToolVersionSet(name string, version string, commit string)

ToolVersionSet can be called once to set the tool info that is reported in the history. The 'version' and 'commit' strings are optional. Omitting them (lower cardinality) makes for a better GitOps experience, but provides less detail.

func ToolVersionString added in v0.1.10

func ToolVersionString() string

ToolVersionString returns the info in a single formatted string. eg. "decK 1.2 (123abc)"

Types

This section is empty.

Jump to

Keyboard shortcuts

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