cfgspec

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfigBuilder = runtime.NewConfigSchemaBuilder(
		addUISchema,
	)
	AddToSchema = ConfigBuilder.AddToSchema
)
View Source
var ConfigSpec = conf.SectionSpec{
	{
		Name:        "Secret",
		Description: "Secret used to sign various data like session cookies and JWTs. If empty, a temporary secret is created.",
		Type:        conf.StringType,
	},
	{
		Name:        "BaseURL",
		Description: "The base URL on which CIS is reachable. If empty, it defaults to the Host header of each HTTP request.",
		Type:        conf.StringType,
	},
	{
		Name:        "Country",
		Description: "The country cisd operates in",
		Default:     "AT",
		Type:        conf.StringType,
	},
	{
		Name:        "DefaultOpenBefore",
		Type:        conf.DurationType,
		Description: "Default value for OpenBefore= in [OpeningHour]",
	},
	{
		Name:        "DefaultCloseAfter",
		Type:        conf.DurationType,
		Description: "Default value for CloseAfter= in [OpeningHour]",
	},
	{
		Name:        "DefaultOnCallDayStart",
		Type:        conf.StringType,
		Description: "Default value for OnCallDayStart= in [OpeningHour]",
	},
	{
		Name:        "DefaultOnCallNightStart",
		Type:        conf.StringType,
		Description: "Default value for OnCallNightStart= in [OpeningHour]",
	},
	{
		Name:        "TimeZone",
		Type:        conf.StringType,
		Description: "The time zone to use for dates and times in the configuration",
		Default:     "UTC",
	},
	{
		Name:        "UnknownContactName",
		Description: "The name of the 'unknown' contact or the special value ${caller}",
		Type:        conf.StringType,
	},
	{
		Name:        "UnknownContactSource",
		Description: "The 'customer-source' of the unknown contact",
		Type:        conf.StringType,
		Default:     "unknown",
	},
	{
		Name:        "UnknownContactID",
		Description: "The ID of the unknown contact",
		Type:        conf.StringType,
		Default:     "1",
	},
	{
		Name:        "LogLevel",
		Description: "The maximum log level that should be printed to console. Should either be a number or the special values 'trace' (7), 'debug' (6), 'info' (5), 'warn' (3) or 'error' (0)",
		Type:        conf.StringType,
		Default:     "info",
	},
	{
		Name:        "Listen",
		Description: "The address for the internal server to listen on",
		Type:        conf.StringType,
		Default:     ":3000",
	},
	{
		Name:        "TrustedProxy",
		Description: "One or more IP addresses in CIDR notation that are trusted to set correct X-Forwareded-For headers",
		Type:        conf.StringSliceType,
		Default:     "",
	},
	{
		Name:        "PrometheusMetricsListener",
		Description: "Listen address for the /metrics endpoint",
		Type:        conf.StringType,
		Default:     "127.0.0.1:3001",
	},
	{
		Name:        "Service",
		Description: "The name of the service. Used for metrics and traces.",
		Type:        conf.StringType,
		Default:     "cis",
	},
	{
		Name:        "Environment",
		Description: "The name of the environment the service is deployed at.",
		Default:     "production",
		Type:        conf.StringType,
	},
	{
		Name:        "ID",
		Description: "An arbitrary ID that is reported together with metrics and traces",
		Type:        conf.StringType,
		Default:     "",
	},
	{
		Name:        "JaegerTracingURL",
		Description: "URL of the Jaeger server to which traces should be reported",
		Type:        conf.StringType,
		Default:     "",
	},
	{
		Name:        "IdentityBackend",
		Description: "The type of identity backend that should be used",
		Default:     "file",
		Type:        conf.StringType,
	},
	{
		Name:        "ConfigProvider",
		Description: "The type of configuration provider to use. Currently 'file' and 'mongo' are supported.",
		Type:        conf.StringType,
		Default:     "file",
	},
	{
		Name:        "SameSite",
		Description: "Value for the SameSite cookie attribute.",
		Default:     "default",
		Type:        conf.StringType,
	},
}

ConfigSpec defines the different configuration stanzas for the Config struct.

