config

package
v0.0.0-...-260b785 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EndpointKindInternal describes a simple or straight forward web-hook call
	EndpointKindInternal EndpointKind = "internal"

	// EndpointKindExternal describes an endpoint on an external server
	EndpointKindExternal EndpointKind = "external"

	// EndpointKindPrepared describes an endpoint on on Space Cloud GraphQL layer
	EndpointKindPrepared EndpointKind = "prepared"

	// EndpointRequestPayloadFormatJSON specifies json payload format for the request
	EndpointRequestPayloadFormatJSON string = "json"

	// EndpointRequestPayloadFormatFormData specifies multipart/form-data payload format for the request
	EndpointRequestPayloadFormatFormData string = "form-data"
)

Variables

ResourceFetchingOrder order is according to space cli apply functionality

Functions

func GenerateResourceID

func GenerateResourceID(clusterID, projectID string, resourceType Resource, arr ...string) string

GenerateResourceID This a generic function for all resource to generate a unique id in a space cloud cluster params are in the form (clusterId,projectId,idOfCurrentResource) for most of the resources database resources are the exception they take the form (clusterId,projectId,dbAlias,idOfCurrentResource)

func StoreConfigToFile

func StoreConfigToFile(conf *Config, path string) error

StoreConfigToFile stores the config file to disk

Types

type Admin

type Admin struct {
	ClusterConfig *ClusterConfig `json:"clusterConfig" yaml:"clusterConfig" mapstructure:"clusterConfig"`
	Integrations  Integrations   `json:"integrations" yaml:"integrations" mapstructure:"integrations"`
}

Admin holds the admin config

type AdminUser

type AdminUser struct {
	User   string `json:"user" yaml:"user" mapstructure:"user"`
	Pass   string `json:"pass" yaml:"pass" mapstructure:"pass"`
	Secret string `json:"secret" yaml:"secret" mapstructure:"secret"`
}

AdminUser holds the user credentials and scope

type Attributes

type Attributes map[string][]string

Attributes describes the attributes of an integration resource.

type AuthStub

type AuthStub struct {
	ID      string `json:"id" yaml:"id" mapstructure:"id"`
	Enabled bool   `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
	Secret  string `json:"secret" yaml:"secret" mapstructure:"secret"`
}

AuthStub holds the config at a single sign in level

type Auths

type Auths map[string]*AuthStub // The key here is the sign in method

Auths holds the mapping of the sign in method

type CacheConfig

type CacheConfig struct {
	Enabled bool   `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
	Conn    string `json:"conn" yaml:"conn" mapstructure:"conn"`

	// Represents Time To Live in seconds, default value is 5 minutes (5 * 60 seconds) if not provided
	DefaultTTL int `json:"defaultTTL" yaml:"defaultTTL" mapstructure:"defaultTTL"`
}

CacheConfig describes the config of the caching module

type ClusterConfig

type ClusterConfig struct {
	LetsEncryptEmail string `json:"letsencryptEmail" yaml:"letsencryptEmail" mapstructure:"letsencryptEmail"`
	EnableTelemetry  bool   `json:"enableTelemetry" yaml:"enableTelemetry" mapstructure:"enableTelemetry"`
}

ClusterConfig holds the cluster level configuration

type Config

type Config struct {
	Projects         Projects         `json:"projects" yaml:"projects" mapstructure:"projects"` // The key here is the project id
	SSL              *SSL             `json:"ssl" yaml:"ssl" mapstructure:"ssl"`
	ClusterConfig    *ClusterConfig   `json:"clusterConfig" yaml:"clusterConfig" mapstructure:"clusterConfig"`
	Integrations     Integrations     `json:"integrations" yaml:"integrations" mapstructure:"integrations"`
	IntegrationHooks IntegrationHooks `json:"integrationsHooks" yaml:"integrationsHooks" mapstructure:"integrationsHooks"`
	CacheConfig      *CacheConfig     `json:"cacheConfig" yaml:"cacheConfig" mapstructure:"cacheConfig"`
}

Config holds the entire configuration

func GenerateEmptyConfig

func GenerateEmptyConfig() *Config

GenerateEmptyConfig creates an empty config file

func LoadConfigFromFile

func LoadConfigFromFile(path string) (*Config, error)

LoadConfigFromFile loads the config from the provided file path

type Crud

type Crud map[string]*CrudStub // The key here is the alias for database type

Crud holds the mapping of database level configuration

type CrudStub

