gitnotify

package
v0.0.0-...-6a0f7f9 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2017 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const GithubProvider = "github"

GithubProvider ..

View Source
const GitlabProvider = "gitlab"

GitlabProvider ..

Variables

This section is empty.

Functions

func CommitLink(provider, repo, ref string) string

CommitLink ..

func CompareLink(provider, repo, oldCommit, newCommit string) string

CompareLink ..

func InitCron

func InitCron()

InitCron initialises the cron related methods

func InitMail

func InitMail()

InitMail initialises mailer if config is setup

func InitRouter

func InitRouter()

InitRouter initialises the routes

func InitSession

func InitSession()

InitSession registers and everything related to the user's session

func InitView

func InitView()

InitView initialises the view

func LoadConfig

func LoadConfig(appConfigFile string)

LoadConfig loads the config from the file

func RepoLink(provider, repo string) string

RepoLink ..

func StringIn

func StringIn(list []string, key string) bool

StringIn finds a key in a list of strings

func Stringify

func Stringify(anyStruct interface{}) string

Stringify attempts to create a reasonable string representation of types. It does things like resolve pointers to their values and omits struct fields with nil values. This is taken from Stringify method of go-github. License can be found at https://github.com/google/go-github/blob/master/LICENSE

func TreeLink(provider, repo, ref string) string

TreeLink ..

func WebhooksList

func WebhooksList() []string

WebhooksList is used while displaying list of webhooks specific integrations available

func WebsiteLink(provider string) string

WebsiteLink ..

Types

type AppConfig

type AppConfig struct {
	ServerProto         string   `yaml:"serverProto"`       // can be http:// or https://
	ServerHost          string   `yaml:"serverHost"`        // domain.com with port . Used at redirection for OAuth
	LocalHost           string   `yaml:"localHost"`         // host:port combination used for starting the server
	DataDir             string   `yaml:"dataDir"`           // relative path from server to write the data
	SettingsFile        string   `yaml:"settingsFile"`      // name of file to be looked up/saved to for data
	FromName            string   `yaml:"fromName"`          // name of from email user
	FromEmail           string   `yaml:"fromEmail"`         // email address of from email address
	GithubAPIEndPoint   string   `yaml:"githubAPIEndPoint"` // server endpoint with protocol for https://api.github.com
	GithubURLEndPoint   string   `yaml:"githubURLEndPoint"` // website end point https://github.com
	GitlabAPIEndPoint   string   `yaml:"gitlabAPIEndPoint"` // server endpoint with protocol for https://gitlab.com/api/v3/
	GitlabURLEndPoint   string   `yaml:"gitlabURLEndPoint"` // website end point https://gitlab.com
	SMTPHost            string   `yaml:"smtpHost"`
	SMTPPort            int      `yaml:"smtpPort"`
	SMTPSesConfSet      string   `yaml:"sesConfigurationSet"` // ses configuration set used as a custom header while sending email
	GoogleAnalytics     string   `yaml:"googleAnalytics"`
	SMTPUser            string   // environment variable
	SMTPPass            string   // environment variable
	CacheMode           bool     `yaml:"cacheMode"` // when cacheMode is false, views are loaded on every request
	WebhookIntegrations []string `yaml:"webhookIntegrations"`
	StatHatKey          string   `yaml:"stathatKey"`
	StatHatEnvironment  string   `yaml:"stathatEnvironment"` // Environment string is used to track Stats in StatHatKey

	TemplateDir         string `yaml:"templateDir"`         // tmpl/
	TemplatePartialsDir string `yaml:"templatePartialsDir"` // tmpl/partials/

	Providers map[string]string // List of ProviderNames that are configured as per auth

	SourceCodeLink string
}

AppConfig is

type Authentication

type Authentication struct {
	Provider string `yaml:"provider"` // github/gitlab
	Name     string `yaml:"name"`     // name of the person addressing to
	Email    string `yaml:"email"`    // email that we will send to
	UserName string `yaml:"username"` // username for identification
	Token    string `yaml:"token"`    // used to query the provider
}

Authentication data/$provider/$user/$settingsFile

func (*Authentication) UserInfo

func (userInfo *Authentication) UserInfo() string

UserInfo provides provider/username

type ByInt

type ByInt []*changeDetail

ByInt ..

func (ByInt) Len

func (a ByInt) Len() int

func (ByInt) Less

func (a ByInt) Less(i, j int) bool

func (ByInt) Swap

func (a ByInt) Swap(i, j int)

type CacheWriter

type CacheWriter struct {
	// contains filtered or unexported fields
}

CacheWriter is the struct to store data temporarily

func (*CacheWriter) Close

func (cw *CacheWriter) Close()

Close saves data to the underlying cache

func (*CacheWriter) Header

func (cw *CacheWriter) Header() http.Header

Header delegates from the original

func (*CacheWriter) SetCachePath

func (cw *CacheWriter) SetCachePath(path string)

SetCachePath sets the cache path and cachable to true

func (*CacheWriter) Write

func (cw *CacheWriter) Write(b []byte) (int, error)

func (*CacheWriter) WriteFromCache

func (cw *CacheWriter) WriteFromCache() bool

WriteFromCache writes to the writer if it could successfully get from cache

func (*CacheWriter) WriteHeader

func (cw *CacheWriter) WriteHeader(code int)

WriteHeader writes the headers

type CacheWriterIface

type CacheWriterIface interface {
	SetCachePath(string)
	WriteFromCache() bool
}

CacheWriterIface should be used to set the cache params SetCachePath should be set before Write() is ever called WriteFromCache will write to the writer directly . returns true when written from cache all status writes >= 400 are treated as uncachable

type Frequency

