config

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 10 Imported by: 1

README

Configuration module

The configuration module for FOXDEN/CHESS services.

Client configuration

In order to run FOXDEN/CHESS client you should have the following configuration in your $HOME/.foxden.yaml file or supply your file to the client --config option:

Services:
  FrontendUrl: https://foxden.url
  DiscoveryUrl: https://foxden-discover.url
  DataManagementUrl: https://foxden-s3.url
  DataBookkeepingUrl: https://foxden-dbs.url
  MetaDataUrl: https://foxden-meta.url
  AuthzUrl: https://foxden-authz.url

Please note, you may change the above example according to FOXDEN setup, e.g. change urls or provide additional port to FOXDEN services.

Server configuration

The server configuration is more complex and defined according to config.go implementation. Here is an example of FOXDEN local setup:

Services:
  FrontendUrl: http://localhost:8344
  DiscoveryUrl: http://localhost:8320
  DataManagementUrl: http://localhost:8340
  DataBookkeepingUrl: http://localhost:8310
  MetaDataUrl: http://localhost:8300
  AuthzUrl: http://localhost:8380
CHESSMetaData:
  SchemaFiles:
    - "schemas/lite.json"
    - "schemas/ID4B.json"
    - "schemas/ID3A.json"
    - "schemas/ID1A3.json"
  SchemaSections: ["User", "Alignment", "DataLocations", "Beam", "Experiment", "Sample"]
  WebSectionKeys:
    User: ["Facility", "Cycle", "PI", "BTR", "Experimenters", "Beamline", "StaffScientist", "BeamlineFundingPartner"]
    Alignment: []
    DataLocations: ["DataLocationRaw", "DataLocationMeta", "DataLocationReduced", "DataLocationScratch", "DataLocationBeamtimeNotes"]
    Beam: ["CESRCondtions"]
    Experiment: ["Detectors","ExperimentType","Technique"]
    Sample: ["SampleType","SampleName","Calibration"] 
  MongoDB:
    DBUri: mongodb://localhost:8230
    DBName: chess
    DBColl: meta
  WebServer:
    Port: 8300
    Verbose: 1
    LogLongFile: true
    GinOptions:
      DisableConsoleColor: true
Kerberos:
  Krb5Conf:  /etc/krb5.conf
  Realm: CLASSE.CORNELL.EDU
Authz:
  DBUri: ./auth.db
  ClientId: xxx
  ClientSecret: xyz
  WebServer:
    Port: 8380
    Verbose: 1
    LogLongFile: true
    GinOptions:
      DisableConsoleColor: true
DataBookkeeping:
  ApiParametersFile: /Users/vk/Work/CHESS/FOXDEN/DataBookkeeping/static/parameters.json
  DBFile: /Users/vk/Work/CHESS/FOXDEN/DataBookkeeping/dbfile
  LexiconFile: /Users/vk/Work/CHESS/FOXDEN/DataBookkeeping/static/lexicon_reader.json
  WebServer:
    Port: 8310
    StaticDir: /Users/vk/Work/CHESS/FOXDEN/DataBookkeeping/static
    Verbose: 1
    LogLongFile: true
    GinOptions:
      DisableConsoleColor: true
DataManagement:
  WebServer:
    Port: 8340
    Verbose: 1
    LogLongFile: true
    GinOptions:
      DisableConsoleColor: true
Discovery:
  MongoDB:
    DBUri: mongodb://localhost:8230
    DBName: chess
    DBColl: meta
  WebServer:
    Port: 8320
    Verbose: 2
    LogLongFile: true
    GinOptions:
      DisableConsoleColor: true
Encryption:
  Cipher: aes
  Secret: bla
Frontend:
  WebServer:
    Port: 8344
    StaticDir: Static
    Verbose: 1
    LogLongFile: true
    GinOptions:
      DisableConsoleColor: true
      Production: true
  OAuth:
    -
      Provider: github
      ClientID: clientid
      ClientSecret: secret
    -
      Provider: google
      ClientID: cleintid
      ClientSecret: secret
      RedirectURL: http://localhost:8344/google/callback

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Info

