schemas

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

schemas

This library provides a common way of providing a schema for an input format. It currently supports type (coercions) and sensitive attributes.

The common interface is defined in schemas.go.

How these are generated per platform and provider wildly differs.

CloudFormation

A zip archive made available at <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-type-sc hemas.html> is embedded in the executable. We load and parse this archive when the first schema is requested.

AWS

We cannot easily import providers using the SDK V2 as Go libraries. Furthermore, these have huge and complex dependency footprints, so we would not want to embed these or include these dependencies within our own go.mod.

Instead, we have a script in tf/generate/generate.sh that clones each provider and replaces its main function by one that extracts the schemas. This way the providers can each have there own set of dependencies (as clashes seem to occur).

The resulting schemas are stored in .json.gz files per provider. These fortunately do not need to be regenerated very frequently.

On the policy engine, these .json.gz files are embedded. The first time a schema is requested, we load all of these into memory.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(val interface{}, schema *Schema) interface{}

func ApplyArray

func ApplyArray(arr []interface{}, schema *Schema) []interface{}

func ApplyObject

func ApplyObject(obj map[string]interface{}, schema *Schema) map[string]interface{}

Types

type Schema

type Schema struct {
	Type       Type               `json:"type"`
	Sensitive  bool               `json:"sensitive,omitempty"`
	Properties map[string]*Schema `json:"properties,omitempty"`
	Items      *Schema            `json:"items,omitempty"`
}

A Schema correponds to a resource or a subtree of a resource. They may contain infinite loops.

type Type

type Type string
const (
	Unknown Type = "unknown"
	Bool    Type = "bool"
	Int     Type = "int"
	Float   Type = "float"
	String  Type = "string"
	Array   Type = "array"
	Map     Type = "map"
	Object  Type = "object"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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