util

package
v0.0.674 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 26 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// CommitStatusPendingDescription is the description used for PR commit status for pipelines we have just kicked off.
	CommitStatusPendingDescription = "Pipeline pending"

	// OverriddenByPrefix is the beginning of the description for commit statuses set by /override
	OverriddenByPrefix = "Overridden by"

	// GitHubAppGitRemoteUsername Username for git https URLs when using a GitHub App token.
	// see https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation
	GitHubAppGitRemoteUsername = "x-access-token"

	// GitHubAppSecretDirEnvVar is the name of the environment variable which would contain secrets when this is configured
	// with the GitHub App.
	GitHubAppSecretDirEnvVar = "GITHUB_APP_SECRET_DIR" // #nosec

	// GitHubAppAPIUserFilename is the filename inside the GitHub App secrets dir which will contain the user we will
	// use for GitHub API calls when present.
	GitHubAppAPIUserFilename = "username"

	// LighthousePipelineActivityNameLabel is added to the LighthouseJob with
	// the name of the PipelineActivity corresponding to it.
	LighthousePipelineActivityNameLabel = "lighthouse.jenkins-x.io/activityName"

	// LighthouseJobAnnotation is added in resources created by lighthouse and
	// carries the name of the job that the pod is running. Since
	// job names can be arbitrarily long, this is added as
	// an annotation instead of a label.
	LighthouseJobAnnotation = "lighthouse.jenkins-x.io/job"

	// OrgLabel is added in resources created by Lighthouse and
	// carries the org associated with the job, eg kubernetes-sigs.
	OrgLabel = "lighthouse.jenkins-x.io/refs.org"

	// RepoLabel is added in resources created by Lighthouse and
	// carries the repo associated with the job, eg test-infra
	RepoLabel = "lighthouse.jenkins-x.io/refs.repo"

	// PullLabel is added in resources created by Lighthouse and
	// carries the PR number associated with the job, eg 321.
	PullLabel = "lighthouse.jenkins-x.io/refs.pull"

	// ContextLabel is added in resources created by Lighthouse and contains the job context.
	ContextLabel = "lighthouse.jenkins-x.io/context"

	// BranchLabel is added in resources created by Lighthouse and contains the branch name for the job.
	BranchLabel = "lighthouse.jenkins-x.io/branch"

	// BuildNumLabel is added in resources created by Lighthouse and contains the build number for the job.
	BuildNumLabel = "lighthouse.jenkins-x.io/buildNum"

	// ActivityOwnerLabel is the label for the org/owner on the PipelineActivity
	ActivityOwnerLabel = "owner"
	// ActivityRepositoryLabel is the label for the repo name on the PipelineActivity
	ActivityRepositoryLabel = "repository"
	// ActivityBranchLabel is the label for the branch name on the PipelineActivity
	ActivityBranchLabel = "branch"
	// ActivityBuildLabel is the label for the build number on the PipelineActivity
	ActivityBuildLabel = "build"
	// ActivityContextLabel is the label for the (optional) pipeline context on the PipelineActivity
	ActivityContextLabel = "context"

	// GithubServer the default github server URL
	GithubServer = "https://github.com"

	// ProwConfigMapName name of the ConfgMap holding the config
	ProwConfigMapName = "config"
	// ProwPluginsConfigMapName name of the ConfigMap holding the plugins config
	ProwPluginsConfigMapName = "plugins"
	// ProwConfigFilename config file name
	ProwConfigFilename = "config.yaml"
	// ProwPluginsFilename plugins file name
	ProwPluginsFilename = "plugins.yaml"

	// LighthouseCommandPrefix is an optional prefix for commands to deal with things like GitLab hijacking /approve
	LighthouseCommandPrefix = "lh-"

	// LighthouseUserAgent is the header value for User-Agent when Lighthouse calls external plugins
	LighthouseUserAgent = "LighthouseHook"

	// LighthouseWebhookKindHeader is the header key used for the webhook kind when relaying to external plugins
	LighthouseWebhookKindHeader = "X-Lighthouse-Webhook-Kind"

	// LighthouseSignatureHeader is the header key used for the signature when relaying to external plugins
	LighthouseSignatureHeader = "X-Lighthouse-Signature"

	// LighthousePayloadTypeHeader is the header key displaying what type of payload this is, either "webhook" or "activity"
	LighthousePayloadTypeHeader = "X-Lighthouse-Payload-Type"

	// LighthousePayloadTypeWebhook is the webhook type
	LighthousePayloadTypeWebhook = "webhook"

	// LighthousePayloadTypeActivity is the activity type
	LighthousePayloadTypeActivity = "activity"
)