func Info() string

func Init

func Init()

Types

type Authz

type Authz struct {
	WebServer  `mapstructure:"WebServer"`
	Encryption `mapstructure:"Encryption"`

	TestMode     bool   `mapstructure:TestMode`  // test mode
	CheckLDAP    bool   `mapstructure:CheckLDAP` // check users scope in LDAP
	DBUri        string `mapstructure:"DBUri"`   // database URI
	ClientID     string `mapstructure:"ClientId"`
	ClientSecret string `mapstructure:"ClientSecret"`
	Domain       string `mapstructure:"Domain"`
	TokenExpires int64  `mapstructure:TokenExpires` // expiration of token
}

Authz represents authz service configuration

type CHESSMetaData

type CHESSMetaData struct {
	WebServer           `mapstructure:"WebServer"`
	MongoDB             `mapstructure:"MongoDB"`
	LexiconFile         string              `mapstructure:"LexiconFile"` // lexicon file
	TestMode            bool                `mapstructure:TestMode`      // test mode
	SchemaFiles         []string            `json:"SchemaFiles"`         // schema files
	SchemaRenewInterval int                 `json:"SchemaRenewInterval"` // schema renew interval
	SchemaSections      []string            `json:"SchemaSections"`      // logical schema section list
	WebSectionKeys      map[string][]string `json:"WebSectionKeys"`      // section order dict
}

CHESSMetaData represents CHESS MetaData configuration

type DID added in v0.1.6

type DID struct {
	Attributes string `mapstructure:attributes` // did attributes, comma separated, default beamline,btr,cycle,sample
	Separator  string `mapstructure:separator`  // did separator, default "/"
	Divider    string `mapstructure:divider`    // did key-value divider, default "="
}

DID structure

type DataBookkeeping

type DataBookkeeping struct {
	WebServer `mapstructure:"WebServer"`

	DBFile             string `mapstructure:"DBFile"`             // dbs db file with secrets
	LexiconFile        string `mapstructure:"LexiconFile"`        // dbs lexicon file
	MaxDBConnections   int    `mapstructure:"MaxDbConnections"`   // maximum number of DB connections
	MaxIdleConnections int    `mapstructure:"MaxIdleConnections"` // maximum number of idle connections
}

DataBookkeeping represents data-bookkeeping service configuration

type DataManagement

type DataManagement struct {
	S3
	WebServer `mapstructure:"WebServer"`
}

DataManagement represents data-management service configuration

type Discovery

type Discovery struct {
	WebServer  `mapstructure:"WebServer"`
	MongoDB    `mapstructure:"MongoDB"`
	Encryption `mapstructure:"Encryption"`
}

Discovery represents discovery service configuration

type Encryption

type Encryption struct {
	Secret string `mapstructure:"Secret"`
	Cipher string `mapstructure:"Cipher"`
}

Encryption represents encryption configuration parameters

type Frontend

type Frontend struct {
	WebServer `mapstructure:"WebServer"`

	// OAuth parts
	OAuth []OAuthRecord `mapstructure:"OAuth"` // oauth configurations

	// captcha parts
	CaptchaSecretKey string `mapstructure:"CaptchaSecretKey"` // re-captcha secret key
	CaptchaPublicKey string `mapstructure:"CaptchaPublicKey"` // re-captcha public key
	CaptchaVerifyUrl string `mapstructure:"CaptchaVerifyUrl"` // re-captcha verify url

	// cookies parts
	UserCookieExpires int64 `mapstructure:"UserCookieExpires"` // expiration of user cookie

	// other options
	TestMode bool `mapstructure:TestMode` // test mode
}

Frontend stores frontend configuration parameters

type GinOptions

type GinOptions struct {
	DisableConsoleColor bool   `mapstructure:"DisableConsoleColor"` // gin console color mode
	Production          bool   `mapstructure:"Production"`          // production mode
	Mode                string `mapstructure:"Mode"`                // gin mode: test, debug, release
}

GinOptions controls go-gin specific options

