trivial-tickets: Index | Files | Directories

package structs

import ""

Package structs supplies project-wide needed data structures, types and constants for the server and the command-line tool.

Package structs supplies project-wide needed data structures, types and constants for the server and the command-line tool.


Package Files

messages.go structs.go


const RandomIDLength int = 10

RandomIDLength is the length of the ticket and mail ids.

type CLIConfig Uses

type CLIConfig struct {
    Host string
    Port uint16
    Cert string

CLIConfig is a struct to hold the CLI config parameters provided on startup.

type CliErrMessage Uses

type CliErrMessage string

CliErrMessage defines different error messages printed when the command-line tool faces an error.

const (
    TooManyInputs CliErrMessage = "too many successive wrong user inputs. Aborting program execution.\n"
    NoValidOption CliErrMessage = "not within the range of valid options"
    EmptyString   CliErrMessage = "string is empty"
    InvalidEmail  CliErrMessage = "not a valid email address"

Various error messages for wrong user inputs

type CliMessage Uses

type CliMessage string

CliMessage defines different standard messages used by the command-line interface that are printed to the console.

const (
    // RequestCommandInput is the message for requesting
    // a command input.
    RequestCommandInput CliMessage = "\nTo fetch Mails from the server, type '0'\n" +
        "To send an email to the server type '1'\n" +
        "To exit this program type '2'\n" +
        "Command: "

    // CommandNotAccepted is the error message if a command
    // is not recognized.
    CommandNotAccepted CliMessage = "Input not accepted, error: "

    // RequestEmailAddress it the message to prompt the user
    // for a valid e-mail input.
    RequestEmailAddress CliMessage = "Please enter your email address. It has to be valid.\nEmail address: "

    // RequestSubject is the message to prompt the user for
    // a ticket subject.
    RequestSubject CliMessage = "Please enter the subject line.\nSubject: "

    // RequestMessage is the message to prompt the user for
    // a ticket message.
    RequestMessage CliMessage = "Please enter the body of the message.\nMessage: "

    // RequestTicketID is the message to prompt the user for
    // an optional ticket id.
    RequestTicketID CliMessage = "If applicable please enter the ticket ID. If left empty, " +
        "a new ticket will be created.\nTicket ID (optional): "

    // To is the string for the output of the recipient of
    // an e-mail.
    To  CliMessage = "To: "

    // Subject is the string for the output of the subject
    // of a ticket.
    Subject CliMessage = "Subject: "

Messages of the command-line tool

type Command Uses

type Command int

Command represents a command-line interface command. This can be either Fetch, Submit or Exit.

const (
    // CommandFetch is the CLI command to fetch emails
    // from the server.
    CommandFetch Command = iota

    // CommandSubmit is the CLI command to submit an
    // email to the server.

    // CommandExit is the CLI command to exit the CLI.

func (Command) String Uses

func (c Command) String() string

String converts a command to its string representation.

type Data Uses

type Data struct {
    Session Session
    Tickets map[string]Ticket
    Users   map[string]User

Data holds session and ticket data to parse to the web templates.

type DataSingleTicket Uses

type DataSingleTicket struct {
    Session Session
    Ticket  Ticket
    Tickets map[string]Ticket
    Users   map[string]User

DataSingleTicket holds the session and ticket data for a call to a single ticket.

type Entry Uses

type Entry struct {
    Date          time.Time `json:"id"`
    FormattedDate string    `json:"formattedDate"`
    User          string    `json:"user"`
    Text          string    `json:"text"`
    ReplyType     string    `json:"replyType"`

Entry describes a single reply within a ticket.

type JSONMap Uses

type JSONMap map[string]interface{}

JSONMap is a type for mapping JSON keys to JSON values. It is mostly used inside the Mail API.

type LogConfig Uses

type LogConfig struct {
    LogLevel  LogLevel
    Verbose   bool
    FullPaths bool

LogConfig defines the logging configuration for the server provided by the startup configuration flags.

type LogLevel Uses

type LogLevel int

LogLevel is a type that defines the level of logging. A high log level such as INFO means that more information and actions are logged to the console. A low log level suppresses the output of messages of a higher log level.

const (
    // LevelInfo is the default log level (all messages
    // are logged).
    LevelInfo LogLevel = iota

    // LevelWarning logs warnings, errors and fatal errors.

    // LevelError only logs errors and fatal errors.

    // LevelFatal only logs fatal errors (not recommended).
    // Fatal errors are always logged.

    // LevelTestDebug is an additional log level used only
    // for debugging inside tests (not configurable).

func AsLogLevel Uses

func AsLogLevel(logLevelString string) LogLevel

AsLogLevel converts a given log level string to a log level. If the log level string is not defined, the return value is -1.

func (LogLevel) String Uses

func (level LogLevel) String() string

String converts a log level to its corresponding output string used in the log.

type Mail Uses

type Mail struct {
    ID      string `json:"id"`
    From    string `json:"from"`
    To      string `json:"to"`
    Subject string `json:"subject"`
    Message string `json:"message"`

Mail struct holds the information for a received email in order to create new tickets or answers.

type ServerConfig Uses

type ServerConfig struct {
    // Port is the port the server is listening to.
    Port uint16

    // Tickets is the directory in which
    // all tickets are stored.
    Tickets string

    // User is the path to the users.json file.
    Users string

    // Mails is the directory in which all
    // mails are stored.
    Mails string

    // Cert is the path to the SSL
    // Certificate file.
    Cert string

    // Key is the path to the SSL Key file.
    Key string

    // Web is the root directory of the server
    // where web resources are located.
    Web string

ServerConfig is a struct to hold the config parameters provided on startup.

type Session Uses

type Session struct {
    ID           string
    User         User
    CreationTime time.Time
    IsLoggedIn   bool

Session is a struct that holds session variables for a certain user.

type SessionManager Uses

type SessionManager struct {
    Name    string
    Session Session
    TTL     int64

SessionManager holds a session and operates on a it.

type Status Uses

type Status int

Status is an enum to represent the current status of a ticket.

const (
    // StatusOpen means the ticket is opened and has
    // no assignee.
    StatusOpen Status = iota

    // StatusInProgress means the ticket is being
    // processed by an assignee.

    // StatusClosed means the ticket has been closed.

func (Status) String Uses

func (status Status) String() string

String converts a ticket status to its corresponding description used in the outgoing mails.

type Ticket Uses

type Ticket struct {
    ID       string  `json:"id"`
    Subject  string  `json:"subject"`
    Status   Status  `json:"status"`
    User     User    `json:"user"`
    Customer string  `json:"customer"`
    Entries  []Entry `json:"entries"`
    MergeTo  string  `json:"mergeTo"`

Ticket represents a ticket.

type User Uses

type User struct {
    ID          string `json:"id"`
    Name        string `json:"name"`
    Username    string `json:"username"`
    Mail        string `json:"mail"`
    Hash        string `json:"hash"`
    IsOnHoliday bool   `json:"isOnHoliday"`

User is the model for a user that works on tickets.


defaultsPackage defaults defines default constraints for the server and the test suite.

Package structs imports 2 packages (graph) and is imported by 11 packages. Updated 2019-03-10. Refresh now. Tools for package owners.