type CrudStub struct {
	Type            string                           `json:"type,omitempty" yaml:"type" mapstructure:"type"` // database type
	DBName          string                           `json:"name,omitempty" yaml:"name" mapstructure:"name"` // name of the logical database or schema name according to the database type
	Conn            string                           `json:"conn,omitempty" yaml:"conn" mapstructure:"conn"`
	Collections     map[string]*TableRule            `json:"collections,omitempty" yaml:"collections" mapstructure:"collections"` // The key here is table name
	PreparedQueries map[string]*DatbasePreparedQuery `json:"preparedQueries,omitempty" yaml:"preparedQueries" mapstructure:"preparedQueries"`
	IsPrimary       bool                             `json:"isPrimary" yaml:"isPrimary" mapstructure:"isPrimary"`
	Enabled         bool                             `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
	BatchTime       int                              `json:"batchTime,omitempty" yaml:"batchTime" mapstructure:"batchTime"`          // time in milli seconds
	BatchRecords    int                              `json:"batchRecords,omitempty" yaml:"batchRecords" mapstructure:"batchRecords"` // indicates number of records per batch
	Limit           int64                            `json:"limit,omitempty" yaml:"limit" mapstructure:"limit"`                      // indicates number of records per batch
}

CrudStub holds the config at the database level

type DatabaseConfig

type DatabaseConfig struct {
	DbAlias      string       `json:"dbAlias,omitempty" yaml:"dbAlias" mapstructure:"dbAlias"`
	Type         string       `json:"type,omitempty" yaml:"type" mapstructure:"type"` // database type
	DBName       string       `json:"name,omitempty" yaml:"name" mapstructure:"name"` // name of the logical database or schema name according to the database type
	Conn         string       `json:"conn,omitempty" yaml:"conn" mapstructure:"conn"`
	IsPrimary    bool         `json:"isPrimary" yaml:"isPrimary" mapstructure:"isPrimary"`
	Enabled      bool         `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
	BatchTime    int          `json:"batchTime,omitempty" yaml:"batchTime" mapstructure:"batchTime"`          // time in milli seconds
	BatchRecords int          `json:"batchRecords,omitempty" yaml:"batchRecords" mapstructure:"batchRecords"` // indicates number of records per batch
	Limit        int64        `json:"limit,omitempty" yaml:"limit" mapstructure:"limit"`                      // indicates number of records to send per request
	DriverConf   DriverConfig `json:"driverConf,omitempty" yaml:"driverConf" mapstructure:"driverConf"`
}

DatabaseConfig stores information of database config

type DatabaseConfigs

type DatabaseConfigs map[string]*DatabaseConfig // Key here is resource id --> clusterId--projectId--resourceType--dbAlias

DatabaseConfigs is a map which stores database config information

type DatabasePreparedQueries

type DatabasePreparedQueries map[string]*DatbasePreparedQuery // Key here is resource id --> clusterId--projectId--resourceType--dbAlias-prepareQueryId

DatabasePreparedQueries is a map which stores database prepared query information

type DatabaseRule

type DatabaseRule struct {
	Table                   string           `json:"col,omitempty" yaml:"col" mapstructure:"col"`
	DbAlias                 string           `json:"dbAlias,omitempty" yaml:"dbAlias" mapstructure:"dbAlias"`
	IsRealTimeEnabled       bool             `json:"isRealtimeEnabled,omitempty" yaml:"isRealtimeEnabled" mapstructure:"isRealtimeEnabled"`
	EnableCacheInvalidation bool             `json:"enableCacheInvalidation,omitempty" yaml:"enableCacheInvalidation" mapstructure:"enableCacheInvalidation"`
	Rules                   map[string]*Rule `json:"rules,omitempty" yaml:"rules" mapstructure:"rules"`
}

DatabaseRule stores information of db rule

type DatabaseRules

type DatabaseRules map[string]*DatabaseRule // Key here is resource id --> clusterId--projectId--resourceType--dbAlias-tableName-rule

DatabaseRules is a map which stores database rules information

type DatabaseSchema

type DatabaseSchema struct {
	Table   string `json:"col,omitempty" yaml:"col" mapstructure:"col"`
	DbAlias string `json:"dbAlias,omitempty" yaml:"dbAlias" mapstructure:"dbAlias"`
	Schema  string `json:"schema,omitempty" yaml:"schema" mapstructure:"schema"`
}

DatabaseSchema stores information of db schemas

type DatabaseSchemas

type DatabaseSchemas map[string]*DatabaseSchema // Key here is resource id --> clusterId--projectId--resourceType--dbAlias-tableName

DatabaseSchemas is a map which stores database schema information

type DatbasePreparedQuery

type DatbasePreparedQuery struct {
	ID        string   `json:"id" yaml:"id" mapstructure:"id"`
	SQL       string   `json:"sql" yaml:"sql" mapstructure:"sql"`
	Rule      *Rule    `json:"rule" yaml:"rule" mapstructure:"rule"`
	DbAlias   string   `json:"dbAlias" yaml:"dbAlias" mapstructure:"dbAlias"`
	Arguments []string `json:"args" yaml:"args" mapstructure:"args"`
}

DatbasePreparedQuery stores information of prepared query

type Deployments

type Deployments struct {
	Services interface{} `json:"services" yaml:"services" mapstructure:"services"`
}

Deployments store all services information for particular project

type DriverConfig

type DriverConfig struct {
	MaxConn        int    `json:"maxConn,omitempty" yaml:"maxConn,omitempty" mapstructure:"maxConn"`                      // for SQL and Mongo
	MaxIdleTimeout int    `json:"maxIdleTimeout,omitempty" yaml:"maxIdleTimeout,omitempty" mapstructure:"maxIdleTimeout"` // for SQL and Mongo
	MinConn        uint64 `json:"minConn,omitempty" yaml:"minConn,omitempty" mapstructure:"minConn"`                      // only for Mongo
	MaxIdleConn    int    `json:"maxIdleConn,omitempty" yaml:"maxIdleConn,omitempty" mapstructure:"maxIdleConn"`          // only for SQL
}

