kube

package
v1.3.270 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: Apache-2.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNamespace the standard namespace for Jenkins X
	DefaultNamespace = "jx"

	// PodNamespaceFile the file path and name for pod namespace
	PodNamespaceFile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
)
View Source
const (
	// ChartAmbassador the default chart for ambassador
	ChartAmbassador = "datawire/ambassador"

	// ChartAnchore the default chart for the Anchore plugin
	ChartAnchore = "stable/anchore-engine"

	// ChartCloudBees the default name of the CloudBees addon chart
	ChartCloudBees = "cb/cdx"

	// ChartExposecontrollerService the default name of the Exposecontroller Service chart for Edit environments
	ChartExposecontrollerService = "jenkins-x/exposecontroller-service"

	// ChartAnchore the default chart for the Anchore plugin
	ChartPipelineEvent = "jenkins-x/pipeline-events-addon"

	// ChartGitea the default name of the gitea chart
	ChartGitea = "jenkins-x/gitea"

	// ChartIstio the default chart for the Istio chart
	ChartIstio = "install/kubernetes/helm/istio"

	// ChartKubeless the default chart for kubeless
	ChartKubeless = "incubator/kubeless"

	// ServiceJenkins is the name of the Jenkins Service
	ServiceJenkins = "jenkins"

	// SecretJenkins is the name of the Jenkins secret
	SecretJenkins = "jenkins"

	// ServiceCloudBees the service name of the CloudBees app for Kubernetes
	ServiceCloudBees = "cb-cdx"

	// ServiceChartMuseum the service name of the Helm Chart Museum service
	ServiceChartMuseum = "jenkins-x-chartmuseum"

	// ServiceKubernetesDashboard the kubernetes dashboard
	ServiceKubernetesDashboard = "jenkins-x-kubernetes-dashboard"

	// SecretJenkinsGitCredentials the git credentials secret
	SecretJenkinsGitCredentials = "jenkins-git-credentials"

	// SecretJenkinsChartMuseum the chart museum secret
	SecretJenkinsChartMuseum = "jenkins-x-chartmuseum"

	// SecretJenkinsReleaseGPG the GPG secrets for doing releases
	SecretJenkinsReleaseGPG = "jenkins-release-gpg"

	// SecretJenkinsPipelineAddonCredentials the chat credentials secret
	SecretJenkinsPipelineAddonCredentials = "jx-pipeline-addon-"

	// SecretJenkinsPipelineChatCredentials the chat credentials secret
	SecretJenkinsPipelineChatCredentials = "jx-pipeline-chat-"

	// SecretJenkinsPipelineGitCredentials the git credentials secret
	SecretJenkinsPipelineGitCredentials = "jx-pipeline-git-"

	// SecretJenkinsPipelineIssueCredentials the issue tracker credentials secret
	SecretJenkinsPipelineIssueCredentials = "jx-pipeline-issues-"

	// ConfigMapExposecontroller the name of the ConfigMap with the Exposecontroller configuration
	ConfigMapExposecontroller = "exposecontroller"

	// ConfigMapIngressConfig the new name of the ConfigMap with the Exposecontroller configuration
	ConfigMapIngressConfig = "ingress-config"

	// ConfigMapJenkinsX the name of the ConfigMap with the Jenkins configuration
	ConfigMapJenkinsX = "jenkins"

	// ConfigMapJenkinsPodTemplates is the ConfigMap containing all the Pod Templates available
	ConfigMapJenkinsPodTemplates = "jenkins-x-pod-templates"

	// ConfigMapJenkinsDockerRegistry is the ConfigMap containing the Docker Registry configuration
	ConfigMapJenkinsDockerRegistry = "jenkins-x-docker-registry"

	// ConfigMapNameJXInstallConfig is the ConfigMap containing the jx installation's CA and server url. Used by jx login
	ConfigMapNameJXInstallConfig = "jx-install-config"

	// LocalHelmRepoName is the default name of the local chart repository where CI/CD releases go to
	LocalHelmRepoName = "releases"

	// DeploymentExposecontrollerService the name of the Deployment for the Exposecontroller Service
	DeploymentExposecontrollerService = "exposecontroller-service"

	// DeploymentProwBuild the name of the Deployment for the Prow webhook engine
	DeploymentProwBuild = "prow-build"

	DefaultEnvironmentGitRepoURL = "https://github.com/jenkins-x/default-environment-charts.git"

	DefaultOrganisationGitRepoURL = "https://github.com/jenkins-x/default-organisation.git"

	// AnnotationTitle the human readable name of a resource which can include mixed case, spaces and punctuation
	AnnotationTitle = "title"

	// AnnotationDescription the tooltip / texual description of an resource
	AnnotationDescription = "description"

	// LabelKind to indicate the kind of auth, such as Git or Issue
	LabelKind = "jenkins.io/kind"

	// ValueKindAddon an addon auth secret/credentials
	ValueKindAddon = "addon"

	// ValueKindChat a chat auth secret/credentials
	ValueKindChat = "chat"

	// ValueKindGit a git auth secret/credentials
	ValueKindGit = "git"

	// ValueKindIssue an issue auth secret/credentials
	ValueKindIssue = "issue"

	// ValueKindCVE an addon auth secret/credentials
	ValueKindCVE = "cve"

	// ValueKindCVE an addon auth PipelineEvent
	ValueKindPipelineEvent = "PipelineEvent"

	// ValueKindEnvironmentRole to indicate a Role which maps to an EnvironmentRoleBinding
	ValueKindEnvironmentRole = "EnvironmentRole"

	// ValueKindCVE an addon auth PipelineEvent
	ValueKindRelease = "Release"

	// ValueKindEditNamespace for edit namespace
	ValueKindEditNamespace = "editspace"

	// LabelServiceKind the label to indicate the auto Server's Kind
	LabelServiceKind = "jenkins.io/service-kind"

	// LabelCreatedBy indicates the service that created this resource
	LabelCreatedBy = "jenkins.io/created-by"

	// LabelPodTemplate the name of the pod template for a DevPod
	LabelPodTemplate = "jenkins.io/pod_template"

	// LabelDevPodName the name of a dev pod
	LabelDevPodName = "jenkins.io/devpod"

	// LabelDevPodUsername the user name owner of the DeVPod
	LabelDevPodUsername = "jenkins.io/devpod_user"

	// LabelUsername the user name owner of a namespace or resource
	LabelUsername = "jenkins.io/user"

	// ValueCreatedByJX for resources created by the Jenkins X CLI
	ValueCreatedByJX = "jx"

	// LabelCredentialsType the kind of jenkins credential for a secret
	LabelCredentialsType = "jenkins.io/credentials-type"

	// ValueCredentialTypeUsernamePassword for user password credential secrets
	ValueCredentialTypeUsernamePassword = "usernamePassword"

	// LabelTeam indicates the team name an environment belongs to
	LabelTeam = "team"

	// LabelEnvironment indicates the name of the environment
	LabelEnvironment = "env"

	// LabelValueDevEnvironment is the value of the LabelTeam label for Development environments (system namespace)
	LabelValueDevEnvironment = "dev"

	// LabelJobKind the kind of job
	LabelJobKind = "jenkins.io/job-kind"

	// ValueJobKindPostPreview
	ValueJobKindPostPreview = "post-preview-step"

	// AnnotationURL indicates a service/server's URL
	AnnotationURL = "jenkins.io/url"

	// AnnotationExpose used to expose service using exposecontroller
	AnnotationExpose = "fabric8.io/expose"

	// AnnotationIngress tells exposecontroller to annotate generated ingress rule with values
	AnnotationIngress = "fabric8.io/ingress.annotations"

	// AnnotationName indicates a service/server's textual name (can be mixed case, contain spaces unlike kubernetes resources)
	AnnotationName = "jenkins.io/name"

	// AnnotationCredentialsDescription the description text for a Credential on a Secret
	AnnotationCredentialsDescription = "jenkins.io/credentials-description"

	// AnnotationWorkingDir the working directory, such as for a DevPod
	AnnotationWorkingDir = "jenkins.io/working-dir"
	// AnnotationLocalDir the local directory that is sync'd to the DevPod
	AnnotationLocalDir = "jenkins.io/local-dir"

	// AnnotationIsDefaultStorageClass used to indicate a storageclass is default
	AnnotationIsDefaultStorageClass = "storageclass.kubernetes.io/is-default-class"

	// SecretDataUsername the username in a Secret/Credentials
	SecretDataUsername = "username"

	// SecretDataPassword the password in a Secret/Credentials
	SecretDataPassword = "password"

	// SecretBasicAuth the name for the Jenkins X basic auth secret
	SecretBasicAuth = "jx-basic-auth"

	JenkinsAdminApiToken = "jenkins-admin-api-token"

	AUTH = "auth"
)
View Source
const (
	CertmanagerCertificateProd    = "letsencrypt-prod"
	CertmanagerCertificateStaging = "letsencrypt-staging"
	CertmanagerIssuerProd         = "letsencrypt-prod"
	CertmanagerIssuerStaging      = "letsencrypt-staging"
)
View Source
const (
	IngressConfigConfigmap = "ingress-config"
	Domain                 = "domain"
	Email                  = "email"
	TLS                    = "tls"
	Issuer                 = "issuer"
	Exposer                = "exposer"
)
View Source
const (
	BitbucketConfigMapKey = "com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration.xml"
	GiteaConfigMapKey     = "org.jenkinsci.plugin.gitea.servers.GiteaServers.xml"
	GithubConfigMapKey    = "org.jenkinsci.plugins.github_branch_source.GitHubConfiguration.xml"
)
View Source
const (
	ExposeAnnotation            = "fabric8.io/expose"
	ExposeURLAnnotation         = "fabric8.io/exposeUrl"
	ExposeGeneratedByAnnotation = "fabric8.io/generated-by"
	JenkinsXSkipTLSAnnotation   = "jenkins-x.io/skip.tls"
	ExposeIngressAnnotation     = "fabric8.io/ingress.annotations"
	CertManagerAnnotation       = "certmanager.k8s.io/issuer"
)
View Source
const (
	OptionName      = "name"
	OptionNamespace = "namespace"
)

