qri: github.com/qri-io/qri/config Index | Files | Directories

package config

import "github.com/qri-io/qri/config"

Package config encapsulates qri configuration options & details. configuration is generally stored as a .yaml file, or provided at CLI runtime via command a line argument

Index

Package Files

api.go cli.go config.go logging.go p2p.go profile.go registry.go remote.go remotes.go render.go repo.go rpc.go store.go test_config.go update.go webapp.go

Constants

const CurrentConfigRevision = 1

CurrentConfigRevision is the latest configuration revision configurations that don't match this revision number should be migrated up

Variables

var DefaultAPIPort = 2503

DefaultAPIPort is local the port webapp serves on by default

var DefaultRPCPort = 2504

DefaultRPCPort is local the port RPC serves on by default

var DefaultUpdateAddress = "127.0.0.1:2506"

DefaultUpdateAddress is the local address Update serves on by default

var DefaultWebappPort = 2505

DefaultWebappPort is local the port webapp serves on by default

func ImmutablePaths Uses

func ImmutablePaths() map[string]bool

ImmutablePaths returns a map of paths that should never be modified

type API Uses

type API struct {
    Enabled bool `json:"enabled"`
    // APIPort specifies the port to listen for JSON API calls
    Port int `json:"port"`
    // read-only mode
    ReadOnly bool `json:"readonly"`
    // remote mode
    //
    // Deprecated: use config.Remote instead
    RemoteMode bool `json:"remotemode"`
    // maximum size of dataset to accept for remote mode
    //
    // Deprecated: use config.Remote instead
    RemoteAcceptSizeMax int64 `json:"remoteacceptsizemax"`
    // timeout for remote sessions, in milliseconds
    //
    // Deprecated: use config.Remote instead
    RemoteAcceptTimeoutMs time.Duration `json:"remoteaccepttimeoutms"`
    // URLRoot is the base url for this server
    URLRoot string `json:"urlroot"`
    // TLS enables https via letsEyncrypt
    TLS bool `json:"tls"`
    // Time in seconds to stop the server after,
    // default 0 means keep alive indefinitely
    DisconnectAfter int `json:"disconnectafter,omitempty"`
    // if true, requests that have X-Forwarded-Proto: http will be redirected
    // to their https variant
    ProxyForceHTTPS bool `json:"proxyforcehttps"`
    // support CORS signing from a list of origins
    AllowedOrigins []string `json:"allowedorigins"`
    // whether to allow requests from addresses other than localhost
    ServeRemoteTraffic bool `json:"serveremotetraffic"`
}

API holds configuration for the qri JSON api

func DefaultAPI Uses

func DefaultAPI() *API

DefaultAPI returns the default configuration details

func (*API) Copy Uses

func (a *API) Copy() *API

Copy returns a deep copy of an API struct

func (API) Validate Uses

func (a API) Validate() error

Validate validates all fields of api returning all errors found.

type CLI Uses

type CLI struct {
    ColorizeOutput bool `json:"colorizeoutput"`
}

CLI defines configuration details for the qri command line client (CLI)

func DefaultCLI Uses

func DefaultCLI() *CLI

DefaultCLI returns a new default CLI configuration

func (*CLI) Copy Uses

func (c *CLI) Copy() *CLI

Copy returns a deep copy of a CLI struct

func (CLI) Validate Uses

func (c CLI) Validate() error

Validate validates all fields of cli returning all errors found.

func (*CLI) WithPrivateValues Uses

func (c *CLI) WithPrivateValues(p *CLI) *CLI

WithPrivateValues returns a deep copy of CLI struct all the privates values of the receiver added to the *CLI param

func (*CLI) WithoutPrivateValues Uses

func (c *CLI) WithoutPrivateValues() *CLI

WithoutPrivateValues returns a deep copy of an CLI struct with all the private values removed

type Config Uses

type Config struct {
    Revision int
    Profile  *ProfilePod
    Repo     *Repo
    Store    *Store
    P2P      *P2P
    Update   *Update

    Registry *Registry
    Remotes  *Remotes
    Remote   *Remote

    CLI     *CLI
    API     *API
    Webapp  *Webapp
    RPC     *RPC
    Logging *Logging

    Render *Render
    // contains filtered or unexported fields
}

Config encapsulates all configuration details for qri

func DefaultConfig Uses

func DefaultConfig() *Config

DefaultConfig gives a new configuration with simple, default settings

func DefaultConfigForTesting Uses

func DefaultConfigForTesting() *Config

DefaultConfigForTesting constructs a config with precomputed keys, only used for testing.

func ReadFromFile Uses

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