type Kerberos

type Kerberos struct {
	Krb5Conf string `mapstructure:Krb5Conf`
	Keytab   string `mapstructure:Keytab`
	Realm    string `mapstructure:Realm`
}

Kerberos defines kerberos optinos

type LDAP added in v0.2.0

type LDAP struct {
	URL      string `mapstructure:"url"`      // ldap url
	BaseDN   string `mapstructure:"baseDN`    // ldap baseDN
	Login    string `mapstructure:"login"`    // LDAP login to use
	Password string `mapstructure:"password"` // LDAP password to use
}

LDAP attributes

type ML added in v0.1.0

type ML struct {
	MLBackends []MLBackend `json:"MLBackends"` // ML backends
	StorageDir string      `json:"StorageDir"`
}

ML defines ML configuration options

type MLApi added in v0.1.0

type MLApi struct {
	Name     string `json:"name"`
	Method   string `json:"method"`
	Endpoint string `json:"endpoint"`
	Accept   string `json:"accept"`
}

MLAPI defines ML API structure

type MLBackend added in v0.1.0

type MLBackend struct {
	Name string  `json:"name"` // ML backend name, e.g. TFaaS
	Type string  `json:"type"` // ML backebd type, e.g. TensorFlow
	URI  string  `json:"uri"`  // ML backend URI, e.g. http://localhost:port
	Apis []MLApi // ML APIs
}

MLBackend represents ML backend engine

type MLHub added in v0.1.0

type MLHub struct {
	WebServer  `mapstructure:"WebServer"`
	MongoDB    `mapstructure:"MongoDB"`
	Encryption `mapstructure:"Encryption"`
	ML         `mapstructure:"ML"`
}

MLHub represents ML service configuration

type MetaData

type MetaData struct {
	WebServer   `mapstructure:"WebServer"`
	MongoDB     `mapstructure:"MongoDB"`
	LexiconFile string `mapstructure:"LexiconFile"` // lexicon file
}

MetaData represents metadata service configuration

type MongoDB

type MongoDB struct {
	DBName string `mapstructure:"DBName"` // database name
	DBColl string `mapstructure:"DBColl"` // database collection
	DBUri  string `mapstructure:"DBUri"`  // database URI
}

MongoDB represents MongoDB parameters

type OAuthRecord

type OAuthRecord struct {
	Provider     string `mapstructure:"Provider"`     // name of the provider
	ClientID     string `mapstructure:"ClientId"`     // client id
	ClientSecret string `mapstructure:"ClientSecret"` // client secret
	RedirectURL  string `mapstructure:"RedirectUrl"`  // redirect url
}

OAuthRecord defines OAuth provider's credentials

type OreCastMetaData

type OreCastMetaData struct {
	WebServer `mapstructure:"WebServer"`
	MongoDB   `mapstructure:"MongoDB"`
}

OreCastMetaData represents OreCast MetaData configuration

type Publication added in v0.1.2

type Publication struct {
	WebServer `mapstructure:"WebServer"`
	Zenodo
}

Publication represents Publication service configuration

type QL added in v0.2.1

type QL struct {
	ServiceMapFile string `mapstructure:ServiceMapFile` // service map file name
	Separator      string `mapstructure:separator`      // ql separator, default ":"
	Verbose        int    `mapstructure:verbose`        // verbosity level
}

QL structure

type S3 added in v0.0.9

type S3 struct {
	AccessKey    string `mapstructure:"AccessKey"`
	AccessSecret string `mapstructure:"AccessSecret"`
	Endpoint     string `mapstructure:"Endpoint"`
	UseSSL       bool   `mapstructure:"UseSSL"`
}

S3 defines s3 structure

type Services