DriverConfig stores the parameters for drivers of Databases.

type Endpoint

type Endpoint struct {
	Kind EndpointKind     `json:"kind" yaml:"kind" mapstructure:"kind"`
	Tmpl TemplatingEngine `json:"template,omitempty" yaml:"template,omitempty" mapstructure:"template"`
	// ReqPayloadFormat specifies the payload format
	// depending upon the payload format, the graphQL request that
	// gets converted to http request will use that format as it's payload
	// currently supported formats are application/json,multipart/form-data
	ReqPayloadFormat string   `json:"requestPayloadFormat" yaml:"requestPayloadFormat" mapstructure:"requestPayloadFormat"`
	ReqTmpl          string   `json:"requestTemplate" yaml:"requestTemplate" mapstructure:"requestTemplate"`
	GraphTmpl        string   `json:"graphTemplate" yaml:"graphTemplate" mapstructure:"graphTemplate"`
	ResTmpl          string   `json:"responseTemplate" yaml:"responseTemplate" mapstructure:"responseTemplate"`
	OpFormat         string   `json:"outputFormat,omitempty" yaml:"outputFormat,omitempty" mapstructure:"outputFormat"`
	Token            string   `json:"token,omitempty" yaml:"token,omitempty" mapstructure:"token"`
	Claims           string   `json:"claims,omitempty" yaml:"claims,omitempty" mapstructure:"claims"`
	Method           string   `json:"method" yaml:"method" mapstructure:"method"`
	Path             string   `json:"path" yaml:"path" mapstructure:"path"`
	Rule             *Rule    `json:"rule,omitempty" yaml:"rule,omitempty" mapstructure:"rule"`
	Headers          Headers  `json:"headers,omitempty" yaml:"headers,omitempty" mapstructure:"headers"`
	Timeout          int      `json:"timeout,omitempty" yaml:"timeout,omitempty" mapstructure:"timeout"` // Timeout is in seconds
	CacheOptions     []string `json:"cacheOptions" yaml:"cacheOptions" mapstructure:"cacheOptions"`
}

Endpoint holds the config of a endpoint

type EndpointKind

type EndpointKind string

EndpointKind describes the type of endpoint. Default value - internal

type Eventing

type Eventing struct {
	Enabled       bool                        `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
	DBAlias       string                      `json:"dbAlias" yaml:"dbAlias" mapstructure:"dbAlias"`
	Rules         map[string]*EventingTrigger `json:"triggers,omitempty" yaml:"triggers" mapstructure:"triggers"`
	InternalRules map[string]*EventingTrigger `json:"internalTriggers,omitempty" yaml:"internalTriggers,omitempty" mapstructure:"internalTriggers"`
	SecurityRules map[string]*Rule            `json:"securityRules,omitempty" yaml:"securityRules,omitempty" mapstructure:"securityRules"`
	Schemas       map[string]SchemaObject     `json:"schemas,omitempty" yaml:"schemas,omitempty" mapstructure:"schemas"`
}

Eventing holds the config for the eventing module (task queue)

type EventingConfig

type EventingConfig struct {
	Enabled       bool             `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
	DBAlias       string           `json:"dbAlias" yaml:"dbAlias" mapstructure:"dbAlias"`
	InternalRules EventingTriggers `json:"internalRules,omitempty" yaml:"internalRules,omitempty" mapstructure:"internalRules"`
}

EventingConfig stores information of eventing config

type EventingRules

type EventingRules map[string]*Rule // Key here is resource id --> clusterId--projectId--resourceType--ruleId

EventingRules is a map which stores database config information

type EventingSchema

type EventingSchema struct {
	ID     string `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id"`
	Schema string `json:"schema" yaml:"schema" mapstructure:"schema"`
}

EventingSchema stores information of eventing schema

type EventingSchemas

type EventingSchemas map[string]*EventingSchema // Key here is resource id --> clusterId--projectId--resourceType--schemaId

EventingSchemas is a map which stores eventing schema information

type EventingTrigger

type EventingTrigger struct {
	Type            string            `json:"type" yaml:"type" mapstructure:"type"`
	Retries         int               `json:"retries" yaml:"retries" mapstructure:"retries"`
	Timeout         int               `json:"timeout" yaml:"timeout" mapstructure:"timeout"` // Timeout is in milliseconds
	ID              string            `json:"id" yaml:"id" mapstructure:"id"`
	URL             string            `json:"url" yaml:"url" mapstructure:"url"`
	Options         map[string]string `json:"options" yaml:"options" mapstructure:"options"`
	Tmpl            TemplatingEngine  `json:"template,omitempty" yaml:"template,omitempty" mapstructure:"template"`
	RequestTemplate string            `json:"requestTemplate,omitempty" yaml:"requestTemplate,omitempty" mapstructure:"requestTemplate"`
	OpFormat        string            `json:"outputFormat,omitempty" yaml:"outputFormat,omitempty" mapstructure:"outputFormat"`
	Claims          string            `json:"claims" yaml:"claims" mapstructure:"claims"`
	Filter          *Rule             `json:"filter" yaml:"filter" mapstructure:"filter"`
	TriggerType     string            `json:"triggerType" yaml:"triggerType" mapstructure:"triggerType"`
}

EventingTrigger stores information of eventing trigger

type EventingTriggers