Variables

View Source
var (
	AddonCharts = map[string]string{
		"ambassador": ChartAmbassador,
		"anchore":    ChartAnchore,
		"cb":         ChartCloudBees,
		"gitea":      ChartGitea,
		"istio":      ChartIstio,
		"kubeless":   ChartKubeless,
		"prometheus": "stable/prometheus",
		"grafana":    "stable/grafana",
	}

	AddonServices = map[string]string{
		"anchore":         "anchore-anchore-engine",
		"pipeline-events": "jx-pipeline-events-elasticsearch-client",
	}
)
View Source
var (
	DefaultQuickstartLocations = []v1.QuickStartLocation{
		{
			GitURL:   gits.GitHubURL,
			GitKind:  gits.KindGitHub,
			Owner:    "jenkins-x-quickstarts",
			Includes: []string{"*"},
			Excludes: []string{"WIP-*"},
		},
	}
)

Functions

func AddUserToConfig added in v1.3.267

func AddUserToConfig(user string, token string, config *api.Config) (*api.Config, error)

AddUserToConfig adds the given user to the config

func AnnotateNamespaceServicesWithCertManager added in v1.3.93

func AnnotateNamespaceServicesWithCertManager(c kubernetes.Interface, ns, issuer string) error

func CertificateAuthorityData added in v1.3.242

