config

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: GPL-3.0 Imports: 15 Imported by: 2

README

config

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

# to get, for example, your profile information
$ qri config get profile

# to set, for example, your api port to 4444
$ qri config set api.port 4444

# to disable rpc connections
$ qri config set rpc.enabled false

Objects and arrays can be indexed into using dot notation, eg as shown above to get or set the api port use api.port To get the first element (which is at index 0) in the p2p.qribootstrapaddrs array: qri config get p2p.qribootstrapaddrs.0

Here is a quick reference of all configurable fields:


Profile

Your profile contains some hairy stuff you shouldn't change once it is set initially.

We strongly recommend you don't change your privkey, ID, and peername.

Created and updated are the timestamps that your profile was created and updated. These will be set automatically, we suggest you don't change these either.

Type, email, name, description, homeurl, color, twitter, and profile and poster photo we strongly encourage you to update!


ID

Profile ID Your id is your identity on Qri and it is set when you first run qri setup or qri connect --setup. Your datasets, your qri nodes, your profile, your identity to your peers are all tied to this profile id. Changing this is bad news bears and will break everything.

DO NOT CHANGE


privkey

private key Your private key is generated when you first run qri setup or qri connect --setup.

DO NOT PUBLISH THIS ANYWHERE.

Your private key is a form of security. If anyone else has your private key, they can pretend to be you. Also bad news bears to change this.


peername

Your moniker on qri. The name that is associated with your profile and datasets.

Let's say your peername is lunalovegood7 (for some reason), and a dataset of yours called best_harry_potter_quotes_ranked.

# a peer would get your profile info by:
$ qri peers lunalovegood74

# and get info on your super important dataset using
$ qri info lunalovegood7/best_harry_potter_quotes_ranked

Your peername is set when you first run qri setup (or qri setup --peername lunalovegood7).

The peername will be mutable in the future, but for now changing your peername is as bad as changing your profile id.

Do not change your peername after setup


created

Date and time timestamp when the qri profile was created on setup. We recommend you do not change this field.


updated

Date and time timestamp when the qri profile was last updated. We recommend you do not change this field as it should auto update on any profile change. (this auto update feature might not be set yet)


type

peer or organization Qri profiles can be associated with a single person or an organization.

Input options (string): peer, organization

Commands:

$ qri config get profile.type

$ qri config set profile.type peer

email

An email address to reach you. If other qri folks can reach you, it will greatly strengthen their trust in yoru datasets.

Input options (string): valid email address

Commands:

$ qri config get profile.email

$ qri config set profile.email example@example.com

name

Your name or organizations name.

Input options (string): max 255 character length

Commands:

$ qri config get profile.name

$ qri config set profile.name Jane Doe

description

A little bio about you or your organization. Can help other users understand the types of data you are interested in.

Input options (string): max 255 character length

Commands:

$ qri config get profile.description 

$ qri config set profile.description "Hi my name is Jane Doe and I am a researcher in the field of loving Harry Potter. I am interested data surrounding the behavior of those who love Harry Potter as much as I do"

homeurl

You or your organization's website.

Input options (string): valid url

Commands:

$ qri config get profile.homeurl

$ qri config set profile.homeurl https://harrypotterlover.com

color

The theme color your prefer when viewing Qri using the webapp. This will expand, but for now the only option is 'default'

Input options (string): default

Commands:

$ qri config get profile.color

$ qri config set profile.color default

thumb

thumbnail photo Your thumbnail photo is auto generated using the profile photo uploaded. We recommend not setting this yourself.


profile photo

Upload a profile photo using a filepath, url, or ipfs hash. This photo is used on the Qri webapp.

Input options (string): valid url, valid filepath, or valid ipfs hash

Commands:

$ qri config get profile.profile

$ qri config set profile.profile ~/Documents/pictures/headshot.jpeg

poster photo

Upload a poster photo (the backdrop to your profile). This photo is used on the Qri webapp.

Input options (string): valid url, valid filepath, or valid ipfs hash

Commands:

$ qri config get profile.poster

$ qri config set profile.poster http://www.imgur.com/pic_of_sunset_i_took_one_time.jpeg

twitter

twitter handle You or your organization's twitter handle. No need to include the @ symbol.

Input options (string): valid twitter handle (max length 15)

Commands:

$ qri config get profile.twitter

$ qri config set profile.twitter lunalovegood7

.


repo

The repo config controls how references to your datasets are stored and (in the future) what additional middleware you want to use when you store it. We don't recommend messing with these, as improper changes can break Qri.


middleware

Middleware is a list of packages that can be used to supliment the process of saving data to Qri. Currently not implemented, but in the future could potentially add encryption middleware, or back up middleware.

Input options (array of strings): not currently implemented


repo type

The type of filestore used to store the references to your data and profile.

Input options (string): fs (currently, any string other string will not work)

Commands:

$ qri config get repo.type

$ qri config set repo.type fs

.


Store

Where and how the datasets are stored.


store type

Where your datasets are stored.

Input options (string): ipfs (currently, any string other string will not work)

Commands:

$ qri config get store.type

$ qri config set store.type ipfs

.


p2p

The p2p config should go unchanged. This config section gives you options to change the way your qri node communicates with other qri nodes.

We strongly recommend you don't change any of these fields but especially not your privkey, pubkey, and peerid.


p2p enabled

Is p2p communication enabled? Probs keep this on if you want any of the benefits of being on the distributed web.

Input options (boolean): true or false

Commands:

$ qri config get p2p.enabled

$ qri config set p2p.enabled true

p2p peerid

The id of this specific node on the network. This will eventually be different from your profile.ID, which is meant to be the identity of all the nodes associated with your profile on the network (eg, if you have qri on two different computers, or on your phone, or tablet)

This is set when you run qri setup

It is associated with your private key and public key, so changes any of them will mess up your p2p communication.

DO NOT CHANGE


p2p privkey

private key Your private key is generated when you first run qri setup or qri connect --setup.

DO NOT PUBLISH THIS ANYWHERE.

Your private key is a form of security. If anyone else has your private key, they can pretend to be you.

It is associated with your public key and peerid, so changes any of them will mess up your p2p communication.

DO NOT CHANGE


pubkey

public key Your public key is what you exchange with peers in order to encrypt your messages and prove your identity.

It is associated with your private key and peerid, so changes any of them will mess up your p2p communication.

DO NOT CHANGE


p2p port

The port to bind a tcp listener. Ignored if Addrs is supplied

Input options (integer): integer

Commands:

$ qri config get p2p.port

$ qri config set p2p.port 0

addrs

List of multiaddresses to listen on

Input options (list of addresses): list of multiadders

Commands:

$ qri config get p2p.addrs

$ qri config set p2p.addrs /ip4/130.211.198.23/tcp/4001/ipfs/QmNX9nSos8sRFvqGTwdEme6LQ8R1eJ8EuFgW32F9jjp2Pb

qribootstrapaddrs

QriBootstrapAddrs lists the addresses to bootstrap you Qri node from. If you change this list, it will take your node a longer time to connect to the Qri network.

Input options (list of addresses): list of multiaddrs

Commands:

$ qri config get p2p.qribootstrapaddrs

$ qri config set p2p.qribootstrapaddrs /ip4/130.211.198.23/tcp/4001/ipfs/QmNX9nSos8sRFvqGTwdEme6LQ8R1eJ8EuFgW32F9jjp2Pb

profilereplication

Profilereplication determines waht to do when this peer sees messages broadcast by it's own profile (from another peer instance). Setting profilereplication to full will cause this peer to automatically pin any data that is verifyably posted the same peer

Input options (string): full

Commands:

$ qri config get p2p.profilereplication

$ qri config set p2p.profilereplication full

bootstrapaddrs

List of addresses to bootstrap qri peers on.

Input options (list of addresses): list of multiaddrs

Commands:

$ qri config get p2p.bootstrapaddrs

$ qri config set p2p.bootstrapaddrs /ip4/130.211.198.23/tcp/4001/ipfs/QmNX9nSos8sRFvqGTwdEme6LQ8R1eJ8EuFgW32F9jjp2Pb

.


cli

cli is the config for the command line interface


colorizeoutput

When true, the output to your terminal will be colorized.

Input options (boolean): true or false

Commands:

$ qri config get cli.colorizeoutput

$ qri config set p2p.colorizeoutput true

.


api

Config for the API server.


api enabled

When true, the api server is enabled when you run qri connect

The api must be enabled and set to port 2503 in order to work locally with the frontend webapp