type EventingTriggers map[string]*EventingTrigger // Key here is resource id --> clusterId--projectId--resourceType--triggerId

EventingTriggers is a map which stores database config information

type FileRule

type FileRule struct {
	ID     string           `json:"id" yaml:"id" mapstructure:"id"`
	Prefix string           `json:"prefix" yaml:"prefix" mapstructure:"prefix"`
	Rule   map[string]*Rule `json:"rule" yaml:"rule" mapstructure:"rule"` // The key can be create, read, delete
}

FileRule is the authorization object at the file rule level

type FileStore

type FileStore struct {
	Enabled        bool        `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
	StoreType      string      `json:"storeType" yaml:"storeType" mapstructure:"storeType"`
	Conn           string      `json:"conn" yaml:"conn" mapstructure:"conn"`
	Endpoint       string      `json:"endpoint" yaml:"endpoint" mapstructure:"endpoint"`
	Bucket         string      `json:"bucket" yaml:"bucket" mapstructure:"bucket"`
	Secret         string      `json:"secret" yaml:"secret" mapstructure:"secret"`
	Rules          []*FileRule `json:"rules,omitempty" yaml:"rules" mapstructure:"rules"`
	DisableSSL     *bool       `json:"disableSSL,omitempty" yaml:"disableSSL,omitempty" mapstructure:"disableSSL"`
	ForcePathStyle *bool       `json:"forcePathStyle,omitempty" yaml:"forcePathStyle,omitempty" mapstructure:"forcePathStyle"`
}

FileStore holds the config for the file store module

type FileStoreConfig

type FileStoreConfig struct {
	Enabled        bool   `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
	StoreType      string `json:"storeType" yaml:"storeType" mapstructure:"storeType"`
	Conn           string `json:"conn" yaml:"conn" mapstructure:"conn"`
	Endpoint       string `json:"endpoint" yaml:"endpoint" mapstructure:"endpoint"`
	Bucket         string `json:"bucket" yaml:"bucket" mapstructure:"bucket"`
	Secret         string `json:"secret" yaml:"secret" mapstructure:"secret"`
	DisableSSL     *bool  `json:"disableSSL,omitempty" yaml:"disableSSL,omitempty" mapstructure:"disableSSL"`
	ForcePathStyle *bool  `json:"forcePathStyle,omitempty" yaml:"forcePathStyle,omitempty" mapstructure:"forcePathStyle"`
}

FileStoreConfig stores information of file store config

type FileStoreRules

type FileStoreRules map[string]*FileRule // Key here is resource id --> clusterId--projectId--resourceType--fileRuleId

FileStoreRules is a map which stores database config information

type GlobalRoutesConfig

type GlobalRoutesConfig struct {
	RequestHeaders  Headers `json:"headers" yaml:"headers" mapstructure:"headers"`
	ResponseHeaders Headers `json:"resHeaders" yaml:"resHeaders" mapstructure:"resHeaders"`
}

GlobalRoutesConfig describes the project level config for ingress routing

type Header struct {
	Key   string `json:"key" yaml:"key" mapstructure:"key"`
	Value string `json:"value" yaml:"value" mapstructure:"value"`
	Op    string `json:"op" yaml:"op" mapstructure:"op"`
}

Header describes the operation to be performed on the header

type Headers

type Headers []Header

Headers describes an array of headers

func (Headers) UpdateHeader

func (headers Headers) UpdateHeader(reqHeaders http.Header)

UpdateHeader updated the header values

type IngressRoutes

type IngressRoutes map[string]*Route // Key here is resource id --> clusterId--projectId--resourceType--routeId

IngressRoutes is a map which stores database config information

type IntegrationAuthResponse

type IntegrationAuthResponse interface {
	// CheckResponse signifies whether the response of the integration module needs to be checked or now.
	// If the value `true` is returned, this means the integration moduke intends to control the response of
	// the auth request.
	CheckResponse() bool

	// The error to be sent back. This error is generated by the integration module. An error can be present when
	// an integration is trying to configure a resource which it does not have access to.
	Error() error

	// Status returns the status code returned by the integration
	Status() int

	// Result returns the value returned by the the hook. It will always be an []interface{} or map[string]interface{}.
	// The receiver must decode it into the appropriate struct if necessary.
	Result() interface{}
}

IntegrationAuthResponse is sent back as a response to auth checks

type IntegrationConfig

type IntegrationConfig struct {
	ID                  string                  `json:"id" yaml:"id" mapstructure:"id"`
	Name                string                  `json:"name" yaml:"name" mapstructure:"name"`
	Key                 string                  `json:"key" yaml:"key" mapstructure:"key"`             // Used for fetching tokens
	License             string                  `json:"license" yaml:"license" mapstructure:"license"` // Used to store level and id
	Version             string                  `json:"version" yaml:"version" mapstructure:"version"`
	ConfigPermissions   []IntegrationPermission `json:"configPermissions" yaml:"configPermissions" mapstructure:"configPermissions"`
	APIPermissions      []IntegrationPermission `json:"apiPermissions" yaml:"apiPermissions" mapstructure:"apiPermissions"`
	Deployments         []interface{}           `json:"deployments" yaml:"deployments" mapstructure:"deployments"`
	SecretSource        string                  `json:"secretSource" yaml:"secretSource" mapstructure:"secretSource"`
	AppURL              string                  `json:"appUrl" yaml:"appUrl" mapstructure:"appUrl"`
	CompatibleVersion   string                  `json:"compatibleVersion" yaml:"compatibleVersion" mapstructure:"compatibleVersion"`
	CompatibleVersionNo int                     `json:"compatibleVersionNo" yaml:"compatibleVersionNo" mapstructure:"compatibleVersionNo"`
	Details             string                  `json:"details" yaml:"details" mapstructure:"details"`
	Description         string                  `json:"description" yaml:"description" mapstructure:"description"`
}

