Documentation ¶
Index ¶
- Constants
- func DecompressGzipTar(readCloser io.ReadCloser, dir string) error
- func DownloadFileFromGithub(owner, repository, fileName, ref, githubURL, user, token string, ...) ([]byte, bool, error)
- func DownloadTrigger(triggerURL, triggerChkSum, dir string, verifyChkSum bool) error
- func DownloadYAML(kubeClient client.Client, namespace string, secretName string, ...) (map[string]interface{}, bool, error)
- func EventListenerURL(kubeClient client.Client, namespace string, name string) (string, error)
- func FindEventListenerForStack(kubeClient client.Client, namespace string, repoStackImage string, ...) (string, string, error)
- func GetGitHubSecret(kubeClient client.Client, namespace string, name string, repoURL string) (string, string, error)
- func GetTriggerInfo(client rest.Interface, namespace string) (*url.URL, string, error)
- func GetWebhookSecret(kubeClient client.Client, namespace string, name string) (string, error)
- func IsHeaderGithub(header map[string][]string) bool
- func MergePathWithErrorCheck(dir string, toMerge string) (string, error)
- func NewDynamicClient(kubeConfig *rest.Config) (dynamic.Interface, error)
- func NewKubeClient(kubeConfig *rest.Config) (*kubernetes.Clientset, error)
- func NewKubeConfig(masterURL, kubeconfigPath string) (*rest.Config, error)
- func ParseGithubURL(url string) (server, org, repo string, err error)
- func ReadFile(fileName string) ([]byte, error)
- func ReadHTTPURL(url string) ([]byte, error)
- func ReadJSON(fileName string) (*unstructured.Unstructured, error)
- func ToDomainName(name string) string
- func ToLabel(input string) string
- func ToLabelName(name string) string
- func UpdateStatus(ctrlClient client.Client, namespace string, name string, ...) error
- func ValidatePayload(sigType, sigHash, secret string, payload []byte) error
- func YAMLToMap(bytes []byte) (map[string]interface{}, error)
- type HashFunc
Constants ¶
const ( ACTIVE = "active" TRIGGER_TEKTON_DEV = "triggers.tekton.dev" EVENT_LISTENER = "EventListener" )
const ( V1 = "v1" V1ALPHA1 = "v1alpha1" KABANEROIO = "kabanero.io" KABANEROS = "kabaneros" ANNOTATIONS = "annotations" DATA = "data" URL = "url" USERNAME = "username" PASSWORD = "password" SECRETS = "secrets" SPEC = "spec" COLLECTIONS = "collections" REPOSITORIES = "repositories" ACTIVATEDEFAULTCOLLECTIONS = "activateDefaultCollections" METADATA = "metadata" )
Kubernetes and Kabanero yaml constants
const ( TRIGGERS = "triggers" CHKSUM = "sha256" )
constants
Variables ¶
This section is empty.
Functions ¶
func DecompressGzipTar ¶
func DecompressGzipTar(readCloser io.ReadCloser, dir string) error
DecompressGzipTar Decompresses and extracts a tar.gz file.
func DownloadFileFromGithub ¶
func DownloadFileFromGithub(owner, repository, fileName, ref, githubURL, user, token string, isEnterprise bool) ([]byte, bool, error)
DownloadFileFromGithub Downloads a file and returns: bytes of the file, true if file exists, and any error
func DownloadTrigger ¶
DownloadTrigger Download the trigger.tar.gz and unpack into the directory
triggerURL: URL that serves the trigger gzipped tar triggerChkSum: the sha256 checksum of the trigger archive dir: directory to unpack the trigger.tar.gz
func DownloadYAML ¶
func DownloadYAML(kubeClient client.Client, namespace string, secretName string, header map[string][]string, bodyMap map[string]interface{}, fileName string) (map[string]interface{}, bool, error)
DownloadYAML Downloads a YAML file from a git repository.
kubeClient: controller client to API server namespace: namespace to look for secret to github secretName name of the secret containing the token to access github header: HTTP header from webhook bodyMap: HTTP message body from webhook
func EventListenerURL ¶
FInd URL for EventListener
func FindEventListenerForStack ¶
func FindEventListenerForStack(kubeClient client.Client, namespace string, repoStackImage string, repoStackVersion string) (string, string, error)
Find the Kabanero Tekton event listener for stack
input:
kubeClient: client to API server namespace: namespace of stack to search for event listener repoStackImage: the name of image as specified in .appsody-config.yaml. For example, "docker.io/appsody/nodejs:0.3" repoStackVersion: the semantic version for the stack, as specified in .appsody-config.yaml. For example "0.3"
Return:
name of listener, or "" if no match exact version found error : if any error occurred when matching the repository to an event listener
func GetGitHubSecret ¶
func GetGitHubSecret(kubeClient client.Client, namespace string, name string, repoURL string) (string, string, error)
GetGitHubSecret Find the user/token for a GitHub API key. The format of the secret: apiVersion: v1 kind: Secret metadata:
name: gh-https-secret annotations: tekton.dev/git-0: https://github.com
type: kubernetes.io/basic-auth stringData:
username: <username> password: <token>
This will scan for a secret with either of the following annotations:
- tekton.dev/git-*
- kabanero.io/git-*
GetGitHubSecret will return the username and token of a secret whose annotation's value is a prefix match for repoURL. Note that a secret with the `kabanero.io/git-*` annotation is preferred over one with `tekton.dev/git-*`. Return: username, token, error Input:
kubeClient: client to API server namespace: namespace to look for secret name: name of the secret, or "" to auto-scan repoURL: name of the repository
func GetTriggerInfo ¶
GetTriggerInfo Get the URL to trigger gzipped tar and its sha256 checksum.
func GetWebhookSecret ¶
Get value of Webhook secret
func IsHeaderGithub ¶
Return true if header is from Github event
func MergePathWithErrorCheck ¶
MergePathWithErrorCheck Merge a directory path with a relative path. Return error if the rectory not a prefix of the merged path after the merge
func NewDynamicClient ¶
NewDynamicClient Creates a new dynamic client
func NewKubeClient ¶
func NewKubeClient(kubeConfig *rest.Config) (*kubernetes.Clientset, error)
NewKubeClient Creates a new kube client
func NewKubeConfig ¶
NewKubeConfig Creates a new kube config
func ParseGithubURL ¶
Parse Github URL into server, org, and repo
Input: url for the github server, e.g., https://github.com/org/repo OUtput: server: The server, e.g., github.com org: The org portion of the url repo: The name of the repo
func ReadHTTPURL ¶
ReadHTTPURL Read remote file from URL and return bytes
func ReadJSON ¶
func ReadJSON(fileName string) (*unstructured.Unstructured, error)
ReadJSON reads a JSON file and returns it as an unstructured.Unstructured object.
func ToDomainName ¶
ToDomainName Convert a name to domain name format. The name must:
- Start with [a-z0-9]. If not, "0" is prepended.
- lower case. If not, lower case is used.
- contain only '.', '-', and [a-z0-9]. If not, "." is used insteaad.
- end with alpha numeric characters. Otherwise, '0' is appended
- can't have consecutive '.'. Consecutive ".." is substituted with ".".
Returns the empty string if the name is empty after conversion
func ToLabelName ¶
ToLabelName Convert the name part of a label. The name must:
- Start with [a-z0-9A-Z]. If not, "0" is prepended.
- End with [a-z0-9A-Z]. If not, "0" is appended
- Intermediate characters can only be: [a-z0-9A-Z] or '_', '-', and '.' If not, '.' is used.
- be maximum maxLabelLength characters long
func UpdateStatus ¶
func UpdateStatus(ctrlClient client.Client, namespace string, name string, summary []eventsv1alpha1.EventStatusSummary) error
Update status for mediator
func ValidatePayload ¶
ValidatePayload verifies that a payload hashed with some secret matches the expected signature