type Services struct {
	FrontendURL        string `mapstructure:"FrontendUrl"`
	DiscoveryURL       string `mapstructure:"DiscoveryUrl"`
	MetaDataURL        string `mapstructure:"MetaDataUrl"`
	MLHubURL           string `mapstructure:"MLHubUrl"`
	DataManagementURL  string `mapstructure:"DataManagementUrl"`
	DataBookkeepingURL string `mapstructure:"DataBookkeepingUrl"`
	AuthzURL           string `mapstructure:"AuthzUrl"`
	SpecScansURL       string `mapstructure:"SpecScansUrl"`
	PublicationURL     string `mapstructure:"PublicationUrl"`
	CHAPBookURL        string `mapstructure:"CHAPBookUrl"`
}

Services represents services structure

type SpecScans added in v0.1.0

type SpecScans struct {
	WebServer `mapstructure:"WebServer"`
	MongoDB   `mapstructure:"MongoDB"`
	DBFile    string `mapstructure:"DBFile"`
}

SpecScans represents SpecScansService configuration

type SrvConfig

type SrvConfig struct {
	QL              `mapstructure:"QL"`
	DID             `mapstructure:"DID"`
	LDAP            `mapstructure:LDAP`
	Frontend        `mapstructure:"Frontend"`
	Discovery       `mapstructure:"Discovery"`
	MetaData        `mapstructure:"MetaData"`
	MLHub           `mapstructure:"MLHub"`
	DataManagement  `mapstructure:"DataManagement"`
	DataBookkeeping `mapstructure:"DataBookkeeping"`
	Authz           `mapstructure:"Authz"`
	Kerberos        `mapstructure:"Kerberos"`
	Services        `mapstructure:"Services"`
	Encryption      `mapstructure:"Encryption"`
	CHESSMetaData   `mapstructure:"CHESSMetaData"`
	OreCastMetaData `mapstructure:"OreCastMetaData"`
	SpecScans       `mapstructure:"SpecScansService"`
	Publication     `mapstructure:"PublicationService"`
}

SrvConfig represents configuration structure

var Config *SrvConfig

Config represnets configuration instance

func ParseConfig

func ParseConfig(cfile string) (SrvConfig, error)

func (*SrvConfig) String added in v0.0.5

func (c *SrvConfig) String() string

type WebServer

type WebServer struct {
	// git server options
	GinOptions `mapstructure:"GinOptions"`

	// basic options
	Port        int    `mapstructure:"Port"`        // server port number
	Verbose     int    `mapstructure:"Verbose"`     // verbose output
	Base        string `mapstructure:"Base"`        // base URL
	StaticDir   string `mapstructure:"StaticDir"`   // speficy static dir location
	LogFile     string `mapstructure:"LogFile"`     // server log file
	LogLongFile bool   `mapstructure:"LogLongFile"` // server log structure

	// middleware server parts
	LimiterPeriod   string   `mapstructure:"Rate"`      // limiter rate value
	LimiterHeader   string   `json:"limiter_header"`    // limiter header to use
	LimiterSkipList []string `json:"limiter_skip_list"` // limiter skip list
	MetricsPrefix   string   `json:"metrics_prefix"`    // metrics prefix used for prometheus

	// etag options
	Etag         string `json:"etag"`          // etag value to use for ETag generation
	CacheControl string `json:"cache_control"` // Cache-Control value, e.g. max-age=300

	// proxy parts
	XForwardedHost      string `mapstructure:"X-Forwarded-Host"`       // X-Forwarded-Host field of HTTP request
	XContentTypeOptions string `mapstructure:"X-Content-Type-Options"` // X-Content-Type-Options option

	// TLS server parts
	RootCAs     string   `mapstructure:"RootCAs"`     // server Root CAs path
	ServerCrt   string   `mapstructure:"ServerCert"`  // server certificate
	ServerKey   string   `mapstructure:"ServerKey"`   // server certificate
	DomainNames []string `mapstructure:"DomainNames"` // LetsEncrypt domain names
}

WebServer represents common web server configuration

func (*WebServer) String added in v0.0.2

func (w *WebServer) String() string

String provides string representation of WebServer structure

type Zenodo added in v0.1.2

type Zenodo struct {
	URL         string `mapstructure:"Url"`         // zenodo url
	AccessToken string `mapstructure:"AccessToken"` // access token
}

Zenodo credentials

Jump to

Keyboard shortcuts

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