func CertificateAuthorityData(config *api.Config, context *api.Context) []byte

CertificateAuthorityData returns the certificate authority data for the given context

func CleanCertmanagerResources added in v1.3.93

func CleanCertmanagerResources(c kubernetes.Interface, ns string, config IngressConfig) error

func CleanServiceAnnotations added in v1.3.93

func CleanServiceAnnotations(c kubernetes.Interface, ns string) error

func ClusterRoleBindingYaml added in v1.1.4

func ClusterRoleBindingYaml(user string) string

func ClusterRoleYaml added in v1.1.4

func ClusterRoleYaml(user string) string

func CompletePromote added in v1.0.87

func CompletePromote(p *v1.PromoteActivityStep) error

func CompletePromotionPullRequest added in v1.0.87

func CompletePromotionPullRequest(a *v1.PipelineActivity, s *v1.PipelineActivityStep, ps *v1.PromoteActivityStep, p *v1.PromotePullRequestStep) error

func CompletePromotionUpdate added in v1.0.87

func CreateClient

func CreateClient(kubeconfig *string) (kubernetes.Interface, error)

CreateClient creates a new kubernetes client

func CreateEnvironmentSurvey added in v1.0.2

func CreateEnvironmentSurvey(out io.Writer, batchMode bool, authConfigSvc auth.AuthConfigService, devEnv *v1.Environment, data *v1.Environment,
	config *v1.Environment, forkEnvGitURL string, ns string, jxClient versioned.Interface, kubeClient kubernetes.Interface, envDir string,
	gitRepoOptions *gits.GitRepositoryOptions, helmValues config.HelmValuesConfig, prefix string, git gits.Gitter) (gits.GitProvider, error)

CreateEnvironmentSurvey creates a Survey on the given environment using the default options from the CLI

func CreateServiceLink(client kubernetes.Interface, currentNamespace, targetNamespace, serviceName, externalURL string) error

func CreateTeam added in v1.3.146

func CreateTeam(ns string, name string, members []string) *v1.Team

CreateTeam creates a new default Team

func CreateUser added in v1.3.146

func CreateUser(ns string, login string, name string, email string) *v1.User

CreateUser creates a new default User

func CurrentCluster added in v1.3.267

func CurrentCluster(config *api.Config) (string, *api.Cluster)

CurrentCluster returns the current cluster

func CurrentContext

func CurrentContext(config *api.Config) *api.Context

CurrentContext returns the current context

func CurrentNamespace

func CurrentNamespace(config *api.Config) string

CurrentNamespace returns the current namespace in the context

func CurrentServer

func CurrentServer(config *api.Config) string

CurrentServer returns the current context's server

func DeleteJob added in v1.2.27

func DeleteJob(client kubernetes.Interface, namespace, name string) error

func DeleteService added in v1.2.134

func DeleteService(client *kubernetes.Clientset, namespace string, serviceName string) error

func DeleteTeam added in v1.3.146

func DeleteTeam(jxClient versioned.Interface, ns string, teamName string) error

DeleteTeam deletes the team resource but does not uninstall the underlying namespaces

func DeleteUser added in v1.3.146

func DeleteUser(jxClient versioned.Interface, ns string, userName string) error

DeleteUser deletes the user resource but does not uninstall the underlying namespaces

func DeploymentPodCount added in v1.1.4

func DeploymentPodCount(client kubernetes.Interface, name, namespace string) (int, error)

func EmailToK8sId added in v1.3.49

func EmailToK8sId(email string) string

func EnableInsecureRegistry added in v1.1.4

func EnableInsecureRegistry(iqJson string, dockerRegistry string) (string, error)

EnableInsecureRegistry appends the Docker Registry

func EnsureDevEnvironmentSetup added in v1.0.58

func EnsureDevEnvironmentSetup(jxClient versioned.Interface, ns string) (*v1.Environment, error)

EnsureDevEnvironmentSetup ensures that the Environment is created in the given namespace

func EnsureEditEnvironmentSetup added in v1.2.40

func EnsureEditEnvironmentSetup(kubeClient kubernetes.Interface, jxClient versioned.Interface, ns string, username string) (*v1.Environment, error)

EnsureEditEnvironmentSetup ensures that the Environment is created in the given namespace

func EnsureEnvironmentNamespaceSetup added in v1.0.2

func EnsureEnvironmentNamespaceSetup(kubeClient kubernetes.Interface, jxClient versioned.Interface, env *v1.Environment, ns string) error

func EnsureGitServiceExistsForHost added in v1.0.114

func EnsureGitServiceExistsForHost(jxClient versioned.Interface, devNs string, kind string, name string, gitUrl string, out io.Writer) error

EnsureGitServiceExistsForHost ensures that there is a GitService CRD for the given host and kind

func EnsureNamespaceCreated added in v1.0.2

func EnsureNamespaceCreated(kubeClient kubernetes.Interface, name string, labels map[string]string, annotations map[string]string) error

Ensure that the namespace exists for the given name

func EnvironmentMatches added in v1.3.16

func EnvironmentMatches(env *v1.Environment, filter *v1.EnvironmentFilter) bool

EnvironmentMatches returns true if the environment matches the given filter

func EnvironmentMatchesAny added in v1.3.16

func EnvironmentMatchesAny(env *v1.Environment, filters []v1.EnvironmentFilter) bool