type Frequency struct {
	TimeZone     string `yaml:"tz"`
	TimeZoneName string `yaml:"tzname"`
	// Minute string // 0-59 allowed
	Hour string `yaml:"hour"` // Hour - 0-23 allowed
	// MonthDay string // 1-31 allowed. Ignore if you want to use weekday vs weekend
	// Month - cannot be set
	WeekDay string `yaml:"weekday"` // 0-6 to point SUN-SAT
}

Frequency is the cron format along with a TimeZone to process Minute, Monthday and Month cannot be controlled. Consider them to be '*'

type GitClient

type GitClient interface{}

GitClient is used to abstract out github vs gitlab client

type GitRefWithCommit

type GitRefWithCommit struct {
	Name   string
	Commit string
}

GitRefWithCommit contains branch or tag name with Commit

type GitRemoteIface

type GitRemoteIface interface {
	// Helper methods
	WebsiteLink() string
	RepoLink(string) string
	TreeLink(string, string) string
	CommitLink(string, string) string
	CompareLink(string, string, string) string

	// Methods containing logic
	Branches(string) ([]*GitRefWithCommit, error)
	Tags(string) ([]*GitRefWithCommit, error)

	SearchRepos(string) ([]*searchRepoItem, error)
	SearchUsers(string) ([]*searchUserItem, error)
	DefaultBranch(string) (string, error)
	BranchesWithoutRefs(string) ([]string, error)

	RemoteOrgType(string) (string, error)
	ReposForUser(string) ([]*searchRepoItem, error)
}

GitRemoteIface defines the list of methods

type Information

type Information struct {
	Repo RepoInformation `yaml:",inline"`
	Org  OrgInformation  `yaml:",inline"`
	Type string          `yaml:"type"` // type is either Org or Repo
}

Information has the type and contains either Org or Repo Information. This is more of an interface/abstract role based on type

func (*Information) UnmarshalYAML

func (i *Information) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML overrides the default unmarshaling logic

type LocalCommitRef

type LocalCommitRef map[string]string

LocalCommitRef is of the form map[BranchName] = "1234567890abcdef"

type MailContent

type MailContent struct {
	WebsiteURL string
	User       string // provider/username
	Name       string
	Data       []*gnDiffData
	SavedFile  string
}

MailContent ..

type OrgInformation

type OrgInformation struct {
	OrgType string   `yaml:"org_type,omitempty"`
	Repos   []string `yaml:"repos,omitempty,flow"`
}

OrgInformation is info for org and ref_type

type Organisation

type Organisation struct {
	Name     string `yaml:"name"`
	Type     string `yaml:"type"`
	Provider string
}

Organisation is a user/org that is being tracked

type ProviderIndex

type ProviderIndex struct {
	Providers    []string
	ProvidersMap map[string]string
}

ProviderIndex is used for setting up the providers

type Repo

type Repo struct {
	Repo            string      `yaml:"repo"`
	NamedReferences []reference `yaml:"commits"`
	Branches        bool        `yaml:"new_branches"`
	Tags            bool        `yaml:"new_tags"`
	Provider        string
}

Repo is a repository that is being tracked

func (*Repo) String

func (r *Repo) String() string

type RepoInformation

type RepoInformation struct {
	Tags     []string       `yaml:"tags,omitempty,flow"`
	Branches []string       `yaml:"branches,omitempty,flow"`
	Commits  LocalCommitRef `yaml:"commits,omitempty"`
}

RepoInformation is all the information fetched from remote location, updated and saved contains the fetched_info

type Setting

type Setting struct {
	Version `yaml:"version"`
	Repos   []*Repo                 `yaml:"repos"`
	Orgs    []*Organisation         `yaml:"orgs"`
	Auth    *Authentication         `yaml:"auth"`
	User    *UserNotification       `yaml:"user_notification"`
	Info    map[string]*Information `yaml:"fetched_info"`
}

Setting is the data structure that has all the details

data/$provider/$username/settings.yml

func (*Setting) String

func (c *Setting) String() string

type SlackAttachment

type SlackAttachment struct {
	Fallback       string                 `json:"fallback"`
	Title          string                 `json:"title"`
	Color          string                 `json:"color,omitempty"`
	PreText        string                 `json:"pretext"`
	AuthorName     string                 `json:"author_name"`
	AuthorLink     string                 `json:"author_link"`
	Fields         []SlackAttachmentField `json:"fields"`
	MarkdownFormat []string               `json:"mrkdwn_in"`
	Text           string                 `json:"text"`
	ThumbnailURL   string                 `json:"thumb_url,omitempty"`
}

SlackAttachment ..

type SlackAttachmentField

type SlackAttachmentField struct {
	Title string `json:"title"`
	Value string `json:"value"`
	Short bool   `json:"short"`
}

SlackAttachmentField ..

type SlackMessage

type SlackMessage struct {
	Username    string            `json:"username"`
	Text        string            `json:"text"`
	Attachments []SlackAttachment `json:"attachments"`
}

SlackMessage ..

type SlackTypeLink struct {
	Text string
	Href string
}

SlackTypeLink ..

func (*SlackTypeLink) String

func (s *SlackTypeLink) String() string

<http://www.amazon.com|Amazon>

type UserNotification

type UserNotification struct {
	Email     string `yaml:"email"`
	Name      string `yaml:"name"`
	Disabled  bool   `yaml:"disabled"`
	Frequency `yaml:",inline"`

	WebhookURL  string `yaml:"webhook_url"`
	WebhookType string `yaml:"webhook_type"`
}

UserNotification is the customization/scheduling is provided for user NOTE: this can be an array of notifications like email, Webhook options. not gonna make the change to the array

type UserPage

type UserPage struct {
	NextRunTimes []string
}

UserPage ..

type Version

type Version string

Version of the structure

Jump to

Keyboard shortcuts

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