IntegrationConfig describes the configuration of a single integration

type IntegrationHook

type IntegrationHook struct {
	ID            string     `json:"id" yaml:"id" mapstructure:"id"`
	IntegrationID string     `json:"integrationId" yaml:"integrationId" mapstructure:"integrationId"`
	Kind          string     `json:"kind" yaml:"kind" mapstructure:"kind"` // `hook` or `hijack`
	Resource      []string   `json:"resources" yaml:"resources" mapstructure:"resources"`
	Verbs         []string   `json:"verbs" yaml:"verbs" mapstructure:"verbs"`
	URL           string     `json:"url" yaml:"url" mapstructure:"url"`
	Attributes    Attributes `json:"attributes" yaml:"attributes" mapstructure:"attributes"`
	Rule          *Rule      `json:"rule,omitempty" yaml:"rule,omitempty" mapstructure:"rule"`
}

IntegrationHook describes the config for a integration hook

type IntegrationHookResponse

type IntegrationHookResponse struct {
	Action IntegrationHookResponseAction `json:"action"`
	Result interface{}                   `json:"result"`
	Error  string                        `json:"error"`
}

IntegrationHookResponse describes the response format of integration hooks

type IntegrationHookResponseAction

type IntegrationHookResponseAction string

IntegrationHookResponseAction describes the kind of action to be taken

const (
	// IgnoreHookResponse is used when the response of the hook is to be ignored
	IgnoreHookResponse IntegrationHookResponseAction = "ignore"

	// HijackHookResponse is used when the integration intends to hijack the request
	HijackHookResponse IntegrationHookResponseAction = "hijack"

	// ErrorHookResponse is used when the hook encountered an internal error. The error is simply logged by the gateway
	ErrorHookResponse IntegrationHookResponseAction = "error"
)

type IntegrationHooks

type IntegrationHooks map[string]*IntegrationHook

IntegrationHooks describes all the hooks specific to a integration

type IntegrationPermission

type IntegrationPermission struct {
	ID         string     `json:"id" yaml:"id" mapstructure:"id"`
	Resources  []string   `json:"resources" yaml:"resources" mapstructure:"resources"`    // Eg. db-schema, eventing-trigger, db-api
	Attributes Attributes `json:"attributes" yaml:"attributes" mapstructure:"attributes"` // Extra attributes like db and col go here
	Verbs      []string   `json:"verbs" yaml:"verbs" mapstructure:"verbs"`                // Eg. read, write, hook
}

IntegrationPermission describes a single permission object

type Integrations

type Integrations map[string]*IntegrationConfig

Integrations describes all the integrations registered in the cluster

func (Integrations) Get

func (integrations Integrations) Get(id string) (*IntegrationConfig, bool)

Get checks if id exists in the integration array and returns it

type JWTAlg

type JWTAlg string

JWTAlg is type of method used for signing token

const (
	// HS256 is method used for signing token
	HS256 JWTAlg = "HS256"

	// RS256 is method used for signing token
	RS256 JWTAlg = "RS256"

	// JwkURL is the method for identifying a secret that has to be validated against secret kes fetched from url
	JwkURL JWTAlg = "JWK_URL"

	// RS256Public is the method for identifying a secret that has to be validated against with a public key
	RS256Public JWTAlg = "RS256_PUBLIC"
)

type LetsEncrypt

type LetsEncrypt struct {
	ID                 string   `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id"`
	WhitelistedDomains []string `json:"domains" yaml:"domains" mapstructure:"domains"`
}

LetsEncrypt describes the configuration for let's encrypt

type Project

