config

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 7 Imported by: 0

Documentation

Overview

Package config provides tools to load and validate configuration data for the t3c tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	TrafficOps   TrafficOps   `json:"trafficOps"`
	TrafficOpsDB TrafficOpsDB `json:"trafficOpsDB"`
	Default      Default      `json:"default"`
	UseIMS       bool         `json:"use_ims"`
}

Config reflects the structure of the test-to-api.conf file. It also implements github.com/apache/trafficcontrol/lib/go-log.Config for logging.

func LoadConfig

func LoadConfig(confPath string) (Config, error)

LoadConfig reads the given configuration file into a Config.

func (Config) DebugLog

func (c Config) DebugLog() log.LogLocation

DebugLog provides the location to which debug-level messages should be logged.

func (Config) ErrorLog

func (c Config) ErrorLog() log.LogLocation

ErrorLog provides the location to which error-level messages should be logged.

func (Config) EventLog

func (c Config) EventLog() log.LogLocation

EventLog provides the location to which event-level messages should be logged.

func (Config) InfoLog

func (c Config) InfoLog() log.LogLocation

InfoLog provides the location to which info-level messages should be logged.

func (Config) WarningLog

func (c Config) WarningLog() log.LogLocation

WarningLog provides the location to which warning-level messages should be logged.

type Default

type Default struct {
	Session Session   `json:"session"`
	Log     Locations `json:"logLocations"`
	// IncludeSystemTests has no effect or known purpose.
	//
	// Deprecated: This field has no effect or known purpose.
	IncludeSystemTests bool `json:"includeSystemTests"`
}

Default represents the default values of a set of options that can be overridden by command-line options.

type Locations

type Locations struct {
	Debug   string `json:"debug"`
	Event   string `json:"event"`
	Error   string `json:"error"`
	Info    string `json:"info"`
	Warning string `json:"warning"`
}

Locations is a set of logging locations as defined by the github.com/apache/trafficcontrol/lib/go-log package.

type Session

type Session struct {
	TimeoutInSecs int `json:"timeoutInSecs" envconfig:"SESSION_TIMEOUT_IN_SECS"`
}

Session contains default configuration options for authenticated sessions with the Traffic Ops API.

type TrafficOps

type TrafficOps struct {
	// URL is the URL of a Traffic Ops instance being used for the tests.
	URL string `json:"URL" envconfig:"TO_URL"`

	// UserPassword is the password of *all* users in the 'Users' property.
	UserPassword string `json:"password" envconfig:"TO_USER_PASSWORD"`

	// Users are the Traffic Ops users to be used in testing.
	Users Users `json:"users"`

	// Insecure instructs tests whether or not to skip certificate verification.
	Insecure bool `json:"sslInsecure" envconfig:"SSL_INSECURE"`
}

TrafficOps is the section of a Config dealing with Traffic Ops-related information.

type TrafficOpsDB

type TrafficOpsDB struct {
	// Name is the name of a PostgreSQL database used by the testing Traffic Ops
	// instance.
	Name string `json:"dbname" envconfig:"TODB_NAME"`

	// Hostname is the network hostname where the Traffic Ops database is
	// running.
	Hostname string `json:"hostname" envconfig:"TODB_HOSTNAME"`

	// User is the name of a PostgreSQL user/role that has permissions to
	// manipulate the database identified in Name.
	User string `json:"user" envconfig:"TODB_USER"`

	// Password is the password for the PostgreSQL user/role given in User.
	Password string `json:"password" envconfig:"TODB_PASSWORD"`

	// Port is the port on which PostgreSQL listens for connections to the
	// database used by the testing Traffic Ops instance.
	Port string `json:"port" envconfig:"TODB_PORT"`

	// DBType is a Go database/sql driver name to use when connecting to the
	// Traffic Ops testing instance's database. This MUST be "Pg" (or
	// omitted/blank/null, which uses the default value of "Pg").
	//
	// Deprecated: Since Traffic Ops 3.0, only PostgreSQL databases are
	// supported, so this field has no purpose and will probably be removed at
	// some point.
	DBType string `json:"type" envconfig:"TODB_TYPE"`

	// SSL instructs the database driver that the PostgreSQL instance used by
	// the tests requires SSL-secured connections.
	SSL bool `json:"ssl" envconfig:"TODB_SSL"`

	// Description is a textual description of the database.
	//
	// Deprecated: This unused field serves no purpose, and will likely be
	// removed in the future.
	Description string `json:"description" envconfig:"TODB_DESCRIPTION"`
}

TrafficOpsDB is the section of a Config dealing with Traffic Ops DB-related information.

type Users

type Users struct {

	// Disallowed is the username of a "disallowed" Traffic Ops user.
	//
	// Deprecated: This is unused in t3c tests, and may be removed in the
	// future.
	Disallowed string `json:"disallowed" envconfig:"TO_USER_DISALLOWED"`

	// ReadOnly is the username of a Traffic Ops user with "read-only"
	// Permissions.
	//
	// Deprecated: This is unused in t3c tests, and may be removed in the
	// future.
	ReadOnly string `json:"readOnly" envconfig:"TO_USER_READ_ONLY"`

	// Operations is the username of a Traffic Ops user with "operations"-level
	// Permissions.
	//
	// Deprecated: This is unused in t3c tests, and may be removed in the
	// future.
	Operations string `json:"operations" envconfig:"TO_USER_OPERATIONS"`

	// Admin is the username of a Traffic Ops user with the special "admin"
	// Role.
	Admin string `json:"admin" envconfig:"TO_USER_ADMIN"`

	// Portal is the username of a Traffic Ops user with "portal"-level
	// Permissions.
	//
	// Deprecated: This is unused in t3c tests, and may be removed in the
	// future.
	Portal string `json:"portal" envconfig:"TO_USER_PORTAL"`

	// Federation is the username of a Traffic Ops user with
	// "federation"-level Permissions.
	//
	// Deprecated: This is unused in t3c tests, and may be removed in the
	// future.
	Federation string `json:"federation" envconfig:"TO_USER_FEDERATION"`

	// Extension is the username of a Traffic Ops user allowed to manipulate
	// extensions (i.e. creating new serverchecks).
	//
	// These tests currently use Traffic Ops API version 3.0, so the only
	// username that can possibly work is literally "extension". This property
	// MUST be configured to be "extension", or the tests will erroneously fail,
	// no matter what "Priv Level" and/or Permissions you give the user!
	Extension string `json:"extension" envconfig:"TO_USER_EXTENSION"`
}

Users structures are the "users" section of the "trafficOps" section of the testing configuration file, and are a collection of the usernames of Traffic Ops users that are used in testing.

Jump to

Keyboard shortcuts

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