config

package
v0.0.0-...-8cb11cc Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2016 License: MIT Imports: 9 Imported by: 0

README

Configuration

When starting up Autograder the first time, a set of configuration variables need to be set. These variables get stored in a JSON formatted file named config.

Here is an example configuration file:

{
  "HomepageURL": "http://autograder.uis.no/",
  "ClientID": "123456789",
  "ClientSecret": "123456789abcdef",
  "BasePath": "/usr/share/autograder/"
}

The configuration file is stored in the base path.

Documentation

Index

Constants

View Source
const (
	// SysName is the name of the system (in case we need to rename it)
	SysName = "Autograder"
	// SysNameLC is lower case version of the name of the system
	SysNameLC = "autograder"
	// SysURL is the placeholder URL for the system
	SysURL = "http://autograder.org"
	// FileName is the default file name for the JSON configuration file.
	FileName = "config"
	// StdPath is the default path used unless a path is provided at start up.
	StdPath = "./autograder"
)

Variables

This section is empty.

Functions

func IsSet

func IsSet() bool

IsSet returns true if a current configuration has been initialized.

func PrintInstructions

func PrintInstructions()

PrintInstructions prints the configuration instructions.

Types

type Configuration

type Configuration struct {
	URL               string `json:",omitempty"`
	Admin             string `json:",omitempty"`
	OAuthClientID     string `json:",omitempty"`
	OAuthClientSecret string `json:",omitempty"`
	BasePath          string `json:",omitempty"`
}

Configuration contains the necessary configuration data for the system.

func Get

func Get() Configuration

Get returns a copy of the current configuration.

func Load

func Load(path string) (*Configuration, error)

Load loads the configuration file in the provided directory.

func NewConfig

func NewConfig(url, admin, clientID, clientSecret, path string) (*Configuration, error)

NewConfig creates a new configuration object.

func (*Configuration) Save

func (c *Configuration) Save() error

Save saves the configuration file in basepath.

func (*Configuration) SetCurrent

func (c *Configuration) SetCurrent()

SetCurrent sets the current configuration. After this it cannot be set again.

Jump to

Keyboard shortcuts

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