type Project struct {
	ProjectConfig *ProjectConfig `json:"projectConfig" yaml:"projectConfig" mapstructure:"projectConfig"`

	DatabaseConfigs         DatabaseConfigs         `json:"dbConfigs" yaml:"dbConfigs" mapstructure:"dbConfigs"`
	DatabaseSchemas         DatabaseSchemas         `json:"dbSchemas" yaml:"dbSchemas" mapstructure:"dbSchemas"`
	DatabaseRules           DatabaseRules           `json:"dbRules" yaml:"dbRules" mapstructure:"dbRules"`
	DatabasePreparedQueries DatabasePreparedQueries `json:"dbPreparedQuery" yaml:"dbPreparedQuery" mapstructure:"dbPreparedQuery"`

	EventingConfig   *EventingConfig  `json:"eventingConfig" yaml:"eventingConfig" mapstructure:"eventingConfig"`
	EventingSchemas  EventingSchemas  `json:"eventingSchemas" yaml:"eventingSchemas" mapstructure:"eventingSchemas"`
	EventingRules    EventingRules    `json:"eventingRules" yaml:"eventingRules" mapstructure:"eventingRules"`
	EventingTriggers EventingTriggers `json:"eventingTriggers" yaml:"eventingTriggers" mapstructure:"eventingTriggers"`

	FileStoreConfig *FileStoreConfig `json:"fileStoreConfig" yaml:"fileStoreConfig" mapstructure:"fileStoreConfig"`
	FileStoreRules  FileStoreRules   `json:"fileStoreRules" yaml:"fileStoreRules" mapstructure:"fileStoreRules"`

	Auths Auths `json:"auths" yaml:"auths" mapstructure:"auths"`

	LetsEncrypt *LetsEncrypt `json:"letsencrypt" yaml:"letsencrypt" mapstructure:"letsencrypt"`

	IngressRoutes IngressRoutes       `json:"ingressRoute" yaml:"ingressRoute" mapstructure:"ingressRoute"`
	IngressGlobal *GlobalRoutesConfig `json:"ingressGlobal" yaml:"ingressGlobal" mapstructure:"ingressGlobal"`

	RemoteService Services `json:"remoteServices" yaml:"remoteServices" mapstructure:"remoteServices"`
}

Project holds the project level configuration

func GenerateEmptyProject

func GenerateEmptyProject(project *ProjectConfig) *Project

GenerateEmptyProject creates a empty project

type ProjectConfig

type ProjectConfig struct {
	ID                 string    `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id"`
	Name               string    `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name"`
	Secrets            []*Secret `json:"secrets,omitempty" yaml:"secrets,omitempty" mapstructure:"secrets"`
	SecretSource       string    `json:"secretSource,omitempty" yaml:"secretSource,omitempty" mapstructure:"secretSource"`
	IsIntegration      bool      `json:"isIntegration,omitempty" yaml:"isIntegration,omitempty" mapstructure:"isIntegration"`
	AESKey             string    `json:"aesKey,omitempty" yaml:"aesKey,omitempty" mapstructure:"aesKey"`
	DockerRegistry     string    `json:"dockerRegistry,omitempty" yaml:"dockerRegistry,omitempty" mapstructure:"dockerRegistry"`
	ContextTimeGraphQL int       `json:"contextTimeGraphQL,omitempty" yaml:"contextTimeGraphQL,omitempty" mapstructure:"contextTimeGraphQL"` // contextTime sets the timeout of query
}

ProjectConfig stores information of individual project

type Projects

type Projects map[string]*Project // Key here is project id

Projects is a map which stores config information of all project in a cluster

type ReadCacheOptions

type ReadCacheOptions struct {
	TTL               int64 `json:"ttl" yaml:"ttl" mapstructure:"ttl"` // here ttl is represented in seconds
	InstantInvalidate bool  `json:"instantInvalidate" yaml:"instantInvalidate" mapstructure:"instantInvalidate"`
}

ReadCacheOptions describes the cache options in requests

type Resource

type Resource string

Resource is a resource type

const (
	// ResourceAuthProvider is a resource
	ResourceAuthProvider Resource = "auth-provider"

	// ResourceProject is a resource
	ResourceProject Resource = "project"

	// ResourceDatabaseConfig is a resource
	ResourceDatabaseConfig Resource = "db-config"
	// ResourceDatabaseSchema is a resource
	ResourceDatabaseSchema Resource = "db-schema"
	// ResourceDatabaseRule is a resource
	ResourceDatabaseRule Resource = "db-rule"
	// ResourceDatabasePreparedQuery is a resource
	ResourceDatabasePreparedQuery Resource = "db-prepared-query"

	// ResourceEventingConfig is a resource
	ResourceEventingConfig Resource = "eventing-config"
	// ResourceEventingSchema is a resource
	ResourceEventingSchema Resource = "eventing-schema"
	// ResourceEventingTrigger is a resource
	ResourceEventingTrigger Resource = "eventing-trigger"
	// ResourceEventingRule is a resource
	ResourceEventingRule Resource = "eventing-rule"

	// ResourceFileStoreConfig is a resource
	ResourceFileStoreConfig Resource = "filestore-config"
	// ResourceFileStoreRule is a resource
	ResourceFileStoreRule Resource = "filestore-rule"

	// ResourceProjectLetsEncrypt is a resource
	ResourceProjectLetsEncrypt Resource = "letsencrypt"

	// ResourceIngressRoute is a resource
	ResourceIngressRoute Resource = "ingress-route"
	// ResourceIngressGlobal is a resource
	ResourceIngressGlobal Resource = "ingress-global"

	// ResourceRemoteService is a resource
	ResourceRemoteService Resource = "remote-service"

	// ResourceIntegration is a resource
	ResourceIntegration Resource = "integration"
	// ResourceIntegrationHook is a resource
	ResourceIntegrationHook Resource = "integration-hook"
	// ResourceCluster is a resource
	ResourceCluster Resource = "cluster"

	// ResourceCacheConfig is a resource
	ResourceCacheConfig Resource = "cache-config"

	// ResourceDeleteEvent syncman uses this const to represent a delete event
	ResourceDeleteEvent = "delete"
	// ResourceUpdateEvent syncman uses this const to represent a delete event
	ResourceUpdateEvent = "update"
	// ResourceAddEvent syncman uses this const to represent a delete event
	ResourceAddEvent = "add"
)