Input options (boolean): true or false

Commands:

$ qri config get api.enabled

$ qri config set api.enabled true

api port

The api will listen for calls at this port.

The api must be enabled and set to port 2503 in order to work locally with the frontend webapp.

Input options (integer):

Commands:

$ qri config get api.port

$ qri config set api.port 2503

readonly

When true, the api will only respond to certain GET requests. Doesn't allow any calls that will amend, save, add, or delete datasets or profile information.

Input options (boolean): true and false

Commands:

$ qri config get api.readonly

$ qri config set api.readonly false

.


webapp

Config for the API server.


webapp enabled

When true, if your node is connected (qri connect) you can go to localhost:2505 in your browser to view the webapp.

The api must be enabled and set to port 2503 in order to work locally with the frontend webapp

Input options (boolean): true or false

Commands:

$ qri config get api.enabled

$ qri config set api.enabled true

webapp port

The api will listen for calls at this port.

The api must be enabled and set to port 2503 in order to work locally with the frontend webapp.

Input options (integer):

Commands:

$ qri config get api.port

$ qri config set api.port 2503

.


rpc

Config for the RPC listener.


rpc enabled

When true, rpc connections are enabled.

Input options (boolean): true or false

Commands:

$ qri config get rpc.enabled

$ qri config set rpc.enabled true

rpc port

The rpc will listen for calls at this port. Qri standard is 2504.

Input options (integer):

Commands:

$ qri config get rpc.port

$ qri config set rpc.port 2504

.


logging

Config for the logger.


levels

The different log levels can be set in this object

- qriapi

Log levels for the api

Input options (string): info, error, debug, warn

Commands:

$ qri config get logging.levels.qriapi.info

$ qri config set logging.levels {"qriapi":"info"}

Documentation

Overview

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

Constants

View Source
const CurrentConfigRevision = 1

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

Variables

View Source
var DefaultAPIPort = 2503

DefaultAPIPort is local the port webapp serves on by default

View Source
var DefaultRPCPort = 2504

DefaultRPCPort is local the port RPC serves on by default

View Source
var DefaultWebappPort = 2505

DefaultWebappPort is local the port webapp serves on by default

Functions

func ImmutablePaths

func ImmutablePaths() map[string]bool

ImmutablePaths returns a map of paths that should never be modified

Types

type API

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"`
	// 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"`
}

API holds configuration for the qri JSON api

func DefaultAPI

func DefaultAPI() *API

DefaultAPI returns the default configuration details

func (*API) Copy added in v0.3.2

func (a *API) Copy() *API

Copy returns a deep copy of an API struct

func (API) Validate

func (a API) Validate() error

Validate validates all fields of api returning all errors found.

type CLI

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

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

func DefaultCLI

func DefaultCLI() *CLI

DefaultCLI returns a new default CLI configuration

func (*CLI) Copy added in v0.3.2

func (c *CLI) Copy() *CLI

Copy returns a deep copy of a CLI struct

func (CLI) Validate

func (c CLI) Validate() error

Validate validates all fields of cli returning all errors found.

func (*CLI) WithPrivateValues added in v0.3.2

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 added in v0.3.2

func (c *CLI) WithoutPrivateValues() *CLI

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

type Config

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

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

	Render *Render
}

Config encapsulates all configuration details for qri

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig gives a new configuration with simple, default settings

func DefaultConfigForTesting added in v0.5.2

func DefaultConfigForTesting() *Config

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

func ReadFromFile

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

ReadFromFile reads a YAML configuration file from path

func (*Config) Copy added in v0.3.2

func (cfg *Config) Copy() *Config

Copy returns a deep copy of the Config struct

func (Config) Get

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

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

func (*Config) Set

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

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

func (Config) SummaryString

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

SummaryString creates a pretty string summarizing the configuration, useful for log output

func (Config) Validate

func (cfg Config) Validate() error

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

func (*Config) WithPrivateValues added in v0.3.2

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 added in v0.3.2

func (cfg *Config) WithoutPrivateValues() *Config

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

func (Config) WriteToFile

func (cfg Config) WriteToFile(path string) error

WriteToFile encodes a configration to YAML and writes it to path

type Logging

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

func DefaultLogging() *Logging

DefaultLogging produces a new default logging configuration

