proxyservice

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MPL-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DockerhubRegistry = "https://registry.hub.docker.com"

Functions

func TriggerDockerhubJob added in v0.2.0

func TriggerDockerhubJob(j Jenkins, data *DockerHubWebhookData) error

TriggerDockerhubJob triggers a jenkins job given DockerHubWebhookData

func TriggerHgJob added in v0.2.0

func TriggerHgJob(j Jenkins, repoPath string, repoUrl string, head string, data *HgMessage) error

Types

type CallBackData

type CallBackData struct {
	State       string `json:"state,omitempty"`
	Description string `json:"description,omitempty"`
	Context     string `json:"context,omitempty"`
	TargetURL   string `json:"target_url,omitempty"`
}

CallBackData is the data format described at https://docs.docker.com/docker-hub/webhooks/#callback-json-data

func NewSuccessCallbackData

func NewSuccessCallbackData() *CallBackData

Returns a success callback with state: success

type ChangegroupMessage added in v0.2.0

type ChangegroupMessage struct {
	RepoUrl       string   `json:"repo_url"`
	Heads         []string `json:"heads"`
	PushlogPushes []struct {
		PushId          int    `json:"pushid"`
		User            string `json:"user"`
		Time            int    `json:"time"`
		PushJsonUrl     string `json:"push_json_url"`
		PushFullJsonUrl string `json:"push_full_json_url"`
	} `json:"pushlog_pushes"`
	Source string `json:"Source"`
}

func (*ChangegroupMessage) VerifyMessage added in v0.2.0

func (msg *ChangegroupMessage) VerifyMessage(repoPath string) error

type DockerHubWebhookData

type DockerHubWebhookData struct {
	PushData struct {
		PushedAt int      `json:"pushed_at"`
		Images   []string `json:"images"`
		Tag      string   `json:"tag"`
		Pusher   string   `json:"pusher"`
	} `json:"push_data"`
	CallbackURL string `json:"callback_url"`
	Repository  struct {
		Status          string `json:"status"`
		Description     string `json:"description"`
		IsTrusted       bool   `json:"is_trusted"`
		FullDescription string `json:"full_description"`
		RepoURL         string `json:"repo_url"`
		Owner           string `json:"owner"`
		IsOfficial      bool   `json:"is_official"`
		IsPrivate       bool   `json:"is_private"`
		Name            string `json:"name"`
		Namespace       string `json:"namespace"`
		StarCount       int    `json:"star_count"`
		CommentCount    int    `json:"comment_count"`
		DateCreated     int    `json:"date_created"`
		RepoName        string `json:"repo_name"`
	} `json:"repository"`
}

DockerHubWebhookData represents the dockerhub webhook format

func NewDockerHubWebhookData

func NewDockerHubWebhookData(b []byte) (*DockerHubWebhookData, error)

NewDockerHubWebhookData returns *DockerHubWebhookData from json bytes

func NewDockerHubWebhookDataFromRequest

func NewDockerHubWebhookDataFromRequest(req *http.Request) (*DockerHubWebhookData, error)

NewDockerHubWebhookDataFromRequest returns *DockerHubWebhookData from http.Request Body is returned intact unless error != nil

func (*DockerHubWebhookData) Callback

func (d *DockerHubWebhookData) Callback(cb *CallBackData) error

Callback calls data's callback_url

type DockerHubWebhookHandler

type DockerHubWebhookHandler struct {
	Jenkins         Jenkins
	ValidNameSpaces map[string]bool
}

func NewDockerHubWebhookHandler

func NewDockerHubWebhookHandler(jenkins Jenkins, nameSpaces ...string) *DockerHubWebhookHandler

func (*DockerHubWebhookHandler) ServeHTTP

func (d *DockerHubWebhookHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type HgMessage added in v0.2.0

type HgMessage struct {
	Type string      `json:"type"`
	Data interface{} `json:"data"`
}

https://mozilla-version-control-tools.readthedocs.io/en/latest/hgmo/notifications.html#pulse-notifications

func (*HgMessage) UnmarshalJSON added in v0.2.0

func (msg *HgMessage) UnmarshalJSON(b []byte) error

type HgmoPulseHandler added in v0.2.0

type HgmoPulseHandler struct {
	Jenkins      Jenkins
	Pulse        *pulse.Connection
	QueueName    string
	ValidHgRepos map[string]bool
}

func NewHgmoPulseHandler added in v0.2.0

func NewHgmoPulseHandler(jenkins Jenkins, pulse *pulse.Connection, queueName string, hgRepos ...string) *HgmoPulseHandler

func (*HgmoPulseHandler) Consume added in v0.2.0

func (handler *HgmoPulseHandler) Consume() error

type Jenkins

type Jenkins interface {
	TriggerJob(jobPath string, params url.Values) error
}

func NewJenkins

func NewJenkins(baseURL, user, password string) Jenkins

NewJenkins returns a new Jenkins instance

type JenkinsCrumbIssuer

type JenkinsCrumbIssuer struct {
	Crumb             string `json:"crumb"`
	CrumbRequestField string `json:"crumbRequestField"`
}

type JenkinsServer added in v0.2.0

type JenkinsServer struct {
	BaseURL string

	User     string
	Password string
}

func (*JenkinsServer) NewRequest added in v0.2.0

func (j *JenkinsServer) NewRequest(method, path string, body io.Reader) (*http.Request, error)

NewRequest builds a authed jenkins request. path must be the absolute path starting with "/"

func (*JenkinsServer) PostForm added in v0.2.0

func (j *JenkinsServer) PostForm(path string, data url.Values) (*http.Response, error)

PostForm posts a authed request to jenkins BaseURL + path

func (*JenkinsServer) TriggerJob added in v0.2.0

func (j *JenkinsServer) TriggerJob(jobPath string, params url.Values) error

TriggerJob triggers a jenkins job jobPath should be the full path to the job e.g., /job/pipelines/job/myjob/

type PushJson added in v0.2.0

type PushJson struct {
	Lastpushid int `json:"lastpushid"`
	Pushes     map[int]struct {
		Changesets []string `json:"changesets"`
		Date       int      `json:"date"`
		User       string   `json:"user"`
	} `json:"pushes"`
}

Jump to

Keyboard shortcuts

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