conf

package
v0.0.0-...-5546796 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package conf provides means to load gonsot configuration on-disk

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMethod

type AuthMethod int

AuthMethod is the type of authenticate we'll try to perform

const (
	AuthHeader AuthMethod = iota
	AuthToken
)

func (AuthMethod) String

func (i AuthMethod) String() string

func (*AuthMethod) UnmarshalText

func (a *AuthMethod) UnmarshalText(text []byte) (err error)

UnmarshalText validates before assigning

type Config

type Config struct {
	APIVersion    string
	AuthHeader    string
	AuthMethod    AuthMethod
	DefaultDomain string
	DefaultSite   int
	Email         Email
	SecretKey     string
	URL           URL

	// Manually set Site to override DefaultSite or if you don't set
	// DefaultSite
	Site int
}

Config represents settings needed to connect to an NSoT server

func (*Config) Dump

func (c *Config) Dump(fn string) error

Dump writes the Config instance to provided filename

func (*Config) Load

func (c *Config) Load() error

Load marshalls config files into the struct automatically

There are two locations for gonsot.toml

* System level (Under /etc) * User level (Under $HOME as a dotfile)

User level configs will be preferred, merging if possible with system config. This allows "global" configuration but lets a user do overrides

If existing INI config from pynsot exists and no TOML found, will create TOML config with the same settings

type Email

type Email struct{ mail.Address }

Email is the email address to use to login

func (*Email) MarshalText

func (e *Email) MarshalText() (text []byte, err error)

MarshalText converts back to string form

func (*Email) UnmarshalText

func (e *Email) UnmarshalText(text []byte) (err error)

UnmarshalText validates before assigning

type URL

type URL struct{ url.URL }

URL is the base URL for an NSoT instance

func (*URL) MarshalText

func (u *URL) MarshalText() (text []byte, err error)

MarshalText converts back to string form

func (*URL) UnmarshalText

func (u *URL) UnmarshalText(text []byte) (err error)

UnmarshalText validates before assigning

Jump to

Keyboard shortcuts

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