Documentation ¶
Overview ¶
Copyright 2021 Cloud Privacy Labs, LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 Cloud Privacy Labs, LLC ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- type Bundle
- func (bundle *Bundle) Add(ctx *ls.Context, typeName string, schema *ls.Layer, overlays ...*ls.Layer) (*ls.Layer, error)
- func (bundle *Bundle) Build(ctx *ls.Context, ...) error
- func (bundle *Bundle) GetCachedLayers() map[string]*ls.Layer
- func (bundle *Bundle) GetLayer(ctx *ls.Context, variant string) (*ls.Layer, error)
- func (bundle *Bundle) LoadSchema(variant string) (*ls.Layer, error)
- func (b *Bundle) Merge(bundle Bundle)
- type JSONSchema
- type JSONSchemaReference
- type SchemaRef
- type SpreadsheetReference
- type Variant
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bundle ¶
type Bundle struct { Base string `json:"base" yaml:"base"` Spreadsheets []SpreadsheetReference `json:"spreadsheets" yaml:"spreadsheets"` JSONSchemas []JSONSchema `json:"jsonSchemas" yaml:"jsonSchemas"` Variants map[string]*Variant `json:"variants" yaml:"variants"` // Layers, keyed by layer ID Layers map[string]*ls.Layer // contains filtered or unexported fields }
Bundle defines type names for variants so references can be resolved
func LoadBundle ¶
func LoadBundle(base string, bundleLoader func(parentBundle, loadBundle string) (Bundle, error)) (Bundle, error)
LoadBundle loads a bundle and all the bundles it includes. The bundleLoader is called with the parent bundle name, and the next bundle to load. Parent bundle name can be empty, which means, that is the first bundle to load.
func NewBundleFromVariants ¶
NewBundleFromVariants creates a new bundle from the given variants
func (*Bundle) Add ¶
func (bundle *Bundle) Add(ctx *ls.Context, typeName string, schema *ls.Layer, overlays ...*ls.Layer) (*ls.Layer, error)
Add a new variant to the bundle. The typeName must be unique. If empty, schema type will be used. If there are overlays, the variant will be built using the schema as the base, so caller must create a clone if necessary.
func (*Bundle) Build ¶
func (bundle *Bundle) Build(ctx *ls.Context, spreadsheetLoader func(*ls.Context, string) ([][][]string, error), jsonLoader func(*ls.Context, string) (io.ReadCloser, error), layerLoader func(*ls.Context, string) (*ls.Layer, error)) error
Build collects all parts of a bundle and builds the layers
type JSONSchema ¶
type JSONSchema struct { // NAme of the JSON schema. This name is passed to the json schema // loader to load the schema Name string `json:"name" yaml:"name"` // The ID of the JSON schema. This ID will be used to reference to // this schema within the bundle ID string `json:"id" yaml:"id"` // JSON schema overlays. These overlays are also JSON schemas Overlays []string `json:"overlays" yaml:"overlays"` }
A JSONSchema is a reference to a JSON schema document, with optional overlays. The JSON schema is loaded, and combined with the specified overlays. Then, it is made available to the bundle using the ID
type JSONSchemaReference ¶
type JSONSchemaReference struct { // Refer to a layer by ID. Layer can be imported as a spreadsheet LayerID string `json:"layerId" yaml:"layerId" bson:"layerId"` // This is the reference to the JSON schema defined in the bundle, with an optional fragment Ref string `json:"ref" yaml:"ref" bson:"ref"` Namespace string `json:"namespace" yaml:"namespace" bson:"namespace"` }
func (JSONSchemaReference) GetSchemaBase ¶
func (j JSONSchemaReference) GetSchemaBase() string
GetSchemaBase returns the JSON schema base name, without the fragment
type SchemaRef ¶
type SchemaRef struct { Schema string `json:"schema,omitempty" yaml:"schema,omitempty"` LayerID string `json:"layerId,omitempty" yaml:"layerId,omitempty"` JSONSchema *JSONSchemaReference `json:"jsonSchema" yaml:"jsonSchema"` // contains filtered or unexported fields }
type SpreadsheetReference ¶
type SpreadsheetReference struct { Name string `json:"name" yaml:"name"` Spec *csv.CSVImportSpec `json:"spec" yaml:"spec"` Context []interface{} `json:"context" yaml:"context"` }