EnvironmentMatchesAny returns true if the list of filters is empty or one of the filters matches the given environment

func ExtractDomainValue added in v1.3.176

func ExtractDomainValue(data map[string]string) (string, error)

ExtractDomainValue returns the domain value

func FailedPromote added in v1.0.87

func FailedPromote(p *v1.PromoteActivityStep) error

func FailedPromotionPullRequest added in v1.0.87

func FailedPromotionUpdate added in v1.0.87

func FindService added in v1.2.134

func FindService(client kubernetes.Interface, name string) (*v1.Service, error)

FindService looks up a service by name across all namespaces

func FindServiceHostname added in v1.3.249

func FindServiceHostname(client kubernetes.Interface, namespace string, name string) (string, error)

func FindServiceURL

func FindServiceURL(client kubernetes.Interface, namespace string, name string) (string, error)

func GenerateBuildNumber added in v1.3.236

func GenerateBuildNumber(activities typev1.PipelineActivityInterface, owner string, repository string, branch string) (string, *v1.PipelineActivity, error)

GenerateBuildNumber generates a new build number for the given pipeline

func GetAdminNamespace added in v1.3.146

func GetAdminNamespace(kubeClient kubernetes.Interface, ns string) (string, error)

GetAdminNamespace tries to find the namespace which is annotated as the global admin namespace for the cluster or returns the current namespace

func GetAppName added in v1.0.69

func GetAppName(name string, namespaces ...string) string

GetAppName returns the app name

func GetCommitSha added in v1.0.18

func GetCommitSha(r *metav1.ObjectMeta) string

GetCommitSha returns the git commit sha

func GetCommitURL added in v1.0.18

func GetCommitURL(r *metav1.ObjectMeta) string

GetCommitURL returns the git commit URL

func GetConfigmapData added in v1.0.135

func GetConfigmapData(client kubernetes.Interface, name, ns string) (map[string]string, error)

GetConfigmapData gets config map data

func GetCurrentDomain added in v1.0.135

func GetCurrentDomain(client kubernetes.Interface, ns string) (string, error)

GetCurrentDomain gets the current domain

func GetDeploymentByRepo added in v1.3.197

func GetDeploymentByRepo(client kubernetes.Interface, ns string, repoName string) (*v1beta1.Deployment, error)

func GetDeploymentNames added in v1.0.10

func GetDeploymentNames(client kubernetes.Interface, ns string, filter string) ([]string, error)

func GetDeploymentPods added in v1.0.66

func GetDeploymentPods(client kubernetes.Interface, name, namespace string) ([]v1.Pod, error)

func GetDeployments added in v1.0.17

func GetDeployments(kubeClient kubernetes.Interface, ns string) (map[string]v1beta1.Deployment, error)

func GetDevNamespace added in v1.0.2

func GetDevNamespace(kubeClient kubernetes.Interface, ns string) (string, string, error)

GetDevNamespace returns the developer environment namespace which is the namespace that contains the Environments and the developer tools like Jenkins

func GetDevPodNames added in v1.2.30

func GetDevPodNames(client kubernetes.Interface, ns string, username string) ([]string, map[string]*v1.Pod, error)

GetDevPodNames returns the users dev pod names

func GetEditAppName added in v1.2.42

func GetEditAppName(name string) string

func GetEditEnvironmentNamespace added in v1.2.44

func GetEditEnvironmentNamespace(jxClient versioned.Interface, ns string) (string, error)

GetEditEnvironmentNamespace returns the namespace of the current users edit environment

func GetEnrichedDevEnvironment added in v1.3.247

func GetEnrichedDevEnvironment(kubeClient kubernetes.Interface, jxClient versioned.Interface, ns string) (*v1.Environment, error)

GetEnrichedDevEnvironment lazily creates the dev namespace if it does not already exist and auto-detects the webhook engine if its not specified

func GetEnvVar added in v1.3.46

func GetEnvVar(container *corev1.Container, name string) *corev1.EnvVar

GetEnvVar returns the env var if its defined for the given name

func GetEnvironment added in v1.3.197

func GetEnvironment(jxClient versioned.Interface, ns string, name string) (*v1.Environment, error)

GetEnvironment find an environment by name

func GetEnvironmentNames added in v1.0.2

func GetEnvironmentNames(jxClient versioned.Interface, ns string) ([]string, error)

GetEnvironmentNames returns the sorted list of environment names

func GetEnvironmentNamespace added in v1.2.31

func GetEnvironmentNamespace(jxClient versioned.Interface, ns, environment string) (string, error)

GetEnvironments returns the namespace name for a given environment

func GetEnvironmentRoles added in v1.3.249

func GetEnvironmentRoles(jxClient versioned.Interface, ns string) (map[string]*v1.EnvironmentRoleBinding, []string, error)

GetEnvironmentRoles returns all the environment role binding names and details

func GetEnvironments added in v1.0.2

func GetEnvironments(jxClient versioned.Interface, ns string) (map[string]*v1.Environment, []string, error)

GetEnvironments returns a map of the environments along with a sorted list of names

func GetEnvironmentsByPrURL added in v1.3.197

func GetEnvironmentsByPrURL(jxClient versioned.Interface, ns string, prURL string) (*v1.Environment, error)

GetEnvironmentsByPrURL find an environment by a pull request URL

func GetFilteredEnvironmentNames added in v1.2.75

func GetFilteredEnvironmentNames(jxClient versioned.Interface, ns string, fn func(environment *v1.Environment) bool) ([]string, error)

GetFilteredEnvironmentNames returns the sorted list of environment names

func GetGitServiceKind added in v1.0.114

