utils

package
v0.0.0-...-adcba70 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const HostIndexFieldName = ".hosts"

HostIndexFieldName is the field indexes on Services to store the hostnames they are active for

Variables

View Source
var MatchingLabels = client.MatchingLabels{"app.kubernetes.io/managed-by": "review-app-controller"}

MatchingLabels selector to select resources managed by the review-app-controller

Functions

func GetChildResourceName

func GetChildResourceName(reviewApp *ReviewAppConfig, pr *PullRequest) string

GetChildResourceName returns a child resource name for a reviewapp and pull request

func GetDeploymentStatus

func GetDeploymentStatus(d *appsv1.Deployment) (string, bool, error)

GetDeploymentStatus returns the status of a deployment like `kubectl rollout status`

func GetHostnameFromTemplate

func GetHostnameFromTemplate(template string, deploymentName string, pr PullRequest, reviewApp ReviewAppConfig) (string, error)

GetHostnameFromTemplate generates a hostname from a template string. Permitted variables are - {{.ReviewAppConfig}} - {{.BranchName}} - {{.DeploymentName}}

func GetHostnamesFromTemplate

func GetHostnamesFromTemplate(templates []string, deploymentName string, pr PullRequest, reviewApp ReviewAppConfig) ([]string, error)

GetHostnamesFromTemplate returns a list of interpolated hostname templates for a a given deployment, pr and review app

func GetResourceLabels

func GetResourceLabels(reviewApp *ReviewAppConfig, pr PullRequest, deploymentName string) map[string]string

GetResourceLabels returns the labels for all ReviewAppConfig child resources with all user supplied labels included

func GetResourceName

func GetResourceName(name ...string) string

GetResourceName returns a normalized resource name

func GetSelectorLabels

func GetSelectorLabels(reviewApp *ReviewAppConfig, pr PullRequest, deploymentName string) map[string]string

GetSelectorLabels returns selector labels to be used with pod selectors in Services and Deployments

func ImageHasDigest

func ImageHasDigest(image string) bool

ImageHasDigest checks if the image has a digest

func IsImageAllowed

func IsImageAllowed(reviewApp ReviewAppConfig, image string) bool

IsImageAllowed checks if the image matches the base image set on the deployments in a ReviewAppConfig

func IsSameImageRepo

func IsSameImageRepo(i1, i2 string) bool

IsSameImageRepo checks if two image names and tags are from the same repository gchr.io/test/repo:v1 and gchr.io/test/repo:v2 is the same repository gchr.io/test/repo:v1 and gchr.io/test/example:v1 is not

func PullRequestFor

func PullRequestFor(reviewApp ReviewAppConfig, opts PullRequestCreationOptions) PullRequest

Types

type PullRequestCreationOptions

type PullRequestCreationOptions struct {
	Image             string
	BranchName        string
	DeployedBy        string
	RepositoryURL     string
	PullRequestURL    string
	PullRequestNumber int
}

Jump to

Keyboard shortcuts

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