func (*Logging) Copy added in v0.3.2

func (l *Logging) Copy() *Logging

Copy returns a deep copy of a Logging struct

func (Logging) Validate

func (l Logging) Validate() error

Validate validates all fields of logging returning all errors found.

type P2P

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 verifyably 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

func DefaultP2P() *P2P

DefaultP2P generates a p2p struct with only bootstrap addresses set

func DefaultP2PForTesting added in v0.5.2

func DefaultP2PForTesting() *P2P

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

func (*P2P) Copy added in v0.3.2

func (cfg *P2P) Copy() *P2P

Copy returns a deep copy of a p2p struct

func (*P2P) DecodePeerID

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

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

func (*P2P) DecodePrivateKey

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

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

func (P2P) Validate

func (cfg P2P) Validate() error

Validate validates all fields of p2p returning all errors found.

type ProfilePod added in v0.3.2

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

func DefaultProfile() *ProfilePod

DefaultProfile gives a new default profile configuration

func DefaultProfileForTesting added in v0.5.2

func DefaultProfileForTesting() *ProfilePod

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

func (*ProfilePod) Copy added in v0.3.2

func (p *ProfilePod) Copy() *ProfilePod

Copy makes a deep copy of the ProfilePod struct

func (*ProfilePod) SetField added in v0.5.2

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 added in v0.3.2

func (p ProfilePod) Validate() error

Validate validates all fields of profile returning all errors found.

type RPC

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

RPC configures a Remote Procedure Call (RPC) listener

func DefaultRPC

func DefaultRPC() *RPC

DefaultRPC creates a new default RPC configuration

func (*RPC) Copy added in v0.3.2

func (cfg *RPC) Copy() *RPC

Copy makes a deep copy of the RPC struct

func (RPC) Validate

func (cfg RPC) Validate() error

Validate validates all fields of rpc returning all errors found.

type Registry added in v0.3.1

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

Registry encapsulates configuration options for centralized qri registries

func DefaultRegistry added in v0.3.1

func DefaultRegistry() *Registry

DefaultRegistry generates a new default registry instance

func (*Registry) Copy added in v0.3.2

func (cfg *Registry) Copy() *Registry

Copy makes a deep copy of the Registry struct

func (Registry) Validate added in v0.3.1

func (cfg Registry) Validate() error

Validate validates all fields of p2p returning all errors found.

type Render added in v0.3.2

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 added in v0.3.2

func DefaultRender() *Render

DefaultRender creates a new default Render configuration

func (*Render) Copy added in v0.3.2

func (cfg *Render) Copy() *Render

Copy returns a deep copy of the Render struct

func (Render) Validate added in v0.3.2

func (cfg Render) Validate() error

Validate validates all fields of render returning all errors found.

type Repo

type Repo struct {
	Middleware []string `json:"middleware"`
	Type       string   `json:"type"`
}

Repo configures a qri repo

func DefaultRepo

func DefaultRepo() *Repo

DefaultRepo creates & returns a new default repo configuration

func (*Repo) Copy added in v0.3.2

func (cfg *Repo) Copy() *Repo

Copy returns a deep copy of the Repo struct

func (Repo) Validate

func (cfg Repo) Validate() error

Validate validates all fields of repo returning all errors found.

type Store

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

Store configures a qri content addessed file store (cafs)

func DefaultStore

func DefaultStore() *Store

DefaultStore returns a new default Store configuration

func (*Store) Copy added in v0.3.2

func (cfg *Store) Copy() *Store

Copy returns a deep copy of the Store struct

func (Store) Validate

func (cfg Store) Validate() error

Validate validates all fields of store returning all errors found.

type Webapp

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

func DefaultWebapp() *Webapp

DefaultWebapp creates a new default Webapp configuration

func (*Webapp) Copy added in v0.3.2

func (cfg *Webapp) Copy() *Webapp

Copy returns a deep copy of the Webapp struct

func (Webapp) Validate

func (cfg Webapp) Validate() error

Validate validates all fields of webapp returning all errors found.

Directories

Path Synopsis
Package migrate defines migrations for qri configuration files
Package migrate defines migrations for qri configuration files
Package test contains predefined set of PeerInfo for testing.
Package test contains predefined set of PeerInfo for testing.

Jump to

Keyboard shortcuts

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