ReadFromFile reads a YAML configuration file from path

func (*Config) Copy Uses

func (cfg *Config) Copy() *Config

Copy returns a deep copy of the Config struct

func (Config) Get Uses

func (cfg Config) Get(path string) (interface{}, error)

Get a config value with case.insensitive.dot.separated.paths

func (Config) Path Uses

func (cfg Config) Path() string

Path gives the unexported filepath for a config

func (*Config) Set Uses

func (cfg *Config) Set(path string, value interface{}) error

Set a config value with case.insensitive.dot.separated.paths

func (*Config) SetPath Uses

func (cfg *Config) SetPath(path string)

SetPath assigns unexported filepath to write config to

func (Config) SummaryString Uses

func (cfg Config) SummaryString() (summary string)

SummaryString creates a pretty string summarizing the configuration, useful for log output TODO (b5): this summary string doesn't confirm these services are actually running. we should move this elsewhere

func (Config) Validate Uses

func (cfg Config) Validate() error

Validate validates each section of the config struct, returning the first error

func (*Config) WithPrivateValues Uses

func (cfg *Config) WithPrivateValues(p *Config) *Config

WithPrivateValues returns a deep copy of the receiver with the private values from the *Config passed in from the params

func (*Config) WithoutPrivateValues Uses

func (cfg *Config) WithoutPrivateValues() *Config

WithoutPrivateValues returns a deep copy of the receiver with the private values removed

func (Config) WriteToFile Uses

func (cfg Config) WriteToFile(path string) error

WriteToFile encodes a configration to YAML and writes it to path

type Logging Uses

type Logging struct {
    // Levels is a map of package_name : log_level (one of [info, error, debug, warn])
    Levels map[string]string `json:"levels"`
}

Logging encapsulates logging configuration

func DefaultLogging Uses

func DefaultLogging() *Logging

DefaultLogging produces a new default logging configuration

func (*Logging) Copy Uses

func (l *Logging) Copy() *Logging

Copy returns a deep copy of a Logging struct

func (Logging) Validate Uses

func (l Logging) Validate() error

Validate validates all fields of logging returning all errors found.

type P2P Uses

type P2P struct {
    // Enabled is a flag for weather this node should connect
    // to the distributed network
    Enabled bool `json:"enabled"`

    // PeerID is this nodes peer identifier
    PeerID string `json:"peerid"`

    PubKey  string `json:"pubkey"`
    PrivKey string `json:"privkey"`

    // Port default port to bind a tcp listener to
    // ignored if Addrs is supplied
    Port int `json:"port"`

    // List of multiaddresses to listen on
    Addrs []ma.Multiaddr `json:"addrs"`

    // QriBootstrapAddrs lists addresses to bootstrap qri node from
    QriBootstrapAddrs []string `json:"qribootstrapaddrs"`

    // HTTPGatewayAddr is an address that qri can use to resolve p2p assets
    // over HTTP, represented as a url. eg: https://ipfs.io
    HTTPGatewayAddr string `json:"httpgatewayaddr"`

    // ProfileReplication determines what to do when this peer sees messages
    // broadcast by it's own profile (from another peer instance). setting
    // ProfileReplication == "full" will cause this peer to automatically pin
    // any data that is verifiably posted by the same peer
    ProfileReplication string `json:"profilereplication"`

    // list of addresses to bootsrap qri peers on
    BootstrapAddrs []string `json:"bootstrapaddrs"`

    // Enable AutoNAT service. unless you're hosting a server, leave this as false
    AutoNAT bool `json:"autoNAT"`
}

P2P encapsulates configuration options for qri peer-2-peer communication

func DefaultP2P Uses

func DefaultP2P() *P2P

DefaultP2P generates a p2p struct with only bootstrap addresses set

func DefaultP2PForTesting Uses

func DefaultP2PForTesting() *P2P

DefaultP2PForTesting constructs a p2p with precomputed keys, only used for testing.

func (*P2P) Copy Uses

func (cfg *P2P) Copy() *P2P

Copy returns a deep copy of a p2p struct

func (*P2P) DecodePeerID Uses

func (cfg *P2P) DecodePeerID() (peer.ID, error)

DecodePeerID takes P2P.ID (a string), and decodes it into a peer.ID

func (*P2P) DecodePrivateKey Uses

func (cfg *P2P) DecodePrivateKey() (crypto.PrivKey, error)

DecodePrivateKey generates a PrivKey instance from base64-encoded config file bytes

func (P2P) Validate Uses

func (cfg P2P) Validate() error

Validate validates all fields of p2p returning all errors found.

