Documentation ¶
Index ¶
- Constants
- func ConnectToDatabase(cfg *config.Config) (*mgo.Session, error)
- func FormatDuration(d time.Duration) string
- func GetMongoSessionFromContext(ctx context.Context) *mgo.Session
- func GetSelfBaseURLFromContext(ctx context.Context) string
- func GetSelfURLFromRequest(r *http.Request) string
- func GetThemeFromContext(ctx context.Context) interface{}
- func NormalizeSlackCustomCommand(cmd models.SlackCustomCommand) models.SlackCustomCommand
- func PT(value string) time.Time
- func PrintBanner(env *Environment)
- func PutMongoSessionInContext(parentContext context.Context, session *mgo.Session) context.Context
- func PutSelfBaseURLInContext(parentContext context.Context, url string) context.Context
- func PutThemeInContext(parentContext context.Context, theme interface{}) context.Context
- func TruncateTables(session *mgo.Session)
- func WhichTimezoneIsMidnightAt(utcHour, utcMinute int) int
- type Environment
Constants ¶
const ( ContextKeyMongoSession = "mongoSession" ContextKeySelfBaseURL = "selfBaseUrl" ContextKeyTheme = "theme" )
const ( // ProductionEnv - a value that indicates about production env ProductionEnv = "production" // DevelopmentEnv - a value that indicates about development env DevelopmentEnv = "development" // TestEnv - a value that indicates about test env TestEnv = "test" )
const ( PassExpiresInMinutes = 5 ClaimedPassesToPurgeAfterDays = 7 )
const ( MongoCollectionTeams = "teams" MongoCollectionTimers = "timers" MongoCollectionTeamUsers = "team_users" MongoCollectionPasses = "passes" )
const ( // ConfigFile - path to YML config file ConfigFile string = "config.yml" )
Variables ¶
This section is empty.
Functions ¶
func ConnectToDatabase ¶
ConnectToDatabase todo
func FormatDuration ¶
FormatDuration formats duration to be like HH:MMh regardless of days, months etc
func GetSelfURLFromRequest ¶
func GetThemeFromContext ¶
func NormalizeSlackCustomCommand ¶
func NormalizeSlackCustomCommand(cmd models.SlackCustomCommand) models.SlackCustomCommand
NormalizeSlackCustomCommand will extract the subcommand form command (see scheme below_) and update the original command: Say the command was: Text = "start Add MongoDB service to docker-compose.yml" The method will do this:
SubCommand = "start" Text = "Add MongoDB service to docker-compose.yml"
func PutSelfBaseURLInContext ¶
func PutThemeInContext ¶
func TruncateTables ¶
func TruncateTables(session *mgo.Session)
TruncateTables - clears database tables, supposed to be run in test's setup method
func WhichTimezoneIsMidnightAt ¶
WhichTimezoneIsMidnightAt - based up on UTC hour it returns an offset (in seconds) for a timezone where midnight (00:00) is
Types ¶
type Environment ¶
Environment is a thing that holds env. specific stuff
func NewEnvironment ¶
func NewEnvironment(environment string, appVersion string) *Environment
NewEnvironment creates a new environment
func (*Environment) MigrateDatabase ¶
func (env *Environment) MigrateDatabase(session *mgo.Session) error
MigrateDatabase - performs database migrations