View Source
var DatabaseSpec = conf.SectionSpec{
	{
		Name:        "DatabaseURI",
		Type:        conf.StringType,
		Description: "The connection string for the MongoDB database",
		Required:    true,
	},
	{
		Name:        "DatabaseName",
		Type:        conf.StringType,
		Description: "The name of the MongoDB database",
		Default:     "cis",
	},
}

DatabaseSpec describes the allowed configuration directives.

View Source
var ExternalLinkSpec = conf.SectionSpec{
	{
		Name:        "ParentMenu",
		Description: "The parent menu item",
		Type:        conf.StringType,
	},
	{
		Name:        "Text",
		Description: "The display text for the link",
		Type:        conf.StringType,
		Required:    true,
	},
	{
		Name:        "Icon",
		Description: "The name of the icon to display",
		Type:        conf.StringType,
	},
	{
		Name:        "Link",
		Description: "The target for the link",
		Type:        conf.StringType,
		Required:    true,
	},
	{
		Name:        "RequiresRole",
		Description: "The link requires one of the defined roles",
		Type:        conf.StringSliceType,
		Annotations: new(conf.Annotation).With(
			runtime.OneOfRoles,
		),
	},
	{
		Name:        "BlankTarget",
		Description: "Open link in a blank target",
		Type:        conf.BoolType,
	},
}

ExternalLinkSpec defines the configuration stanzas for an external link.

View Source
var InfoScreenConfigSpec = conf.SectionSpec{
	{
		Name:        "Enabled",
		Default:     "no",
		Description: "Whether or not to enable the info-screen module",
		Required:    false,
		Type:        conf.BoolType,
	},
	{
		Name:        "LayoutPath",
		Type:        conf.StringSliceType,
		Description: "One or more paths used to search for info-screen slide layouts",
		Required:    true,
	},
	{
		Name:        "UploadDataDirectory",
		Type:        conf.StringType,
		Description: "Directory that should be used to store uploaded files for infoscreen slides",
		Default:     filepath.Join(svcenv.Env().StateDirectory, "uploaded"),
	},
	{
		Name:        "MaxUploadSize",
		Type:        conf.StringType,
		Description: "The maximum allowed size of uploaded files. Supports K(ilo), M(ega) suffixes.",
		Default:     "1M",
	},
}
View Source
var KnownPhoneExtensionSpec = conf.SectionSpec{
	{
		Name:        "ExtensionNumber",
		Description: "The phone extension to match",
		Type:        conf.StringType,
		Required:    true,
	},
	{
		Name:        "DisplayName",
		Description: "The name to display in the UI",
		Type:        conf.StringType,
		Required:    true,
	},
}
View Source
var QuickRosterOverwriteSpec = conf.SectionSpec{
	{
		Name:        "DisplayName",
		Type:        conf.StringType,
		Description: "The display name for the quick-overwrite",
		Required:    true,
		Annotations: new(conf.Annotation).With(
			runtime.Unique(),
		),
	},
	{
		Name:        "TargetNumber",
		Type:        conf.StringType,
		Description: "Target phone number or extension",
		Required:    true,
	},
	{
		Name:        "RequiresRole",
		Type:        conf.StringSliceType,
		Description: "List access to this quick-selector to one or more roles",
		Annotations: new(conf.Annotation).With(
			runtime.OneOfRoles,
		),
	},
}

QuickRosterOverwriteSpec defines the configuration stanzas for a quick-roster overwrite definition.

View Source
var RosterUISpec = conf.SectionSpec{
	{
		Name:        "AllowAnyUserAsOverwrite",
		Type:        conf.BoolType,
		Description: "Whether or not all users should be eligible for roster overwrites",
		Default:     "yes",
	},
	{
		Name:        "AllowPhoneNumberOverwrite",
		Type:        conf.BoolType,
		Description: "Whether or not overwritting the roster using direct phone-numbers should be allowed via the UI. This does not restrict API though.",
		Default:     "yes",
	},
}
View Source
var TriggerActionSpec = conf.SectionSpec{
	{
		Name:        "Name",
		Description: "The name of the action",
		Type:        conf.StringType,
	},
	{
		Name:        "PrimaryTrigger",
		Description: "The ID of the primary trigger used to detect if the action is already pending.",
		Type:        conf.StringType,
		Annotations: new(conf.Annotation).With(
			runtime.OneOfRef("trigger", runtime.IDRef, "Name"),
		),
	},
	{
		Name:        "TriggerGroup",
		Description: "The name of the trigger group to execute. If set, PrimaryTrigger is expected to be part of the group",
		Type:        conf.StringSliceType,
		Annotations: new(conf.Annotation).With(
			runtime.OneOfRef("trigger", "Group", "Group"),
		),
	},
	{
		Name:        "ActionText",
		Description: "The text for the action button",
		Type:        conf.StringType,
	},
	{
		Name:        "PendingText",
		Description: "The text to display if the trigger is already pending.",
		Type:        conf.StringType,
	},
}