func GetGitServiceKind(jxClient versioned.Interface, kubeClient kubernetes.Interface, devNs string, gitServiceURL string) (string, error)

GetGitServiceKind returns the kind of the given host if one can be found or ""

func GetIngress added in v1.2.27

func GetIngress(client kubernetes.Interface, ns, name string) (string, error)

func GetName added in v1.0.18

func GetName(r *metav1.ObjectMeta) string

GetName returns the app name

func GetOrCreateRelease added in v1.3.171

func GetOrCreateRelease(jxClient versioned.Interface, ns string, release *v1.Release) (*v1.Release, error)

GetOrCreateRelease creates or updates the given release resource

func GetOrCreateStage added in v1.3.145

func GetOrCreateStage(a *v1.PipelineActivity, stageName string) (*v1.PipelineActivityStep, *v1.StageActivityStep, bool)

GetOrCreateStage gets or creates the step for the given name

func GetOrderedEnvironments added in v1.2.39

func GetOrderedEnvironments(jxClient versioned.Interface, ns string) (map[string]*v1.Environment, []string, error)

GetOrderedEnvironments returns a map of the environments along with the correctly ordered names

func GetOrderedReleases added in v1.3.171

func GetOrderedReleases(jxClient versioned.Interface, ns string, filter string) ([]v1.Release, error)

GetOrderedReleases returns the releases sorted in newest release first

func GetPendingTeams added in v1.3.146

func GetPendingTeams(jxClient versioned.Interface, ns string) (map[string]*v1.Team, []string, error)

GetPendingTeams returns the pending teams with the sorted order of names

func GetPodCondition added in v1.0.2

func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)

credit https://github.com/kubernetes/kubernetes/blob/8719b4a/pkg/api/v1/pod/util.go GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.

func GetPodMetrics added in v1.0.25

func GetPodMetrics(client *metricsclient.Clientset, ns string) (*metricsv1beta1.PodMetricsList, error)

func GetPodNames added in v1.0.10

func GetPodNames(client kubernetes.Interface, ns string, filter string) ([]string, error)

func GetPodReadyCondition added in v1.0.2

func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition

credit https://github.com/kubernetes/kubernetes/blob/8719b4a/pkg/api/v1/pod/util.go Extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.

func GetPodRestarts added in v1.3.127

func GetPodRestarts(pod *v1.Pod) int32

GetPodRestars returns the number of restarts of a POD

func GetPodVersion added in v1.0.28

func GetPodVersion(pod *corev1.Pod, appName string) string

GetPodVersion returns the version for the given app name

func GetPods added in v1.2.42

func GetPods(client kubernetes.Interface, ns string, filter string) ([]string, map[string]*v1.Pod, error)

func GetPodsWithLabels added in v1.2.69

func GetPodsWithLabels(client kubernetes.Interface, ns string, selector string) ([]string, map[string]*v1.Pod, error)

func GetQuickstartLocations added in v1.2.84

func GetQuickstartLocations(jxClient versioned.Interface, ns string) ([]v1.QuickStartLocation, error)

GetQuickstartLocations returns the current quickstart locations. If no locations are defined yet lets return the defaults

func GetReadyPodNames added in v1.0.10

func GetReadyPodNames(client kubernetes.Interface, ns string, filter string) ([]string, error)

func GetService added in v1.2.77

func GetService(client kubernetes.Interface, currentNamespace, targetNamespace, serviceName string) error

func GetServiceKindFromSecrets added in v1.3.176

func GetServiceKindFromSecrets(kubeClient kubernetes.Interface, ns string, gitServiceURL string) (string, error)

GetServiceKindFromSecrets gets the kind of service from secrets

func GetServiceNames added in v1.0.10

func GetServiceNames(client kubernetes.Interface, ns string, filter string) ([]string, error)

func GetServiceURL added in v1.0.83

func GetServiceURL(svc *v1.Service) string

func GetServiceURLFromMap added in v1.0.83

func GetServiceURLFromMap(services map[string]*v1.Service, name string) string

func GetServiceURLFromName added in v1.2.27

func GetServiceURLFromName(c kubernetes.Interface, name, ns string) (string, error)

func GetServices added in v1.0.83

func GetServices(client kubernetes.Interface, ns string) (map[string]*v1.Service, error)

func GetTeamExposecontrollerConfig added in v1.2.27

func GetTeamExposecontrollerConfig(kubeClient kubernetes.Interface, ns string) (map[string]string, error)

func GetTeamRoles added in v1.3.249

func GetTeamRoles(kubeClient kubernetes.Interface, ns string) (map[string]*rbacv1.Role, []string, error)

GetTeamRoles returns the roles for the given team dev namespace

func GetTeams added in v1.3.27

func GetTeams(kubeClient kubernetes.Interface) ([]*corev1.Namespace, []string, error)

GetTeams returns the Teams the user is a member of

func GetUserRoles added in v1.3.249

func GetUserRoles(jxClient versioned.Interface, ns string, userKind string, userName string) ([]string, error)

UpdateUserRoles updates the EnvironmentRoleBinding values based on the given userRoles userKind is "User" or "ServiceAccount"

func GetUsers added in v1.3.146

func GetUsers(jxClient versioned.Interface, ns string) (map[string]*v1.User, []string, error)

GetUsers returns the pending users with the sorted order of names

func GetVersion added in v1.0.2

func GetVersion(r *metav1.ObjectMeta) string

GetVersion returns the version from the labels on the deployment if it can be deduced

func GetVolume added in v1.3.148

func GetVolume(volumes *[]corev1.Volume, name string) *corev1.Volume

func GetVolumeMount added in v1.3.148

