config

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config is used for storing and manipulating (server) state in plumber. There should be, at most, a single instance of the plumber config that is passed around between various components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(fileName string) bool

Exists determines if a config file exists yet

func WriteConfig

func WriteConfig(fileName string, data []byte) error

WriteConfig writes a Batch struct as JSON into a config.json file

Types

type Config

type Config struct {
	PlumberID       string `json:"plumber_id"`
	Token           string `json:"token"`
	TeamID          string `json:"team_id"`
	UserID          string `json:"user_id"`
	VCServiceToken  string `json:"vc_service_token"`    // entire vc-service JWT
	GitHubToken     string `json:"github_bearer_token"` // retrieved from vc-service JWT contents
	GitHubInstallID int64  `json:"install_id"`

	Connections         map[string]*opts.ConnectionOptions     `json:"-"`
	Relays              map[string]*stypes.Relay               `json:"-"`
	Schemas             map[string]*protos.Schema              `json:"-"`
	Services            map[string]*protos.Service             `json:"-"`
	Reads               map[string]*stypes.Read                `json:"-"`
	ImportRequests      map[string]*protos.ImportGithubRequest `json:"-"`
	Validations         map[string]*common.Validation          `json:"-"`
	Composites          map[string]*opts.Composite             `json:"-"`
	ConnectionsMutex    *sync.RWMutex                          `json:"-"`
	ServicesMutex       *sync.RWMutex                          `json:"-"`
	ReadsMutex          *sync.RWMutex                          `json:"-"`
	RelaysMutex         *sync.RWMutex                          `json:"-"`
	SchemasMutex        *sync.RWMutex                          `json:"-"`
	ImportRequestsMutex *sync.RWMutex                          `json:"-"`
	ValidationsMutex    *sync.RWMutex                          `json:"-"`
	CompositesMutex     *sync.RWMutex                          `json:"-"`
}

Config stores Account IDs and the auth_token cookie

func ReadConfig

func ReadConfig(fileName string) (*Config, error)

ReadConfig reads a config JSON file into a Config struct

func (*Config) DeleteComposite

func (c *Config) DeleteComposite(id string)

DeleteComposite removes a schema validation from in-memory map

func (*Config) DeleteConnection

func (c *Config) DeleteConnection(connID string)

DeleteConnection removes a connection from in-memory map

func (*Config) DeleteImportRequest

func (c *Config) DeleteImportRequest(importID string)

func (*Config) DeleteRead

func (c *Config) DeleteRead(readID string)

DeleteRead removes a read from in-memory map

func (*Config) DeleteRelay

func (c *Config) DeleteRelay(relayID string)

DeleteRelay removes a service from in-memory map

func (*Config) DeleteSchema

func (c *Config) DeleteSchema(schemaID string)

DeleteSchema removes a schema from in-memory map

func (*Config) DeleteService

func (c *Config) DeleteService(schemaID string)

DeleteService removes a service from in-memory map

func (*Config) DeleteValidation

func (c *Config) DeleteValidation(validationID string)

DeleteValidation removes a schema validation from in-memory map

func (*Config) GetComposite

func (c *Config) GetComposite(id string) *opts.Composite

GetComposite retrieves a schema validation from in-memory map

func (*Config) GetConnection

func (c *Config) GetConnection(connID string) *opts.ConnectionOptions

GetConnection retrieves a connection from in-memory map

func (*Config) GetImportRequest

func (c *Config) GetImportRequest(importID string) *protos.ImportGithubRequest

func (*Config) GetRead

func (c *Config) GetRead(readID string) *stypes.Read

GetRead returns an in-progress read from the Read map

func (*Config) GetRelay

func (c *Config) GetRelay(relayID string) *stypes.Relay

GetRelay returns a relay from the in-memory map

func (*Config) GetSchema

func (c *Config) GetSchema(schemaID string) *protos.Schema

GetSchema returns a stored schema

func (*Config) GetService

func (c *Config) GetService(serviceID string) *protos.Service

GetService returns a service from the in-memory map

func (*Config) GetValidation

func (c *Config) GetValidation(validationID string) *common.Validation

GetValidation retrieves a schema validation from in-memory map

func (*Config) Save

func (c *Config) Save() error

Save is a convenience method of persisting the config to disk via a single call

func (*Config) SetComposite

func (c *Config) SetComposite(id string, comp *opts.Composite)

SetComposite saves a schema validation to in-memory map

func (*Config) SetConnection

func (c *Config) SetConnection(connID string, conn *opts.ConnectionOptions)

SetConnection saves a connection to in-memory map

func (*Config) SetImportRequest

func (c *Config) SetImportRequest(importID string, importSchema *protos.ImportGithubRequest)

func (*Config) SetRead

func (c *Config) SetRead(readID string, read *stypes.Read)

SetRead adds an in-progress read to the Read map

func (*Config) SetRelay

func (c *Config) SetRelay(relayID string, relay *stypes.Relay)

SetRelay saves a relay to in-memory map

func (*Config) SetSchema

func (c *Config) SetSchema(schemaID string, schema *protos.Schema)

SetSchema saves a schema to in-memory map

func (*Config) SetService

func (c *Config) SetService(serviceID string, svc *protos.Service)

SetService saves a service to in-memory map

func (*Config) SetValidation

func (c *Config) SetValidation(validationID string, conn *common.Validation)

SetValidation saves a schema validation to in-memory map

type IConfig

type IConfig interface {
	ConfigExists(fileName string) bool
	ReadConfig(fileName string) (*Config, error)
	WriteConfig(fileName string, data []byte) error
}

Jump to

Keyboard shortcuts

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