server

package
v0.4.14 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IssueCommentEventFromJSON

func IssueCommentEventFromJSON(data io.Reader) (*github.IssueCommentEvent, error)

IssueCommentEventFromJSON parses json to a github.IssueCommentEvent

func NewBool

func NewBool(b bool) *bool

NewBool return a bool pointer

func NewInt

func NewInt(n int) *int

NewInt return an int pointer

func NewInt32

func NewInt32(n int32) *int32

NewInt32 return an int32 pointer

func NewInt64

func NewInt64(n int64) *int64

NewInt64 return an int64 pointer

func NewString

func NewString(s string) *string

NewString return a string pointer

func PingEventFromJSON

func PingEventFromJSON(data io.Reader) (*github.PingEvent, error)

PingEventFromJSON parses json to a github.PingEvent

func PullRequestEventFromJSON

func PullRequestEventFromJSON(data io.Reader) (*github.PullRequestEvent, error)

PullRequestEventFromJSON parses json to a github.PullRequestEvent

func PushEventFromJSON added in v0.4.5

func PushEventFromJSON(data io.Reader) (*github.PushEvent, error)

PushEventFromJSON parses json to a github.PushEvent

func ValidateSignature

func ValidateSignature(receivedHash []string, bodyBuffer []byte, secretKey string) error

ValidateSignature function used for validation of webhook requests based on config secret.

Types

type Builds

type Builds struct{}

Builds implements buildsInterface for working with external CI/CD systems.

type CWS

type CWS struct {
	Database                   string
	CWSSiteURL                 string
	CWSSMTPUsername            string
	CWSSMTPPassword            string
	CWSSMTPServer              string
	CWSSMTPPort                string
	CWSSMTPServerTimeout       string
	CWSSMTPConnectionSecurity  string
	CWSEmailReplyToName        string
	CWSEmailReplyToAddress     string
	CWSEmailBCCAddress         string
	CWSCloudURL                string
	CWSStripeKey               string
	CWSCloudDNSDomain          string
	CWSCloudGroupID            string
	CWSBlapiURL                string
	CWSBlapiToken              string
	CWSLicenseGeneratorURL     string
	CWSLicenseGeneratorKey     string
	CWSDisableRenewalChecks    string
	CWSSplitKey                string
	CWSSplitServerID           string
	CloudDefaultProductID      string
	CloudDefaultTrialProductID string
	DockerHubCredentials       string
	CWSPublicPort              string
	CWSPrivatePort             string
}

CWS contains all configuration for the Customer Web Server

type CloudAuth added in v0.3.20

type CloudAuth struct {
	ClientID      string
	ClientSecret  string
	TokenEndpoint string
}

CloudAuth contains all configuration for the Cloud Auth

type Deployment

type Deployment struct {
	Namespace      string
	PR             int
	ImageTag       string
	DeployFilePath string
	Environment    CWS
}

Deployment contains information needed to create a deployment in Kubernetes

type E2EInstance added in v0.4.5

type E2EInstance struct {
	Name           string `json:"name"`
	Platform       string `json:"platform"` // Desktop: linux/macos/windows (OS runner), Mobile: site-1/site-2/site-3 (instance ID)
	Runner         string `json:"runner"`   // For desktop only: GitHub Actions runner label
	URL            string `json:"url"`
	InstallationID string `json:"installation_id"`
	ServerVersion  string `json:"server_version"`
}

E2EInstance represents a single E2E test server instance Note: Platform field has different meanings for desktop vs mobile:

  • Desktop: Platform = OS runner (linux/macos/windows) where tests execute
  • Mobile: Platform = instance identifier (site-1/site-2/site-3) for the test server

type MatterwickConfig