func GetVolumeMount(volumenMounts *[]corev1.VolumeMount, name string) *corev1.VolumeMount

func HasExternalAddress added in v1.0.29

func HasExternalAddress(svc *v1.Service) bool

func IsDaemonSetExists added in v1.2.42

func IsDaemonSetExists(client kubernetes.Interface, name, namespace string) (bool, error)

func IsDeploymentRunning added in v1.0.2

func IsDeploymentRunning(client kubernetes.Interface, name, namespace string) (bool, error)

func IsJobFinished added in v1.3.46

func IsJobFinished(job *batchv1.Job) bool

IsJobFinished returns true if the job has completed

func IsJobSucceeded added in v1.2.27

func IsJobSucceeded(job *batchv1.Job) bool

IsJobSucceeded returns true if the job completed and did not fail

func IsPodReady added in v1.0.2

func IsPodReady(pod *v1.Pod) bool

credit https://github.com/kubernetes/kubernetes/blob/8719b4a/pkg/api/v1/pod/util.go IsPodReady returns true if a pod is ready; false otherwise.

func IsPodReadyConditionTrue added in v1.0.2

func IsPodReadyConditionTrue(status v1.PodStatus) bool

credit https://github.com/kubernetes/kubernetes/blob/8719b4a/pkg/api/v1/pod/util.go IsPodReady retruns true if a pod is ready; false otherwise.

func IsPreviewEnvironment added in v1.2.75

func IsPreviewEnvironment(env *v1.Environment) bool

func IsProwEnabled added in v1.3.270

func IsProwEnabled(kubeClient kubernetes.Interface, ns string) (bool, error)

IsProwEnabled returns true if prow is enabled in the given development namespace

func IsResourceVersionNewer added in v1.3.169

func IsResourceVersionNewer(v1 string, v2 string) bool

IsResourceVersionNewer returns true if the first resource version is newer than the second

func IsServicePresent added in v1.2.27

func IsServicePresent(c kubernetes.Interface, name, ns string) (bool, error)

func LoadConfig

func LoadConfig() (*api.Config, *clientcmd.PathOptions, error)

LoadConfig loads the kubernetes configuration

func MergeMaps added in v1.1.56

func MergeMaps(maps ...map[string]string) map[string]string

MergeMaps merges all the maps together with the entries in the last map overwriting any earlier values

so if you want to add some annotations to a resource you can do resource.Annotations = kube.MergeMaps(resource.Annotations, myAnnotations)

func ModifyNamespace added in v1.3.176

func ModifyNamespace(out io.Writer, dir string, env *v1.Environment, git gits.Gitter) error

ModifyNamespace modifies the namespace

func NewPermanentEnvironment added in v1.3.16

func NewPermanentEnvironment(name string) *v1.Environment

NewPermanentEnvironment creates a new permanent environment for testing

func NewPermanentEnvironmentWithGit added in v1.3.169

func NewPermanentEnvironmentWithGit(name string, gitUrl string) *v1.Environment

NewPermanentEnvironment creates a new permanent environment for testing

func NewPreviewEnvironment added in v1.3.16

func NewPreviewEnvironment(name string) *v1.Environment

NewPreviewEnvironment creates a new preview environment for testing

func ParseXml added in v1.3.176

func ParseXml(xml string) (*etree.Document, string, error)

ParseXml parses XML

func PickEnvironment added in v1.0.2

func PickEnvironment(envNames []string, defaultEnv string) (string, error)

func PodRequestsAndLimits added in v1.1.41

func PodRequestsAndLimits(pod *v1.Pod) (reqs map[v1.ResourceName]resource.Quantity, limits map[v1.ResourceName]resource.Quantity)

func PodStatus added in v1.2.30

func PodStatus(pod *v1.Pod) string

func RegisterEnvironmentCRD added in v1.0.2

func RegisterEnvironmentCRD(apiClient apiextensionsclientset.Interface) error

RegisterEnvironmentCRD ensures that the CRD is registered for Environments

func RegisterEnvironmentRoleBindingCRD added in v1.3.16

func RegisterEnvironmentRoleBindingCRD(apiClient apiextensionsclientset.Interface) error

RegisterEnvironmentRoleBindingCRD ensures that the CRD is registered for Environments

func RegisterGitServiceCRD added in v1.0.114

func RegisterGitServiceCRD(apiClient apiextensionsclientset.Interface) error

RegisterGitServiceCRD ensures that the CRD is registered for GitServices

func RegisterPipelineActivityCRD added in v1.0.84

func RegisterPipelineActivityCRD(apiClient apiextensionsclientset.Interface) error

RegisterPipelineActivityCRD ensures that the CRD is registered for PipelineActivity

func RegisterReleaseCRD added in v1.0.90

func RegisterReleaseCRD(apiClient apiextensionsclientset.Interface) error

RegisterReleaseCRD ensures that the CRD is registered for Release

func RegisterTeamCRD added in v1.3.146

func RegisterTeamCRD(apiClient apiextensionsclientset.Interface) error

RegisterTeamCRD ensures that the CRD is registered for Team

func RegisterUserCRD added in v1.2.63

func RegisterUserCRD(apiClient apiextensionsclientset.Interface) error

RegisterUserCRD ensures that the CRD is registered for User

func RegisterWorkflowCRD added in v1.3.166

func RegisterWorkflowCRD(apiClient apiextensionsclientset.Interface) error

RegisterWorkflowCRD ensures that the CRD is registered for Environments

func ReplaceMakeVariable added in v1.3.176

func ReplaceMakeVariable(lines []string, name string, value string) error

ReplaceMakeVariable needs a description

func RoleBindingKubeSystemYaml added in v1.1.4

