Documentation ¶
Index ¶
Constants ¶
const ( // GHHeader is how we determine whether we are dealing with a GitHub webhook GHHeader = "User-Agent" // GHAgent is the prefix of the GHHeader GHAgent = "GitHub-Hookshot" )
const (
// ServiceName is name of service that we are trying to idle or unidle
ServiceName = "jenkins"
)
Variables ¶
var Recorder = metric.PrometheusRecorder{}
Recorder to capture events
Functions ¶
This section is empty.
Types ¶
type CacheItem ¶
CacheItem represents a cache item consisting of cluster URL, namespace, route, scheme(HTTP, HTTPS etc).
type Codebase ¶
type Codebase struct {
// contains filtered or unexported fields
}
Codebase is an implementation of the codebase interface
type CodebaseService ¶
CodebaseService contains methods that deals with code repository and code hosting services
type GHHookStruct ¶
type GHHookStruct struct { Repository struct { Name string `json:"name"` FullName string `json:"full_name"` GitURL string `json:"git_url"` CloneURL string `json:"clone_url"` } `json:"repository"` }
GHHookStruct a simplified structure to get info from a webhook request
type Jenkins ¶
type Jenkins struct {
// contains filtered or unexported fields
}
Jenkins implements Jenkins interface
func GetJenkins ¶
func GetJenkins(clusters map[string]string, pci *CacheItem, idler idler.Service, tenantClient tenant.Service, tokenData string, logger *log.Entry) (j *Jenkins, osioToken string, err error)
GetJenkins returns an intance of Jenkins struct
type JenkinsService ¶
type JenkinsService interface { Login(osoToken string) (status int, cookie []*http.Cookie, err error) State() (idler.PodState, error) Start() (state idler.PodState, code int, err error) }
JenkinsService talks to wit service, auth service, tenant service and various jenkins instances in order to perform task such as starting a jenkins, logging into one, get information for a jenkins instance such as its url, which namespace it belongs to, which cluster it belongs to etc
type Proxy ¶
type Proxy struct { //TenantCache is used as a temporary cache to optimize number of requests //going to tenant and wit services TenantCache *cache.Cache //ProxyCache is used as a cache for session ids passed by Jenkins in cookies ProxyCache *cache.Cache // contains filtered or unexported fields }
Proxy handles requests, verifies authentication and proxies to Jenkins. If the request comes from Github, it buffers it and replays if Jenkins is not available.
func New ¶
func New( idler idler.Service, tenant tenant.Service, wit wit.Service, storageService storage.Store, config configuration.Configuration, clusters map[string]string) (Proxy, error)
New creates an instance of Proxy client
func (*Proxy) Handle ¶
func (p *Proxy) Handle(w http.ResponseWriter, r *http.Request)
Handle handles requests coming to the proxy and performs action based on the type of request and state of Jenkins.
func (*Proxy) HandleError ¶
HandleError creates a JSON response with a given error and writes it to ResponseWriter
func (*Proxy) OnErrorUIRequest ¶
OnErrorUIRequest handles when there is an error while reverse proxy
func (*Proxy) ProcessBuffer ¶
func (p *Proxy) ProcessBuffer()
ProcessBuffer is a loop running through buffered webhook requests trying to replay them