type Route

type Route struct {
	ID               string        `json:"id" yaml:"id" mapstructure:"id"`
	Project          string        `json:"project" yaml:"project" mapstructure:"project"`
	Source           RouteSource   `json:"source" yaml:"source" mapstructure:"source"`
	Targets          []RouteTarget `json:"targets" yaml:"targets" mapstructure:"targets"`
	Rule             *Rule         `json:"rule" yaml:"rule" mapstructure:"rule"`
	IsRouteCacheable bool          `json:"isRouteCacheable" yaml:"isRouteCacheable" mapstructure:"isRouteCacheable"`
	CacheOptions     []string      `json:"cacheOptions" yaml:"cacheOptions" mapstructure:"cacheOptions"`
	Modify           struct {
		Tmpl            TemplatingEngine `json:"template,omitempty" yaml:"template,omitempty" mapstructure:"template"`
		ReqTmpl         string           `json:"requestTemplate" yaml:"requestTemplate" mapstructure:"requestTemplate"`
		ResTmpl         string           `json:"responseTemplate" yaml:"responseTemplate" mapstructure:"responseTemplate"`
		OpFormat        string           `json:"outputFormat,omitempty" yaml:"outputFormat,omitempty" mapstructure:"outputFormat"`
		RequestHeaders  Headers          `json:"headers" yaml:"headers" mapstructure:"headers"`
		ResponseHeaders Headers          `json:"resHeaders" yaml:"resHeaders" mapstructure:"resHeaders"`
	} `json:"modify" yaml:"modify" mapstructure:"modify"`
}

Route describes the parameters of a single route

func (*Route) SelectTarget

func (r *Route) SelectTarget(ctx context.Context, weight int32) (RouteTarget, error)

SelectTarget returns a target based on the weights assigned

type RouteSource

type RouteSource struct {
	Hosts      []string     `json:"hosts" yaml:"hosts" mapstructure:"hosts"`
	Methods    []string     `json:"methods" yaml:"methods" mapstructure:"methods"`
	URL        string       `json:"url" yaml:"url" mapstructure:"url"`
	RewriteURL string       `json:"rewrite" yaml:"rewrite" mapstructure:"rewrite"`
	Type       RouteURLType `json:"type" yaml:"type" mapstructure:"type"`
	Port       int32        `json:"port" yaml:"port" mapstructure:"port"`
}

RouteSource is the source of routing

type RouteTarget

type RouteTarget struct {
	Host    string          `json:"host" yaml:"host" mapstructure:"host"`
	Port    int32           `json:"port" yaml:"port" mapstructure:"port"`
	Scheme  string          `json:"scheme" yaml:"scheme" mapstructure:"scheme"`
	Weight  int32           `json:"weight" yaml:"weight" mapstructure:"weight"`
	Version string          `json:"version" yaml:"version" mapstructure:"version"`
	Type    RouteTargetType `json:"type" yaml:"type" mapstructure:"type"`
}

RouteTarget is the destination of routing

type RouteTargetType

type RouteTargetType string

RouteTargetType describes how the target should be selected

const (
	// RouteTargetVersion is used to route to versions of the same service
	RouteTargetVersion RouteTargetType = "version"

	// RouteTargetExternal is used to route to external services
	RouteTargetExternal RouteTargetType = "external"
)

type RouteURLType

type RouteURLType string

RouteURLType describes how the url should be evaluated / matched

const (
	// RoutePrefix is used for prefix matching
	RoutePrefix RouteURLType = "prefix"

	// RouteExact is used for matching the url exactly as it is
	RouteExact RouteURLType = "exact"
)

type Routes

type Routes []*Route

Routes describes the configuration for the routing module

func (Routes) Len

func (a Routes) Len() int

Len return length of routes

func (Routes) Less

func (a Routes) Less(i, j int) bool

Less compares two elements of the array

func (Routes) Swap

func (a Routes) Swap(i, j int)

Swap swaps two element of the array

type Rule

type Rule struct {
	ID       string                 `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id"`
	Rule     string                 `json:"rule" yaml:"rule" mapstructure:"rule"`
	Eval     string                 `json:"eval,omitempty" yaml:"eval,omitempty" mapstructure:"eval"`
	Type     string                 `json:"type,omitempty" yaml:"type,omitempty" mapstructure:"type"`
	F1       interface{}            `json:"f1,omitempty" yaml:"f1,omitempty" mapstructure:"f1"`
	F2       interface{}            `json:"f2,omitempty" yaml:"f2,omitempty" mapstructure:"f2"`
	Clauses  []*Rule                `json:"clauses,omitempty" yaml:"clauses,omitempty" mapstructure:"clauses"`
	DB       string                 `json:"db,omitempty" yaml:"db,omitempty" mapstructure:"db"`
	Col      string                 `json:"col,omitempty" yaml:"col,omitempty" mapstructure:"col"`
	Find     map[string]interface{} `json:"find,omitempty" yaml:"find,omitempty" mapstructure:"find"`
	URL      string                 `json:"url,omitempty" yaml:"url,omitempty" mapstructure:"url"`
	Fields   interface{}            `json:"fields,omitempty" yaml:"fields,omitempty" mapstructure:"fields"`
	Field    string                 `json:"field,omitempty" yaml:"field,omitempty" mapstructure:"field"`
	Value    interface{}            `json:"value,omitempty" yaml:"value,omitempty" mapstructure:"value"`
	Clause   *Rule                  `json:"clause,omitempty" yaml:"clause,omitempty" mapstructure:"clause"`
	Name     string                 `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name"`
	Error    string                 `json:"error,omitempty" yaml:"error,omitempty" mapstructure:"error"`
	Store    string                 `json:"store,omitempty" yaml:"store,omitempty" mapstructure:"store"`
	Claims   string                 `json:"claims,omitempty" yaml:"claims,omitempty" mapstructure:"claims"`
	Template TemplatingEngine       `json:"template,omitempty" yaml:"template,omitempty" mapstructure:"template"`
	ReqTmpl  string                 `json:"requestTemplate,omitempty" yaml:"requestTemplate,omitempty" mapstructure:"requestTemplate"`
	OpFormat string                 `json:"outputFormat,omitempty" yaml:"outputFormat,omitempty" mapstructure:"outputFormat"`
	Cache    *ReadCacheOptions      `json:"cache,omitempty" yaml:"cache,omitempty" mapstructure:"cache"`
}