func RoleBindingKubeSystemYaml(user string) string

func RoleBindings added in v1.1.65

func RoleBindings(client kubernetes.Interface, namespace string) (string, error)

func RoleKubeSystemYaml added in v1.1.4

func RoleKubeSystemYaml(user string) string

func SaveAsConfigMap added in v1.3.242

func SaveAsConfigMap(c kubernetes.Interface, configMapName string, ns string, obj interface{}) (*v1.ConfigMap, error)

SaveAsConfigMap to the specified namespace as a config map.

func Server

func Server(config *api.Config, context *api.Context) string

Server returns the server of the given context

func SortEnvironments added in v1.0.2

func SortEnvironments(environments []v1.Environment)

func SortListWatchByName added in v1.1.32

func SortListWatchByName(listWatch *cache.ListWatch)

func SortReleases added in v1.3.171

func SortReleases(releases []v1.Release)

SortReleases sorts the releases in name order then latest version first

func SortRuntimeObjectsByName added in v1.1.32

func SortRuntimeObjectsByName(objects []runtime.Object)

func StartPromote added in v1.0.87

func StartPromote(p *v1.PromoteActivityStep) error

func StartPromotionPullRequest added in v1.0.87

func StartPromotionUpdate added in v1.0.87

func ToMetaTime added in v1.2.99

func ToMetaTime(t *time.Time) *metav1.Time

ToMetaTime converts the go time pointer to a meta time

func ToValidName added in v1.0.84

func ToValidName(name string) string

ToValidName converts the given string into a valid kubernetes resource name

func ToValidNameWithDots added in v1.0.93

func ToValidNameWithDots(name string) string

ToValidNameWithDots converts the given string into a valid kubernetes resource name

func UpdateConfig added in v1.3.248

func UpdateConfig(namespace string, server string, caData string, user string, token string) error

UpdateConfig defines new config entries for jx

func UpdateJenkinsGitServers added in v1.2.3

func UpdateJenkinsGitServers(cm *corev1.ConfigMap, server *auth.AuthServer, userAuth *auth.UserAuth, credentials string) (bool, error)

UpdateJenkinsGitServers update the Jenkins ConfigMap with any missing git server configurations for the given server and token

func UpdateUserRoles added in v1.3.249

func UpdateUserRoles(kubeClient kubernetes.Interface, jxClient versioned.Interface, ns string, userKind string, userName string, userRoles []string, roles map[string]*rbacv1.Role) error

UpdateUserRoles updates the EnvironmentRoleBinding values based on the given userRoles. userKind is "User" or "ServiceAccount"

func ValidNameOption added in v1.0.2

func ValidNameOption(option string, value string) error

func ValidSubDomainOption added in v1.0.2

func ValidSubDomainOption(option string, value string) error

func ValidateEnvironmentDoesNotExist added in v1.0.2

func ValidateEnvironmentDoesNotExist(jxClient versioned.Interface, ns string, str string) error

func ValidateName added in v1.0.2

func ValidateName(val interface{}) error

func ValidateSubDomain added in v1.0.2

func ValidateSubDomain(val interface{}) error

func WaitForAllDeploymentsToBeReady added in v1.0.2

func WaitForAllDeploymentsToBeReady(client kubernetes.Interface, namespace string, timeoutPerDeploy time.Duration) error

func WaitForDeploymentToBeReady added in v1.0.2

func WaitForDeploymentToBeReady(client kubernetes.Interface, name, namespace string, timeout time.Duration) error

WaitForDeploymentToBeReady waits for the pods of a deployment to become ready

func WaitForExternalIP added in v1.0.29

func WaitForExternalIP(client kubernetes.Interface, name, namespace string, timeout time.Duration) error

waits for the pods of a deployment to become ready

func WaitForJobToSucceeded added in v1.2.27

func WaitForJobToSucceeded(client kubernetes.Interface, namespace, jobName string, timeout time.Duration) error

waits for the job to complete

func WaitForPodNameToBeReady added in v1.2.30

func WaitForPodNameToBeReady(client kubernetes.Interface, namespace string, name string, timeout time.Duration) error

waits for the pod to become ready using the pod name

func WaitForPodToBeReady added in v1.0.2

func WaitForPodToBeReady(client kubernetes.Interface, selector labels.Selector, namespace string, timeout time.Duration) error

waits for the pod to become ready using label selector to match the pod

Types

type ByName added in v1.1.32

type ByName []runtime.Object

func (ByName) Len added in v1.1.32

func (a ByName) Len() int

func (ByName) Less added in v1.1.32

func (a ByName) Less(i, j int) bool

func (ByName) Swap added in v1.1.32

func (a ByName) Swap(i, j int)

type ByOrder added in v1.0.2

type ByOrder []v1.Environment

func (ByOrder) Len added in v1.0.2

func (a ByOrder) Len() int

func (ByOrder) Less added in v1.0.2

func (a ByOrder) Less(i, j int) bool

func (ByOrder) Swap added in v1.0.2

func (a ByOrder) Swap(i, j int)

type ClusterStatus added in v1.1.41

type ClusterStatus struct {
	Name string
	// contains filtered or unexported fields
}

func GetClusterStatus added in v1.1.41

func GetClusterStatus(client kubernetes.Interface, namespace string) (ClusterStatus, error)

func (*ClusterStatus) AverageCpuPercent added in v1.1.41

func (clusterStatus *ClusterStatus) AverageCpuPercent() int

func (*ClusterStatus) AverageMemPercent added in v1.1.41

func (clusterStatus *ClusterStatus) AverageMemPercent() int

func (*ClusterStatus) CheckResource added in v1.1.41