type MatterwickConfig struct {
	ListenAddress       string
	MatterWickURL       string
	GithubAccessToken   string
	GitHubTokenReserve  int
	GithubUsername      string
	GitHubWebhookSecret string
	Org                 string
	Username            string

	SetupSpinWick        string
	SetupSpinWickHA      string
	SetupSpinWickWithCWS string
	SpinWickHALicense    string
	ProvisionerServer    string
	AWSAPIKey            string
	DNSNameTestServer    string

	CloudGroupID               string
	SetupSpinmintMessage       string
	SetupSpinmintFailedMessage string
	DestroyedSpinmintMessage   string

	DockerRegistryURL string
	DockerUsername    string
	DockerPassword    string

	MattermostWebhookURL            string
	MattermostWebhookFooter         string
	MattermostCredentialsWebhookURL string
	MattermostCredentialsChannelURL string

	KubeClusterName   string
	KubeClusterRegion string

	LogSettings struct {
		EnableDebug bool
		ConsoleJSON bool
	}

	CWSPublicAPIAddress   string
	CWSInternalAPIAddress string
	CWSAPIKey             string
	CWSUserPassword       string
	CWSSpinwickGroupID    string

	CWS CWS

	CloudAuth CloudAuth

	// PluginRepoToIDMapping maps repository names to plugin IDs for mmctl commands
	// Key: repository name (e.g., "mattermost-plugin-boards")
	// Value: plugin ID to use for mmctl enable command
	PluginRepoToIDMapping map[string]string

	E2ELabel                string
	E2EMobileIOSLabel       string
	E2EMobileAndroidLabel   string
	E2EResetServersLabel    string
	E2EUsername             string
	E2EPassword             string
	E2EServerVersion        string
	E2EAutoTriggerOnMaster  bool
	E2EReleasePatternPrefix string
	E2ETestWorkflowNames    []string // workflow names of the actual test workflows (for completion-based cleanup)
	// E2EInstanceMaxAge is the minimum age (in hours) a non-PR E2E instance must reach
	// before the periodic orphan-cleanup scan will delete it. This prevents the scan
	// from destroying instances that are still being used by a currently-running test.
	// Set to the longest expected E2E run duration plus a small buffer.
	// Default (0): 3 hours.
	E2EInstanceMaxAge int

	// E2EPRInstanceMaxAge is the maximum age (in hours) a PR E2E instance may reach before
	// the periodic cleanup scan deletes it. PR instances are intentionally kept alive between
	// label toggles and across commits so the same servers can be reused for re-runs, so this
	// is much longer than E2EInstanceMaxAge. When such an instance is reaped its in-memory
	// tracking entry is also evicted, so re-applying E2E/Run provisions a fresh set.
	// Default (0): 24 hours.
	E2EPRInstanceMaxAge int

	// CMTTriggerWorkflowName is the workflow name (the "name:" field) of the lightweight
	// CMT trigger workflow in the desktop/mobile repos. Matterwick provisions instances and
	// dispatches compatibility-matrix-testing.yml when it receives a workflow_run "requested"
	// event for this workflow.
	CMTTriggerWorkflowName string

	// CMTTestWorkflowName is the workflow name of the actual CMT test workflow
	// (compatibility-matrix-testing.yml). Used to distinguish CMT completions (cleanup by
	// run ID) from regular E2E completions (cleanup by SHA).
	CMTTestWorkflowName string

	// CMTServerVersions is an OPTIONAL manual override for the CMT version set. When non-empty
	// it is used verbatim (values must be valid Mattermost image tags: full semver, no "v"
	// prefix, e.g. "10.11.0"). When empty (the normal case) matterwick auto-derives the set
	// from Mattermost's GitHub releases via Server.resolveCMTServerVersions.
	CMTServerVersions []string
}

MatterwickConfig defines all config for to run the server

func GetConfig

func GetConfig(fileName string) (*MatterwickConfig, error)

GetConfig gets the config

type MockedBuilds

type MockedBuilds struct {
	Version string
}

MockedBuilds implements buildsInterface but returns hardcoded information. This is used for local development and/or testing.

type Server

type Server struct {
	Config *MatterwickConfig
	Router *mux.Router

	Builds buildsInterface

	StartTime time.Time

	Logger logrus.FieldLogger

	CloudClient *cloudModel.Client
	// contains filtered or unexported fields
}

Server is the MatterWick server.

func New

func New(config *MatterwickConfig) *Server

New returns a new server with the desired configuration

func (*Server) CheckLimitRateAndAbortRequest

func (s *Server) CheckLimitRateAndAbortRequest() bool

CheckLimitRateAndAbortRequest checks the api rate and abort the request if needed

func (*Server) CheckLimitRateAndSleep

func (s *Server) CheckLimitRateAndSleep()

CheckLimitRateAndSleep checks the api rate and sleep if needed

func (*Server) GetPullRequestFromGithub

func (s *Server) GetPullRequestFromGithub(pullRequest *github.PullRequest) (*model.PullRequest, error)

GetPullRequestFromGithub get updated pr info

func (*Server) GetUpdateChecks

func (s *Server) GetUpdateChecks(owner, repoName string, prNumber int) (*model.PullRequest, error)

GetUpdateChecks retrieve updated status checks from GH

func (*Server) Start

func (s *Server) Start()

Start starts a server

func (*Server) Stop

func (s *Server) Stop()

Stop stops a server

type WebhookRequest

type WebhookRequest struct {
	Username string `json:"username"`
	Text     string `json:"text"`
}

WebhookRequest defines the message to send to MM

type WorkflowRunWebhookPayload added in v0.4.5

type WorkflowRunWebhookPayload struct {
	Action      string                 `json:"action"`
	WorkflowRun WorkflowRunWithInputs  `json:"workflow_run"`
	Repository  map[string]interface{} `json:"repository"`
	Workflow    map[string]interface{} `json:"workflow"`
}

WorkflowRunWebhookPayload is the parsed body of a workflow_run webhook event.

func ParseWorkflowRunEventWithInputs added in v0.4.5

func ParseWorkflowRunEventWithInputs(data io.Reader) (*WorkflowRunWebhookPayload, error)

ParseWorkflowRunEventWithInputs decodes a workflow_run webhook payload from r.

type WorkflowRunWithInputs added in v0.4.5

type WorkflowRunWithInputs struct {
	ID         int64             `json:"id"`
	Name       string            `json:"name"`
	HeadBranch string            `json:"head_branch"`
	HeadSHA    string            `json:"head_sha"`
	Event      string            `json:"event"` // triggering event: "push", "schedule", "workflow_dispatch", etc.
	Inputs     map[string]string `json:"inputs"`
}

WorkflowRunWithInputs is the workflow_run object extended with the workflow_dispatch inputs field.

Jump to

Keyboard shortcuts

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