config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config read and validate config file

Package config provides functionality to validate YAML configuration using a JSON schema. This package defines a SchemaValidator type that allows you to validate a YAML content against a predefined JSON schema. The JSON schema is embedded using the //go:embed directive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Organization Organization      `yaml:"organization"`
	Discovery    Discovery         `yaml:"discovery"`
	Storage      Storage           `yaml:"storage"`
	Sources      map[string]Source `yaml:"source"`
	Relation     Relation          `yaml:"relations"`
}

AppConfig provides configuration for the tools

func Load

func Load(path string) (*AppConfig, error)

Load loads configuration file

type Discovery

type Discovery struct {
	Name           string `yaml:"name"`
	Description    string `yaml:"description"`
	WorkerPoolSize int    `yaml:"worker_pool_size"`
}

Discovery hold discovery configuration

type Organization

type Organization struct {
	Name string `yaml:"name"`
}

Organization store organization data

type Relation

type Relation struct {
	RelationCriteria []RelationCriteria `yaml:"criteria"`
}

Relation represent relationship rules

type RelationCriteria

type RelationCriteria struct {
	Name                 string               `yaml:"name"`
	Kind                 string               `yaml:"kind"`
	MetadataKey          string               `yaml:"metadata_key"`
	MetadataValue        string               `yaml:"metadata_value"`
	RelatedKind          string               `yaml:"related_kind"`
	RelatedMetadataKey   string               `yaml:"related_metadata_key"`
	RelatedMetadataValue string               `yaml:"related_metadata_value"`
	Source               RelationCriteriaNode `yaml:"source"`
	Target               RelationCriteriaNode `yaml:"target"`
}

RelationCriteria represents criteria for relation builder

type RelationCriteriaNode

type RelationCriteriaNode struct {
	Kind      string `yaml:"kind"`
	MetaKey   string `yaml:"meta_key"`
	MetaValue string `yaml:"meta_value"`
}

RelationCriteriaNode represent source and target

type SchemaValidator

type SchemaValidator struct {
}

SchemaValidator struct represent schema validator

func NewSchemaValidator

func NewSchemaValidator() *SchemaValidator

NewSchemaValidator construct a new validator

func (*SchemaValidator) Validate

func (sv *SchemaValidator) Validate(yamlContent string) error

Validate validates the provided YAML content against the embedded JSON schema.

type Source

type Source struct {
	Type          string            `yaml:"type"`
	Configuration map[string]string `yaml:"configuration"`
	Fields        []string          `yaml:"fields"`
	Schedule      string            `yaml:"schedule,omitempty"`
}

Source holds source configuration

type SourceConfiguration

type SourceConfiguration struct {
	RootDirectory string `yaml:"root_directory"`
}

SourceConfiguration store source configuration data

type Storage

type Storage struct {
	BatchSize     int                    `yaml:"batch_size"`
	Engines       map[string]interface{} `yaml:"engines"`
	DefaultEngine string                 `yaml:"default_engine"`
}

Storage store storage configuration

Jump to

Keyboard shortcuts

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