Rule is the authorisation object at the query level

type SSL

type SSL struct {
	Enabled bool   `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
	Crt     string `json:"crt" yaml:"crt" mapstructure:"crt"`
	Key     string `json:"key" yaml:"key" mapstructure:"key"`
}

SSL holds the certificate and key file locations

type SchemaObject

type SchemaObject struct {
	ID     string `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id"`
	Schema string `json:"schema" yaml:"schema" mapstructure:"schema"`
}

SchemaObject is the body of the request for adding schema

type Secret

type Secret struct {
	IsPrimary bool   `json:"isPrimary" yaml:"isPrimary" mapstructure:"isPrimary"` // used by the frontend & backend to generate token out of multiple secrets
	Alg       JWTAlg `json:"alg" yaml:"alg" mapstructure:"alg"`                   // RSA256 or HMAC256

	KID string `json:"kid" yaml:"kid" mapstructure:"kid"` // uniquely identifies a secret

	JwkURL string      `json:"jwkUrl" yaml:"jwkUrl" mapstructure:"jwkUrl"`
	JwkKey interface{} `json:"-" yaml:"-"`

	Audience []string `json:"aud" yaml:"aud" mapstructure:"aud"`
	Issuer   []string `json:"iss" yaml:"iss" mapstructure:"iss"`

	// Used for HMAC256 secret
	Secret string `json:"secret" yaml:"secret" mapstructure:"secret"`

	// Use for RSA256
	PublicKey  string `json:"publicKey" yaml:"publicKey" mapstructure:"publicKey"`
	PrivateKey string `json:"privateKey" yaml:"privateKey" mapstructure:"privateKey"`
}

Secret describes the a secret object

type Service

type Service struct {
	ID        string               `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id"`    // eg. http://localhost:8080
	URL       string               `json:"url,omitempty" yaml:"url,omitempty" mapstructure:"url"` // eg. http://localhost:8080
	Endpoints map[string]*Endpoint `json:"endpoints,omitempty" yaml:"endpoints,omitempty" mapstructure:"endpoints"`
}

Service holds the config of service

type Services

type Services map[string]*Service

Services holds the config of services

type ServicesModule

type ServicesModule struct {
	Services         Services `json:"externalServices" yaml:"externalServices" mapstructure:"externalServices"`
	InternalServices Services `json:"internalServices" yaml:"internalServices" mapstructure:"internalServices"`
}

ServicesModule holds the config for the service module

type Static

type Static struct {
	Routes         []*StaticRoute `json:"routes" yaml:"routes" mapstructure:"routes"`
	InternalRoutes []*StaticRoute `json:"internalRoutes" yaml:"internalRoutes" mapstructure:"internalRoutes"`
}

Static holds the config for the static files module

type StaticRoute

type StaticRoute struct {
	ID        string `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id"`
	Path      string `json:"path" yaml:"path" mapstructure:"path"`
	URLPrefix string `json:"prefix" yaml:"prefix" mapstructure:"prefix"`
	Host      string `json:"host" yaml:"host" mapstructure:"host"`
	Proxy     string `json:"proxy" yaml:"proxy" mapstructure:"proxy"`
	Protocol  string `json:"protocol,omitempty" yaml:"protocol,omitempty" mapstructure:"protocol"`
}

StaticRoute holds the config for each route

type TableRule

type TableRule struct {
	IsRealTimeEnabled bool             `json:"isRealtimeEnabled,omitempty" yaml:"isRealtimeEnabled" mapstructure:"isRealtimeEnabled"`
	Rules             map[string]*Rule `json:"rules,omitempty" yaml:"rules" mapstructure:"rules"` // The key here is query, insert, update or delete
	Schema            string           `json:"schema,omitempty" yaml:"schema" mapstructure:"schema"`
}

TableRule contains the config at the collection level

type TemplatingEngine

type TemplatingEngine string

TemplatingEngine describes the type of endpoint. Default value - go

const (
	// TemplatingEngineGo describes the go templating engine
	TemplatingEngineGo TemplatingEngine = "go"
)

Jump to

Keyboard shortcuts

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