Variables

This section is empty.

Functions

func AddAuthToSCMClient added in v0.0.492

func AddAuthToSCMClient(client *scm.Client, token string, isGitHubApp bool)

AddAuthToSCMClient configures an existing go-scm client with transport and authorization using the given token, depending on whether the token is a GitHub App token

func CallExternalPluginsWithActivityRecord added in v0.0.650

func CallExternalPluginsWithActivityRecord(l *logrus.Entry, externalPlugins []plugins.ExternalPlugin, activity *record.ActivityRecord, hmacToken string, wg *sync.WaitGroup)

CallExternalPluginsWithActivityRecord dispatches the provided activity record to the external plugins.

func CallExternalPluginsWithWebhook added in v0.0.650

func CallExternalPluginsWithWebhook(l *logrus.Entry, externalPlugins []plugins.ExternalPlugin, webhook scm.Webhook, hmacToken string, wg *sync.WaitGroup)

CallExternalPluginsWithWebhook dispatches the provided webhook to the external plugins.

func DirExists added in v0.0.492

func DirExists(path string) (bool, error)

DirExists checks if path exists and is a directory

func ExternalPluginsForEvent added in v0.0.650

func ExternalPluginsForEvent(pluginConfig *plugins.ConfigAgent, eventKind string, srcRepo string) []plugins.ExternalPlugin

ExternalPluginsForEvent returns whether there are any external plugins that need to get the present event.

func FileExists added in v0.0.492

func FileExists(path string) (bool, error)

FileExists checks if path exists and is a file

func GetGitHubAppAPIUser added in v0.0.492

func GetGitHubAppAPIUser() (string, error)

GetGitHubAppAPIUser returns the username to be used for GitHub API calls with the GitHub App, if so configured. If there is no configured secrets dir, it returns an empty string.

func GetGitHubAppSecretDir added in v0.0.492

func GetGitHubAppSecretDir() string

GetGitHubAppSecretDir returns the location of the GitHub App secrets dir, if defined, and an empty string otherwise

func ParseExternalPluginEvent added in v0.0.650

func ParseExternalPluginEvent(req *http.Request, secretToken string) (scm.Webhook, *record.ActivityRecord, error)

ParseExternalPluginEvent parses a webhook relayed to an external plugin

func ToValidName added in v0.0.525

func ToValidName(name string) string

ToValidName converts the given string into a valid Kubernetes resource name

func ToValidNameTruncated added in v0.0.525

func ToValidNameTruncated(name string, maxLength int) string

ToValidNameTruncated converts the given string into a valid Kubernetes resource name, truncating the result if it is more than maxLength characters.

Types

type OwnerTokensDir added in v0.0.492

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

OwnerTokensDir handles finding owner based tokens in a directory for GitHub Apps

func NewOwnerTokensDir added in v0.0.492

func NewOwnerTokensDir(gitServer, dir string) *OwnerTokensDir

NewOwnerTokensDir creates a new dir token scanner

func (*OwnerTokensDir) FindToken added in v0.0.492

func (o *OwnerTokensDir) FindToken(owner string) (string, error)

FindToken finds the token for the given owner

Jump to

Keyboard shortcuts

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