type ProfilePod Uses

type ProfilePod struct {
    ID       string `json:"id"`
    PrivKey  string `json:"privkey,omitempty"`
    Peername string `json:"peername"`
    // Created timestamp
    Created time.Time `json:"created"`
    // Updated timestamp
    Updated time.Time `json:"updated"`
    // specifies weather this is a user or an organization
    Type string `json:"type"`
    // user's email address
    Email string `json:"email"`
    // user name field. could be first[space]last, but not strictly enforced
    Name string `json:"name"`
    // user-filled description of self
    Description string `json:"description"`
    // url this user wants the world to click
    HomeURL string `json:"homeurl"`
    // color this user likes to use as their theme color
    Color string `json:"color"`
    // Thumb path for user's thumbnail
    Thumb string `json:"thumb"`
    // Profile photo
    Photo string `json:"photo"`
    // Poster photo for users's profile page
    Poster string `json:"poster"`
    // Twitter is a peer's twitter handle
    Twitter string `json:"twitter"`
    // Online indicates if the user is currently connected to the qri network
    // Should not serialize to config.yaml
    Online bool `json:"online,omitempty"`
    // PeerIDs maps this profile to peer Identifiers in the form /[network]/peerID example:
    // /ipfs/QmSyDX5LYTiwQi861F5NAwdHrrnd1iRGsoEvCyzQMUyZ4W
    // where QmSy... is a peer identifier on the IPFS peer-to-peer network
    // Should not serialize to config.yaml
    PeerIDs []string `json:"peerIDs,omitempty"`
    // NetworkAddrs keeps a list of locations for this profile on the network as multiaddr strings
    // Should not serialize to config.yaml
    NetworkAddrs []string `json:"networkAddrs,omitempty"`
}

ProfilePod is serializable plain-old-data that configures a qri profile

func DefaultProfile Uses

func DefaultProfile() *ProfilePod

DefaultProfile gives a new default profile configuration

func DefaultProfileForTesting Uses

func DefaultProfileForTesting() *ProfilePod

DefaultProfileForTesting constructs a profile with precomputed keys, only used for testing.

func (*ProfilePod) Copy Uses

func (p *ProfilePod) Copy() *ProfilePod

Copy makes a deep copy of the ProfilePod struct

func (*ProfilePod) SetField Uses

func (p *ProfilePod) SetField(field, value string) error

SetField assigns to the name field of the Profile. TODO: Replace this with a generic package.

func (ProfilePod) Validate Uses

func (p ProfilePod) Validate() error

Validate validates all fields of profile returning all errors found.

type RPC Uses

type RPC struct {
    Enabled bool `json:"enabled"`
    Port    int  `json:"port"`
}

RPC configures a Remote Procedure Call (RPC) listener

func DefaultRPC Uses

func DefaultRPC() *RPC

DefaultRPC creates a new default RPC configuration

func (*RPC) Copy Uses

func (cfg *RPC) Copy() *RPC

Copy makes a deep copy of the RPC struct

func (RPC) Validate Uses

func (cfg RPC) Validate() error

Validate validates all fields of rpc returning all errors found.

type Registry Uses

type Registry struct {
    Location string `json:"location"`
}

Registry encapsulates configuration options for centralized qri registries

func DefaultRegistry Uses

func DefaultRegistry() *Registry

DefaultRegistry generates a new default registry instance

func (*Registry) Copy Uses

func (cfg *Registry) Copy() *Registry

Copy makes a deep copy of the Registry struct

func (Registry) Validate Uses

func (cfg Registry) Validate() error

Validate validates all fields of p2p returning all errors found.

type Remote Uses

type Remote struct {
    // remote mode
    Enabled bool `json:"enabled"`
    // maximum size of dataset to accept for remote mode
    AcceptSizeMax int64 `json:"acceptsizemax"`
    // timeout for remote sessions, in milliseconds
    AcceptTimeoutMs time.Duration `json:"accepttimeoutms"`
    // require clients pushing blocks to send all blocks
    RequireAllBlocks bool `json:"requireallblocks"`
    // allow clients to request unpins for their own pushes
    AllowRemoves bool `json:"allowremoves"`
}

Remote configures Qri for control over the network, accepting dataset push requests

func (*Remote) Copy Uses

func (cfg *Remote) Copy() *Remote

Copy returns a deep copy of the Remote struct

func (Remote) Validate Uses

func (cfg Remote) Validate() error

Validate validates all fields of render returning all errors found.

type Remotes Uses

type Remotes map[string]string

Remotes encapsulates configuration options for remotes

func (*Remotes) Copy Uses