func (clusterStatus *ClusterStatus) CheckResource() string

func (*ClusterStatus) Info added in v1.1.45

func (clusterStatus *ClusterStatus) Info() string

func (*ClusterStatus) MinimumResourceLimit added in v1.1.45

func (clusterStatus *ClusterStatus) MinimumResourceLimit() int

func (*ClusterStatus) NodeCount added in v1.1.49

func (clusterStatus *ClusterStatus) NodeCount() int

type HeapterConfig added in v1.0.26

type HeapterConfig struct {
	KubeClient        kubernetes.Interface
	HeapsterNamespace string
	HeapsterScheme    string
	HeapsterPort      string
	HeapsterService   string
	// contains filtered or unexported fields
}

func (*HeapterConfig) GetPodMetrics added in v1.0.26

func (q *HeapterConfig) GetPodMetrics(ns string, pod string, selector string, metric string, start string, end string) ([]byte, error)

type IngressConfig added in v1.3.93

type IngressConfig struct {
	Email   string `structs:"email" yaml:"email" json:"email"`
	Domain  string `structs:"domain" yaml:"domain" json:"domain"`
	Issuer  string `structs:"issuer" yaml:"issuer" json:"issuer"`
	Exposer string `structs:"exposer" yaml:"exposer" json:"exposer"`
	TLS     bool   `structs:"tls" yaml:"tls" json:"tls"`
}

func GetIngressConfig added in v1.3.93

func GetIngressConfig(c kubernetes.Interface, ns string) (IngressConfig, error)

type JXInstallConfig added in v1.3.242

type JXInstallConfig struct {
	Server string `structs:"server" yaml:"server" json:"server"`
	CA     []byte `structs:"ca.crt" yaml:"ca.crt" json:"ca.crt"`
}

JXInstallConfig is the struct used to create the jx-install-config configmap

type NodeStatus added in v1.1.41

type NodeStatus struct {
	Name            string
	AllocatedMemory *resource.Quantity
	AllocatedCPU    *resource.Quantity
	CpuReqs         resource.Quantity
	CpuLimits       resource.Quantity

	MemReqs   resource.Quantity
	MemLimits resource.Quantity
	// contains filtered or unexported fields
}

func Status added in v1.1.41

func Status(client kubernetes.Interface, namespace string, node v1.Node) (NodeStatus, error)

type PipelineActivityKey added in v1.0.84

type PipelineActivityKey struct {
	Name              string
	Pipeline          string
	Build             string
	Version           string
	BuildURL          string
	BuildLogsURL      string
	ReleaseNotesURL   string
	LastCommitSHA     string
	LastCommitMessage string
	LastCommitURL     string
	GitInfo           *gits.GitRepositoryInfo
}

func (*PipelineActivityKey) GetOrCreate added in v1.0.84

GetOrCreate gets or creates the pipeline activity

func (*PipelineActivityKey) IsValid added in v1.0.84

func (k *PipelineActivityKey) IsValid() bool

type PipelineDetails added in v1.3.247

type PipelineDetails struct {
	GitOwner      string
	GitRepository string
	BranchName    string
	Pipeline      string
	Build         string
}

func CreatePipelineDetails added in v1.3.247

func CreatePipelineDetails(activity *v1.PipelineActivity) *PipelineDetails

CreatePipelineDetails creates a PipelineDetails object populated from the activity

type PromoteStepActivityKey added in v1.0.87

type PromoteStepActivityKey struct {
	PipelineActivityKey

	Environment    string
	ApplicationURL string
}

func (*PromoteStepActivityKey) GetOrCreatePreview added in v1.2.70

GetOrCreatePreview gets or creates the Preview step for the key

func (*PromoteStepActivityKey) GetOrCreatePromote added in v1.0.87

GetOrCreatePromote gets or creates the Promote step for the key

func (*PromoteStepActivityKey) GetOrCreatePromotePullRequest added in v1.0.87

GetOrCreatePromotePullRequest gets or creates the PromotePullRequest for the key

func (*PromoteStepActivityKey) GetOrCreatePromoteUpdate added in v1.0.87

GetOrCreatePromoteUpdate gets or creates the Promote for the key

func (*PromoteStepActivityKey) OnPromotePullRequest added in v1.0.87

func (k *PromoteStepActivityKey) OnPromotePullRequest(activities typev1.PipelineActivityInterface, fn PromotePullRequestFn) error

func (*PromoteStepActivityKey) OnPromoteUpdate added in v1.0.87

type PromoteUpdateFn added in v1.0.87

type ReleaseOrder added in v1.3.171

type ReleaseOrder []v1.Release

func (ReleaseOrder) Len added in v1.3.171

func (a ReleaseOrder) Len() int

func (ReleaseOrder) Less added in v1.3.171

func (a ReleaseOrder) Less(i, j int) bool

func (ReleaseOrder) Swap added in v1.3.171

func (a ReleaseOrder) Swap(i, j int)

type ServiceURL

type ServiceURL struct {
	Name string
	URL  string
}

func FindServiceURLs

func FindServiceURLs(client kubernetes.Interface, namespace string) ([]ServiceURL, error)

type UserDetailService added in v1.3.49

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

func NewUserDetailService added in v1.3.49

func NewUserDetailService(jxClient versioned.Interface, namespace string) UserDetailService

func (*UserDetailService) CreateOrUpdateUser added in v1.3.49

func (this *UserDetailService) CreateOrUpdateUser(u *v1.UserDetails) error

func (*UserDetailService) FindByEmail added in v1.3.49

func (this *UserDetailService) FindByEmail(email string) *v1.UserDetails

Jump to

Keyboard shortcuts

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