TriggerActionSpec defines the configuration spec that can be used for the custom trigger actions.

View Source
var UISpec = conf.SectionSpec{
	{
		Name:        "HideUsersWithRole",
		Description: "A list or role names. All users that have one of the given roles are hidden from (most parts of) the UI",
		Type:        conf.StringSliceType,
		Annotations: new(conf.Annotation).With(
			runtime.OneOfRoles,
		),
	},
	{
		Name:        "UserPhoneExtensionProperties",
		Description: "A list of user properties that hold phone extensions and should be used to link from call log records to users",
		Type:        conf.StringSliceType,
		Annotations: new(conf.Annotation).With(
			runtime.OneOfRef("UserProperty", "Name", "Name"),
		),
	},
	{
		Name:        "CreateEventAlwaysAllowCalendar",
		Description: "A list of calendar IDs that should always be displayed/allowed when creating new events.",
		Type:        conf.StringSliceType,
	},
	{
		Name:    "OnCallRosterType",
		Type:    conf.StringType,
		Default: "Tierarzt",
	},
	{
		Name:    "OfftimeCommentScope",
		Type:    conf.StringType,
		Default: "offtime-requests",
	},
	{
		Name:    "ComputerAccountRole",
		Type:    conf.StringType,
		Default: "computer-accounts",
	},
}

UISpec defines what configuration stanzas are supported.

Functions

func ParseLogLevel

func ParseLogLevel(l string) (logger.Severity, error)

ParseLogLevel parses the string l and returns the respective logger.Severity. l should either be a number or the special values 'trace' (7), 'debug' (6), 'info' (5), 'warn' (3) or 'error' (0).

Types

type Config

type Config struct {
	Secret   string
	Country  string
	TimeZone string
	LogLevel string

	// ConfigProvider defines the type of configuration provider
	// that should be used by CIS.
	ConfigProvider string

	// IdentityBackend configures the backend type that should be
	// used for user configuration.
	IdentityBackend string

	// Service is the name of the service. It's used when reporting
	// metrics and traces.
	Service string
	// Environment defines an arbitrary environment string that is
	// reported together with metrics and traces.
	Environment string
	// ID defines an arbitrary ID for this service instances. This might
	// be set to the Container ID or Allocation ID and is reported together
	// with metrics and traces.
	ID string
	// JaegerTracingURL, when set, should point to the collector of a
	// Jaeger deployment.
	JaegerTracingURL string

	// HTTP Server configuration
	BaseURL                   string
	Listen                    string
	TrustedProxy              []string
	PrometheusMetricsListener string
	SameSite                  string

	UnknownContactName   string
	UnknownContactSource string
	UnknownContactID     string

	DefaultOpenBefore time.Duration
	DefaultCloseAfter time.Duration

	DefaultOnCallDayStart   string
	DefaultOnCallNightStart string
}

Config groups global configuration values that are used by various subsystems of cisd.

type DatabaseConfig

type DatabaseConfig struct {
	// DatabaseURI holds the connection string to the MongoDB database.
	DatabaseURI string

	// DatabaseName holds the name of the mongodb database to use
	DatabaseName string
}

DatabaseConfig groups configuration options for the mongodb database.

type InfoScreenConfig

type InfoScreenConfig struct {
	Enabled             bool     `option:"Enabled"`
	LayoutPaths         []string `option:"LayoutPath"`
	UploadDataDirectory string   `option:"UploadDataDirectory"`
	MaxUploadSize       string   `option:"MaxUploadSize"`
}

Jump to

Keyboard shortcuts

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