func (r *Remotes) Copy() *Remotes

Copy creates a copy of a Remotes struct

func (*Remotes) Get Uses

func (r *Remotes) Get(name string) (string, bool)

Get retrieves an address from the name of remote

func (*Remotes) SetArbitrary Uses

func (r *Remotes) SetArbitrary(key string, val interface{}) (err error)

SetArbitrary is for implementing the ArbitrarySetter interface defined by base/fill_struct.go

type Render Uses

type Render struct {
    // TemplateUpdateAddress is currently an IPNS location to check for updates. api.Server starts
    // this address is checked, and if the hash there differs from DefaultTemplateHash, it'll use that instead
    TemplateUpdateAddress string `json:"templateUpdateAddress"`
    // DefaultTemplateHash is a hash of the compiled template
    // this is fetched and replaced via dnslink when the render server starts
    // the value provided here is just a sensible fallback for when dnslink lookup fails,
    // pointing to a known prior version of the the render
    DefaultTemplateHash string `json:"defaultTemplateHash"`
}

Render configures the qri render command

func DefaultRender Uses

func DefaultRender() *Render

DefaultRender creates a new default Render configuration

func (*Render) Copy Uses

func (cfg *Render) Copy() *Render

Copy returns a deep copy of the Render struct

func (Render) Validate Uses

func (cfg Render) Validate() error

Validate validates all fields of render returning all errors found.

type Repo Uses

type Repo struct {
    Middleware []string `json:"middleware"`
    Type       string   `json:"type"`
    Path       string   `json:"path,omitempty"`
}

Repo configures a qri repo

func DefaultRepo Uses

func DefaultRepo() *Repo

DefaultRepo creates & returns a new default repo configuration

func (*Repo) Copy Uses

func (cfg *Repo) Copy() *Repo

Copy returns a deep copy of the Repo struct

func (Repo) Validate Uses

func (cfg Repo) Validate() error

Validate validates all fields of repo returning all errors found.

type Store Uses

type Store struct {
    Type    string                 `json:"type"`
    Options map[string]interface{} `json:"options,omitempty"`
    Path    string                 `json:"path,omitempty"`
}

Store configures a qri content addessed file store (cafs)

func DefaultStore Uses

func DefaultStore() *Store

DefaultStore returns a new default Store configuration

func (*Store) Copy Uses

func (cfg *Store) Copy() *Store

Copy returns a deep copy of the Store struct

func (Store) Validate Uses

func (cfg Store) Validate() error

Validate validates all fields of store returning all errors found.

type Update Uses

type Update struct {
    Type      string `json:"type"`
    Daemonize bool   `json:"daemonize"`
    Address   string `json:"address"`
}

Update configures a Remote Procedure Call (Update) listener

func DefaultUpdate Uses

func DefaultUpdate() *Update

DefaultUpdate creates a new default Update configuration

func (*Update) Copy Uses

func (cfg *Update) Copy() *Update

Copy makes a deep copy of the Update struct

func (Update) Validate Uses

func (cfg Update) Validate() error

Validate validates all fields of rpc returning all errors found.

type Webapp Uses

type Webapp struct {
    Enabled bool `json:"enabled"`
    Port    int  `json:"port"`
    // token for analytics tracking
    AnalyticsToken string `json:"analyticstoken"`
    // EntrypointUpdateAddress is currently an IPNS location to check for updates. api.Server starts
    // this address is checked, and if the hash there differs from EntrypointHash, it'll use that instead
    EntrypointUpdateAddress string `json:"entrypointupdateaddress"`
    // EntrypointHash is a hash of the compiled webapp (the output of running webpack https://github.com/qri-io/frontend)
    // this is fetched and replaced via dnslink when the webapp server starts
    // the value provided here is just a sensible fallback for when dnslink lookup fails,
    // pointing to a known prior version of the the webapp
    EntrypointHash string `json:"entrypointhash"`
}

Webapp configures the qri webapp service

func DefaultWebapp Uses

func DefaultWebapp() *Webapp

DefaultWebapp creates a new default Webapp configuration

func (*Webapp) Copy Uses

func (cfg *Webapp) Copy() *Webapp

Copy returns a deep copy of the Webapp struct

func (Webapp) Validate Uses

func (cfg Webapp) Validate() error

Validate validates all fields of webapp returning all errors found.

Directories

PathSynopsis
migratePackage migrate defines migrations for qri configuration files
testPackage test contains predefined set of PeerInfo for testing.

Package config imports 13 packages (graph) and is imported by 12 packages. Updated 2019-09-20. Refresh now. Tools for package owners.